import { INITIATIVE_STATUSES, INITIATIVE_STATUS_LABELS } from '../constants/status.js' import { GateSelect } from './GateSelect.jsx' import { flattenProjectOptions } from '../utils/projectTree.js' import { projectArchetypeLabel } from '../utils/archetypes.js' const CONTAINER_KINDS = [ { value: '', label: '— Standard —' }, { value: 'project', label: 'Projekt' }, { value: 'stream', label: 'Stream' }, { value: 'phase', label: 'Phase' }, { value: 'release', label: 'Release' }, ] export function ProjectForm({ initial = {}, projects = [], roadmapItems = [], excludeProjectId = '', onSubmit, onCancel, busy = false, submitLabel = 'Speichern', initiativeArchetypeKey = '', initiativeArchetypes = [], projectArchetypes = [], }) { const parentOptions = flattenProjectOptions( projects.filter((p) => p.id !== excludeProjectId), ) async function handleSubmit(e) { e.preventDefault() const form = e.target const parentValue = form.parent_project_id?.value ?? '' const kindValue = form.container_kind?.value ?? '' const gateValue = form.roadmap_item_id?.value ?? '' const targetValue = form.target_date?.value ?? '' const sortValue = form.sort_order?.value ?? '0' await onSubmit({ title: form.title.value.trim(), description: form.description.value, status: form.status.value, parent_project_id: parentValue || undefined, clear_parent_project: parentValue === '', container_kind: kindValue || undefined, clear_container_kind: kindValue === '', roadmap_item_id: gateValue || undefined, clear_roadmap_item: gateValue === '', target_date: targetValue || undefined, clear_target_date: !targetValue, sort_order: Number.parseInt(sortValue, 10) || 0, }) } return (
{initiativeArchetypeKey && (

Archetyp wird vom Vorhaben übernommen:{' '} {projectArchetypeLabel( `project.${initiativeArchetypeKey.replace(/^initiative\./, '')}`, projectArchetypes, initiativeArchetypes, )} . „Art“ unten ist nur die Struktur-Rolle (Projekt, Stream, Phase …).

)}