ente_nazionale_frontend/components/associations/association-table.tsx
Linas 7c3225f06e Search by NAS folder number, drop Indirizzo column, remove manual ratifica field
- Association list search now also matches nasFolderNumber.
- Dropped the "Indirizzo" column from the list table (still editable
  in the edit dialog, just not shown in the table).
- Removed the manual "Codice ratifica" field from the edit dialog -
  it's derived automatically now, so a manual override field was
  redundant and a source of stale/wrong values; the underlying field
  is untouched by this (existing values are preserved via the
  spread), just no longer directly editable here.
- Saving a NAS folder number that's already used by another
  association now warns (with the other association's name) before
  proceeding, since a collision silently produces two associations
  with the same ratification code.

Verified live: table has no Indirizzo column, searching "2" surfaces
"#2 ENCAP ODV", the ratification code field is gone from the edit
dialog, and setting folder 4 (already used by ENCAP - COMITATO
REGIONALE VENETO) triggers the duplicate warning.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017hQcuUQFue2bFvrYw2UQhK
2026-08-24 19:39:40 +03:00

71 lines
2.3 KiB
TypeScript

"use client";
import { useRouter } from "next/navigation";
import { ChevronRight } from "lucide-react";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import type { Association } from "@/lib/models";
import { AssociationStatusBadge } from "./association-status-badge";
export function AssociationTable({ associations }: { associations: Association[] }) {
const router = useRouter();
if (associations.length === 0) {
return (
<div className="rounded-lg border border-dashed py-16 text-center text-sm text-muted-foreground">
Nessuna associazione trovata
</div>
);
}
return (
<div className="rounded-lg border bg-background">
<Table>
<TableHeader>
<TableRow>
<TableHead>Nome</TableHead>
<TableHead className="hidden lg:table-cell">P.IVA</TableHead>
<TableHead className="hidden lg:table-cell">RUNTS</TableHead>
<TableHead>Stato</TableHead>
<TableHead className="w-8" />
</TableRow>
</TableHeader>
<TableBody>
{associations.map((association) => (
<TableRow
key={association.id}
className="cursor-pointer"
onClick={() => router.push(`/dashboard/${association.id}`)}
>
<TableCell className="font-medium">
{association.nasFolderNumber != null && (
<span className="text-muted-foreground">#{association.nasFolderNumber} </span>
)}
{association.name}
</TableCell>
<TableCell className="hidden text-muted-foreground lg:table-cell">
{association.vatNumber || "—"}
</TableCell>
<TableCell className="hidden text-muted-foreground lg:table-cell">
{association.runtsId || "—"}
</TableCell>
<TableCell>
<AssociationStatusBadge isShown={association.isShown} />
</TableCell>
<TableCell>
<ChevronRight className="size-4 text-muted-foreground" />
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
);
}