diff --git a/Frontend/src/Components/QuestionList/QuestionEdit.jsx b/Frontend/src/Components/QuestionList/QuestionEdit.jsx index 678cfe45..77c8fbc0 100644 --- a/Frontend/src/Components/QuestionList/QuestionEdit.jsx +++ b/Frontend/src/Components/QuestionList/QuestionEdit.jsx @@ -42,19 +42,22 @@ export const QuestionEdit = ({ q, index, updateQ, setEdit }) => { } }; - const handleSubmit = (toggleEdit, editQ) => async e => { - e.preventDefault(); + const handleSubmit = async (toggleEdit, editQ) => { + // e.preventDefault(); if(isEmpty(title) || isEmpty(difficulty) || isEmpty(topic) || isEmpty(description)) { - setIsMissingField(true); + setIsMissingField(true); } else { - setIsMissingField(false); - const response = await editQ(q._id, title, description, difficulty, topic, language); - if(response.status === 200) { - toggleEdit(false); - } else { - let res = await response.json(); - setErrorVar(res.errors) - } + + setIsMissingField(false); + + const response = await editQ(q._id, title, description, difficulty, topic, language); + + if(response.status === 200) { + toggleEdit(false); + } else { + let res = await response.json(); + setErrorVar(res.errors) + } } } @@ -94,6 +97,7 @@ export const QuestionEdit = ({ q, index, updateQ, setEdit }) => {
diff --git a/Frontend/src/Components/QuestionList/QuestionList.jsx b/Frontend/src/Components/QuestionList/QuestionList.jsx index 2251741c..11435a9e 100644 --- a/Frontend/src/Components/QuestionList/QuestionList.jsx +++ b/Frontend/src/Components/QuestionList/QuestionList.jsx @@ -86,8 +86,8 @@ export const Questions = () => { if (response.status === 200) { setFilterApplied(false); - fetchQuestions(); - return []; + await fetchQuestions(); + return response; } else { return ['Unable to edit question']; }