diff --git a/src/components/settings/AccountDeletionDialog.tsx b/src/components/settings/AccountDeletionDialog.tsx index 9951d2e2..160942b4 100644 --- a/src/components/settings/AccountDeletionDialog.tsx +++ b/src/components/settings/AccountDeletionDialog.tsx @@ -48,7 +48,7 @@ export function AccountDeletionDialog({ open, onOpenChange, userEmail, onDeletio { action: 'Request account deletion' } ); sessionStorage.setItem('mfa_step_up_required', 'true'); - sessionStorage.setItem('mfa_intended_path', '/settings?tab=privacy'); + sessionStorage.setItem('mfa_intended_path', '/settings'); window.location.href = '/auth'; return; } @@ -66,6 +66,10 @@ export function AccountDeletionDialog({ open, onOpenChange, userEmail, onDeletio if (error) throw error; + // Clear MFA session storage + sessionStorage.removeItem('mfa_step_up_required'); + sessionStorage.removeItem('mfa_intended_path'); + dispatch({ type: 'REQUEST_DELETION', payload: { scheduledDate: data.scheduled_deletion_at } diff --git a/src/components/settings/AccountProfileTab.tsx b/src/components/settings/AccountProfileTab.tsx index 30a028b6..91bfa0cd 100644 --- a/src/components/settings/AccountProfileTab.tsx +++ b/src/components/settings/AccountProfileTab.tsx @@ -84,7 +84,7 @@ export function AccountProfileTab() { isValid: usernameValidation.isAvailable !== false }); - // Check for existing deletion request on mount + // Check for existing deletion request on mount (both pending and confirmed) useEffect(() => { const checkDeletionRequest = async () => { if (!user?.id) return; @@ -93,7 +93,7 @@ export function AccountProfileTab() { .from('account_deletion_requests') .select('*') .eq('user_id', user.id) - .eq('status', 'pending') + .in('status', ['pending', 'confirmed']) .maybeSingle(); if (!error && data) { @@ -210,12 +210,12 @@ export function AccountProfileTab() { }; const handleDeletionRequested = async () => { - // Refresh deletion request data + // Refresh deletion request data (check for both pending and confirmed) const { data, error } = await supabase .from('account_deletion_requests') .select('*') .eq('user_id', user!.id) - .eq('status', 'pending') + .in('status', ['pending', 'confirmed']) .maybeSingle(); if (!error && data) { @@ -235,6 +235,7 @@ export function AccountProfileTab() { {deletionRequest && ( )} diff --git a/src/components/settings/DeletionStatusBanner.tsx b/src/components/settings/DeletionStatusBanner.tsx index ecc9db5b..74f06b11 100644 --- a/src/components/settings/DeletionStatusBanner.tsx +++ b/src/components/settings/DeletionStatusBanner.tsx @@ -9,10 +9,11 @@ import { getErrorMessage } from '@/lib/errorHandler'; interface DeletionStatusBannerProps { scheduledDate: string; + status: 'pending' | 'confirmed'; onCancelled: () => void; } -export function DeletionStatusBanner({ scheduledDate, onCancelled }: DeletionStatusBannerProps) { +export function DeletionStatusBanner({ scheduledDate, status, onCancelled }: DeletionStatusBannerProps) { const [loading, setLoading] = useState(false); const { toast } = useToast(); @@ -64,20 +65,38 @@ export function DeletionStatusBanner({ scheduledDate, onCancelled }: DeletionSta return ( - Account Deactivated - Deletion Scheduled + + {status === 'pending' ? 'Deletion Requested' : 'Account Deactivated - Deletion Scheduled'} + -

- Your account is deactivated and scheduled for permanent deletion on {formattedDate}. -

-

- {daysRemaining > 0 ? ( - <> - {daysRemaining} day{daysRemaining !== 1 ? 's' : ''} remaining to cancel. - - ) : ( - 'You can now confirm deletion with your confirmation code.' - )} -

+ {status === 'pending' ? ( + <> +

+ You have requested account deletion. Please check your email for a confirmation code. + You must enter the code within 24 hours to proceed. +

+

+ After confirming with the code, your account will be deactivated and scheduled for deletion on{' '} + {formattedDate}. +

+ + ) : ( + <> +

+ Your account is deactivated and scheduled for permanent deletion on{' '} + {formattedDate}. +

+

+ {daysRemaining > 0 ? ( + <> + {daysRemaining} day{daysRemaining !== 1 ? 's' : ''} remaining to cancel. + + ) : ( + 'Your account will be deleted within 24 hours.' + )} +

+ + )}