mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 15:31:13 -05:00
Refactor account deletion flow
This commit is contained in:
@@ -71,13 +71,12 @@ export function AccountDeletionDialog({ open, onOpenChange, userEmail, onDeletio
|
||||
if (error) throw error;
|
||||
|
||||
toast({
|
||||
title: 'Account Deleted',
|
||||
description: 'Your account has been permanently deleted.',
|
||||
title: 'Deletion Confirmed',
|
||||
description: 'Your account has been deactivated and scheduled for permanent deletion.',
|
||||
});
|
||||
|
||||
// Sign out and redirect
|
||||
await supabase.auth.signOut();
|
||||
window.location.href = '/';
|
||||
// Refresh the page to show the deletion banner
|
||||
window.location.reload();
|
||||
} catch (error: any) {
|
||||
toast({
|
||||
variant: 'destructive',
|
||||
@@ -159,7 +158,7 @@ export function AccountDeletionDialog({ open, onOpenChange, userEmail, onDeletio
|
||||
|
||||
<Alert variant="destructive">
|
||||
<AlertDescription>
|
||||
<strong>2-Week Waiting Period:</strong> Your account will be deactivated immediately, but you'll have 14 days to cancel before permanent deletion. You'll receive a confirmation code via email.
|
||||
<strong>24-Hour Code + 2-Week Waiting Period:</strong> After confirming with the code (within 24 hours), your account will be deactivated immediately. You'll then have 14 days to cancel before permanent deletion.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
</div>
|
||||
@@ -169,7 +168,7 @@ export function AccountDeletionDialog({ open, onOpenChange, userEmail, onDeletio
|
||||
{step === 'confirm' && (
|
||||
<Alert variant="destructive">
|
||||
<AlertDescription>
|
||||
Are you absolutely sure? This will deactivate your account immediately and schedule it for permanent deletion in 2 weeks.
|
||||
Are you absolutely sure? You'll receive a confirmation code via email. After confirming with the code, your account will be deactivated and scheduled for deletion in 2 weeks.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
@@ -179,15 +178,11 @@ export function AccountDeletionDialog({ open, onOpenChange, userEmail, onDeletio
|
||||
<Alert>
|
||||
<Info className="w-4 h-4" />
|
||||
<AlertDescription>
|
||||
Your account has been deactivated and will be deleted on{' '}
|
||||
<strong>{scheduledDate ? new Date(scheduledDate).toLocaleDateString() : '14 days from now'}</strong>.
|
||||
A 6-digit confirmation code has been sent to <strong>{userEmail}</strong>. Enter it below within 24 hours to confirm deletion. Your account will be deactivated and scheduled for deletion on{' '}
|
||||
<strong>{scheduledDate ? new Date(scheduledDate).toLocaleDateString() : '14 days from confirmation'}</strong>.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<p className="text-sm">
|
||||
A 6-digit confirmation code has been sent to <strong>{userEmail}</strong>.
|
||||
</p>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="confirmationCode">Confirmation Code</Label>
|
||||
@@ -222,12 +217,6 @@ export function AccountDeletionDialog({ open, onOpenChange, userEmail, onDeletio
|
||||
{loading ? <Loader2 className="w-4 h-4 animate-spin" /> : 'Resend Code'}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Alert>
|
||||
<AlertDescription className="text-xs">
|
||||
Note: You cannot confirm deletion until the 2-week period has passed. You can cancel at any time during this period.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
</div>
|
||||
)}
|
||||
</AlertDialogDescription>
|
||||
@@ -271,7 +260,7 @@ export function AccountDeletionDialog({ open, onOpenChange, userEmail, onDeletio
|
||||
disabled={loading || !codeReceived || confirmationCode.length !== 6}
|
||||
>
|
||||
{loading ? <Loader2 className="w-4 h-4 animate-spin mr-2" /> : null}
|
||||
Confirm Deletion
|
||||
Verify Code & Deactivate Account
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -59,10 +59,10 @@ export function DeletionStatusBanner({ scheduledDate, onCancelled }: DeletionSta
|
||||
return (
|
||||
<Alert variant="destructive" className="mb-6">
|
||||
<AlertTriangle className="w-4 h-4" />
|
||||
<AlertTitle>Account Deletion Scheduled</AlertTitle>
|
||||
<AlertTitle>Account Deactivated - Deletion Scheduled</AlertTitle>
|
||||
<AlertDescription className="space-y-2">
|
||||
<p>
|
||||
Your account is scheduled for permanent deletion on <strong>{formattedDate}</strong>.
|
||||
Your account is <strong>deactivated</strong> and scheduled for permanent deletion on <strong>{formattedDate}</strong>.
|
||||
</p>
|
||||
<p className="text-sm">
|
||||
{daysRemaining > 0 ? (
|
||||
|
||||
Reference in New Issue
Block a user