Show and make editable the NAS folder number

Prefixes the association name with "#<folder>" in the list table and
the detail page title, and adds an editable field for it in the edit
dialog - needed since some associations are missing it (NAS folders
that were never numbered), which is what silently blanks their
ratification code on the attestato.

Verified live: table and detail title show "#2 ENCAP ODV", the edit
field reflects the current value, and saving a new value updates both
immediately.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017hQcuUQFue2bFvrYw2UQhK
This commit is contained in:
Linas Puplauskas 2026-08-24 19:06:04 +03:00
parent 9274377a3d
commit 82c6d1e2cb
4 changed files with 22 additions and 2 deletions

View File

@ -147,7 +147,7 @@ export default function AssociationDetailPage() {
Torna alle associazioni Torna alle associazioni
</Button> </Button>
<PageHeader <PageHeader
title={association.name} title={association.nasFolderNumber != null ? `#${association.nasFolderNumber} ${association.name}` : association.name}
description={`${association.associates?.length ?? 0} soci registrati`} description={`${association.associates?.length ?? 0} soci registrati`}
actions={ actions={
<> <>

View File

@ -44,7 +44,12 @@ export function AssociationTable({ associations }: { associations: Association[]
className="cursor-pointer" className="cursor-pointer"
onClick={() => router.push(`/dashboard/${association.id}`)} onClick={() => router.push(`/dashboard/${association.id}`)}
> >
<TableCell className="font-medium">{association.name}</TableCell> <TableCell className="font-medium">
{association.nasFolderNumber != null && (
<span className="text-muted-foreground">#{association.nasFolderNumber} </span>
)}
{association.name}
</TableCell>
<TableCell className="hidden max-w-64 truncate text-muted-foreground md:table-cell"> <TableCell className="hidden max-w-64 truncate text-muted-foreground md:table-cell">
{association.address} {association.address}
</TableCell> </TableCell>

View File

@ -31,6 +31,7 @@ export function EditAssociationDialog({
const [vatNumber, setVatNumber] = useState(association.vatNumber ?? ""); const [vatNumber, setVatNumber] = useState(association.vatNumber ?? "");
const [runtsId, setRuntsId] = useState(association.runtsId ?? ""); const [runtsId, setRuntsId] = useState(association.runtsId ?? "");
const [ratificationCode, setRatificationCode] = useState(association.ratificationCode ?? ""); const [ratificationCode, setRatificationCode] = useState(association.ratificationCode ?? "");
const [nasFolderNumber, setNasFolderNumber] = useState(association.nasFolderNumber?.toString() ?? "");
const [isShown, setIsShown] = useState(association.isShown ?? true); const [isShown, setIsShown] = useState(association.isShown ?? true);
useEffect(() => { useEffect(() => {
@ -40,6 +41,7 @@ export function EditAssociationDialog({
setVatNumber(association.vatNumber ?? ""); setVatNumber(association.vatNumber ?? "");
setRuntsId(association.runtsId ?? ""); setRuntsId(association.runtsId ?? "");
setRatificationCode(association.ratificationCode ?? ""); setRatificationCode(association.ratificationCode ?? "");
setNasFolderNumber(association.nasFolderNumber?.toString() ?? "");
setIsShown(association.isShown ?? true); setIsShown(association.isShown ?? true);
} }
}, [open, association]); }, [open, association]);
@ -55,6 +57,7 @@ export function EditAssociationDialog({
vatNumber, vatNumber,
runtsId, runtsId,
ratificationCode, ratificationCode,
nasFolderNumber: nasFolderNumber.trim() === "" ? undefined : Number(nasFolderNumber),
isShown, isShown,
}); });
onSaved(updated); onSaved(updated);
@ -111,6 +114,17 @@ export function EditAssociationDialog({
/> />
</div> </div>
<div className="space-y-2">
<Label htmlFor="e-nasFolderNumber">Numero cartella NAS</Label>
<Input
id="e-nasFolderNumber"
type="number"
value={nasFolderNumber}
onChange={(e) => setNasFolderNumber(e.target.value)}
placeholder="Usato per generare il codice di ratifica"
/>
</div>
<div className="flex items-center justify-between rounded-lg border p-3 sm:col-span-2"> <div className="flex items-center justify-between rounded-lg border p-3 sm:col-span-2">
<div> <div>
<Label htmlFor="e-isShown">Associazione attiva</Label> <Label htmlFor="e-isShown">Associazione attiva</Label>

View File

@ -28,6 +28,7 @@ export interface Association {
associates?: Associate[]; associates?: Associate[];
users?: User[]; users?: User[];
ratificationCode?: string; ratificationCode?: string;
nasFolderNumber?: number;
} }
export interface LoginResponse { export interface LoginResponse {