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
This commit is contained in:
parent
5c50f28f7e
commit
7c3225f06e
@ -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]);
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@ export function AssociationTable({ associations }: { associations: Association[]
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Nome</TableHead>
|
||||
<TableHead className="hidden md:table-cell">Indirizzo</TableHead>
|
||||
<TableHead className="hidden lg:table-cell">P.IVA</TableHead>
|
||||
<TableHead className="hidden lg:table-cell">RUNTS</TableHead>
|
||||
<TableHead>Stato</TableHead>
|
||||
@ -50,9 +49,6 @@ export function AssociationTable({ associations }: { associations: Association[]
|
||||
)}
|
||||
{association.name}
|
||||
</TableCell>
|
||||
<TableCell className="hidden max-w-64 truncate text-muted-foreground md:table-cell">
|
||||
{association.address}
|
||||
</TableCell>
|
||||
<TableCell className="hidden text-muted-foreground lg:table-cell">
|
||||
{association.vatNumber || "—"}
|
||||
</TableCell>
|
||||
|
||||
@ -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({
|
||||
<Input id="e-runtsId" value={runtsId} onChange={(e) => setRuntsId(e.target.value)} />
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="e-ratificationCode">Codice ratifica (es. LO183)</Label>
|
||||
<Input
|
||||
id="e-ratificationCode"
|
||||
value={ratificationCode}
|
||||
onChange={(e) => setRatificationCode(e.target.value)}
|
||||
placeholder="Usato nell'attestato di adesione"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="e-nasFolderNumber">Numero cartella NAS</Label>
|
||||
<Input
|
||||
|
||||
Loading…
Reference in New Issue
Block a user