import { GripVertical, Trash2, ChevronDown, ChevronUp } from 'lucide-react' import { useState } from 'react' import type { IntakeFormField, IntakeFieldType } from '@/types' const FIELD_TYPE_OPTIONS: { value: IntakeFieldType; label: string }[] = [ { value: 'text', label: 'Text' }, { value: 'textarea', label: 'Text Area' }, { value: 'number', label: 'Number' }, { value: 'ip_address', label: 'IP Address' }, { value: 'email', label: 'Email' }, { value: 'url', label: 'URL' }, { value: 'select', label: 'Select (Dropdown)' }, { value: 'multi_select', label: 'Multi-Select' }, { value: 'checkbox', label: 'Checkbox' }, { value: 'password', label: 'Password' }, ] interface IntakeFieldEditorProps { field: IntakeFormField onUpdate: (updates: Partial) => void onRemove: () => void } export function IntakeFieldEditor({ field, onUpdate, onRemove }: IntakeFieldEditorProps) { const [expanded, setExpanded] = useState(false) const needsOptions = field.field_type === 'select' || field.field_type === 'multi_select' return (
{/* Header row */}
onUpdate({ label: e.target.value })} placeholder="Field label" className="min-w-0 flex-1 rounded border border-border bg-card px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-hidden focus:ring-1 focus:ring-primary/20" />
{/* Expanded details */} {expanded && (
onUpdate({ variable_name: e.target.value.toLowerCase().replace(/[^a-z0-9_]/g, '') })} placeholder="e.g. server_name" className="w-full rounded border border-border bg-card px-2 py-1.5 text-sm font-mono text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-hidden focus:ring-1 focus:ring-primary/20" />

Used as [VAR:{field.variable_name}]

onUpdate({ placeholder: e.target.value || undefined })} placeholder="Hint text" className="w-full rounded border border-border bg-card px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-hidden focus:ring-1 focus:ring-primary/20" />
onUpdate({ help_text: e.target.value || undefined })} placeholder="Description or instructions" className="w-full rounded border border-border bg-card px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-hidden focus:ring-1 focus:ring-primary/20" />
onUpdate({ default_value: e.target.value || undefined })} placeholder="Pre-filled value" className="w-full rounded border border-border bg-card px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-hidden focus:ring-1 focus:ring-primary/20" />
onUpdate({ group_name: e.target.value || undefined })} placeholder="e.g. Network Settings" className="w-full rounded border border-border bg-card px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-primary focus:outline-hidden focus:ring-1 focus:ring-primary/20" />
{needsOptions && (