diff --git a/src/index.tsx b/src/index.tsx
index 605fb23c..e2020c30 100755
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -6,17 +6,14 @@ import "./index.css";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import lightTheme from "./utils/themes/light";
import { ThemeProvider } from "@mui/material";
-import HorizontalLinearStepper from "./ui_kit/Stepper";
import StartPage from "./pages/startPage/StartPage";
import Main from "./pages/main";
-import FirstQuiz from "./pages/createQuize/FirstQuiz";
import QuestionsPage from "./pages/Questions/QuestionsPage";
import ContactFormPage from "./pages/ContactFormPage/ContactFormPage";
import InstallQuiz from "./pages/InstallQuiz/InstallQuiz";
import { Result } from "./pages/Result/Result";
import { Setting } from "./pages/Result/Setting";
-import MyQuizzes from "./pages/createQuize/MyQuizzes";
import MyQuizzesFull from "./pages/createQuize/MyQuizzesFull";
import ImageCrop from "@ui_kit/Modal/ImageCrop";
diff --git a/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx b/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx
index 378d4f9f..dddfb55e 100644
--- a/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx
+++ b/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx
@@ -1,4 +1,5 @@
import { useState } from "react";
+import { useParams } from "react-router-dom";
import { Draggable } from "react-beautiful-dnd";
import {
Box,
@@ -36,6 +37,7 @@ export const AnswerItem = ({
variant,
icon,
}: AnswerItemProps) => {
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
const theme = useTheme();
@@ -55,8 +57,11 @@ export const AnswerItem = ({
const answerNew = variants.slice();
answerNew[index].answer = event.target.value;
- updateQuestionsList(totalIndex, {
- content: { ...listQuestions[totalIndex].content, variants: answerNew },
+ updateQuestionsList(quizId, totalIndex, {
+ content: {
+ ...listQuestions[quizId][totalIndex].content,
+ variants: answerNew,
+ },
});
};
@@ -64,8 +69,11 @@ export const AnswerItem = ({
const answerNew = variants.slice();
answerNew.push({ answer: "", answerLong: "", hints: "" });
- updateQuestionsList(totalIndex, {
- content: { ...listQuestions[totalIndex].content, variants: answerNew },
+ updateQuestionsList(quizId, totalIndex, {
+ content: {
+ ...listQuestions[quizId][totalIndex].content,
+ variants: answerNew,
+ },
});
};
@@ -73,8 +81,11 @@ export const AnswerItem = ({
const answerNew = variants.slice();
answerNew.splice(index, 1);
- updateQuestionsList(totalIndex, {
- content: { ...listQuestions[totalIndex].content, variants: answerNew },
+ updateQuestionsList(quizId, totalIndex, {
+ content: {
+ ...listQuestions[quizId][totalIndex].content,
+ variants: answerNew,
+ },
});
};
@@ -82,8 +93,11 @@ export const AnswerItem = ({
const answerNew = variants.slice();
answerNew[index].hints = event.target.value;
- updateQuestionsList(totalIndex, {
- content: { ...listQuestions[totalIndex].content, variants: answerNew },
+ updateQuestionsList(quizId, totalIndex, {
+ content: {
+ ...listQuestions[quizId][totalIndex].content,
+ variants: answerNew,
+ },
});
};
diff --git a/src/pages/Questions/AnswerDraggableList/index.tsx b/src/pages/Questions/AnswerDraggableList/index.tsx
index 897d3114..2c5b075f 100644
--- a/src/pages/Questions/AnswerDraggableList/index.tsx
+++ b/src/pages/Questions/AnswerDraggableList/index.tsx
@@ -1,3 +1,4 @@
+import { useParams } from "react-router-dom";
import { Box } from "@mui/material";
import { DragDropContext, Droppable } from "react-beautiful-dnd";
@@ -22,11 +23,13 @@ export const AnswerDraggableList = ({
totalIndex,
icon,
}: AnswerDraggableListProps) => {
+ const quizId = Number(useParams().quizId);
+
const onDragEnd = ({ destination, source }: DropResult) => {
if (destination) {
const newItems = reorder(variants, source.index, destination.index);
- updateVariants(totalIndex, newItems);
+ updateVariants(quizId, totalIndex, newItems);
}
};
diff --git a/src/pages/Questions/ButtonsOptions.tsx b/src/pages/Questions/ButtonsOptions.tsx
index 1b0a8edc..e638309c 100644
--- a/src/pages/Questions/ButtonsOptions.tsx
+++ b/src/pages/Questions/ButtonsOptions.tsx
@@ -17,7 +17,7 @@ interface Props {
}
export default function ButtonsOptions({ SSHC, switchState, totalIndex }: Props) {
- const params = Number(useParams().quizId);
+ const quizId = Number(useParams().quizId);
const {openedModalSettings} = questionStore()
const openedModal = () => {
resetSomeField({openedModalSettings: "open"})
@@ -64,7 +64,7 @@ export default function ButtonsOptions({ SSHC, switchState, totalIndex }: Props)
key={title}
onClick={() => {
SSHC(value);
- {myFunc()}
+ myFunc()
}}
sx={{
backgroundColor: switchState === value ? theme.palette.brightPurple.main : "transparent",
@@ -87,7 +87,7 @@ export default function ButtonsOptions({ SSHC, switchState, totalIndex }: Props)
- removeQuestion(totalIndex)}>
+ removeQuestion(quizId, totalIndex)}>
diff --git a/src/pages/Questions/ButtonsOptionsAndPict.tsx b/src/pages/Questions/ButtonsOptionsAndPict.tsx
index 26b64933..1e638c4a 100644
--- a/src/pages/Questions/ButtonsOptionsAndPict.tsx
+++ b/src/pages/Questions/ButtonsOptionsAndPict.tsx
@@ -24,7 +24,7 @@ export default function ButtonsOptionsAndPict({
switchState,
totalIndex,
}: Props) {
- const params = Number(useParams().quizId);
+ const quizId = Number(useParams().quizId);
const { openedModalSettings } = questionStore();
const theme = useTheme();
@@ -181,7 +181,7 @@ export default function ButtonsOptionsAndPict({
removeQuestion(totalIndex)}
+ onClick={() => removeQuestion(quizId, totalIndex)}
>
diff --git a/src/pages/Questions/DataOptions/DataOptions.tsx b/src/pages/Questions/DataOptions/DataOptions.tsx
index 7539490b..f76d3059 100644
--- a/src/pages/Questions/DataOptions/DataOptions.tsx
+++ b/src/pages/Questions/DataOptions/DataOptions.tsx
@@ -1,3 +1,4 @@
+import { useParams } from "react-router-dom";
import { Box, Typography, useTheme } from "@mui/material";
import ButtonsOptions from "../ButtonsOptions";
import SwitchData from "./switchData";
@@ -12,6 +13,7 @@ interface Props {
export default function DataOptions({ totalIndex }: Props) {
const [switchState, setSwitchState] = useState("setting");
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
const theme = useTheme();
@@ -20,10 +22,10 @@ export default function DataOptions({ totalIndex }: Props) {
};
useEffect(() => {
- if (listQuestions[totalIndex].content.type !== "mask") {
- const clonContent = listQuestions[totalIndex].content;
+ if (listQuestions[quizId][totalIndex].content.type !== "mask") {
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.type = "calendar";
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}
}, []);
@@ -41,21 +43,25 @@ export default function DataOptions({ totalIndex }: Props) {
>
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.type = "calendar";
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
>
Использовать календарь
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.type = "mask";
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
>
Использовать маску
diff --git a/src/pages/Questions/DataOptions/settingData.tsx b/src/pages/Questions/DataOptions/settingData.tsx
index a188f286..57cc076a 100644
--- a/src/pages/Questions/DataOptions/settingData.tsx
+++ b/src/pages/Questions/DataOptions/settingData.tsx
@@ -1,3 +1,4 @@
+import { useParams } from "react-router-dom";
import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
import InfoIcon from "../../../assets/icons/InfoIcon";
@@ -8,6 +9,7 @@ type SettingsDataProps = {
};
export default function SettingsData({ totalIndex }: SettingsDataProps) {
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
return (
@@ -16,20 +18,20 @@ export default function SettingsData({ totalIndex }: SettingsDataProps) {
Настройки календаря
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.dateRange = target.checked;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.time = target.checked;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
diff --git a/src/pages/Questions/DraggableList/QuestionPageCard.tsx b/src/pages/Questions/DraggableList/QuestionPageCard.tsx
index 1bc09693..5607ebde 100644
--- a/src/pages/Questions/DraggableList/QuestionPageCard.tsx
+++ b/src/pages/Questions/DraggableList/QuestionPageCard.tsx
@@ -1,3 +1,4 @@
+import { useParams } from "react-router-dom";
import {
Box,
Checkbox,
@@ -133,9 +134,11 @@ export default function QuestionsPageCard({
totalIndex,
draggableProps,
}: Props) {
+ const quizId = Number(useParams().quizId);
const theme = useTheme();
const { listQuestions } = questionStore();
- const { type: switchState, expanded: isExpanded } = listQuestions[totalIndex];
+ const { type: switchState, expanded: isExpanded } =
+ listQuestions[quizId][totalIndex];
return (
{
- updateQuestionsList(totalIndex, { title: e.target.value });
- console.log(listQuestions[totalIndex].title);
+ updateQuestionsList(quizId, totalIndex, {
+ title: e.target.value,
+ });
+ console.log(listQuestions[quizId][totalIndex].title);
}}
InputProps={{
startAdornment: (
@@ -198,7 +203,7 @@ export default function QuestionsPageCard({
- updateQuestionsList(totalIndex, { expanded: !isExpanded })
+ updateQuestionsList(quizId, totalIndex, { expanded: !isExpanded })
}
>
{isExpanded ? : }
@@ -222,12 +227,12 @@ export default function QuestionsPageCard({
userSelect: "none",
}}
/>
- copyQuestion(totalIndex)}>
+ copyQuestion(quizId, totalIndex)}>
removeQuestion(totalIndex)}
+ onClick={() => removeQuestion(quizId, totalIndex)}
>
diff --git a/src/pages/Questions/DraggableList/index.tsx b/src/pages/Questions/DraggableList/index.tsx
index 8dd879a2..09aa689b 100644
--- a/src/pages/Questions/DraggableList/index.tsx
+++ b/src/pages/Questions/DraggableList/index.tsx
@@ -1,4 +1,5 @@
import { useState } from "react";
+import { useParams } from "react-router-dom";
import { Box } from "@mui/material";
import { DragDropContext, Droppable } from "react-beautiful-dnd";
@@ -13,6 +14,7 @@ import type { DropResult } from "react-beautiful-dnd";
export const DraggableList = () => {
const [draggableId, setDraggableId] = useState(-1);
const [dropPlaceIndex, setDropPlaceIndex] = useState(-1);
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
const onDrop = () => {
@@ -22,9 +24,13 @@ export const DraggableList = () => {
const onDragEnd = ({ destination, source }: DropResult) => {
if (destination) {
- const newItems = reorder(listQuestions, source.index, destination.index);
+ const newItems = reorder(
+ listQuestions[quizId],
+ source.index,
+ destination.index
+ );
- updateQuestionsListDragAndDrop(newItems);
+ updateQuestionsListDragAndDrop(quizId, newItems);
}
};
@@ -43,7 +49,7 @@ export const DraggableList = () => {
{...provided.droppableProps}
onMouseUp={onDrop}
>
- {listQuestions.map((_, index) => (
+ {listQuestions[quizId]?.map((_, index) => (
{
setSwitchState(data);
@@ -26,8 +28,11 @@ export default function DropDown({ totalIndex }: Props) {
const answerNew = variants.slice();
answerNew.push({ answer: "", answerLong: "", hints: "" });
- updateQuestionsList(totalIndex, {
- content: { ...listQuestions[totalIndex].content, variants: answerNew },
+ updateQuestionsList(quizId, totalIndex, {
+ content: {
+ ...listQuestions[quizId][totalIndex].content,
+ variants: answerNew,
+ },
});
};
diff --git a/src/pages/Questions/DropDown/settingDropDown.tsx b/src/pages/Questions/DropDown/settingDropDown.tsx
index c8b90169..a6d5dc4b 100644
--- a/src/pages/Questions/DropDown/settingDropDown.tsx
+++ b/src/pages/Questions/DropDown/settingDropDown.tsx
@@ -1,3 +1,4 @@
+import { useParams } from "react-router-dom";
import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
import CustomTextField from "@ui_kit/CustomTextField";
@@ -11,6 +12,7 @@ type SettingDropDownProps = {
};
export default function SettingDropDown({ totalIndex }: SettingDropDownProps) {
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
return (
@@ -28,11 +30,11 @@ export default function SettingDropDown({ totalIndex }: SettingDropDownProps) {
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.default = target.value;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
diff --git a/src/pages/Questions/Emoji/Emoji.tsx b/src/pages/Questions/Emoji/Emoji.tsx
index a160b776..4c45b9ff 100644
--- a/src/pages/Questions/Emoji/Emoji.tsx
+++ b/src/pages/Questions/Emoji/Emoji.tsx
@@ -1,3 +1,4 @@
+import { useParams } from "react-router-dom";
import { Box, Link, Typography, useTheme } from "@mui/material";
import EnterIcon from "../../../assets/icons/questionsPage/enterIcon";
import ButtonsOptions from "../ButtonsOptions";
@@ -13,6 +14,7 @@ interface Props {
export default function Emoji({ totalIndex }: Props) {
const [switchState, setSwitchState] = React.useState("setting");
const { listQuestions } = questionStore();
+ const quizId = Number(useParams().quizId);
const theme = useTheme();
const SSHC = (data: string) => {
@@ -23,7 +25,7 @@ export default function Emoji({ totalIndex }: Props) {
<>
@@ -38,12 +40,12 @@ export default function Emoji({ totalIndex }: Props) {
sx={{ color: theme.palette.brightPurple.main }}
onClick={() => {
const answerNew =
- listQuestions[totalIndex].content.variants.slice();
+ listQuestions[quizId][totalIndex].content.variants.slice();
answerNew.push({ answer: "", answerLong: "", hints: "" });
- updateQuestionsList(totalIndex, {
+ updateQuestionsList(quizId, totalIndex, {
content: {
- ...listQuestions[totalIndex].content,
+ ...listQuestions[quizId][totalIndex].content,
variants: answerNew,
},
});
diff --git a/src/pages/Questions/Emoji/settingEmoji.tsx b/src/pages/Questions/Emoji/settingEmoji.tsx
index 92d3be87..06c77635 100644
--- a/src/pages/Questions/Emoji/settingEmoji.tsx
+++ b/src/pages/Questions/Emoji/settingEmoji.tsx
@@ -1,3 +1,4 @@
+import { useParams } from "react-router-dom";
import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
import InfoIcon from "../../../assets/icons/InfoIcon";
@@ -8,6 +9,7 @@ type SettingEmojiProps = {
};
export default function SettingEmoji({ totalIndex }: SettingEmojiProps) {
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
return (
@@ -16,20 +18,20 @@ export default function SettingEmoji({ totalIndex }: SettingEmojiProps) {
Настройки ответов
{
- let clonContent = listQuestions[totalIndex].content;
+ let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.multi = e.target.checked;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
{
- let clonContent = listQuestions[totalIndex].content;
+ let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.own = e.target.checked;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
diff --git a/src/pages/Questions/OptionsAndPicture/OptionsAndPicture.tsx b/src/pages/Questions/OptionsAndPicture/OptionsAndPicture.tsx
index 54cc3a12..a9970362 100644
--- a/src/pages/Questions/OptionsAndPicture/OptionsAndPicture.tsx
+++ b/src/pages/Questions/OptionsAndPicture/OptionsAndPicture.tsx
@@ -1,4 +1,5 @@
import { Box, Link, Typography, ButtonBase, useTheme } from "@mui/material";
+import { useParams } from "react-router-dom";
import AddImage from "../../../assets/icons/questionsPage/addImage";
import EnterIcon from "../../../assets/icons/questionsPage/enterIcon";
import ButtonsOptionsAndPict from "../ButtonsOptionsAndPict";
@@ -13,6 +14,7 @@ interface Props {
export default function OptionsAndPicture({ totalIndex }: Props) {
const [switchState, setSwitchState] = React.useState("setting");
const { listQuestions } = questionStore();
+ const quizId = Number(useParams().quizId);
const theme = useTheme();
const SSHC = (data: string) => {
setSwitchState(data);
@@ -22,48 +24,53 @@ export default function OptionsAndPicture({ totalIndex }: Props) {
<>
- {listQuestions[totalIndex].content.variants.map((_, index) => (
-
- {
- if (target.files?.length) {
- const clonContent = listQuestions[totalIndex].content;
-
- clonContent.variants[index].answer = URL.createObjectURL(
- target.files[0]
- );
-
- updateQuestionsList(totalIndex, { content: clonContent });
- }
- }}
- hidden
- accept="image/*"
- multiple
- type="file"
- />
-
- (
+
- Добавьте ответ
-
-
- ))}
+ {
+ if (target.files?.length) {
+ const clonContent =
+ listQuestions[quizId][totalIndex].content;
+
+ clonContent.variants[index].answer = URL.createObjectURL(
+ target.files[0]
+ );
+
+ updateQuestionsList(quizId, totalIndex, {
+ content: clonContent,
+ });
+ }
+ }}
+ hidden
+ accept="image/*"
+ multiple
+ type="file"
+ />
+
+
+ Добавьте ответ
+
+
+ )
+ )}
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.variants.push({
answer: "",
answerLong: "",
hints: "",
});
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
>
Добавьте ответ
diff --git a/src/pages/Questions/OptionsPicture/OptionsPicture.tsx b/src/pages/Questions/OptionsPicture/OptionsPicture.tsx
index 7081fbe1..e82adb05 100644
--- a/src/pages/Questions/OptionsPicture/OptionsPicture.tsx
+++ b/src/pages/Questions/OptionsPicture/OptionsPicture.tsx
@@ -1,4 +1,5 @@
import { useState } from "react";
+import { useParams } from "react-router-dom";
import { Box, Link, Typography, Button, useTheme } from "@mui/material";
import ButtonsOptions from "../ButtonsOptions";
@@ -16,6 +17,7 @@ interface Props {
export default function OptionsPicture({ totalIndex }: Props) {
const theme = useTheme();
+ const quizId = Number(useParams().quizId);
const [switchState, setSwitchState] = useState("setting");
const { listQuestions } = questionStore();
@@ -25,11 +27,11 @@ export default function OptionsPicture({ totalIndex }: Props) {
const addImage = ({ target }: ChangeEvent) => {
if (target.files?.length) {
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.images.push(URL.createObjectURL(target.files[0]));
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}
};
diff --git a/src/pages/Questions/OptionsPicture/settingOpytionsPict.tsx b/src/pages/Questions/OptionsPicture/settingOpytionsPict.tsx
index 3aa1afe8..66ab2d2c 100644
--- a/src/pages/Questions/OptionsPicture/settingOpytionsPict.tsx
+++ b/src/pages/Questions/OptionsPicture/settingOpytionsPict.tsx
@@ -1,4 +1,5 @@
import { useEffect } from "react";
+import { useParams } from "react-router-dom";
import { Box, Button, Typography, useTheme } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
@@ -70,18 +71,19 @@ export function SelectIconButton({ Icon, isActive = false, onClick }: Props) {
export default function SettingOpytionsPict({
totalIndex,
}: SettingOpytionsPictProps) {
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
useEffect(() => {
- if (!listQuestions[totalIndex].content.xy) {
+ if (!listQuestions[quizId][totalIndex].content.xy) {
updateProportions("1:1");
}
}, []);
const updateProportions = (proportions: string) => {
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.xy = proportions;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
};
return (
@@ -100,7 +102,9 @@ export default function SettingOpytionsPict({
updateProportions(value)}
- isActive={listQuestions[totalIndex].content.xy === value}
+ isActive={
+ listQuestions[quizId][totalIndex].content.xy === value
+ }
Icon={icon}
/>
))}
@@ -111,24 +115,25 @@ export default function SettingOpytionsPict({
- updateQuestionsList(totalIndex, {
+ updateQuestionsList(quizId, totalIndex, {
content: {
- ...listQuestions[totalIndex].content,
- multi: !listQuestions[totalIndex].content.multi,
+ ...listQuestions[quizId][totalIndex].content,
+ multi: !listQuestions[quizId][totalIndex].content.multi,
},
})
}
/>
- updateQuestionsList(totalIndex, {
+ updateQuestionsList(quizId, totalIndex, {
content: {
- ...listQuestions[totalIndex].content,
- largeCheck: !listQuestions[totalIndex].content.largeCheck,
+ ...listQuestions[quizId][totalIndex].content,
+ largeCheck:
+ !listQuestions[quizId][totalIndex].content.largeCheck,
},
})
}
@@ -146,26 +151,30 @@ export default function SettingOpytionsPict({
>
- updateQuestionsList(totalIndex, {
+ updateQuestionsList(quizId, totalIndex, {
content: {
- ...listQuestions[totalIndex].content,
+ ...listQuestions[quizId][totalIndex].content,
format: "carousel",
},
})
}
- isActive={listQuestions[totalIndex].content.format === "carousel"}
+ isActive={
+ listQuestions[quizId][totalIndex].content.format === "carousel"
+ }
Icon={FormatIcon2}
/>
- updateQuestionsList(totalIndex, {
+ updateQuestionsList(quizId, totalIndex, {
content: {
- ...listQuestions[totalIndex].content,
+ ...listQuestions[quizId][totalIndex].content,
format: "masonry",
},
})
}
- isActive={listQuestions[totalIndex].content.format === "masonry"}
+ isActive={
+ listQuestions[quizId][totalIndex].content.format === "masonry"
+ }
Icon={FormatIcon1}
/>
diff --git a/src/pages/Questions/OwnTextField/OwnTextField.tsx b/src/pages/Questions/OwnTextField/OwnTextField.tsx
index 0d6c0dbc..5006d498 100644
--- a/src/pages/Questions/OwnTextField/OwnTextField.tsx
+++ b/src/pages/Questions/OwnTextField/OwnTextField.tsx
@@ -1,4 +1,5 @@
import { useState } from "react";
+import { useParams } from "react-router-dom";
import { Box, Typography, useTheme } from "@mui/material";
import CustomTextField from "@ui_kit/CustomTextField";
@@ -16,6 +17,7 @@ interface Props {
}
export default function OwnTextField({ totalIndex }: Props) {
const [switchState, setSwitchState] = useState("setting");
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
const theme = useTheme();
@@ -37,11 +39,11 @@ export default function OwnTextField({ totalIndex }: Props) {
>
) => {
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.placeholder = target.value;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
diff --git a/src/pages/Questions/OwnTextField/settingTextField.tsx b/src/pages/Questions/OwnTextField/settingTextField.tsx
index 36a38691..54a1dc84 100644
--- a/src/pages/Questions/OwnTextField/settingTextField.tsx
+++ b/src/pages/Questions/OwnTextField/settingTextField.tsx
@@ -1,3 +1,4 @@
+import { useParams } from "react-router-dom";
import {
Box,
FormControl,
@@ -32,6 +33,7 @@ export default function SettingTextField({
totalIndex,
}: SettingTextFieldProps) {
const { listQuestions } = questionStore();
+ const quizId = Number(useParams().quizId);
const theme = useTheme();
return (
@@ -43,18 +45,18 @@ export default function SettingTextField({
aria-labelledby="demo-controlled-radio-buttons-group"
name="controlled-radio-buttons-group"
value={ANSWER_TYPES.findIndex(
- ({ value }) => listQuestions[totalIndex].content[value]
+ ({ value }) => listQuestions[quizId][totalIndex].content[value]
)}
onChange={({ target }: React.ChangeEvent) => {
const clonContent = {
- ...listQuestions[totalIndex].content,
+ ...listQuestions[quizId][totalIndex].content,
single: false,
multi: false,
number: false,
[ANSWER_TYPES[Number(target.value)].value]: true,
};
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
>
{ANSWER_TYPES.map(({ name }, index) => (
diff --git a/src/pages/Questions/PageOptions/PageOptions.tsx b/src/pages/Questions/PageOptions/PageOptions.tsx
index 1e69cebc..41a90413 100644
--- a/src/pages/Questions/PageOptions/PageOptions.tsx
+++ b/src/pages/Questions/PageOptions/PageOptions.tsx
@@ -1,4 +1,5 @@
import { useState } from "react";
+import { useParams } from "react-router-dom";
import { Box, Typography, useTheme } from "@mui/material";
import ButtonsOptions from "../ButtonsOptions";
import CustomTextField from "@ui_kit/CustomTextField";
@@ -18,6 +19,7 @@ export default function PageOptions({ disableInput, totalIndex }: Props) {
const [openImageModal, setOpenImageModal] = useState(false);
const [openVideoModal, setOpenVideoModal] = useState(false);
const [switchState, setSwitchState] = useState("setting");
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
const theme = useTheme();
@@ -40,11 +42,11 @@ export default function PageOptions({ disableInput, totalIndex }: Props) {
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.text = target.value;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
@@ -75,9 +77,11 @@ export default function PageOptions({ disableInput, totalIndex }: Props) {
onClose={() => setOpenImageModal(false)}
imgHC={(fileList) => {
if (fileList?.length) {
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.picture = URL.createObjectURL(fileList[0]);
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, {
+ content: clonContent,
+ });
}
}}
/>
@@ -106,11 +110,11 @@ export default function PageOptions({ disableInput, totalIndex }: Props) {
setOpenVideoModal(false)}
- video={listQuestions[totalIndex].content.video}
+ video={listQuestions[quizId][totalIndex].content.video}
onUpload={(url) => {
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.video = url;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
diff --git a/src/pages/Questions/QuestionsPage.tsx b/src/pages/Questions/QuestionsPage.tsx
index 085df079..9ee5b4bd 100755
--- a/src/pages/Questions/QuestionsPage.tsx
+++ b/src/pages/Questions/QuestionsPage.tsx
@@ -25,7 +25,7 @@ export default function QuestionsPage() {
const collapseEverything = () => {
listQuestions[quizId].forEach((item, index) => {
- updateQuestionsList(quizId, { ...item, expanded: false });
+ updateQuestionsList(quizId, index, { ...item, expanded: false });
});
};
diff --git a/src/pages/Questions/RatingOptions/RatingOptions.tsx b/src/pages/Questions/RatingOptions/RatingOptions.tsx
index efa5f7b2..5a70dfae 100644
--- a/src/pages/Questions/RatingOptions/RatingOptions.tsx
+++ b/src/pages/Questions/RatingOptions/RatingOptions.tsx
@@ -1,4 +1,5 @@
import { useState } from "react";
+import { useParams } from "react-router-dom";
import { Box, Typography, useTheme } from "@mui/material";
import ButtonsOptions from "../ButtonsOptions";
import Rating from "@mui/material/Rating";
@@ -12,6 +13,7 @@ interface Props {
export default function RatingOptions({ totalIndex }: Props) {
const [switchState, setSwitchState] = useState("setting");
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
const theme = useTheme();
@@ -33,7 +35,7 @@ export default function RatingOptions({ totalIndex }: Props) {
>
`${value} Heart${value !== 1 ? "s" : ""}`
}
@@ -42,9 +44,9 @@ export default function RatingOptions({ totalIndex }: Props) {
emptyIcon={}
sx={{ display: "flex", gap: "15px" }}
onChange={(_, value) => {
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.starts = value || 0;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.form = name;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, {
+ content: clonContent,
+ });
}}
sx={{
backgroundColor:
- listQuestions[totalIndex].content.form === name
+ listQuestions[quizId][totalIndex].content.form === name
? theme.palette.brightPurple.main
: "transparent",
color:
- listQuestions[totalIndex].content.form === name
+ listQuestions[quizId][totalIndex].content.form === name
? "#ffffff"
: theme.palette.grey3.main,
width: "40px",
@@ -90,16 +94,16 @@ export default function SettingSlider({ totalIndex }: SettingSliderProps) {
Количество
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.steps = Number(value) || 1;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
diff --git a/src/pages/Questions/SliderOptions/SliderOptions.tsx b/src/pages/Questions/SliderOptions/SliderOptions.tsx
index bb5e2aa8..ff3fe54f 100644
--- a/src/pages/Questions/SliderOptions/SliderOptions.tsx
+++ b/src/pages/Questions/SliderOptions/SliderOptions.tsx
@@ -1,4 +1,5 @@
-import { Box, Typography, useTheme } from "@mui/material";
+import { useParams } from "react-router-dom";
+import { Box, Typography } from "@mui/material";
import ButtonsOptions from "../ButtonsOptions";
import React from "react";
import CustomTextField from "@ui_kit/CustomTextField";
@@ -11,8 +12,9 @@ interface Props {
export default function SliderOptions({ totalIndex }: Props) {
const [switchState, setSwitchState] = React.useState("setting");
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
- const theme = useTheme();
+
const SSHC = (data: string) => {
setSwitchState(data);
};
@@ -34,25 +36,33 @@ export default function SliderOptions({ totalIndex }: Props) {
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.range = `${target.value}—${
- listQuestions[totalIndex].content.range.split("—")[1]
+ listQuestions[quizId][totalIndex].content.range.split("—")[1]
}`;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, {
+ content: clonContent,
+ });
}}
/>
—
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.range = `${
- listQuestions[totalIndex].content.range.split("—")[0]
+ listQuestions[quizId][totalIndex].content.range.split("—")[0]
}—${target.value}`;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, {
+ content: clonContent,
+ });
}}
/>
@@ -68,11 +78,13 @@ export default function SliderOptions({ totalIndex }: Props) {
Начальное значение
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.start = Number(target.value);
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, {
+ content: clonContent,
+ });
}}
/>
@@ -80,11 +92,13 @@ export default function SliderOptions({ totalIndex }: Props) {
Шаг
{
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.step = Number(target.value);
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, {
+ content: clonContent,
+ });
}}
/>
diff --git a/src/pages/Questions/SliderOptions/settingSlider.tsx b/src/pages/Questions/SliderOptions/settingSlider.tsx
index ff343197..4047816c 100644
--- a/src/pages/Questions/SliderOptions/settingSlider.tsx
+++ b/src/pages/Questions/SliderOptions/settingSlider.tsx
@@ -1,3 +1,4 @@
+import { useParams } from "react-router-dom";
import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
import InfoIcon from "../../../assets/icons/InfoIcon";
@@ -8,6 +9,7 @@ type SettingSliderProps = {
};
export default function SettingSlider({ totalIndex }: SettingSliderProps) {
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
return (
@@ -16,11 +18,11 @@ export default function SettingSlider({ totalIndex }: SettingSliderProps) {
Настройки ползунка
{
- let clonContent = listQuestions[totalIndex].content;
+ let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.chooseRange = e.target.checked;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
diff --git a/src/pages/Questions/SwitchQuestionsPage.tsx b/src/pages/Questions/SwitchQuestionsPage.tsx
index ed695187..38ff8e61 100644
--- a/src/pages/Questions/SwitchQuestionsPage.tsx
+++ b/src/pages/Questions/SwitchQuestionsPage.tsx
@@ -19,9 +19,10 @@ interface Props {
}
export default function SwitchQuestionsPage({ totalIndex }: Props) {
- const params = Number(useParams().quizId);
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
- const switchState = listQuestions[totalIndex].type;
+
+ const switchState = listQuestions[quizId][totalIndex].type;
switch (switchState) {
case "variant":
return ;
diff --git a/src/pages/Questions/TypeQuestions.tsx b/src/pages/Questions/TypeQuestions.tsx
index 5c5b2dad..6d5b7c9e 100755
--- a/src/pages/Questions/TypeQuestions.tsx
+++ b/src/pages/Questions/TypeQuestions.tsx
@@ -10,91 +10,101 @@ import Slider from "../../assets/icons/questionsPage/slider";
import Download from "../../assets/icons/questionsPage/download";
import Page from "../../assets/icons/questionsPage/page";
import RatingIcon from "../../assets/icons/questionsPage/rating";
-import {Box, useTheme} from "@mui/material";
+import { Box, useTheme } from "@mui/material";
import React from "react";
-import {useParams} from "react-router-dom";
-import {questionStore, updateQuestionsList} from "@root/questions";
+import { useParams } from "react-router-dom";
+import { questionStore, updateQuestionsList } from "@root/questions";
interface Props {
- totalIndex: number
+ totalIndex: number;
}
-export default function TypeQuestions({totalIndex }: Props) {
- const theme = useTheme()
- const params = Number(useParams().quizId);
- const {listQuestions} = questionStore()
- const switchState = listQuestions[totalIndex].type
- const buttonTypeQuestions: { icon: JSX.Element; title: string; value: string }[] = [
- {
- icon: ,
- title: 'Варианты ответов',
- value: 'variant',
- },
- {
- icon: ,
- title: 'Варианты с картинками',
- value: 'images',
- },
- {
- icon: ,
- title: 'Варианты и картинка',
- value: 'varimg',
- },
- {
- icon: ,
- title: 'Эмоджи',
- value: 'emoji',
- },
- {
- icon: ,
- title: 'Своё поле для ввода',
- value: 'text',
- },
- {
- icon: ,
- title: 'Выпадающий список',
- value: 'select',
- },
- {
- icon: ,
- title: 'Дата',
- value: 'date',
- },
- {
- icon: ,
- title: 'Ползунок',
- value: 'number',
- },
- {
- icon: ,
- title: 'Загрузка файла',
- value: 'file',
- },
- {
- icon: ,
- title: 'Страница',
- value: 'page',
- },
- {
- icon: ,
- title: 'Рейтинг',
- value: 'rating',
- },
- ];
- return (
-
-
- {buttonTypeQuestions.map(({ icon, title, value }) => (
- {
- console.log(value)
- updateQuestionsList(totalIndex, {type: value})
- }}
- icon={icon}
- text={title}
- />
- ))}
-
- )
+export default function TypeQuestions({ totalIndex }: Props) {
+ const theme = useTheme();
+ const quizId = Number(useParams().quizId);
+ const { listQuestions } = questionStore();
+ const switchState = listQuestions[quizId][totalIndex].type;
+ const buttonTypeQuestions: {
+ icon: JSX.Element;
+ title: string;
+ value: string;
+ }[] = [
+ {
+ icon: ,
+ title: "Варианты ответов",
+ value: "variant",
+ },
+ {
+ icon: ,
+ title: "Варианты с картинками",
+ value: "images",
+ },
+ {
+ icon: ,
+ title: "Варианты и картинка",
+ value: "varimg",
+ },
+ {
+ icon: ,
+ title: "Эмоджи",
+ value: "emoji",
+ },
+ {
+ icon: ,
+ title: "Своё поле для ввода",
+ value: "text",
+ },
+ {
+ icon: ,
+ title: "Выпадающий список",
+ value: "select",
+ },
+ {
+ icon: ,
+ title: "Дата",
+ value: "date",
+ },
+ {
+ icon: ,
+ title: "Ползунок",
+ value: "number",
+ },
+ {
+ icon: ,
+ title: "Загрузка файла",
+ value: "file",
+ },
+ {
+ icon: ,
+ title: "Страница",
+ value: "page",
+ },
+ {
+ icon: ,
+ title: "Рейтинг",
+ value: "rating",
+ },
+ ];
+ return (
+
+ {buttonTypeQuestions.map(({ icon, title, value }) => (
+ {
+ console.log(value);
+ updateQuestionsList(quizId, totalIndex, { type: value });
+ }}
+ icon={icon}
+ text={title}
+ />
+ ))}
+
+ );
}
diff --git a/src/pages/Questions/UploadFile/UploadFile.tsx b/src/pages/Questions/UploadFile/UploadFile.tsx
index 716fea8e..1bee8373 100644
--- a/src/pages/Questions/UploadFile/UploadFile.tsx
+++ b/src/pages/Questions/UploadFile/UploadFile.tsx
@@ -1,4 +1,5 @@
import { useState, useEffect } from "react";
+import { useParams } from "react-router-dom";
import {
Box,
FormControl,
@@ -30,6 +31,7 @@ const DESIGN_TYPES = [
export default function UploadFile({ totalIndex }: Props) {
const [switchState, setSwitchState] = useState("setting");
+ const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
const theme = useTheme();
@@ -38,20 +40,20 @@ export default function UploadFile({ totalIndex }: Props) {
};
const handleChange = ({ target }: SelectChangeEvent) => {
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.type = target.value;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
};
useEffect(() => {
const isTypeSetted = DESIGN_TYPES.find(
- ({ value }) => value === listQuestions[totalIndex].content.type
+ ({ value }) => value === listQuestions[quizId][totalIndex].content.type
);
if (!isTypeSetted) {
- const clonContent = listQuestions[totalIndex].content;
+ const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.type = DESIGN_TYPES[0].value;
- updateQuestionsList(totalIndex, { content: clonContent });
+ updateQuestionsList(quizId, totalIndex, { content: clonContent });
}
}, []);
@@ -80,7 +82,7 @@ export default function UploadFile({ totalIndex }: Props) {