Änderungen (relevant):

- Add‑on Checkout auf Transactions + Transaction‑ID speichern: app/Services/Addons/EventAddonCheckoutService.php
  - Paket/Marketing Checkout auf Transactions: app/Services/Paddle/PaddleCheckoutService.php
  - Gift‑Voucher Checkout: Customer anlegen/finden + Transactions: app/Services/GiftVouchers/
    GiftVoucherCheckoutService.php
  - Tests aktualisiert: tests/Feature/Tenant/EventAddonCheckoutTest.php, tests/Unit/PaddleCheckoutServiceTest.php,
tests/Unit/GiftVoucherCheckoutServiceTest.php
This commit is contained in:
Codex Agent
2025-12-29 18:04:28 +01:00
parent 795e37ee12
commit 5f521d055f
26 changed files with 783 additions and 102 deletions

View File

@@ -14,7 +14,7 @@ import {
ADMIN_PUBLIC_LANDING_PATH,
ADMIN_WELCOME_BASE_PATH,
} from './constants';
import { getTenantPackagesOverview } from './api';
import { fetchOnboardingStatus, getTenantPackagesOverview } from './api';
import { getSelectedPackageId } from './mobile/lib/onboardingSelection';
import { resolveOnboardingRedirect } from './mobile/lib/onboardingGuard';
const AuthCallbackPage = React.lazy(() => import('./mobile/AuthCallbackPage'));
@@ -47,14 +47,15 @@ const MobileWelcomeSummaryPage = React.lazy(() => import('./mobile/welcome/Welco
const MobileWelcomeEventPage = React.lazy(() => import('./mobile/welcome/WelcomeEventPage'));
function RequireAuth() {
const { status } = useAuth();
const { status, user } = useAuth();
const location = useLocation();
const { hasEvents, isLoading: eventsLoading } = useEventContext();
const selectedPackageId = getSelectedPackageId();
const isWelcomePath = location.pathname.startsWith(ADMIN_WELCOME_BASE_PATH);
const isBillingPath = location.pathname.startsWith(ADMIN_BILLING_PATH);
const isTenantAdmin = Boolean(user && user.role !== 'member');
const shouldCheckPackages =
status === 'authenticated' && !eventsLoading && !hasEvents && !isWelcomePath && !isBillingPath;
status === 'authenticated' && isTenantAdmin && !eventsLoading && !hasEvents && !isWelcomePath && !isBillingPath;
const { data: packagesData, isLoading: packagesLoading } = useQuery({
queryKey: ['mobile', 'onboarding', 'packages-overview'],
@@ -63,8 +64,18 @@ function RequireAuth() {
staleTime: 60_000,
});
const { data: onboardingStatus, isLoading: onboardingLoading } = useQuery({
queryKey: ['mobile', 'onboarding', 'status'],
queryFn: fetchOnboardingStatus,
enabled: shouldCheckPackages,
staleTime: 60_000,
});
const hasActivePackage =
Boolean(packagesData?.activePackage) || Boolean(packagesData?.packages?.some((pkg) => pkg.active));
const isOnboardingDismissed = Boolean(onboardingStatus?.steps?.dismissed_at);
const isOnboardingCompleted = Boolean(onboardingStatus?.steps?.completed_at);
const shouldBlockOnboarding = shouldCheckPackages && onboardingLoading;
const redirectTarget = resolveOnboardingRedirect({
hasEvents,
@@ -73,6 +84,8 @@ function RequireAuth() {
pathname: location.pathname,
isWelcomePath,
isBillingPath,
isOnboardingDismissed,
isOnboardingCompleted,
});
if (status === 'loading') {
@@ -87,7 +100,7 @@ function RequireAuth() {
return <Navigate to={ADMIN_LOGIN_START_PATH} state={{ from: location }} replace />;
}
if (!isWelcomePath && !isBillingPath && (eventsLoading || packagesLoading)) {
if (!isWelcomePath && !isBillingPath && (eventsLoading || packagesLoading || shouldBlockOnboarding)) {
return (
<div className="flex min-h-screen items-center justify-center text-sm text-muted-foreground">
Bitte warten ...