"use client" import { MoreVertical, RotateCcw, Trash2 } from "lucide-react" import { Button } from "@/components/ui/button" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { useContactsStore } from "@/lib/contacts/contacts-store" import { fullContactDisplayName } from "@/lib/contacts/types" import { avatarColor, senderInitial } from "@/lib/sender-display" export function TrashView() { const { deletedContacts, restoreContact, emptyTrash } = useContactsStore() function formatDate(ts: number): string { return new Date(ts).toLocaleDateString("fr-FR", { day: "numeric", month: "short", }) } return (
{/* Warning banner */} {deletedContacts.length > 0 && (

Les contacts qui sont dans la corbeille depuis plus de 30 jours seront supprimés définitivement

)} {/* Title */}

Corbeille ({deletedContacts.length})

{deletedContacts.length === 0 && (

La corbeille est vide

)} {deletedContacts.length > 0 && ( <> {/* Table header */}
Nom Raison du placement dans la corbeille Date de suppression
{/* Rows */} {deletedContacts.map((entry) => { const { contact, deletedAt, reason } = entry const displayName = fullContactDisplayName(contact) const name = displayName || contact.emails[0]?.value || "?" const color = avatarColor(name) const initial = senderInitial(name) return (
{contact.avatarUrl ? ( {name} ) : ( {initial} )} {name} {reason} {formatDate(deletedAt)} restoreContact(contact.id)}> Restaurer useContactsStore.getState().deleteContact(contact.id)} className="text-red-600 focus:text-red-600" > Supprimer définitivement
) })} )}
) }