From 8d81c12fbee9409a8108348bdb17b04c62fab723 Mon Sep 17 00:00:00 2001 From: David Katrinka Date: Sun, 4 Jan 2026 23:33:04 +0100 Subject: [PATCH] fixed question modal and form --- .../GenerateQuestionModal.tsx | 22 ++++++++++++++++--- src/pages/QuestionForm/QuestionForm.tsx | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/components/GenerateQuestionModal/GenerateQuestionModal.tsx b/src/components/GenerateQuestionModal/GenerateQuestionModal.tsx index 4c9e34e..3a547a2 100644 --- a/src/components/GenerateQuestionModal/GenerateQuestionModal.tsx +++ b/src/components/GenerateQuestionModal/GenerateQuestionModal.tsx @@ -12,12 +12,12 @@ import { import { useOpenaiGenerateQuestion } from "../../hooks/questions/useOpenaiGenerateQuestion"; import type { QuestionPayload } from "../../api/questionsApi"; +import { useCategories } from "../../hooks/categories/useCategories"; type Props = { open: boolean; onClose: () => void; onGenerated: (question: QuestionPayload) => void; - }; const GenerateQuestionModal = ({ open, onClose, onGenerated }: Props) => { @@ -28,6 +28,7 @@ const GenerateQuestionModal = ({ open, onClose, onGenerated }: Props) => { const [language, setLanguage] = useState<"en" | "sr" | "hu" | "ru">("en"); const [difficulty, setDifficulty] = useState(5); const [prompt, setPrompt] = useState(""); + const { data: categories } = useCategories(); const handleGenerate = () => { if (!categoryId || !prompt.trim()) return; @@ -69,14 +70,29 @@ const GenerateQuestionModal = ({ open, onClose, onGenerated }: Props) => { Text - setCategoryId(Number(e.target.value))} fullWidth sx={{ mb: 2 }} - /> + /> */} + setCategoryId(Number(e.target.value))} + fullWidth + required + sx={{ mb: 3 }} + > + {categories?.map((cat) => ( + + {cat.name} + + ))} + { difficulty, category_id: Number(categoryId), variants: type === "text" ? [] : variants, - correct_answers: correctAnswers, + correct_answers: type === "text" ? [textAnswer]: correctAnswers, }; if (isUpdate && id) {