Skip to content

Account settings #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions src/Pages/Selectquiz/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,49 @@ import { Link, useNavigate } from 'react-router-dom';
import { IoIosArrowDown } from "react-icons/io";
import AddQuiz from './Addquiz/Index';
import EditQuiz from './Editquiz/EditQuiz';
import axios from 'axios';
import { useEffect, useState } from 'react';

type Quiz = {
id: string
year: number
title: string
description: string | null
date: string
}

type selectQuizProps = {
option: string
quiz?: Quiz
}

const SelectQuiz = ({option} : selectQuizProps) => {
const [quizList, setQuizList] = useState<Quiz[] | null>(null)
const [isLoading, setIsLoading] = useState<boolean>(false)
const [err, setErr] = useState<string>("")
const navigate=useNavigate()

const getQuiz = async () => {
try {
setIsLoading(true)
const res = await axios.get("https://sigma-website-backend.onrender.com/api/sigma-quiz")
setIsLoading(false)
setQuizList(res.data)
console.log(res)
} catch (error) {
setIsLoading(false)
if (axios.isAxiosError(error)) {
setErr(error.message)
} else {
setErr("Error fetching quizzes. Please try again")
}
}
}

useEffect(() =>{
getQuiz()
}, [])

return (
<div className="select-quiz-page">
<div className="select-quiz-container">
Expand All @@ -22,10 +59,10 @@ const SelectQuiz = ({option} : selectQuizProps) => {
<p>Select which quiz you choose to operate</p>

<div className="select-field">
<select name="" id="">
<option value="">2024 Roseline Etuokwu Quiz Competition</option>
</select>
<IoIosArrowDown size={30} color="black" className="arrow-down" />
<select >
{isLoading? <option>Loading...</option>: err? <option>{err}</option>: quizList?.map((quiz, index) => ( <option key={index}>{quiz.title}</option> ))}
</select>
<IoIosArrowDown size={30} color="black" className="arrow-down"/>
</div>

<div className="add-edit-btns">
Expand Down
Loading