98 lines
2.6 KiB
TypeScript
98 lines
2.6 KiB
TypeScript
import { FIELD_CLASSES } from "@/components/ui/FormField";
|
|
|
|
const LABEL = "mb-1 block text-sm font-medium text-asphalt-grey";
|
|
|
|
// Name, dann Strasse + Nr und PLZ + Ort jeweils in einer Zeile (Nr/PLZ schmal).
|
|
// Feldnamen passen zu validateOrtFormular.
|
|
export function AdressFelder({
|
|
idPrefix,
|
|
werte = {},
|
|
}: {
|
|
idPrefix: string;
|
|
werte?: {
|
|
name?: string | null;
|
|
strasse?: string | null;
|
|
hausnummer?: string | null;
|
|
plz?: string | null;
|
|
ort?: string | null;
|
|
};
|
|
}) {
|
|
const id = (feld: string) => `${idPrefix}-${feld}`;
|
|
return (
|
|
<div className="mb-4 flex flex-col gap-3">
|
|
<div>
|
|
<label htmlFor={id("name")} className={LABEL}>
|
|
Name
|
|
</label>
|
|
<input
|
|
id={id("name")}
|
|
name="name"
|
|
required
|
|
autoComplete="organization"
|
|
placeholder="z. B. Autohaus Widmann Aalen"
|
|
defaultValue={werte.name ?? ""}
|
|
className={FIELD_CLASSES}
|
|
/>
|
|
</div>
|
|
<div className="flex gap-3">
|
|
<div className="min-w-0 flex-1">
|
|
<label htmlFor={id("strasse")} className={LABEL}>
|
|
Straße
|
|
</label>
|
|
<input
|
|
id={id("strasse")}
|
|
name="strasse"
|
|
required
|
|
autoComplete="address-line1"
|
|
defaultValue={werte.strasse ?? ""}
|
|
className={FIELD_CLASSES}
|
|
/>
|
|
</div>
|
|
<div className="w-24 shrink-0">
|
|
<label htmlFor={id("hausnummer")} className={LABEL}>
|
|
Nr.
|
|
</label>
|
|
<input
|
|
id={id("hausnummer")}
|
|
name="hausnummer"
|
|
defaultValue={werte.hausnummer ?? ""}
|
|
className={FIELD_CLASSES}
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div className="flex gap-3">
|
|
<div className="w-28 shrink-0">
|
|
<label htmlFor={id("plz")} className={LABEL}>
|
|
PLZ
|
|
</label>
|
|
<input
|
|
id={id("plz")}
|
|
name="plz"
|
|
required
|
|
inputMode="numeric"
|
|
pattern="\d{5}"
|
|
maxLength={5}
|
|
autoComplete="postal-code"
|
|
title="5 Ziffern"
|
|
defaultValue={werte.plz ?? ""}
|
|
className={FIELD_CLASSES}
|
|
/>
|
|
</div>
|
|
<div className="min-w-0 flex-1">
|
|
<label htmlFor={id("ort")} className={LABEL}>
|
|
Ort
|
|
</label>
|
|
<input
|
|
id={id("ort")}
|
|
name="ort"
|
|
required
|
|
autoComplete="address-level2"
|
|
defaultValue={werte.ort ?? ""}
|
|
className={FIELD_CLASSES}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|