feat: Implementierung des Checkout-Logins mit E-Mail/Username-Support
This commit is contained in:
@@ -124,14 +124,18 @@ export function CheckoutWizardProvider({
|
||||
if (savedState) {
|
||||
try {
|
||||
const parsed = JSON.parse(savedState);
|
||||
// Restore state selectively
|
||||
if (parsed.selectedPackage) dispatch({ type: 'SELECT_PACKAGE', payload: parsed.selectedPackage });
|
||||
if (parsed.currentStep) dispatch({ type: 'GO_TO_STEP', payload: parsed.currentStep });
|
||||
if (parsed.selectedPackage && initialPackage && parsed.selectedPackage.id === initialPackage.id && parsed.currentStep !== 'confirmation') {
|
||||
// Restore state selectively
|
||||
if (parsed.selectedPackage) dispatch({ type: 'SELECT_PACKAGE', payload: parsed.selectedPackage });
|
||||
if (parsed.currentStep) dispatch({ type: 'GO_TO_STEP', payload: parsed.currentStep });
|
||||
} else {
|
||||
localStorage.removeItem('checkout-wizard-state');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to restore checkout state:', error);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
}, [initialPackage]);
|
||||
|
||||
// Save state to localStorage whenever it changes
|
||||
useEffect(() => {
|
||||
@@ -141,6 +145,13 @@ export function CheckoutWizardProvider({
|
||||
}));
|
||||
}, [state.selectedPackage, state.currentStep]);
|
||||
|
||||
// Clear localStorage when confirmation step is reached
|
||||
useEffect(() => {
|
||||
if (state.currentStep === 'confirmation') {
|
||||
localStorage.removeItem('checkout-wizard-state');
|
||||
}
|
||||
}, [state.currentStep]);
|
||||
|
||||
const selectPackage = useCallback((pkg: CheckoutPackage) => {
|
||||
dispatch({ type: 'SELECT_PACKAGE', payload: pkg });
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user