diff --git a/src/pages/Questions/answerOptions/AnswerDraggableList/AnswerItem.tsx b/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx
similarity index 100%
rename from src/pages/Questions/answerOptions/AnswerDraggableList/AnswerItem.tsx
rename to src/pages/Questions/AnswerDraggableList/AnswerItem.tsx
diff --git a/src/pages/Questions/AnswerDraggableList/StrictModeDroppable.tsx b/src/pages/Questions/AnswerDraggableList/StrictModeDroppable.tsx
new file mode 100644
index 00000000..6441c17e
--- /dev/null
+++ b/src/pages/Questions/AnswerDraggableList/StrictModeDroppable.tsx
@@ -0,0 +1,23 @@
+import { useState, useEffect } from "react";
+import { Droppable } from "react-beautiful-dnd";
+
+import type { DroppableProps } from "react-beautiful-dnd";
+
+export const StrictModeDroppable = ({ children, ...props }: DroppableProps) => {
+ const [enabled, setEnabled] = useState(false);
+
+ useEffect(() => {
+ const animation = requestAnimationFrame(() => setEnabled(true));
+
+ return () => {
+ setEnabled(false);
+ cancelAnimationFrame(animation);
+ };
+ }, []);
+
+ if (!enabled) {
+ return null;
+ }
+
+ return {children};
+};
diff --git a/src/pages/Questions/answerOptions/AnswerDraggableList/helper.ts b/src/pages/Questions/AnswerDraggableList/helper.ts
similarity index 100%
rename from src/pages/Questions/answerOptions/AnswerDraggableList/helper.ts
rename to src/pages/Questions/AnswerDraggableList/helper.ts
diff --git a/src/pages/Questions/answerOptions/AnswerDraggableList/index.tsx b/src/pages/Questions/AnswerDraggableList/index.tsx
similarity index 100%
rename from src/pages/Questions/answerOptions/AnswerDraggableList/index.tsx
rename to src/pages/Questions/AnswerDraggableList/index.tsx
diff --git a/src/pages/Questions/ButtonsOptionsAndPict.tsx b/src/pages/Questions/ButtonsOptionsAndPict.tsx
index 7fd1e614..26b64933 100644
--- a/src/pages/Questions/ButtonsOptionsAndPict.tsx
+++ b/src/pages/Questions/ButtonsOptionsAndPict.tsx
@@ -10,7 +10,6 @@ import DeleteIcon from "../../assets/icons/questionsPage/deleteIcon";
import ImgIcon from "../../assets/icons/questionsPage/imgIcon";
import { useParams } from "react-router-dom";
import { questionStore, removeQuestion, resetSomeField } from "@root/questions";
-import { branchStore } from "@root/branches";
import "./ButtonsOptionsAndPict.css";
@@ -27,7 +26,6 @@ export default function ButtonsOptionsAndPict({
}: Props) {
const params = Number(useParams().quizId);
const { openedModalSettings } = questionStore();
- const { branch } = branchStore();
const theme = useTheme();
const openedModal = () => {
diff --git a/src/pages/Questions/DropDown/DropDown.tsx b/src/pages/Questions/DropDown/DropDown.tsx
index 7a06a908..f195f8ff 100644
--- a/src/pages/Questions/DropDown/DropDown.tsx
+++ b/src/pages/Questions/DropDown/DropDown.tsx
@@ -1,5 +1,9 @@
+import { useState } from "react";
import { Box, Typography, Link, useTheme } from "@mui/material";
-import React from "react";
+import { AnswerDraggableList } from "../AnswerDraggableList";
+
+import { questionStore, updateQuestionsList } from "@root/questions";
+
import EnterIcon from "../../../assets/icons/questionsPage/enterIcon";
import SwitchDropDown from "./switchDropDown";
import ButtonsOptions from "../ButtonsOptions";
@@ -9,35 +13,48 @@ interface Props {
}
export default function DropDown({ totalIndex }: Props) {
+ const [switchState, setSwitchState] = useState("setting");
+ const { listQuestions } = questionStore();
const theme = useTheme();
- const [switchState, setSwitchState] = React.useState("setting");
+ const variants = listQuestions[totalIndex].content.variants;
const SSHC = (data: string) => {
setSwitchState(data);
};
+ const addNewAnswer = () => {
+ const answerNew = variants.slice();
+ answerNew.push({ answer: "", answerLong: "", hints: "" });
+
+ updateQuestionsList(totalIndex, {
+ content: { ...listQuestions[totalIndex].content, variants: answerNew },
+ });
+ };
+
return (
<>
-
- Добавьте ответ
-
+ {variants.length === 0 ? (
+
+ Добавьте ответ
+
+ ) : (
+
+ )}
{
- // console.info("I'm a button.");
- // }}
+ onClick={addNewAnswer}
>
Добавьте ответ
diff --git a/src/pages/Questions/DropDown/settingDropDown.tsx b/src/pages/Questions/DropDown/settingDropDown.tsx
index 4d708b1f..c8b90169 100644
--- a/src/pages/Questions/DropDown/settingDropDown.tsx
+++ b/src/pages/Questions/DropDown/settingDropDown.tsx
@@ -1,25 +1,49 @@
-import {Box, Typography} from "@mui/material";
+import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
import CustomTextField from "@ui_kit/CustomTextField";
+
+import { questionStore, updateQuestionsList } from "@root/questions";
+
import InfoIcon from "../../../assets/icons/InfoIcon";
-export default function SettingDropDown() {
- return(
- <>
-
-
- Настройки ответов
-
+type SettingDropDownProps = {
+ totalIndex: number;
+};
- Текст в выпадающем списке
-
-
-
- Настройки вопросов
-
-
-
-
- >
- )
-}
\ No newline at end of file
+export default function SettingDropDown({ totalIndex }: SettingDropDownProps) {
+ const { listQuestions } = questionStore();
+
+ return (
+ <>
+
+
+
+ Настройки ответов
+
+
+
+ Текст в выпадающем списке
+
+ {
+ const clonContent = listQuestions[totalIndex].content;
+ clonContent.default = target.value;
+ updateQuestionsList(totalIndex, { content: clonContent });
+ }}
+ />
+
+
+
+ Настройки вопросов
+
+
+
+
+
+ >
+ );
+}
diff --git a/src/pages/Questions/DropDown/switchDropDown.tsx b/src/pages/Questions/DropDown/switchDropDown.tsx
index 88aa794f..ac7d3b12 100644
--- a/src/pages/Questions/DropDown/switchDropDown.tsx
+++ b/src/pages/Questions/DropDown/switchDropDown.tsx
@@ -14,7 +14,7 @@ export default function SwitchDropDown({
}: Props) {
switch (switchState) {
case "setting":
- return ;
+ return ;
break;
case "help":
return ;
diff --git a/src/pages/Questions/OptionsPicture/OptionsPicture.tsx b/src/pages/Questions/OptionsPicture/OptionsPicture.tsx
index e64c2cf8..7081fbe1 100644
--- a/src/pages/Questions/OptionsPicture/OptionsPicture.tsx
+++ b/src/pages/Questions/OptionsPicture/OptionsPicture.tsx
@@ -1,36 +1,48 @@
-import { Box, Link, Typography, useTheme } from "@mui/material";
-import React from "react";
+import { useState } from "react";
+import { Box, Link, Typography, Button, useTheme } from "@mui/material";
+
+import ButtonsOptions from "../ButtonsOptions";
+import { questionStore, updateQuestionsList } from "@root/questions";
+
import EnterIcon from "../../../assets/icons/questionsPage/enterIcon";
import AddImage from "../../../assets/icons/questionsPage/addImage";
-import ButtonsOptions from "../ButtonsOptions";
import SwitchAnswerOptionsPict from "./switchOptionsPict";
+
+import type { ChangeEvent } from "react";
+
interface Props {
totalIndex: number;
}
+
export default function OptionsPicture({ totalIndex }: Props) {
const theme = useTheme();
- const [switchState, setSwitchState] = React.useState("setting");
- // const [addInput, setAddInput] = React.useState([
- // 0: {name: "распутье", variants: ["дорога влево", "дорога вправо"]};
- // ]);
+ const [switchState, setSwitchState] = useState("setting");
+ const { listQuestions } = questionStore();
+
const SSHC = (data: string) => {
setSwitchState(data);
};
- // const createCondition = (name) => {
- // addInput([...state, {name: name}])
- // }
- //
- // const deleteCondition = (index) => {
- //
- // }
+ const addImage = ({ target }: ChangeEvent) => {
+ if (target.files?.length) {
+ const clonContent = listQuestions[totalIndex].content;
+
+ clonContent.images.push(URL.createObjectURL(target.files[0]));
+
+ updateQuestionsList(totalIndex, { content: clonContent });
+ }
+ };
+
return (
<>
-
+
void;
}
+type SettingOpytionsPictProps = {
+ totalIndex: number;
+};
+
+const PROPORTIONS = [
+ { value: "1:1", icon: ProportionsIcon11 },
+ { value: "2:1", icon: ProportionsIcon21 },
+ { value: "1:2", icon: ProportionsIcon12 },
+];
+
export function SelectIconButton({ Icon, isActive = false, onClick }: Props) {
const theme = useTheme();
return (
}
+ startIcon={
+
+ }
sx={{
backgroundColor: isActive ? theme.palette.brightPurple.main : "#eee4fc",
borderRadius: 0,
border: "none",
- color: isActive ? theme.palette.brightPurple.main : theme.palette.grey2.main,
+ color: isActive
+ ? theme.palette.brightPurple.main
+ : theme.palette.grey2.main,
p: "7px",
width: "auto",
minWidth: 0,
@@ -35,19 +58,31 @@ export function SelectIconButton({ Icon, isActive = false, onClick }: Props) {
},
"&:hover": {
border: "none",
- borderColor: isActive ? theme.palette.brightPurple.main : theme.palette.grey2.main,
+ borderColor: isActive
+ ? theme.palette.brightPurple.main
+ : theme.palette.grey2.main,
},
}}
/>
);
}
-type Proportions = "oneOne" | "twoOne" | "oneTwo";
-type AlignType = "left" | "right";
+export default function SettingOpytionsPict({
+ totalIndex,
+}: SettingOpytionsPictProps) {
+ const { listQuestions } = questionStore();
-export default function SettingOpytionsPict() {
- const [proportions, setProportions] = useState("oneOne");
- const [alignType, setAlignType] = useState("left");
+ useEffect(() => {
+ if (!listQuestions[totalIndex].content.xy) {
+ updateProportions("1:1");
+ }
+ }, []);
+
+ const updateProportions = (proportions: string) => {
+ const clonContent = listQuestions[totalIndex].content;
+ clonContent.xy = proportions;
+ updateQuestionsList(totalIndex, { content: clonContent });
+ };
return (
<>
@@ -61,25 +96,43 @@ export default function SettingOpytionsPict() {
marginBottom: "20px",
}}
>
- setProportions("oneOne")}
- isActive={proportions === "oneOne"}
- Icon={ProportionsIcon11}
- />
- setProportions("twoOne")}
- isActive={proportions === "twoOne"}
- Icon={ProportionsIcon21}
- />
- setProportions("oneTwo")}
- isActive={proportions === "oneTwo"}
- Icon={ProportionsIcon12}
- />
+ {PROPORTIONS.map(({ value, icon }, index) => (
+ updateProportions(value)}
+ isActive={listQuestions[totalIndex].content.xy === value}
+ Icon={icon}
+ />
+ ))}
- Настройки ответов
-
-
+
+ Настройки ответов
+
+
+
+ updateQuestionsList(totalIndex, {
+ content: {
+ ...listQuestions[totalIndex].content,
+ multi: !listQuestions[totalIndex].content.multi,
+ },
+ })
+ }
+ />
+
+ updateQuestionsList(totalIndex, {
+ content: {
+ ...listQuestions[totalIndex].content,
+ large: !listQuestions[totalIndex].content.large,
+ },
+ })
+ }
+ />
@@ -91,14 +144,34 @@ export default function SettingOpytionsPict() {
marginBottom: "20px",
}}
>
- setAlignType("left")} isActive={alignType === "left"} Icon={FormatIcon2} />
setAlignType("right")}
- isActive={alignType === "right"}
+ onClick={() =>
+ updateQuestionsList(totalIndex, {
+ content: {
+ ...listQuestions[totalIndex].content,
+ format: "carousel",
+ },
+ })
+ }
+ isActive={listQuestions[totalIndex].content.format === "carousel"}
+ Icon={FormatIcon2}
+ />
+
+ updateQuestionsList(totalIndex, {
+ content: {
+ ...listQuestions[totalIndex].content,
+ format: "masonry",
+ },
+ })
+ }
+ isActive={listQuestions[totalIndex].content.format === "masonry"}
Icon={FormatIcon1}
/>
- Настройки вопросов
+
+ Настройки вопросов
+
diff --git a/src/pages/Questions/OptionsPicture/switchOptionsPict.tsx b/src/pages/Questions/OptionsPicture/switchOptionsPict.tsx
index 72d06866..de7e7dd2 100644
--- a/src/pages/Questions/OptionsPicture/switchOptionsPict.tsx
+++ b/src/pages/Questions/OptionsPicture/switchOptionsPict.tsx
@@ -14,13 +14,13 @@ export default function SwitchAnswerOptionsPict({
}: Props) {
switch (switchState) {
case "setting":
- return ;
+ return ;
break;
case "help":
return ;
break;
case "branching":
- return ;
+ return ;
break;
default:
return <>>;
diff --git a/src/pages/Questions/OwnTextField/settingTextField.tsx b/src/pages/Questions/OwnTextField/settingTextField.tsx
index ee22ce49..36a38691 100644
--- a/src/pages/Questions/OwnTextField/settingTextField.tsx
+++ b/src/pages/Questions/OwnTextField/settingTextField.tsx
@@ -13,15 +13,13 @@ import { questionStore, updateQuestionsList } from "@root/questions";
import InfoIcon from "../../../assets/icons/InfoIcon";
-import type { QuestionType } from "@root/questions";
-
type SettingTextFieldProps = {
totalIndex: number;
};
type Answer = {
name: string;
- value: QuestionType;
+ value: "single" | "multi" | "number";
};
const ANSWER_TYPES: Answer[] = [
@@ -45,11 +43,17 @@ export default function SettingTextField({
aria-labelledby="demo-controlled-radio-buttons-group"
name="controlled-radio-buttons-group"
value={ANSWER_TYPES.findIndex(
- ({ value }) => value === listQuestions[totalIndex].content.type
+ ({ value }) => listQuestions[totalIndex].content[value]
)}
onChange={({ target }: React.ChangeEvent) => {
- const clonContent = listQuestions[totalIndex].content;
- clonContent.type = ANSWER_TYPES[Number(target.value)].value;
+ const clonContent = {
+ ...listQuestions[totalIndex].content,
+ single: false,
+ multi: false,
+ number: false,
+ [ANSWER_TYPES[Number(target.value)].value]: true,
+ };
+
updateQuestionsList(totalIndex, { content: clonContent });
}}
>
diff --git a/src/pages/Questions/UploadFile/UploadFile.tsx b/src/pages/Questions/UploadFile/UploadFile.tsx
index 38774ca1..716fea8e 100644
--- a/src/pages/Questions/UploadFile/UploadFile.tsx
+++ b/src/pages/Questions/UploadFile/UploadFile.tsx
@@ -1,3 +1,4 @@
+import { useState, useEffect } from "react";
import {
Box,
FormControl,
@@ -8,7 +9,9 @@ import {
useTheme,
} from "@mui/material";
import ButtonsOptions from "../ButtonsOptions";
-import React, { useState } from "react";
+
+import { questionStore, updateQuestionsList } from "@root/questions";
+
import InfoIcon from "../../../assets/icons/InfoIcon";
import ArrowDown from "../../../assets/icons/ArrowDownIcon";
import SwitchUpload from "./switchUpload";
@@ -17,25 +20,41 @@ interface Props {
totalIndex: number;
}
+const DESIGN_TYPES = [
+ { name: "Все типы файлов", value: "all" },
+ { name: "Изображения", value: "picture" },
+ { name: "Видео", value: "video" },
+ { name: "Аудио", value: "audio" },
+ { name: "Документ", value: "document" },
+];
+
export default function UploadFile({ totalIndex }: Props) {
+ const [switchState, setSwitchState] = useState("setting");
+ const { listQuestions } = questionStore();
const theme = useTheme();
- const [switchState, setSwitchState] = React.useState("setting");
+
const SSHC = (data: string) => {
setSwitchState(data);
};
- const designTypes = [
- ["Все типы файлов"],
- ["Изображения"],
- ["Видео"],
- ["Аудио"],
- ["Документ"],
- ];
- const [designType, setDesignType] = useState(designTypes[0][0]);
- const handleChange = (event: SelectChangeEvent) => {
- setDesignType(event.target.value);
+ const handleChange = ({ target }: SelectChangeEvent) => {
+ const clonContent = listQuestions[totalIndex].content;
+ clonContent.type = target.value;
+ updateQuestionsList(totalIndex, { content: clonContent });
};
+ useEffect(() => {
+ const isTypeSetted = DESIGN_TYPES.find(
+ ({ value }) => value === listQuestions[totalIndex].content.type
+ );
+
+ if (!isTypeSetted) {
+ const clonContent = listQuestions[totalIndex].content;
+ clonContent.type = DESIGN_TYPES[0].value;
+ updateQuestionsList(totalIndex, { content: clonContent });
+ }
+ }, []);
+
return (
<>
}
>
- {designTypes.map((type) => (
+ {DESIGN_TYPES.map(({ name, value }) => (
))}
diff --git a/src/pages/Questions/UploadFile/settingUpload.tsx b/src/pages/Questions/UploadFile/settingUpload.tsx
index b3b1336b..15245742 100644
--- a/src/pages/Questions/UploadFile/settingUpload.tsx
+++ b/src/pages/Questions/UploadFile/settingUpload.tsx
@@ -1,15 +1,31 @@
-import {Box, Typography} from "@mui/material";
+import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
+
+import { questionStore, updateQuestionsList } from "@root/questions";
+
import InfoIcon from "../../../assets/icons/InfoIcon";
+type SettingsUploadProps = {
+ totalIndex: number;
+};
-export default function SettingsUpload() {
- return (
-
- Настройки вопроса
-
-
-
-
- );
-};
\ No newline at end of file
+export default function SettingsUpload({ totalIndex }: SettingsUploadProps) {
+ const { listQuestions } = questionStore();
+
+ return (
+
+ Настройки вопроса
+ {
+ const clonContent = listQuestions[totalIndex].content;
+ clonContent.autofill = target.checked;
+ updateQuestionsList(totalIndex, { content: clonContent });
+ }}
+ />
+
+
+
+ );
+}
diff --git a/src/pages/Questions/UploadFile/switchUpload.tsx b/src/pages/Questions/UploadFile/switchUpload.tsx
index 783feac7..83d19b2c 100644
--- a/src/pages/Questions/UploadFile/switchUpload.tsx
+++ b/src/pages/Questions/UploadFile/switchUpload.tsx
@@ -14,13 +14,13 @@ export default function SwitchUpload({
}: Props) {
switch (switchState) {
case "setting":
- return ;
+ return ;
break;
case "help":
return ;
break;
case "branching":
- return ;
+ return ;
break;
default:
return <>>;
diff --git a/src/pages/Questions/answerOptions/AnswerOptions.tsx b/src/pages/Questions/answerOptions/AnswerOptions.tsx
index a0c82379..c6eff88f 100755
--- a/src/pages/Questions/answerOptions/AnswerOptions.tsx
+++ b/src/pages/Questions/answerOptions/AnswerOptions.tsx
@@ -2,7 +2,7 @@ import { useState } from "react";
import { Box, Typography, Link, useTheme } from "@mui/material";
import EnterIcon from "../../../assets/icons/questionsPage/enterIcon";
import SwitchAnswerOptions from "./switchAnswerOptions";
-import { AnswerDraggableList } from "./AnswerDraggableList";
+import { AnswerDraggableList } from "../AnswerDraggableList";
import ButtonsOptionsAndPict from "../ButtonsOptionsAndPict";
import { questionStore, updateQuestionsList } from "@root/questions";
diff --git a/src/pages/Questions/answerOptions/responseSettings.tsx b/src/pages/Questions/answerOptions/responseSettings.tsx
index 24410a50..6a465748 100644
--- a/src/pages/Questions/answerOptions/responseSettings.tsx
+++ b/src/pages/Questions/answerOptions/responseSettings.tsx
@@ -1,23 +1,31 @@
+import { useState, useEffect } from "react";
import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
import InfoIcon from "../../../assets/icons/InfoIcon";
import * as React from "react";
import CustomTextField from "@ui_kit/CustomTextField";
-import { useParams } from "react-router-dom";
import { questionStore, updateQuestionsList } from "@root/questions";
+import type { ChangeEvent } from "react";
+
interface Props {
totalIndex: number;
}
export default function ResponseSettings({ totalIndex }: Props) {
- const params = Number(useParams().quizId);
+ const [checked, setChecked] = useState(false);
const { listQuestions } = questionStore();
- const [checked, setChecked] = React.useState([true, false]);
- const handleChange = (event: React.ChangeEvent) => {
- setChecked([checked[0], event.target.checked]);
+
+ const handleChange = (event: ChangeEvent) => {
+ setChecked(event.target.checked);
};
+ useEffect(() => {
+ if (listQuestions[totalIndex].content.innerName.length) {
+ setChecked(true);
+ }
+ }, []);
+
return (
@@ -62,18 +70,18 @@ export default function ResponseSettings({ totalIndex }: Props) {
{" "}
- {checked[1] && (
+ {checked && (
{
+ text={listQuestions[totalIndex].content.innerName}
+ onChange={({ target }) => {
let clonContent = listQuestions[totalIndex].content;
- clonContent.innerName = e.target.value;
+ clonContent.innerName = target.value;
updateQuestionsList(totalIndex, { content: clonContent });
}}
/>
diff --git a/src/pages/Questions/branchingQuestions.tsx b/src/pages/Questions/branchingQuestions.tsx
index 92a9ca94..ee281397 100644
--- a/src/pages/Questions/branchingQuestions.tsx
+++ b/src/pages/Questions/branchingQuestions.tsx
@@ -1,4 +1,3 @@
-import { useEffect } from "react";
import {
Box,
Button,
@@ -18,7 +17,6 @@ import {
resetSomeField,
updateQuestionsList,
} from "@root/questions";
-import { branchStore, updateBranchState } from "@root/branches";
import { Select } from "./Select";
import DeleteIcon from "@icons/questionsPage/deleteIcon";
@@ -42,20 +40,8 @@ export default function BranchingQuestions({
totalIndex,
}: BranchingQuestionsProps) {
const { openedModalSettings, listQuestions } = questionStore();
- const { branch } = branchStore();
const theme = useTheme();
- useEffect(() => {
- updateBranchState({
- action: listQuestions[totalIndex].content.rule.show
- ? ACTIONS[0]
- : ACTIONS[1],
- condition: listQuestions[totalIndex].content.rule.or
- ? CONDITIONS[0]
- : CONDITIONS[1],
- });
- }, []);
-
const handleClose = () => {
resetSomeField({ openedModalSettings: "" });
};
@@ -120,7 +106,6 @@ export default function BranchingQuestions({
const clonContent = listQuestions[totalIndex].content;
clonContent.rule.show = action === ACTIONS[0];
updateQuestionsList(totalIndex, { content: clonContent });
- updateBranchState({ action });
}}
/>
@@ -165,7 +150,7 @@ export default function BranchingQuestions({