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