add questions state rollback on request error
This commit is contained in:
parent
4f68ddfad5
commit
9a4f4e8a66
@ -267,6 +267,8 @@ export const updateQuestion = async <T = AnyTypedQuizQuestion>(
|
||||
);
|
||||
|
||||
const request = async () => {
|
||||
const rollbackQuestions = useQuestionsStore.getState();
|
||||
|
||||
const q =
|
||||
useQuestionsStore.getState().questions.find((q) => q.id === questionId) ||
|
||||
useQuestionsStore
|
||||
@ -300,6 +302,8 @@ export const updateQuestion = async <T = AnyTypedQuizQuestion>(
|
||||
} catch (error) {
|
||||
if (isAxiosCanceledError(error)) return;
|
||||
|
||||
useQuestionsStore.setState(rollbackQuestions);
|
||||
|
||||
devlog("Error editing question", { error, questionId });
|
||||
enqueueSnackbar("Не удалось сохранить вопрос");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user