Skip to content

Commit ca85ddf

Browse files
Merge pull request eduardconstantin#139 from eduardconstantin/feat/replace-formik
Feat/replace formik
2 parents 4ca5b18 + 4beaf56 commit ca85ddf

File tree

5 files changed

+383
-8
lines changed

5 files changed

+383
-8
lines changed

app/exam/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { NextPage } from "next";
55
import { gql, useQuery } from "@apollo/client";
66
import useTimer from "@azure-fundamentals/hooks/useTimer";
77
import { Button } from "@azure-fundamentals/components/Button";
8-
import QuizExamForm from "@azure-fundamentals/components/QuizExamForm";
8+
import QuizExamForm from "@azure-fundamentals/components/QuizExamFormUF";
99
import { Question } from "@azure-fundamentals/components/types";
1010
import ExamResult from "@azure-fundamentals/components/ExamResult";
1111

@@ -128,7 +128,7 @@ const Exam: NextPage<{ searchParams: { url: string; name: string } }> = ({
128128
totalQuestions={data.randomQuestions?.length}
129129
currentQuestionIndex={currentQuestionIndex}
130130
question={currentQuestion?.question ?? ""}
131-
options={currentQuestion?.options}
131+
options={currentQuestion?.options ?? []}
132132
images={currentQuestion?.images}
133133
stopTimer={stopTimer}
134134
revealExam={revealExam}

components/QuizExamForm.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { useEffect, useState } from "react";
1+
import { useEffect, useState, type FC } from "react";
22
import Image from "next/image";
33
import { Question } from "./types";
44
import { FieldArray, FormikProvider, Field, useFormik } from "formik";
5+
import { useForm } from "react-hook-form";
56
import { Button } from "./Button";
67
import useResults from "@azure-fundamentals/hooks/useResults";
78

@@ -24,7 +25,7 @@ type Props = {
2425
images?: { url: string; alt: string }[];
2526
};
2627

27-
const QuizExamForm: React.FC<Props> = ({
28+
const QuizExamForm: FC<Props> = ({
2829
isLoading,
2930
handleNextQuestion,
3031
handleSkipQuestion,
@@ -44,7 +45,7 @@ const QuizExamForm: React.FC<Props> = ({
4445
}) => {
4546
const [showCorrectAnswer, setShowCorrectAnswer] = useState<boolean>(false);
4647
const [savedAnswers, setSavedAnswers] = useState<any>([]);
47-
const { points, reCount } = useResults(savedAnswers);
48+
const { points, reCount } = useResults();
4849
const [selectedImage, setSelectedImage] = useState<{
4950
url: string;
5051
alt: string;
@@ -301,7 +302,9 @@ const QuizExamForm: React.FC<Props> = ({
301302
}`}
302303
>
303304
<svg
304-
className={`border ${noOfAnswers>1?"rounded":"rounded-full"} absolute h-5 w-5 p-0.5 ${
305+
className={`border ${
306+
noOfAnswers > 1 ? "rounded" : "rounded-full"
307+
} absolute h-5 w-5 p-0.5 ${
305308
showCorrectAnswer &&
306309
formik.values.options[index]?.isAnswer
307310
? "text-emerald-500 border-emerald-600"

0 commit comments

Comments
 (0)