ENCOA-260, ENCOA-259

This commit is contained in:
Carlos-Mesquita
2024-12-09 18:37:51 +00:00
parent 35d28fbff6
commit 7538392e44
12 changed files with 301 additions and 57 deletions

View File

@@ -7,15 +7,12 @@ import { Module } from "@/interfaces";
import { updateExamWithUserSolutions } from "@/stores/exam/utils";
import { defaultExamUserSolutions } from "@/utils/exams";
type UpdateRoot = {
type: 'UPDATE_ROOT';
payload: {
updates: Partial<ExamEditorStore>
}
};
type RootActions = { type: 'FULL_RESET' } | { type: "INIT_EXAM_EDIT", payload: { exam: Exam; examModule: Module; id: string } };
type RootActions = { type: 'FULL_RESET' } |
{ type: 'INIT_EXAM_EDIT', payload: { exam: Exam; examModule: Module; id: string } } |
{ type: 'UPDATE_ROOT'; payload: { updates: Partial<ExamEditorStore> } } |
{ type: 'RESET_MODULE'; payload: { module: Module } };
export type Action = ModuleActions | SectionActions | UpdateRoot | RootActions;
export type Action = ModuleActions | SectionActions | RootActions;
export const rootReducer = (
state: ExamEditorStore,
@@ -55,6 +52,16 @@ export const rootReducer = (
...state,
...updates
};
case 'RESET_MODULE':
const { module } = action.payload;
const timer = ["reading", "writing", "level"].includes(module) ?
60 : (module === "speaking" ? 14 : 30);
return {
modules: {
...state.modules,
[module]: defaultModuleSettings(module, timer),
},
};
case 'FULL_RESET':
return {
title: "",