diff --git a/src/components/PlansSection.tsx b/src/components/PlansSection.tsx index 5e10b94..b064022 100644 --- a/src/components/PlansSection.tsx +++ b/src/components/PlansSection.tsx @@ -143,10 +143,17 @@ const PlansSection = () => { e: React.ChangeEvent ) => { const { name, value } = e.target; - setForm((p) => ({ ...p, [name]: value })); + setForm((p) => { + const next = { ...p, [name]: value }; + if (name === "postnummer") { + const suggested = cityFromPostalCode(value); + if (suggested) next.stad = suggested; + } + return next; + }); if (errors[name]) setErrors((p) => ({ ...p, [name]: "" })); - if (name === "postnummer" && errors.postnummer) { - setErrors((p) => ({ ...p, postnummer: "" })); + if (name === "postnummer") { + setErrors((p) => ({ ...p, postnummer: "", stad: "" })); } };