import { useState } from 'react'; import { RotateCcw, Trash2, Loader2 } from 'lucide-react'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, } from '@/components/ui/dialog'; import { Button } from '@/components/ui/button'; import { formatUSD } from '@/lib/money'; function daysLeftLabel(days) { if (days == null) return null; if (days <= 0) return 'purges today'; if (days === 1) return '1 day left'; return `${days} days left`; } /** * Lists bills that were soft-deleted within the 30-day recovery window and lets * the user restore them — a durable path beyond the transient "Undo" toast. * * Presentational: the parent owns the list (`bills`) and the async `onRestore`, * so restoring refreshes the page's active bills too. */ export default function RecentlyDeletedBillsDialog({ open, onOpenChange, bills = [], onRestore }) { const [busyId, setBusyId] = useState(null); async function handleRestore(bill) { setBusyId(bill.id); try { await onRestore(bill); } finally { setBusyId(null); } } return ( Recently deleted Deleted bills are kept for 30 days before they’re permanently removed. Restore one to bring it back. {bills.length === 0 ? (

Nothing to recover

Bills you delete will appear here for 30 days.

) : ( )}
); }