diff --git a/src/components/forms/SelectorWithLabelForm.tsx b/src/components/forms/SelectorWithLabelForm.tsx index 35e5c81..2ac163a 100644 --- a/src/components/forms/SelectorWithLabelForm.tsx +++ b/src/components/forms/SelectorWithLabelForm.tsx @@ -1,3 +1,5 @@ +import { useId } from "react"; + import { Select, SelectContent, @@ -6,37 +8,47 @@ import { SelectValue, } from "@/components/ui/select"; -import { SelectProps } from "@radix-ui/react-select"; - -export type SelectorItem = { - value: string; - label: string; -}; +import { FormState, Question } from "./Form"; -export interface SelectorProps extends SelectProps { - label: string; - items: SelectorItem[]; - placeholder: string; -} +// prettier-ignore +export type SelectorWithLabelFormProps = + Omit, "questionType" | "dataType"> & + FormState export const SelectorWithLabelForm = ({ - label, - items, - placeholder, - ...selectProps -}: SelectorProps) => { + questionText, + options, + formState, + setFormState, +}: SelectorWithLabelFormProps) => { + const htmlFor = useId(); + return ( -
-

{label}

- + setFormState({ + ...formState, + [questionText]: value, + }) + } + > + + - - {items.map((item, index) => { + + {options.map((option, index) => { return ( - - {item.label} + + {option} ); })}