import { type PaymentType, type Platform, type Skill, type SkillLevel } from "@prisma/client" import { type Dispatch, type SetStateAction, useEffect, useState } from "react"; type QuestionTypes = Platform | Skill | SkillLevel | PaymentType | string; interface Option { label: string, value: T, } interface Question { for: string, header: string, question: string, options: Option[] } const questions: Question[] = [ { for: "ages", header: "Age of Patient", question: "How old is the patient?", options: [ { label: "Child (0-10)", value: "0-9", }, { label: "Teen (10-20)", value: "10-20", }, { label: "Adult (21+)", value: "21-100", }, ], }, { for: "platforms", header: "Desired Platforms", question: "What platform(s) does the resource need to be on?", options: [ { label: "Apple (iOS)", value: "APP_IOS", }, { label: "Android", value: "APP_ANDROID", }, { label: "Web-Based", value: "WEBSITE", }, { label: "PDF (printable)", value: "PDF", } ] }, { for: "skill_levels", header: "Skill Level", question: "What skill level(s) should the resource have?", options: [ { label: "Beginner", value: "BEGINNER", }, { label: "Intermediate", value: "INTERMEDIATE", }, { label: "Advanced", value: "ADVANCED", } ] }, { for: "skills", header: "Skills Practiced", question: "What skill(s) would you like the resource to cover?", options: [ { label: "Phonemes", value: "PHONEMES", }, { label: "Words", value: "WORDS", }, { label: "Sentence", value: "SENTENCES", }, { label: "Discourse/Complex", value: "DISCOURSE", }, { label: "Music", value: "MUSIC", }, { label: "Environmental Sounds", value: "ENVIRONMENT", }, ] } ] const ChoiceQuestion = ({question, formData, updateFormData}: {question: Question, formData: Record, updateFormData: Dispatch>>}) => { const OptionToggle = ({option}: {option: Option}) => { const selected = formData[question.for]?.includes(option.value) ?? false; const handleToggle = () => { const newFormData = { ...formData }; if (!newFormData[question.for]) { newFormData[question.for] = [option.value]; } else if (newFormData[question.for]?.includes(option.value)) { newFormData[question.for] = newFormData[question.for]?.filter(function(item) { return item !== option.value }) ?? []; } else { newFormData[question.for] = [...newFormData[question.for] ?? [], option.value]; } updateFormData(newFormData); } return ( ) } useEffect(() => { if (!formData[question.for]) { const newFormData = {...formData}; newFormData[question.for] = []; updateFormData(newFormData); } }); const htmlOptions: JSX.Element[] = [] const optionButtons: JSX.Element[] = [] question.options.forEach((option, index) => { optionButtons.push() htmlOptions.push() }); return (

{question.question}

{optionButtons}
) } const SearchForm = ({questions}: {questions: Question[]}) => { const [formData, setFormData] = useState<(Record)>({}); const questionComponents = questions.map((question, index) => { return }) return (
{questionComponents}
) } const SearchPage = () => { return <>

Search

} export default SearchPage