"use client"; import { Button } from "@/components/ui/button"; import { TextInput } from "@/components/ui/TextInput/TextInput"; import type { FormScreenDefinition, FormFieldDefinition } from "@/lib/funnel/types"; import type { BuilderScreen } from "@/lib/admin/builder/types"; interface FormScreenConfigProps { screen: BuilderScreen & { template: "form" }; onUpdate: (updates: Partial) => void; } export function FormScreenConfig({ screen, onUpdate }: FormScreenConfigProps) { const formScreen = screen as FormScreenDefinition & { position: any }; const updateField = (index: number, updates: Partial) => { const newFields = [...(formScreen.fields || [])]; newFields[index] = { ...newFields[index], ...updates }; onUpdate({ fields: newFields }); }; const addField = () => { const newField: FormFieldDefinition = { id: `field_${Date.now()}`, label: "New Field", placeholder: "Enter value", type: "text", required: true, }; onUpdate({ fields: [...(formScreen.fields || []), newField] }); }; const removeField = (index: number) => { const newFields = formScreen.fields?.filter((_, i) => i !== index) || []; onUpdate({ fields: newFields }); }; return (
{/* Title Configuration */}
onUpdate({ title: { ...formScreen.title, text: value, font: formScreen.title?.font || "manrope", weight: formScreen.title?.weight || "bold", } })} />
{/* Subtitle Configuration */}
onUpdate({ subtitle: value ? { text: value, font: formScreen.subtitle?.font || "inter", weight: formScreen.subtitle?.weight || "medium", color: formScreen.subtitle?.color || "muted", } : undefined })} />
{/* Form Fields Configuration */}

Form Fields

{formScreen.fields?.map((field, index) => (
Field {index + 1}
updateField(index, { id: value })} />
updateField(index, { label: value })} />
updateField(index, { placeholder: value })} />
{field.maxLength && (
updateField(index, { maxLength: parseInt(e.target.value) || undefined })} />
)}
))} {(!formScreen.fields || formScreen.fields.length === 0) && (
No fields added yet. Click "Add Field" to get started.
)}
{/* Bottom Action Button */}
onUpdate({ bottomActionButton: { text: value || "Continue", } })} />
); }