diff --git a/admin-compliance/app/sdk/document-generator/_components/ContextSectionForm.tsx b/admin-compliance/app/sdk/document-generator/_components/ContextSectionForm.tsx new file mode 100644 index 0000000..96ee0b2 --- /dev/null +++ b/admin-compliance/app/sdk/document-generator/_components/ContextSectionForm.tsx @@ -0,0 +1,102 @@ +'use client' + +import { TemplateContext } from '../contextBridge' +import { SECTION_FIELDS } from '../_constants' + +export default function ContextSectionForm({ + section, + context, + onChange, +}: { + section: keyof TemplateContext + context: TemplateContext + onChange: (section: keyof TemplateContext, key: string, value: unknown) => void +}) { + const fields = SECTION_FIELDS[section] + const sectionData = context[section] as unknown as Record + + return ( +
+ {fields.map((field) => { + const rawValue = sectionData[field.key] + const inputCls = 'w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-purple-400' + + if (field.type === 'boolean') { + return ( +
+ onChange(section, field.key, e.target.checked)} + className="w-4 h-4 accent-purple-600" + /> + +
+ ) + } + + if (field.type === 'select' && field.opts) { + return ( +
+ + +
+ ) + } + + if (field.type === 'textarea') { + return ( +
+ +