import { useState } from "react"; import { apiRequest } from "../../api/client"; import type { Standort } from "../../api/types"; interface Props { standorte: Standort[]; onGeaendert: () => Promise; onFehler: (text: string) => void; } export function StandortSection({ standorte, onGeaendert, onFehler }: Props) { const [name, setName] = useState(""); const [wirdAngelegt, setWirdAngelegt] = useState(false); async function anlegen() { setWirdAngelegt(true); try { await apiRequest("/standorte", { method: "POST", body: { name } }); setName(""); await onGeaendert(); } catch { onFehler("Standort konnte nicht angelegt werden."); } finally { setWirdAngelegt(false); } } return (

Standort anlegen

setName(e.target.value)} placeholder="Name des Standorts" />
{standorte.length > 0 && (
    {standorte.map((s) => (
  • {s.name}
  • ))}
)}
); }