Skip to content

Commit

Permalink
fix: reset quiz attempt to be able to start again
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoEscaleira committed Feb 15, 2024
1 parent 83641f7 commit f97cc2b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/QuizAttempt/QuizAttempt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function QuizAttempt({ quiz, handleQuizStart, handleQuizEnd }: QuizAttemp
useEffect(() => {
// TODO: randomize questions array
setQuestions(quiz.questions);
setQuestionIndex(0);
}, [hasAttemptStarted]);

const question = questions[questionIndex];
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Game/CountryQuizList.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Button, Card, CardBody, CardFooter, CardHeader, Spinner, Typography } from "@material-tailwind/react";
import { useNavigate, useSearchParams } from "react-router-dom";
import { DifficultyChip } from "@components/DifficultyChip/DifficultyChip.tsx";
import { TimeLimitChip } from "@components/TimeLimitChip/TimeLimitChip.tsx";
import { CountryQuizzesQuery } from "@generated/graphql.ts";
import { CountryInfoModal } from "@pages/Game/CountryInfoModal.tsx";
import { useCountryDetails } from "@utils/hooks/useCountryDetails.ts";
import { TimeLimitChip } from "@components/TimeLimitChip/TimeLimitChip.tsx";
import { DifficultyChip } from "@components/DifficultyChip/DifficultyChip.tsx";

interface CountryQuizListProps {
quizList: CountryQuizzesQuery["quizList"];
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Quiz/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useState } from "react";
import { useQuery } from "@apollo/client";
import {
Accordion,
Expand All @@ -15,7 +16,6 @@ import { TimeLimitChip } from "@components/TimeLimitChip/TimeLimitChip.tsx";
import { gql } from "@generated/gql.ts";
import { QuizData } from "@generated/graphql.ts";
import { useCountryDetails } from "@utils/hooks/useCountryDetails.ts";
import { useState } from "react";

const GET_QUIZ = gql(/* GraphQL */ `
query QuizById($quizId: String!) {
Expand Down

0 comments on commit f97cc2b

Please sign in to comment.