frontPanel/src/utils/deleteTimeoutedQuestions.ts

25 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { AnyTypedQuizQuestion, UntypedQuizQuestion } from "@model/questionTypes/shared";
import { Quiz } from "@model/quiz/quiz";
import { updateSomeWorkBackend } from "@root/uiTools/actions";
import { DeleteFunction } from "@utils/deleteFunc";
type allQuestionsTypes = AnyTypedQuizQuestion | UntypedQuizQuestion
export const deleteTimeoutedQuestions = async (questions: allQuestionsTypes[], quiz: Quiz|undefined) => {
console.log("Я отвечаю за удаление неудалёнышей при переключении. Привет, буде знакомы")
const questionsForDeletion = questions.filter(
({ type, deleted }) => type && type !== "result" && deleted
) as AnyTypedQuizQuestion[];
if (questionsForDeletion.length > 0) {
console.log("меняю занятость беком на true")
updateSomeWorkBackend(true)
await Promise.allSettled(
questionsForDeletion.map(question => DeleteFunction(questions, question, quiz))
)
console.log("______________меняю на 'можно редактировать дальше'______________")
updateSomeWorkBackend(false)
}
};