Skip to content

Commit

Permalink
Merge pull request #139 from eduardconstantin/feat/replace-formik
Browse files Browse the repository at this point in the history
Feat/replace formik
  • Loading branch information
eduardconstantin authored Nov 4, 2024
2 parents 4ca5b18 + 4beaf56 commit ca85ddf
Show file tree
Hide file tree
Showing 5 changed files with 383 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/exam/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { NextPage } from "next";
import { gql, useQuery } from "@apollo/client";
import useTimer from "@azure-fundamentals/hooks/useTimer";
import { Button } from "@azure-fundamentals/components/Button";
import QuizExamForm from "@azure-fundamentals/components/QuizExamForm";
import QuizExamForm from "@azure-fundamentals/components/QuizExamFormUF";
import { Question } from "@azure-fundamentals/components/types";
import ExamResult from "@azure-fundamentals/components/ExamResult";

Expand Down Expand Up @@ -128,7 +128,7 @@ const Exam: NextPage<{ searchParams: { url: string; name: string } }> = ({
totalQuestions={data.randomQuestions?.length}
currentQuestionIndex={currentQuestionIndex}
question={currentQuestion?.question ?? ""}
options={currentQuestion?.options}
options={currentQuestion?.options ?? []}
images={currentQuestion?.images}
stopTimer={stopTimer}
revealExam={revealExam}
Expand Down
11 changes: 7 additions & 4 deletions components/QuizExamForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useEffect, useState } from "react";
import { useEffect, useState, type FC } from "react";
import Image from "next/image";
import { Question } from "./types";
import { FieldArray, FormikProvider, Field, useFormik } from "formik";
import { useForm } from "react-hook-form";
import { Button } from "./Button";
import useResults from "@azure-fundamentals/hooks/useResults";

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

const QuizExamForm: React.FC<Props> = ({
const QuizExamForm: FC<Props> = ({
isLoading,
handleNextQuestion,
handleSkipQuestion,
Expand All @@ -44,7 +45,7 @@ const QuizExamForm: React.FC<Props> = ({
}) => {
const [showCorrectAnswer, setShowCorrectAnswer] = useState<boolean>(false);
const [savedAnswers, setSavedAnswers] = useState<any>([]);
const { points, reCount } = useResults(savedAnswers);
const { points, reCount } = useResults();
const [selectedImage, setSelectedImage] = useState<{
url: string;
alt: string;
Expand Down Expand Up @@ -301,7 +302,9 @@ const QuizExamForm: React.FC<Props> = ({
}`}
>
<svg
className={`border ${noOfAnswers>1?"rounded":"rounded-full"} absolute h-5 w-5 p-0.5 ${
className={`border ${
noOfAnswers > 1 ? "rounded" : "rounded-full"
} absolute h-5 w-5 p-0.5 ${
showCorrectAnswer &&
formik.values.options[index]?.isAnswer
? "text-emerald-500 border-emerald-600"
Expand Down
Loading

0 comments on commit ca85ddf

Please sign in to comment.