Added the ability to view all exams

This commit is contained in:
Tiago Ribeiro
2023-09-23 13:34:14 +01:00
parent 7a957e4d78
commit 6dda49a917
9 changed files with 324 additions and 2 deletions

19
src/hooks/useExams.tsx Normal file
View File

@@ -0,0 +1,19 @@
import {Exam} from "@/interfaces/exam";
import axios from "axios";
import {useEffect, useState} from "react";
export default function useExams() {
const [exams, setExams] = useState<Exam[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [isError, setIsError] = useState(false);
useEffect(() => {
setIsLoading(true);
axios
.get<Exam[]>("/api/exam")
.then((response) => setExams(response.data))
.finally(() => setIsLoading(false));
}, []);
return {exams, isLoading, isError};
}