From 7c3225f06eb3e065b72ccbfa827ce5a1a2f26f21 Mon Sep 17 00:00:00 2001 From: Linas Date: Mon, 24 Aug 2026 19:39:40 +0300 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_017hQcuUQFue2bFvrYw2UQhK --- app/dashboard/page.tsx | 10 ++++-- components/associations/association-table.tsx | 4 --- .../associations/edit-association-dialog.tsx | 32 +++++++++++-------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index f2c08c7..8c7d352 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -40,9 +40,13 @@ export default function DashboardPage() { const query_ = query.trim().toLowerCase(); if (!query_) return associations; return associations.filter((association) => - [association.name, association.address, association.vatNumber, association.runtsId].some( - (value) => value?.toLowerCase().includes(query_) - ) + [ + association.name, + association.address, + association.vatNumber, + association.runtsId, + association.nasFolderNumber?.toString(), + ].some((value) => value?.toLowerCase().includes(query_)) ); }, [associations, query]); diff --git a/components/associations/association-table.tsx b/components/associations/association-table.tsx index 6c8d197..3889257 100644 --- a/components/associations/association-table.tsx +++ b/components/associations/association-table.tsx @@ -30,7 +30,6 @@ export function AssociationTable({ associations }: { associations: Association[] Nome - Indirizzo P.IVA RUNTS Stato @@ -50,9 +49,6 @@ export function AssociationTable({ associations }: { associations: Association[] )} {association.name} - - {association.address} - {association.vatNumber || "—"} diff --git a/components/associations/edit-association-dialog.tsx b/components/associations/edit-association-dialog.tsx index dd0a07c..357cffe 100644 --- a/components/associations/edit-association-dialog.tsx +++ b/components/associations/edit-association-dialog.tsx @@ -14,7 +14,7 @@ import { import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Switch } from "@/components/ui/switch"; -import { updateAssociation } from "@/lib/api"; +import { getAssociations, updateAssociation } from "@/lib/api"; import type { Association } from "@/lib/models"; export function EditAssociationDialog({ @@ -30,7 +30,6 @@ export function EditAssociationDialog({ const [address, setAddress] = useState(association.address); const [vatNumber, setVatNumber] = useState(association.vatNumber ?? ""); const [runtsId, setRuntsId] = useState(association.runtsId ?? ""); - const [ratificationCode, setRatificationCode] = useState(association.ratificationCode ?? ""); const [nasFolderNumber, setNasFolderNumber] = useState(association.nasFolderNumber?.toString() ?? ""); const [isShown, setIsShown] = useState(association.isShown ?? true); @@ -40,7 +39,6 @@ export function EditAssociationDialog({ setAddress(association.address); setVatNumber(association.vatNumber ?? ""); setRuntsId(association.runtsId ?? ""); - setRatificationCode(association.ratificationCode ?? ""); setNasFolderNumber(association.nasFolderNumber?.toString() ?? ""); setIsShown(association.isShown ?? true); } @@ -50,13 +48,29 @@ export function EditAssociationDialog({ e.preventDefault(); setSaving(true); try { + if (nasFolderNumber.trim() !== "") { + const folderNumber = Number(nasFolderNumber); + const others = await getAssociations(); + const duplicate = others.find( + (a) => a.id !== association.id && a.nasFolderNumber === folderNumber + ); + if (duplicate) { + const proceed = confirm( + `Il numero cartella ${folderNumber} è già usato da "${duplicate.name}". Continuare comunque?` + ); + if (!proceed) { + setSaving(false); + return; + } + } + } + const updated = await updateAssociation(association.id!, { ...association, name, address, vatNumber, runtsId, - ratificationCode, nasFolderNumber: nasFolderNumber.trim() === "" ? undefined : Number(nasFolderNumber), isShown, }); @@ -104,16 +118,6 @@ export function EditAssociationDialog({ setRuntsId(e.target.value)} /> -
- - setRatificationCode(e.target.value)} - placeholder="Usato nell'attestato di adesione" - /> -
-