1
0
Fork 0
fahrPool/web/components/auftraege/SchadenFotoFelder.tsx

44 lines
1.4 KiB
TypeScript

"use client";
import { useState } from "react";
import { FormField, FIELD_CLASSES } from "@/components/ui/FormField";
import { buttonClasses } from "@/components/ui/Button";
export function SchadenFotoFelder() {
const [zeilen, setZeilen] = useState<number[]>([0]);
return (
<div className="mb-4 flex flex-col gap-4">
{zeilen.map((index) => (
<div key={index} className="rounded-md border border-aluminium-grey p-3">
<FormField label={`Schadensfoto ${index + 1} (optional)`} htmlFor={`foto_schaden_${index}`}>
<input
id={`foto_schaden_${index}`}
name={`foto_schaden_${index}`}
type="file"
accept="image/*"
className={FIELD_CLASSES}
/>
</FormField>
<FormField label="Beschreibung (optional)" htmlFor={`foto_schaden_${index}_beschreibung`}>
<input
id={`foto_schaden_${index}_beschreibung`}
name={`foto_schaden_${index}_beschreibung`}
type="text"
placeholder="z. B. Kratzer hintere Stoßstange"
className={FIELD_CLASSES}
/>
</FormField>
</div>
))}
<button
type="button"
onClick={() => setZeilen((prev) => [...prev, prev.length])}
className={buttonClasses("secondary", false)}
>
Weiteres Schadensfoto hinzufügen
</button>
</div>
);
}