import { X } from "lucide-react"; import { Button } from "@/components/ui/Button"; import { Field, SelectField, TextField } from "@/components/ui/Field"; import { Lookup } from "@/components/ui/Lookup"; import { fmtDate } from "@/lib/format"; import type { OpenPositionResolved } from "@/lib/positions"; import type { HireDraftData } from "./types"; type StepPositionProps = { draft: HireDraftData; update: (patch: Partial) => void; openPositions: OpenPositionResolved[]; }; export function StepPosition({ draft, update, openPositions }: StepPositionProps) { const selected = openPositions.find((p) => p.id === draft.positionId) ?? null; async function search(query: string): Promise { const q = query.toLowerCase(); return openPositions.filter((p) => p.title.toLowerCase().includes(q) || p.position_number.includes(q)); } return (
{!selected ? ( {(p) => ( {...p} placeholder="Positionsname oder -nummer…" onSearch={search} onSelect={(pos) => update({ positionId: pos.id })} renderResult={(pos) => (
{pos.title}
{pos.position_number} · {pos.orgLabel}
)} /> )}
) : (

Position

{selected.title}
{selected.position_number} · {selected.orgLabel}
Gültig ab {fmtDate(selected.valid_from)}
)} update({ besetzung: v as HireDraftData["besetzung"] })} placeholder="Bitte wählen…" options={[ { value: "Extern", label: "Extern" }, { value: "Intern", label: "Intern" }, ]} /> {}} disabled hint="Ergibt sich aus der gewählten Position." />
); }