From 5a9c6634790f67a3622ce626c9fc084b60b8bc15 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:49:06 -0400 Subject: [PATCH] Create select renderer --- components/FormGenerator.tsx | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/components/FormGenerator.tsx b/components/FormGenerator.tsx index 333dc2c..c154966 100644 --- a/components/FormGenerator.tsx +++ b/components/FormGenerator.tsx @@ -138,6 +138,34 @@ export default function ({ ); } + function renderSelectElements( + c: component, + state: { [k: string]: string | string[] }, + setState: Dispatch> + ) { + if (!c.options) throw new Error("Options for select are undefined!"); + + const selectOptions = []; + + for (const option of c.options) { + selectOptions.push(); + } + + return ( + + ); + } + function generateReactComponents( components: component[], state: { [k: string]: string | string[] }, @@ -202,8 +230,13 @@ export default function ({ ); break; + case "radio": + fragmentsList.push(renderRadioElements(component, state, setState)); + break; + case "select": - fragmentsList.push(); + fragmentsList.push(renderSelectElements(component, state, setState)); + break; } fragmentsList.push(
,
,
);