forked from fahrPool/fahrPool
84 lines
2.6 KiB
TypeScript
84 lines
2.6 KiB
TypeScript
"use client";
|
|
|
|
import { useState } from "react";
|
|
import { FormField, FIELD_CLASSES } from "@/components/ui/FormField";
|
|
import { FUEHRERSCHEINKLASSEN, type NutzerDetails } from "@/lib/nutzerverwaltung/details";
|
|
|
|
const CHECKBOX_LABEL_CLASSES =
|
|
"flex min-h-11 items-center gap-2 rounded-md border border-aluminium-grey px-3 text-asphalt-grey";
|
|
|
|
export function NutzerDetailsFelder({ idPrefix, details }: { idPrefix: string; details: NutzerDetails }) {
|
|
const [fahrerkarte, setFahrerkarte] = useState(details.fahrerkarte);
|
|
|
|
return (
|
|
<>
|
|
<FormField label="Telefon" htmlFor={`${idPrefix}-telefon`}>
|
|
<input
|
|
id={`${idPrefix}-telefon`}
|
|
name="telefon"
|
|
type="tel"
|
|
inputMode="tel"
|
|
autoComplete="tel"
|
|
placeholder="+49 170 1234567"
|
|
defaultValue={details.telefon ?? ""}
|
|
className={FIELD_CLASSES}
|
|
/>
|
|
</FormField>
|
|
|
|
<fieldset className="mb-4">
|
|
<legend className="mb-1 text-sm font-medium text-asphalt-grey">Führerscheinklassen</legend>
|
|
<div className="flex flex-wrap gap-2">
|
|
{FUEHRERSCHEINKLASSEN.map((klasse) => (
|
|
<label key={klasse} className={CHECKBOX_LABEL_CLASSES}>
|
|
<input
|
|
type="checkbox"
|
|
name="fuehrerscheinklassen"
|
|
value={klasse}
|
|
defaultChecked={details.fuehrerscheinklassen.includes(klasse)}
|
|
className="h-5 w-5"
|
|
/>
|
|
{klasse}
|
|
</label>
|
|
))}
|
|
</div>
|
|
</fieldset>
|
|
|
|
<div className="mb-4 flex flex-col gap-2">
|
|
<label className={CHECKBOX_LABEL_CLASSES}>
|
|
<input
|
|
type="checkbox"
|
|
name="fahrerkarte"
|
|
checked={fahrerkarte}
|
|
onChange={(event) => setFahrerkarte(event.target.checked)}
|
|
className="h-5 w-5"
|
|
/>
|
|
Fahrerkarte vorhanden
|
|
</label>
|
|
</div>
|
|
|
|
<FormField label="Fahrerkarte gültig bis" htmlFor={`${idPrefix}-fahrerkarte-ablauf`}>
|
|
<input
|
|
id={`${idPrefix}-fahrerkarte-ablauf`}
|
|
name="fahrerkarteAblauf"
|
|
type="date"
|
|
disabled={!fahrerkarte}
|
|
defaultValue={details.fahrerkarteAblauf ?? ""}
|
|
className={FIELD_CLASSES}
|
|
/>
|
|
</FormField>
|
|
|
|
<div className="mb-4">
|
|
<label className={CHECKBOX_LABEL_CLASSES}>
|
|
<input
|
|
type="checkbox"
|
|
name="berechtigung95"
|
|
defaultChecked={details.berechtigung95}
|
|
className="h-5 w-5"
|
|
/>
|
|
Berechtigung 95 (Code 95) vorhanden
|
|
</label>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|