/** * Start node (Formular) — define fields that appear at run time (payload.*). */ import React, { useMemo } from 'react'; import type { NodeConfigRendererProps } from '../configs/types'; import styles from '../../editor/Automation2FlowEditor.module.css'; type FormField = { name: string; label: string; type: 'text' | 'number' | 'email' | 'date' | 'boolean' | 'clickup_status'; statusOptions?: Array<{ value: string; label: string }>; }; const FORM_FIELD_TYPES = ['text', 'number', 'email', 'date', 'boolean', 'clickup_status'] as const; function parseFields(params: Record): FormField[] { const raw = params.formFields; if (!Array.isArray(raw)) return [{ name: 'field1', label: 'Feld 1', type: 'text' }]; return raw.map((f, i) => { if (f && typeof f === 'object' && !Array.isArray(f)) { const o = f as Record; const t = String(o.type ?? 'text'); const name = String(o.name ?? `field${i + 1}`); const label = String(o.label ?? `Feld ${i + 1}`); const type = ( FORM_FIELD_TYPES.includes(t as (typeof FORM_FIELD_TYPES)[number]) ? t : 'text' ) as FormField['type']; if (type === 'clickup_status' && Array.isArray(o.statusOptions)) { return { name, label, type: 'clickup_status', statusOptions: o.statusOptions as Array<{ value: string; label: string }>, }; } return { name, label, type }; } return { name: `field${i + 1}`, label: `Feld ${i + 1}`, type: 'text' as const }; }); } export const FormStartNodeConfig: React.FC = ({ params, updateParam }) => { const fields = useMemo(() => parseFields(params), [params]); const setFields = (next: FormField[]) => { updateParam('formFields', next); }; return (

Formular-Felder werden beim Start ausgefüllt und liegen unter{' '} payload.<name> in der Start-Ausgabe.

{fields.map((f, idx) => (
{ const next = [...fields]; next[idx] = { ...f, name: e.target.value }; setFields(next); }} /> { const next = [...fields]; next[idx] = { ...f, label: e.target.value }; setFields(next); }} />
))}
); };