feat(admin): Weeztix setup wizard, integration status badges
- Summary view when Weeztix is configured; edits only via 3-step wizard - Step 1: reuse or replace OAuth client ID/secret; callback URL shown - Step 2: OAuth connect (resume wizard after callback when started from wizard) - Step 3: coupon, prefix, usage; finishing exits wizard - PreregistrationPage: mailwizz/weeztix integration status helpers - Pages index: Integrations column with MW/WZ badges; edit page: status cards Made-with: Cursor
This commit is contained in:
@@ -15,7 +15,7 @@ use RuntimeException;
|
||||
|
||||
class WeeztixOAuthController extends Controller
|
||||
{
|
||||
public function redirect(PreregistrationPage $page): RedirectResponse
|
||||
public function redirect(Request $request, PreregistrationPage $page): RedirectResponse
|
||||
{
|
||||
$this->authorize('update', $page);
|
||||
|
||||
@@ -38,6 +38,7 @@ class WeeztixOAuthController extends Controller
|
||||
session([
|
||||
'weeztix_oauth_state' => $state,
|
||||
'weeztix_page_id' => $page->id,
|
||||
'weeztix_oauth_resume_wizard' => $request->boolean('wizard'),
|
||||
]);
|
||||
|
||||
$redirectUri = $config->redirect_uri;
|
||||
@@ -90,7 +91,7 @@ class WeeztixOAuthController extends Controller
|
||||
|
||||
$config = $page->weeztixConfig;
|
||||
if ($config === null) {
|
||||
session()->forget(['weeztix_oauth_state', 'weeztix_page_id']);
|
||||
$this->forgetOauthSession();
|
||||
|
||||
return redirect()
|
||||
->route('admin.pages.weeztix.edit', $page)
|
||||
@@ -110,30 +111,52 @@ class WeeztixOAuthController extends Controller
|
||||
'message' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
session()->forget(['weeztix_oauth_state', 'weeztix_page_id']);
|
||||
$resumeWizard = $this->forgetOauthSession();
|
||||
|
||||
return redirect()
|
||||
->route('admin.pages.weeztix.edit', $page)
|
||||
->route('admin.pages.weeztix.edit', $this->weeztixEditParams($page, $resumeWizard, 2))
|
||||
->with('error', __('Verbinden met Weeztix is mislukt. Controleer je gegevens en probeer opnieuw.'));
|
||||
}
|
||||
|
||||
session()->forget(['weeztix_oauth_state', 'weeztix_page_id']);
|
||||
$resumeWizard = $this->forgetOauthSession();
|
||||
|
||||
return redirect()
|
||||
->route('admin.pages.weeztix.edit', $page)
|
||||
->route('admin.pages.weeztix.edit', $this->weeztixEditParams($page, $resumeWizard, 3))
|
||||
->with('status', __('Succesvol verbonden met Weeztix.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{page: PreregistrationPage, wizard?: int, step?: int}
|
||||
*/
|
||||
private function weeztixEditParams(PreregistrationPage $page, bool $resumeWizard, int $step): array
|
||||
{
|
||||
$params = ['page' => $page];
|
||||
if ($resumeWizard) {
|
||||
$params['wizard'] = 1;
|
||||
$params['step'] = $step;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
private function forgetOauthSession(): bool
|
||||
{
|
||||
$resumeWizard = (bool) session()->pull('weeztix_oauth_resume_wizard', false);
|
||||
session()->forget(['weeztix_oauth_state', 'weeztix_page_id']);
|
||||
|
||||
return $resumeWizard;
|
||||
}
|
||||
|
||||
private function redirectToWeeztixEditWithSessionPage(string $message): RedirectResponse
|
||||
{
|
||||
$pageId = session('weeztix_page_id');
|
||||
session()->forget(['weeztix_oauth_state', 'weeztix_page_id']);
|
||||
$resumeWizard = $this->forgetOauthSession();
|
||||
|
||||
if (is_int($pageId) || is_numeric($pageId)) {
|
||||
$page = PreregistrationPage::query()->find((int) $pageId);
|
||||
if ($page !== null) {
|
||||
return redirect()
|
||||
->route('admin.pages.weeztix.edit', $page)
|
||||
->route('admin.pages.weeztix.edit', $this->weeztixEditParams($page, $resumeWizard, 2))
|
||||
->with('error', $message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user