- Created a Diagnostics component;
- Corrected the history code;
This commit is contained in:
23
src/utils/exams.ts
Normal file
23
src/utils/exams.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import {Module} from "@/interfaces";
|
||||
import {Exam, ReadingExam, ListeningExam, WritingExam, SpeakingExam} from "@/interfaces/exam";
|
||||
import axios from "axios";
|
||||
|
||||
export const getExamById = async (module: Module, id: string): Promise<Exam | undefined> => {
|
||||
const examRequest = await axios<Exam>(`/api/exam/${module}/${id}`);
|
||||
if (examRequest.status !== 200) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const newExam = examRequest.data;
|
||||
|
||||
switch (module) {
|
||||
case "reading":
|
||||
return newExam as ReadingExam;
|
||||
case "listening":
|
||||
return newExam as ListeningExam;
|
||||
case "writing":
|
||||
return newExam as WritingExam;
|
||||
case "speaking":
|
||||
return newExam as SpeakingExam;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user