fix: drag & drop
This commit is contained in:
parent
dd7f2621ac
commit
79b6442377
@ -23,6 +23,7 @@ import {
|
|||||||
updateQuestionsList,
|
updateQuestionsList,
|
||||||
removeQuestion,
|
removeQuestion,
|
||||||
} from "@root/questions";
|
} from "@root/questions";
|
||||||
|
import { quizStore } from "@root/quizes";
|
||||||
import { DoubleTick } from "@icons/questionsPage/DoubleTick";
|
import { DoubleTick } from "@icons/questionsPage/DoubleTick";
|
||||||
import { DoubleArrowRight } from "@icons/questionsPage/DoubleArrowRight";
|
import { DoubleArrowRight } from "@icons/questionsPage/DoubleArrowRight";
|
||||||
import { VectorQuestions } from "@icons/questionsPage/VectorQuestions";
|
import { VectorQuestions } from "@icons/questionsPage/VectorQuestions";
|
||||||
@ -36,23 +37,19 @@ interface Props {
|
|||||||
SSHC: (data: string) => void;
|
SSHC: (data: string) => void;
|
||||||
totalIndex: number;
|
totalIndex: number;
|
||||||
sx?: SxProps;
|
sx?: SxProps;
|
||||||
disableSettings?: boolean;
|
|
||||||
disableBranching?: boolean;
|
|
||||||
disableMiniButtons?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ButtonsOptions({
|
export default function ButtonsOptions({
|
||||||
SSHC,
|
SSHC,
|
||||||
switchState,
|
switchState,
|
||||||
totalIndex,
|
totalIndex,
|
||||||
disableSettings = false,
|
|
||||||
disableBranching = false,
|
|
||||||
disableMiniButtons = false,
|
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const quizId = Number(useParams().quizId);
|
const quizId = Number(useParams().quizId);
|
||||||
const { openedModalSettings, listQuestions } = questionStore();
|
const { openedModalSettings, listQuestions } = questionStore();
|
||||||
|
const { listQuizes } = quizStore();
|
||||||
const [openedReallyChangingModal, setOpenedReallyChangingModal] =
|
const [openedReallyChangingModal, setOpenedReallyChangingModal] =
|
||||||
useState<boolean>(false);
|
useState<boolean>(false);
|
||||||
|
const quize = listQuizes[quizId];
|
||||||
const question = listQuestions[quizId][totalIndex] as QuizQuestionBase;
|
const question = listQuestions[quizId][totalIndex] as QuizQuestionBase;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -132,7 +129,7 @@ export default function ButtonsOptions({
|
|||||||
{buttonSetting.map(({ icon, title, value, myFunc }) => (
|
{buttonSetting.map(({ icon, title, value, myFunc }) => (
|
||||||
<Box key={value}>
|
<Box key={value}>
|
||||||
{value === "branching" ? (
|
{value === "branching" ? (
|
||||||
!disableBranching && (
|
quize.config.type === "quize" && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
arrow
|
arrow
|
||||||
placement="right"
|
placement="right"
|
||||||
@ -196,8 +193,7 @@ export default function ButtonsOptions({
|
|||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{(value !== "setting" ||
|
{value !== "setting" && quize.config.type === "quize" && (
|
||||||
(value === "setting" && !disableSettings)) && (
|
|
||||||
<MiniButtonSetting
|
<MiniButtonSetting
|
||||||
key={title}
|
key={title}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@ -229,7 +225,7 @@ export default function ButtonsOptions({
|
|||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
{!disableMiniButtons && (
|
{quize.config.type === "quize" && (
|
||||||
<>
|
<>
|
||||||
<MiniButtonSetting
|
<MiniButtonSetting
|
||||||
onClick={() => setOpenedReallyChangingModal(true)}
|
onClick={() => setOpenedReallyChangingModal(true)}
|
||||||
|
|||||||
@ -1,10 +0,0 @@
|
|||||||
.MuiTooltip-popper > .MuiTooltip-tooltip {
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 6px;
|
|
||||||
color: #9A9AAF;
|
|
||||||
box-shadow: 0px 8px 24px rgba(210, 208, 225, 0.4);
|
|
||||||
}
|
|
||||||
|
|
||||||
.MuiTooltip-popper > .MuiTooltip-tooltip .MuiTooltip-arrow::before {
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
@ -29,8 +29,6 @@ import { DoubleTick } from "@icons/questionsPage/DoubleTick";
|
|||||||
import { VectorQuestions } from "@icons/questionsPage/VectorQuestions";
|
import { VectorQuestions } from "@icons/questionsPage/VectorQuestions";
|
||||||
import { ReallyChangingModal } from "@ui_kit/Modal/ReallyChangingModal/ReallyChangingModal";
|
import { ReallyChangingModal } from "@ui_kit/Modal/ReallyChangingModal/ReallyChangingModal";
|
||||||
|
|
||||||
import "./ButtonsOptionsAndPict.css";
|
|
||||||
|
|
||||||
import type { QuizQuestionBase } from "../../model/questionTypes/shared";
|
import type { QuizQuestionBase } from "../../model/questionTypes/shared";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -151,6 +149,19 @@ export default function ButtonsOptionsAndPict({
|
|||||||
<Tooltip
|
<Tooltip
|
||||||
arrow
|
arrow
|
||||||
placement="right"
|
placement="right"
|
||||||
|
componentsProps={{
|
||||||
|
tooltip: {
|
||||||
|
sx: {
|
||||||
|
background: "#fff",
|
||||||
|
borderRadius: "6px",
|
||||||
|
color: "#9A9AAF",
|
||||||
|
boxShadow: "0px 8px 24px rgba(210, 208, 225, 0.4)",
|
||||||
|
"& .MuiTooltip-arrow": {
|
||||||
|
color: "#FFF",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}}
|
||||||
title={
|
title={
|
||||||
<Box>
|
<Box>
|
||||||
<Typography
|
<Typography
|
||||||
|
|||||||
@ -38,7 +38,7 @@ export default memo(
|
|||||||
maxWidth: "800px",
|
maxWidth: "800px",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
marginBottom: "40px",
|
marginTop: "30px",
|
||||||
gap: "5px",
|
gap: "5px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useDebouncedCallback } from "use-debounce";
|
import { useDebouncedCallback } from "use-debounce";
|
||||||
|
|
||||||
|
import CustomTextField from "@ui_kit/CustomTextField";
|
||||||
import { ChooseAnswerModal } from "./ChooseAnswerModal";
|
import { ChooseAnswerModal } from "./ChooseAnswerModal";
|
||||||
import FormTypeQuestions from "../FormTypeQuestions";
|
import FormTypeQuestions from "../FormTypeQuestions";
|
||||||
import SwitchQuestionsPage from "../../SwitchQuestionsPage";
|
import SwitchQuestionsPage from "../../SwitchQuestionsPage";
|
||||||
@ -181,6 +182,10 @@ export default function QuestionsPageCard({
|
|||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
border: "none",
|
border: "none",
|
||||||
boxShadow: "none",
|
boxShadow: "none",
|
||||||
|
marginBottom: "20px",
|
||||||
|
borderRadius: "0",
|
||||||
|
borderTopLeftRadius: "12px",
|
||||||
|
borderTopRightRadius: "12px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
@ -188,9 +193,25 @@ export default function QuestionsPageCard({
|
|||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
padding: 0,
|
padding: 0,
|
||||||
borderRadius: "12px",
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<CustomTextField
|
||||||
|
placeholder={`Заголовок ${totalIndex + 1} вопроса`}
|
||||||
|
text={question.title}
|
||||||
|
onChange={({ target }) => debounced(target.value)}
|
||||||
|
sx={{ margin: "20px", width: "auto" }}
|
||||||
|
InputProps={{
|
||||||
|
endAdornment: (
|
||||||
|
<>
|
||||||
|
<InputAdornment {...draggableProps} position="start">
|
||||||
|
<PointsIcon
|
||||||
|
style={{ color: "#9A9AAF", fontSize: "30px" }}
|
||||||
|
/>
|
||||||
|
</InputAdornment>
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
{question.type.length === 0 ? (
|
{question.type.length === 0 ? (
|
||||||
<FormTypeQuestions totalIndex={totalIndex} />
|
<FormTypeQuestions totalIndex={totalIndex} />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@ -70,7 +70,9 @@ export default function FormQuestionsPage() {
|
|||||||
boxShadow: "0px 10px 30px #e7e7e7",
|
boxShadow: "0px 10px 30px #e7e7e7",
|
||||||
borderRadius: "12px",
|
borderRadius: "12px",
|
||||||
marginBottom: "40px",
|
marginBottom: "40px",
|
||||||
border: "1px solid transparent",
|
borderTop: "1px solid transparent",
|
||||||
|
borderBottom: "1px solid transparent",
|
||||||
|
background: "#FFFFFF",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FormDraggableList />
|
<FormDraggableList />
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { Box, Typography } from "@mui/material";
|
import { useDebouncedCallback } from "use-debounce";
|
||||||
|
import { Box } from "@mui/material";
|
||||||
|
|
||||||
import QuestionsMiniButton from "@ui_kit/QuestionsMiniButton";
|
import QuestionsMiniButton from "@ui_kit/QuestionsMiniButton";
|
||||||
import CustomTextField from "@ui_kit/CustomTextField";
|
import CustomTextField from "@ui_kit/CustomTextField";
|
||||||
import ButtonsOptions from "../ButtonsOptions";
|
import ButtonsOptions from "../ButtonsOptions";
|
||||||
|
import SwitchAnswerOptions from "../answerOptions/switchAnswerOptions";
|
||||||
|
|
||||||
import Answer from "../../../assets/icons/questionsPage/answer";
|
import Answer from "../../../assets/icons/questionsPage/answer";
|
||||||
import OptionsPict from "../../../assets/icons/questionsPage/options_pict";
|
import OptionsPict from "../../../assets/icons/questionsPage/options_pict";
|
||||||
@ -99,22 +101,25 @@ export const BUTTON_TYPE_QUESTIONS: ButtonTypeQuestion[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default function FormTypeQuestions({ totalIndex }: Props) {
|
export default function FormTypeQuestions({ totalIndex }: Props) {
|
||||||
const [switchState, setSwitchState] = useState("setting");
|
const [switchState, setSwitchState] = useState("");
|
||||||
const quizId = Number(useParams().quizId);
|
const quizId = Number(useParams().quizId);
|
||||||
const { listQuestions } = questionStore();
|
const { listQuestions } = questionStore();
|
||||||
const question = listQuestions[quizId][totalIndex] as QuizQuestionBase;
|
const question = listQuestions[quizId][totalIndex] as QuizQuestionBase;
|
||||||
|
const debounced = useDebouncedCallback((title) => {
|
||||||
|
updateQuestionsList<QuizQuestionBase>(quizId, totalIndex, { title });
|
||||||
|
}, 1000);
|
||||||
|
console.log("listQuestions[quizId]", listQuestions[quizId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ paddingTop: "20px" }}>
|
<Box>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexWrap: "wrap",
|
flexWrap: "wrap",
|
||||||
gap: "20px",
|
gap: "20px",
|
||||||
margin: "0 20px 20px",
|
margin: "20px",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CustomTextField placeholder="Заголовок 1 вопроса" text={""} />
|
|
||||||
{BUTTON_TYPE_QUESTIONS.map(({ icon, title, value }) => (
|
{BUTTON_TYPE_QUESTIONS.map(({ icon, title, value }) => (
|
||||||
<QuestionsMiniButton
|
<QuestionsMiniButton
|
||||||
key={title}
|
key={title}
|
||||||
@ -137,10 +142,8 @@ export default function FormTypeQuestions({ totalIndex }: Props) {
|
|||||||
switchState={switchState}
|
switchState={switchState}
|
||||||
SSHC={setSwitchState}
|
SSHC={setSwitchState}
|
||||||
totalIndex={totalIndex}
|
totalIndex={totalIndex}
|
||||||
disableSettings
|
|
||||||
disableBranching
|
|
||||||
disableMiniButtons
|
|
||||||
/>
|
/>
|
||||||
|
<SwitchAnswerOptions switchState={switchState} totalIndex={totalIndex} />
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import {
|
|||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
|
||||||
import type { ChangeEvent, KeyboardEvent, FocusEvent } from "react";
|
import type { ChangeEvent, KeyboardEvent, FocusEvent } from "react";
|
||||||
|
import type { InputProps } from "@mui/material";
|
||||||
|
|
||||||
interface CustomTextFieldProps {
|
interface CustomTextFieldProps {
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
@ -17,6 +18,7 @@ interface CustomTextFieldProps {
|
|||||||
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
|
||||||
text?: string;
|
text?: string;
|
||||||
sx?: SxProps<Theme>;
|
sx?: SxProps<Theme>;
|
||||||
|
InputProps?: Partial<InputProps>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CustomTextField({
|
export default function CustomTextField({
|
||||||
@ -28,6 +30,7 @@ export default function CustomTextField({
|
|||||||
onChange,
|
onChange,
|
||||||
onKeyDown,
|
onKeyDown,
|
||||||
onBlur,
|
onBlur,
|
||||||
|
InputProps,
|
||||||
}: CustomTextFieldProps) {
|
}: CustomTextFieldProps) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
@ -55,6 +58,7 @@ export default function CustomTextField({
|
|||||||
},
|
},
|
||||||
...sx,
|
...sx,
|
||||||
}}
|
}}
|
||||||
|
InputProps={InputProps}
|
||||||
inputProps={{
|
inputProps={{
|
||||||
sx: {
|
sx: {
|
||||||
borderRadius: "10px",
|
borderRadius: "10px",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user