feat: enhance ResidenzaSection to automatically set cap_residenza based on selected comune and update placeholders for input fields

This commit is contained in:
Marco Pedone 2026-03-20 17:23:43 +01:00
parent ed93eb12a1
commit 7c49ca8f66

View file

@ -593,6 +593,12 @@ const ResidenzaSection = ({
onValueChange={async (value) => {
field.onChange(value.value);
await trigger("comune_residenza");
const selectedComune = comuni.find(
(c) => c.catasto === value.value,
);
if (selectedComune?.cap) {
setValue("cap_residenza", selectedComune.cap);
}
}}
options={options}
placeholder="Seleziona..."
@ -626,6 +632,7 @@ const ResidenzaSection = ({
);
}}
/>
<FormField
control={control}
name="cap_residenza"
@ -640,7 +647,7 @@ const ResidenzaSection = ({
<Input
{...field}
id="cap_residenza"
placeholder="00100"
placeholder=""
type="text"
/>
</FormControl>
@ -664,7 +671,7 @@ const ResidenzaSection = ({
<Input
{...field}
id="via_residenza"
placeholder="Via Roma"
placeholder="Via ..."
type="text"
/>
</FormControl>
@ -688,7 +695,7 @@ const ResidenzaSection = ({
<Input
{...field}
id="civico_residenza"
placeholder="50"
placeholder=""
type="text"
/>
</FormControl>