import { useState } from 'react' import { DynamicArrayField } from './DynamicArrayField' import { useTreeEditorStore } from '@/store/treeEditorStore' import { MarkdownContent } from '@/components/ui/MarkdownContent' import type { TreeStructure } from '@/types' import { cn } from '@/lib/utils' interface NodeFormResolutionProps { node: TreeStructure onUpdate: (updates: Partial) => void } export function NodeFormResolution({ node, onUpdate }: NodeFormResolutionProps) { const { validationErrors } = useTreeEditorStore() const [showPreview, setShowPreview] = useState(false) const titleError = validationErrors.find( e => e.nodeId === node.id && e.field === 'title' ) const handleAddStep = () => { onUpdate({ resolution_steps: [...(node.resolution_steps || []), ''] }) } const handleRemoveStep = (index: number) => { const newSteps = [...(node.resolution_steps || [])] newSteps.splice(index, 1) onUpdate({ resolution_steps: newSteps }) } const handleUpdateStep = (index: number, value: string) => { const newSteps = [...(node.resolution_steps || [])] newSteps[index] = value onUpdate({ resolution_steps: newSteps }) } const handleReorderSteps = (fromIndex: number, toIndex: number) => { const newSteps = [...(node.resolution_steps || [])] const [moved] = newSteps.splice(fromIndex, 1) newSteps.splice(toIndex, 0, moved) onUpdate({ resolution_steps: newSteps }) } return (
{/* Title */}
onUpdate({ title: e.target.value })} placeholder="e.g., VDA Successfully Registered" className={cn( 'mt-1 block w-full rounded-md border px-3 py-2 text-sm', 'bg-background text-foreground placeholder:text-muted-foreground', 'focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary', titleError ? 'border-destructive' : 'border-input' )} /> {titleError && (

{titleError.message}

)}
{/* Description */}
{node.description && ( )}

Supports markdown: **bold**, *italic*, - lists, 1. numbered lists, `code`

{showPreview && node.description ? (
) : (