Guard checkout payment step behind login
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-04 12:43:04 +01:00
parent 1afd49bd24
commit cbb010acca
5 changed files with 56 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ import { AuthStep } from "./steps/AuthStep";
import { ConfirmationStep } from "./steps/ConfirmationStep";
import { useAnalytics } from '@/hooks/useAnalytics';
import { cn } from "@/lib/utils";
import toast from 'react-hot-toast';
const PaymentStep = lazy(() => import('./steps/PaymentStep').then((module) => ({ default: module.PaymentStep })));
@@ -80,6 +81,7 @@ const WizardBody: React.FC<{
authUser,
isAuthenticated,
paymentCompleted,
goToStep,
} = useCheckoutWizard();
const progressRef = useRef<HTMLDivElement | null>(null);
const hasMountedRef = useRef(false);
@@ -114,6 +116,13 @@ const WizardBody: React.FC<{
});
}, [currentStep, trackEvent]);
useEffect(() => {
if (currentStep === 'payment' && !isAuthenticated) {
toast.error(t('checkout.payment_step.auth_required'));
goToStep('auth');
}
}, [currentStep, goToStep, isAuthenticated, t]);
useEffect(() => {
if (typeof window === 'undefined' || !progressRef.current) {
return;