remove questions on quiz delete
This commit is contained in:
parent
d4a3025eda
commit
42cf32c185
@ -121,6 +121,10 @@ export const updateQuestionsList = <T = AnyQuizQuestion>(
|
||||
questionStore.setState({ listQuestions: questionListClone });
|
||||
};
|
||||
|
||||
export const removeQuestionsByQuizId = (quizId: number) => setProducedState(state => {
|
||||
delete state.listQuestions[quizId];
|
||||
}, "removeQuestionsByQuizId");
|
||||
|
||||
export const updateQuestionsListDragAndDrop = (
|
||||
quizId: number,
|
||||
updatedQuestions: AnyQuizQuestion[]
|
||||
|
@ -1,5 +1,6 @@
|
||||
import {create} from "zustand";
|
||||
import {persist} from "zustand/middleware";
|
||||
import { removeQuestionsByQuizId } from "./questions";
|
||||
|
||||
interface QuizStore {
|
||||
listQuizes: { [key: number]: Quizes };
|
||||
@ -87,6 +88,8 @@ export const quizStore = create<QuizStore>()(
|
||||
return accumulator;
|
||||
}, {});
|
||||
set({listQuizes: newState});
|
||||
|
||||
removeQuestionsByQuizId(id);
|
||||
},
|
||||
createBlank: () => {
|
||||
const id = getRandom(1000000, 10000000)
|
||||
|
Loading…
Reference in New Issue
Block a user