Guard checkout payment step behind login
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user