import { useState } from 'react'; import { useForm } from '../../context/FormContext'; import FillBlank from '../fields/FillBlank'; import CheckboxGroup from '../fields/CheckboxGroup'; import ExerciseList from '../fields/ExerciseList'; import TextInput from '../fields/TextInput'; import StaticText from '../fields/StaticText'; import { ChevronDown, ChevronRight } from 'lucide-react'; import * as Icons from 'lucide-react'; function getIcon(name, size = 20) { const Icon = Icons[name]; return Icon ? : null; } function FieldRenderer({ field, sectionId }) { switch (field.type) { case 'fill-blank': return ; case 'checkbox-group': return ; case 'exercise-list': return ; case 'text': case 'number': return ; case 'static': return ; default: return null; } } export default function SectionRenderer({ section }) { const { formState, toggleSection } = useForm(); const isEnabled = formState.enabledSections[section.id] !== false; const [collapsedSubs, setCollapsedSubs] = useState({}); const toggleSubsection = (subId) => { setCollapsedSubs(prev => ({ ...prev, [subId]: !prev[subId] })); }; return (
{getIcon(section.icon, 20)}

{section.title}

{section.cptCode && ( {section.cptCode} )}
toggleSection(section.id)} role="switch" aria-checked={isEnabled} title={isEnabled ? 'Disable section' : 'Enable section'} />
{section.subsections.map(sub => { const isCollapsed = collapsedSubs[sub.id]; return (
{!isCollapsed && (
{sub.fields.map(field => ( ))}
)}
); })}
); }