Added title to the exam generate
This commit is contained in:
@@ -258,7 +258,11 @@ const PartTab = ({
|
||||
);
|
||||
};
|
||||
|
||||
const ReadingGeneration = () => {
|
||||
interface Props {
|
||||
id: string;
|
||||
}
|
||||
|
||||
const ReadingGeneration = ({ id } : Props) => {
|
||||
const [part1, setPart1] = useState<ReadingPart>();
|
||||
const [part2, setPart2] = useState<ReadingPart>();
|
||||
const [part3, setPart3] = useState<ReadingPart>();
|
||||
@@ -300,13 +304,18 @@ const ReadingGeneration = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!id) {
|
||||
toast.error("Please insert a title before submitting");
|
||||
return;
|
||||
}
|
||||
|
||||
setIsLoading(true);
|
||||
const exam: ReadingExam = {
|
||||
parts,
|
||||
isDiagnostic: false,
|
||||
minTimer,
|
||||
module: "reading",
|
||||
id: generate({minLength: 4, maxLength: 8, min: 3, max: 5, join: " ", formatter: capitalize}),
|
||||
id,
|
||||
type: "academic",
|
||||
variant: parts.length === 3 ? "full" : "partial",
|
||||
difficulty,
|
||||
@@ -328,7 +337,7 @@ const ReadingGeneration = () => {
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
toast.error("Something went wrong while generating, please try again later.");
|
||||
toast.error(error.response.data.error || "Something went wrong while generating, please try again later.");
|
||||
})
|
||||
.finally(() => setIsLoading(false));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user