feat: Implementierung des Checkout-Logins mit E-Mail/Username-Support

This commit is contained in:
Codex Agent
2025-10-08 21:57:46 +02:00
parent cee279cbab
commit 417b1da484
25 changed files with 730 additions and 212 deletions

View File

@@ -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 });
}, []);