const cancelCheckout = useCallback(() => { // Track abandoned checkout (fire and forget) if (state.authUser || state.selectedPackage) { fetch('/checkout/track-abandoned', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '', }, body: JSON.stringify({ package_id: state.selectedPackage.id, last_step: ['package', 'auth', 'payment', 'confirmation'].indexOf(state.currentStep) + 1, user_id: state.authUser?.id, email: state.authUser?.email, }), }).catch(error => { console.error('Failed to track abandoned checkout:', error); }); } // State aus localStorage entfernen localStorage.removeItem('checkout-wizard-state'); // Zur Package-Übersicht zurückleiten window.location.href = '/packages'; }, [state]);