"use client" import { ArrowLeft, Download, Pencil, Star, Trash2, Mail, Phone, Building2, MapPin, Cake, FileText, MessageSquare, Video, } from "lucide-react" import { Button } from "@/components/ui/button" import { useContactsStore } from "@/lib/contacts/contacts-store" import { fullContactDisplayName } from "@/lib/contacts/types" import { avatarColor, senderInitial } from "@/lib/sender-display" import { useNavStore } from "@/lib/stores/nav-store" import { downloadContactVCard } from "@/lib/contacts/export-contacts" import { CONTACTS_HEADING_TEXT, CONTACTS_MUTED_TEXT, CONTACTS_PAGE_ICON_BTN_CLASS, CONTACTS_PAGE_TAG_CLASS, CONTACTS_PANEL_DIVIDER_CLASS, CONTACTS_PANEL_MUTED_ICON_CLASS, CONTACTS_PANEL_PRIMARY_ACTION_CLASS, CONTACTS_PANEL_SECONDARY_ICON_BTN_CLASS, } from "@/lib/contacts-chrome-classes" import { cn } from "@/lib/utils" const FRENCH_MONTHS = [ "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre", ] function formatBirthday(b: { day?: number; month?: number; year?: number }): string { const parts: string[] = [] if (b.day) parts.push(String(b.day)) if (b.month) parts.push(FRENCH_MONTHS[b.month - 1] ?? "") if (b.year) parts.push(String(b.year)) return parts.join(" ") } interface ContactDetailPageProps { contactId: string onBack: () => void onEdit: (id: string) => void } export function ContactDetailPage({ contactId, onBack, onEdit }: ContactDetailPageProps) { const { contacts, softDeleteContact } = useContactsStore() const labelRows = useNavStore((s) => s.labelRows) const contact = contacts.find((c) => c.id === contactId) if (!contact) { return (
Contact introuvable
) } const displayName = fullContactDisplayName(contact) const name = displayName || contact.emails[0]?.value || contact.phones[0]?.value || "?" const color = avatarColor(name) const initial = senderInitial(name) const primaryEmail = contact.emails[0]?.value function handleDelete() { softDeleteContact(contactId, "Supprimé manuellement") onBack() } return (
{contact.avatarUrl ? ( {name} ) : (
{initial}
)}

{name}

{contact.company && (

{contact.jobTitle ? `${contact.jobTitle} — ` : ""} {contact.company}

)} {contact.labels && contact.labels.length > 0 && (
{contact.labels.map((labelId) => { const row = labelRows.find((r) => r.id === labelId) return row ? ( {row.label} ) : null })}
)}
{primaryEmail && (
)}
{contact.emails.length > 0 && ( }> {contact.emails.map((e, i) => (

{e.value}

{e.label}

))}
)} {contact.phones.length > 0 && ( }> {contact.phones.map((p, i) => (

{p.value}

{p.label}

))}
)} {contact.company && ( }>

{contact.company}

{contact.department && (

{contact.department}

)} {contact.jobTitle && (

{contact.jobTitle}

)}
)} {contact.addresses && contact.addresses.length > 0 && ( }> {contact.addresses.map((addr, i) => (

{[addr.street, [addr.postalCode, addr.city].filter(Boolean).join(" "), addr.region, addr.country] .filter(Boolean) .join(", ")}

{addr.label}

))}
)} {contact.birthday && (contact.birthday.day || contact.birthday.month) && ( }>

{formatBirthday(contact.birthday)}

)} {contact.notes && ( }>

{contact.notes}

)}
) } function DetailRow({ icon, children }: { icon: React.ReactNode; children: React.ReactNode }) { return (
{icon}
{children}
) }