import { Pencil, Trash2 } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import type { Associate } from "@/lib/models"; const ROLE_LABELS: Record = { PRESIDENT: "Presidente", VICE_PRESIDENT: "Vicepresidente", SECRETARY: "Segretario", ASSOCIATE: "Socio", }; export function AssociateTable({ associates, onEdit, onDelete, }: { associates: Associate[]; onEdit?: (index: number) => void; onDelete?: (index: number) => Promise | void; }) { const editable = Boolean(onEdit || onDelete); if (associates.length === 0) { return (

Nessun socio registrato

); } return ( Nome Ruolo Codice fiscale Indirizzo Cittadinanza {editable && } {associates.map((associate, index) => ( {associate.name} {associate.surname} {ROLE_LABELS[associate.role] ?? associate.role} {associate.fiscalCode || "—"} {associate.address || "—"} {associate.italianCitizen ? "Italiana" : "Straniera"} {editable && (
{onEdit && ( )} {onDelete && ( } title="Rimuovere il socio?" description={`${associate.name} ${associate.surname} verrà rimosso dall'associazione.`} confirmLabel="Rimuovi" onConfirm={() => onDelete(index)} /> )}
)}
))}
); }