fix date question type
This commit is contained in:
parent
1c8b2aef2f
commit
b2f66c73af
@ -10,7 +10,6 @@ export const QUIZ_QUESTION_DATE: Omit<QuizQuestionDate, "id"> = {
|
||||
required: false,
|
||||
innerNameCheck: false,
|
||||
innerName: "",
|
||||
type: "calendar",
|
||||
dateRange: false,
|
||||
time: false,
|
||||
},
|
||||
|
@ -13,7 +13,6 @@ export interface QuizQuestionDate extends QuizQuestionBase {
|
||||
innerNameCheck: boolean;
|
||||
/** Поле "Внутреннее название вопроса" */
|
||||
innerName: string;
|
||||
type: "calendar" | "mask";
|
||||
dateRange: boolean;
|
||||
time: boolean;
|
||||
hint: QuestionHint;
|
||||
|
@ -1,12 +1,9 @@
|
||||
import { useParams } from "react-router-dom";
|
||||
import { Box, Typography, Tooltip, useMediaQuery, useTheme } from "@mui/material";
|
||||
import { Box, Tooltip, Typography, useMediaQuery, useTheme } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import InfoIcon from "../../../assets/icons/InfoIcon";
|
||||
import ButtonsOptions from "../ButtonsOptions";
|
||||
import SwitchData from "./switchData";
|
||||
import { useState, useEffect } from "react";
|
||||
import InfoIcon from "../../../assets/icons/InfoIcon";
|
||||
import { questionStore, updateQuestionsList } from "@root/questions";
|
||||
|
||||
import type { QuizQuestionDate } from "../../../model/questionTypes/date";
|
||||
|
||||
interface Props {
|
||||
totalIndex: number;
|
||||
@ -14,24 +11,13 @@ interface Props {
|
||||
|
||||
export default function DataOptions({ totalIndex }: Props) {
|
||||
const [switchState, setSwitchState] = useState("setting");
|
||||
const quizId = Number(useParams().quizId);
|
||||
const { listQuestions } = questionStore();
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
||||
const question = listQuestions[quizId][totalIndex] as QuizQuestionDate;
|
||||
|
||||
const SSHC = (data: string) => {
|
||||
setSwitchState(data);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (question.content.type !== "mask") {
|
||||
updateQuestionsList<QuizQuestionDate>(quizId, totalIndex, {
|
||||
content: { ...question.content, type: "calendar" },
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
|
@ -49,7 +49,7 @@ import { ArrowDownIcon } from "@icons/questionsPage/ArrowDownIcon";
|
||||
import { ReactComponent as PlusIcon } from "../../../assets/icons/plus.svg";
|
||||
|
||||
import type { DraggableProvidedDragHandleProps } from "react-beautiful-dnd";
|
||||
import type { QuizQuestionBase } from "../../../model/questionTypes/shared";
|
||||
import type { AnyQuizQuestion, QuizQuestionInitial } from "../../../model/questionTypes/shared";
|
||||
|
||||
interface Props {
|
||||
totalIndex: number;
|
||||
@ -152,10 +152,10 @@ export default function QuestionsPageCard({
|
||||
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
||||
const { listQuestions } = questionStore();
|
||||
const question = listQuestions[quizId][totalIndex] as QuizQuestionBase;
|
||||
const question = listQuestions[quizId][totalIndex];
|
||||
const anchorRef = useRef(null);
|
||||
const debounced = useDebouncedCallback((title) => {
|
||||
updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, { title });
|
||||
updateQuestionsList<QuizQuestionInitial>(quizId, totalIndex, { title });
|
||||
}, 200);
|
||||
|
||||
useEffect(() => {
|
||||
@ -261,7 +261,7 @@ export default function QuestionsPageCard({
|
||||
sx={{ padding: "0", margin: "5px" }}
|
||||
disableRipple
|
||||
onClick={() =>
|
||||
updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, {
|
||||
updateQuestionsList<QuizQuestionInitial>(quizId, totalIndex, {
|
||||
expanded: !question.expanded,
|
||||
})
|
||||
}
|
||||
@ -350,7 +350,7 @@ export default function QuestionsPageCard({
|
||||
removeQuestionForce(quizId, removedId);
|
||||
}, 5000);
|
||||
|
||||
updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, {
|
||||
updateQuestionsList<AnyQuizQuestion>(quizId, totalIndex, {
|
||||
...question,
|
||||
deleteTimeoutId: newTimeoutId,
|
||||
});
|
||||
@ -395,7 +395,7 @@ export default function QuestionsPageCard({
|
||||
borderRadius: "12px",
|
||||
}}
|
||||
>
|
||||
{question.type.length === 0 ? (
|
||||
{question.type === "nonselected" ? (
|
||||
<TypeQuestions totalIndex={totalIndex} />
|
||||
) : (
|
||||
<SwitchQuestionsPage totalIndex={totalIndex} />
|
||||
|
Loading…
Reference in New Issue
Block a user