'use client'; import { useState } from 'react'; import { Download, LogOut, RotateCcw, ShieldAlert } from 'lucide-react'; import { Button } from '@/components/ui/Button'; import { api, ApiError } from '@/lib/api'; import { useAuthStore } from '@/stores/auth'; import { formatPurgeDate } from '@/lib/deletion'; interface AccountLockedProps { /** ISO timestamp of when deletion was requested. */ requestedAt: string; } /** * Full-screen takeover for an account pending deletion. * * Every product endpoint 403s for a locked account, so rendering the normal app * would be a wall of errors. This gives the user the only three things they can * still do: come back, take their data, or leave. */ export function AccountLocked({ requestedAt }: AccountLockedProps) { const logout = useAuthStore((state) => state.logout); const setUser = useAuthStore((state) => state.setUser); const [busy, setBusy] = useState<'restore' | 'export' | undefined>(undefined); const [error, setError] = useState(undefined); const onRestore = async () => { setError(undefined); setBusy('restore'); try { setUser(await api.cancelAccountDeletion()); } catch (err) { setError( err instanceof ApiError ? err.message : 'Your account could not be restored.', ); setBusy(undefined); } }; const onExport = async () => { setError(undefined); setBusy('export'); try { await api.exportAccountData(); } catch (err) { setError( err instanceof ApiError ? err.message : 'Your data could not be exported.', ); } finally { setBusy(undefined); } }; return (

Account scheduled for deletion

Everything in this account will be permanently erased on{' '} {formatPurgeDate(requestedAt)}. Until then it is locked: you cannot run tasks or use any part of the product.

Restoring brings the account straight back. It does not reinstate a subscription that was cancelled when you requested deletion.

{error && (

> ERROR: {error}

)}
); }