From 0b14a7458e1d302262f276e52dcc2ede842cd03c Mon Sep 17 00:00:00 2001 From: Dmitry Date: Wed, 17 Dec 2025 04:04:21 +0300 Subject: [PATCH] fixes --- .../src/components/forms/SimpleQuestionForm.tsx | 12 ++++++++++++ mnemo_cards_admin/src/types/questions.ts | 14 ++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/mnemo_cards_admin/src/components/forms/SimpleQuestionForm.tsx b/mnemo_cards_admin/src/components/forms/SimpleQuestionForm.tsx index 0d504b7..b4c5243 100644 --- a/mnemo_cards_admin/src/components/forms/SimpleQuestionForm.tsx +++ b/mnemo_cards_admin/src/components/forms/SimpleQuestionForm.tsx @@ -32,6 +32,18 @@ export function SimpleQuestionForm({ const [buttons, setButtons] = useState(question.options || []) const [answer, setAnswer] = useState(question.answer || '') + useEffect(() => { + onChange({ + questionType: QuestionType.SIMPLE, + word, + text: text || undefined, + image: image || undefined, + audio: audio || undefined, + options: buttons, + answer, + }) + }, [word, text, image, audio, buttons, answer, onChange]) + const addButton = () => { const newButton: TestButton = { id: `btn_${Date.now()}`, diff --git a/mnemo_cards_admin/src/types/questions.ts b/mnemo_cards_admin/src/types/questions.ts index 047bc66..69f872d 100644 --- a/mnemo_cards_admin/src/types/questions.ts +++ b/mnemo_cards_admin/src/types/questions.ts @@ -1,7 +1,9 @@ -export const enum QuestionType { - SIMPLE = 'simple', - INPUT_BUTTONS = 'input_buttons', -} +export const QuestionType = { + SIMPLE: 'simple', + INPUT_BUTTONS: 'input_buttons', +} as const + +export type QuestionType = typeof QuestionType[keyof typeof QuestionType] // Соответствует полю options в БД export interface TestButton { @@ -28,11 +30,11 @@ export interface BaseQuestion { } export interface SimpleQuestion extends BaseQuestion { - questionType: QuestionType.SIMPLE + questionType: 'simple' } export interface InputButtonsQuestion extends BaseQuestion { - questionType: QuestionType.INPUT_BUTTONS + questionType: 'input_buttons' template: string // Хранится в uiData }