diff --git a/src/components/Steps/Form/SelectField.tsx b/src/components/Steps/Form/SelectField.tsx index 37e0cfc..361aa17 100644 --- a/src/components/Steps/Form/SelectField.tsx +++ b/src/components/Steps/Form/SelectField.tsx @@ -1,12 +1,12 @@ import styles from "@/styles/Home.module.css"; -import { MyForm, MyFormKey } from "@/types/FormTypes"; +import { QuizCreatorForm, QuizCreatorFormKey } from "@/types/FormTypes"; import { OptionType } from "@/types/types"; import { Control, Controller } from "react-hook-form"; import Select from "react-select"; interface SelectFieldProps { - control: Control; + control: Control; options: OptionType[]; - name_: MyFormKey; + name_: QuizCreatorFormKey; placeholder?: string; } diff --git a/src/components/Steps/StudentDetails.tsx b/src/components/Steps/StudentDetails.tsx index c184fef..08e68d1 100644 --- a/src/components/Steps/StudentDetails.tsx +++ b/src/components/Steps/StudentDetails.tsx @@ -1,6 +1,6 @@ import { Step } from "@/pages/SessionCreator"; import styles from "@/styles/Home.module.css"; -import { MyForm } from "@/types/FormTypes"; +import { QuizCreatorForm } from "@/types/FormTypes"; import { ActiveFormProps } from "@/types/types"; import { SubmitHandler, useForm } from "react-hook-form"; import { @@ -17,11 +17,11 @@ export default function StudentDetails({ setActiveStep, setData, }: ActiveFormProps) { - const { register, handleSubmit, control } = useForm({ + const { register, handleSubmit, control } = useForm({ defaultValues: { ...data.student }, }); - const onSubmit: SubmitHandler = (student) => { + const onSubmit: SubmitHandler = (student) => { setData((prevData) => ({ ...prevData, student })); setActiveStep(Step.TEST_DETAILS); diff --git a/src/components/Steps/TestDetails.tsx b/src/components/Steps/TestDetails.tsx index 08e0d00..57e171c 100644 --- a/src/components/Steps/TestDetails.tsx +++ b/src/components/Steps/TestDetails.tsx @@ -1,7 +1,7 @@ import styles from "../../styles/Home.module.css"; import { Step } from "@/pages/SessionCreator"; -import { MyForm } from "@/types/FormTypes"; +import { QuizCreatorForm } from "@/types/FormTypes"; import { ActiveFormProps } from "@/types/types"; import { SubmitHandler, useForm } from "react-hook-form"; import { @@ -17,11 +17,11 @@ import SelectField from "./Form/SelectField"; // Renders sub-page containing test details export function TestDetails({ data, setActiveStep, setData }: ActiveFormProps) { - const { register, handleSubmit, control } = useForm({ + const { register, handleSubmit, control } = useForm({ defaultValues: { ...data.test }, }); - const onSubmit: SubmitHandler = (test) => { + const onSubmit: SubmitHandler = (test) => { setData((prevData) => ({ ...prevData, test })); setActiveStep(Step.TIMELINE); @@ -75,7 +75,7 @@ export function TestDetails({ data, setActiveStep, setData }: ActiveFormProps) { options={OptionalLimitOptions} placeholder="Optional Limit" /> - {/* TODO: ADD more conditions realated to generated data */} + {data.test.id ? ( <> ({ + const { register, handleSubmit, control, reset } = useForm({ defaultValues: { ...data.timeline }, }); @@ -28,7 +28,7 @@ export default function Timeline({ reset(); }, [shouldSubmit, data]); - const onSubmit: SubmitHandler = (timeline) => { + const onSubmit: SubmitHandler = (timeline) => { setData((prevData) => ({ ...prevData, timeline })); setShouldSubmit(true); @@ -88,26 +88,32 @@ export default function Timeline({ name_="sessionType" options={SessionTypeOptions} /> - - {/* + {data.timeline.id ? ( + <> + + {/* // TODO: same as test details render acc to need */} - - + + + + ) : ( + <> + )}