fix: css styles and store interaction

This commit is contained in:
IlyaDoronin 2023-09-08 16:42:52 +03:00
parent 2d944f8c47
commit f8ca505608
12 changed files with 353 additions and 33 deletions

@ -109,7 +109,7 @@ export const AnswerItem = ({
key={index} key={index}
fullWidth fullWidth
variant="standard" variant="standard"
sx={{ p: "0 0 20px 0" }} sx={{ padding: "0 0 20px 0" }}
> >
<TextField <TextField
value={variant.answer} value={variant.answer}
@ -171,7 +171,7 @@ export const AnswerItem = ({
}} }}
sx={{ sx={{
"& .MuiInputBase-root": { "& .MuiInputBase-root": {
padding: "13.5px", padding: icon ? "5px 13.5px" : "13.5px",
borderRadius: "10px", borderRadius: "10px",
background: "#ffffff", background: "#ffffff",
}, },

@ -1,6 +1,7 @@
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox"; import CustomCheckbox from "@ui_kit/CustomCheckbox";
import CustomTextField from "@ui_kit/CustomTextField";
import InfoIcon from "../../../assets/icons/InfoIcon"; import InfoIcon from "../../../assets/icons/InfoIcon";
import { questionStore, updateQuestionsList } from "@root/questions"; import { questionStore, updateQuestionsList } from "@root/questions";
@ -17,7 +18,7 @@ export default function SettingsData({ totalIndex }: SettingsDataProps) {
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px" }}>
<Typography>Настройки календаря</Typography> <Typography>Настройки календаря</Typography>
<CustomCheckbox <CustomCheckbox
label={"Выбор диапозона дат"} label={"Выбор диапазона дат"}
checked={listQuestions[quizId][totalIndex].content.dateRange} checked={listQuestions[quizId][totalIndex].content.dateRange}
handleChange={({ target }) => { handleChange={({ target }) => {
const clonContent = listQuestions[quizId][totalIndex].content; const clonContent = listQuestions[quizId][totalIndex].content;
@ -35,10 +36,45 @@ export default function SettingsData({ totalIndex }: SettingsDataProps) {
}} }}
/> />
</Box> </Box>
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px", minWidth: "350px", marginRight: "30px" }}>
<Typography>Настройки вопросов</Typography> <Typography>Настройки вопросов</Typography>
<CustomCheckbox label={"Необязательный вопрос"} /> <CustomCheckbox
<CustomCheckbox label={"Внутреннее название вопроса"} /> <InfoIcon /> label={"Необязательный вопрос"}
checked={!listQuestions[quizId][totalIndex].required}
handleChange={(e) => {
updateQuestionsList(quizId, totalIndex, {
required: !e.target.checked,
});
}}
/>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CustomCheckbox
label={"Внутреннее название вопроса"}
checked={listQuestions[quizId][totalIndex].content.innerNameCheck}
handleChange={(e) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerNameCheck = e.target.checked;
if (!e.target.checked) {
clonContent.innerName = "";
}
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>{" "}
<InfoIcon />
</Box>
{listQuestions[quizId][totalIndex].content.innerNameCheck && (
<CustomTextField
placeholder={"Развёрнутое описание вопроса"}
text={listQuestions[quizId][totalIndex].content.innerName}
onChange={({ target }) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerName = target.value;
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
)}
</Box> </Box>
</Box> </Box>
); );

@ -38,12 +38,51 @@ export default function SettingDropDown({ totalIndex }: SettingDropDownProps) {
}} }}
/> />
</Box> </Box>
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px", width: "100%" }}>
<Typography sx={{ marginBottom: "15px" }}> <Typography sx={{ marginBottom: "15px" }}>
Настройки вопросов Настройки вопросов
</Typography> </Typography>
<CustomCheckbox label={"Необязательный вопрос"} /> <CustomCheckbox
<CustomCheckbox label={"Внутреннее название вопроса"} /> <InfoIcon /> label={"Необязательный вопрос"}
checked={!listQuestions[quizId][totalIndex].required}
handleChange={(e) => {
updateQuestionsList(quizId, totalIndex, {
required: !e.target.checked,
});
}}
/>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CustomCheckbox
label={"Внутреннее название вопроса"}
checked={listQuestions[quizId][totalIndex].content.innerNameCheck}
handleChange={(e) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerNameCheck = e.target.checked;
if (!e.target.checked) {
clonContent.innerName = "";
}
updateQuestionsList(quizId, totalIndex, {
content: clonContent,
});
}}
/>{" "}
<InfoIcon />
</Box>
{listQuestions[quizId][totalIndex].content.innerNameCheck && (
<CustomTextField
placeholder={"Развёрнутое описание вопроса"}
text={listQuestions[quizId][totalIndex].content.innerName}
onChange={({ target }) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerName = target.value;
updateQuestionsList(quizId, totalIndex, {
content: clonContent,
});
}}
/>
)}
</Box> </Box>
</Box> </Box>
</> </>

@ -1,6 +1,7 @@
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox"; import CustomCheckbox from "@ui_kit/CustomCheckbox";
import CustomTextField from "@ui_kit/CustomTextField";
import InfoIcon from "../../../assets/icons/InfoIcon"; import InfoIcon from "../../../assets/icons/InfoIcon";
import { questionStore, updateQuestionsList } from "@root/questions"; import { questionStore, updateQuestionsList } from "@root/questions";
@ -13,7 +14,7 @@ export default function SettingEmoji({ totalIndex }: SettingEmojiProps) {
const { listQuestions } = questionStore(); const { listQuestions } = questionStore();
return ( return (
<Box sx={{ display: "flex" }}> <Box sx={{ display: "flex", justifyContent: "space-between" }}>
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px" }}>
<Typography>Настройки ответов</Typography> <Typography>Настройки ответов</Typography>
<CustomCheckbox <CustomCheckbox
@ -35,10 +36,45 @@ export default function SettingEmoji({ totalIndex }: SettingEmojiProps) {
}} }}
/> />
</Box> </Box>
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px", minWidth: "350px", marginRight: "30px" }}>
<Typography>Настройки вопросов</Typography> <Typography>Настройки вопросов</Typography>
<CustomCheckbox label={"Необязательный вопрос"} /> <CustomCheckbox
<CustomCheckbox label={"Внутреннее название вопроса"} /> <InfoIcon /> label={"Необязательный вопрос"}
checked={!listQuestions[quizId][totalIndex].required}
handleChange={(e) => {
updateQuestionsList(quizId, totalIndex, {
required: !e.target.checked,
});
}}
/>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CustomCheckbox
label={"Внутреннее название вопроса"}
checked={listQuestions[quizId][totalIndex].content.innerNameCheck}
handleChange={(e) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerNameCheck = e.target.checked;
if (!e.target.checked) {
clonContent.innerName = "";
}
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>{" "}
<InfoIcon />
</Box>
{listQuestions[quizId][totalIndex].content.innerNameCheck && (
<CustomTextField
placeholder={"Развёрнутое описание вопроса"}
text={listQuestions[quizId][totalIndex].content.innerName}
onChange={({ target }) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerName = target.value;
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
)}
</Box> </Box>
</Box> </Box>
); );

@ -89,7 +89,13 @@ export default function SettingOpytionsPict({
return ( return (
<> <>
<Box sx={{ display: "flex" }}> <Box
sx={{
display: "flex",
justifyContent: "space-between",
marginRight: "30px",
}}
>
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px" }}>
<Typography sx={{ marginBottom: "15px" }}>Пропорции</Typography> <Typography sx={{ marginBottom: "15px" }}>Пропорции</Typography>
<Box <Box
@ -152,7 +158,7 @@ export default function SettingOpytionsPict({
} }
/> />
</Box> </Box>
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px", minWidth: "350px" }}>
<Typography sx={{ marginBottom: "15px" }}>Форма</Typography> <Typography sx={{ marginBottom: "15px" }}>Форма</Typography>
<Box <Box
sx={{ sx={{
@ -205,7 +211,7 @@ export default function SettingOpytionsPict({
}) })
} }
/> />
<Box sx={{ display: "flex" }}> <Box sx={{ display: "flex", alignItems: "center" }}>
<CustomCheckbox <CustomCheckbox
sx={{ width: "100%" }} sx={{ width: "100%" }}
label={"Внутреннее название вопроса"} label={"Внутреннее название вопроса"}

@ -9,6 +9,7 @@ import {
useTheme, useTheme,
} from "@mui/material"; } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox"; import CustomCheckbox from "@ui_kit/CustomCheckbox";
import CustomTextField from "@ui_kit/CustomTextField";
import { questionStore, updateQuestionsList } from "@root/questions"; import { questionStore, updateQuestionsList } from "@root/questions";
@ -37,7 +38,13 @@ export default function SettingTextField({
const theme = useTheme(); const theme = useTheme();
return ( return (
<Box sx={{ display: "flex" }}> <Box
sx={{
display: "flex",
justifyContent: "space-between",
marginRight: "50px",
}}
>
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px" }}>
<Typography>Настройки ответов</Typography> <Typography>Настройки ответов</Typography>
<FormControl> <FormControl>
@ -71,11 +78,54 @@ export default function SettingTextField({
</RadioGroup> </RadioGroup>
</FormControl> </FormControl>
</Box> </Box>
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px", display: "flex", flexDirection: "column" }}>
<Typography>Настройки вопросов</Typography> <Typography>Настройки вопросов</Typography>
<CustomCheckbox label={"Автозаполнение адреса"} /> <CustomCheckbox
<CustomCheckbox label={"Необязательный вопрос"} /> label={"Автозаполнение адреса"}
<CustomCheckbox label={"Внутреннее название вопроса"} /> <InfoIcon /> checked={listQuestions[quizId][totalIndex].content.autofill}
handleChange={({ target }) => {
const clonContent = listQuestions[quizId][totalIndex].content;
clonContent.autofill = target.checked;
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
<CustomCheckbox
label={"Необязательный вопрос"}
checked={!listQuestions[quizId][totalIndex].required}
handleChange={(e) => {
updateQuestionsList(quizId, totalIndex, {
required: !e.target.checked,
});
}}
/>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CustomCheckbox
label={"Внутреннее название вопроса"}
checked={listQuestions[quizId][totalIndex].content.innerNameCheck}
handleChange={(e) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerNameCheck = e.target.checked;
if (!e.target.checked) {
clonContent.innerName = "";
}
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>{" "}
<InfoIcon />
</Box>
{listQuestions[quizId][totalIndex].content.innerNameCheck && (
<CustomTextField
placeholder={"Развёрнутое описание вопроса"}
text={listQuestions[quizId][totalIndex].content.innerName}
onChange={({ target }) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerName = target.value;
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
)}
</Box> </Box>
</Box> </Box>
); );

@ -1,15 +1,54 @@
import { useParams } from "react-router-dom";
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox"; import CustomCheckbox from "@ui_kit/CustomCheckbox";
import CustomTextField from "@ui_kit/CustomTextField";
import { questionStore, updateQuestionsList } from "@root/questions";
import InfoIcon from "../../../assets/icons/InfoIcon"; import InfoIcon from "../../../assets/icons/InfoIcon";
export default function SettingPageOptions() { type SettingPageOptionsProps = {
totalIndex: number;
};
export default function SettingPageOptions({
totalIndex,
}: SettingPageOptionsProps) {
const quizId = Number(useParams().quizId);
const { listQuestions } = questionStore();
return ( return (
<Box sx={{ display: "flex", flexDirection: "column", padding: "20px" }}> <Box sx={{ display: "flex", flexDirection: "column", padding: "20px" }}>
<Typography>Настройки вопроса</Typography> <Typography>Настройки вопроса</Typography>
<Box sx={{ display: "flex", alignItems: "center" }}> <Box sx={{ display: "flex", alignItems: "center" }}>
<CustomCheckbox label={"Внутреннее название вопроса"} /> <CustomCheckbox
label={"Внутреннее название вопроса"}
checked={listQuestions[quizId][totalIndex].content.innerNameCheck}
handleChange={({ target }) =>
updateQuestionsList(quizId, totalIndex, {
content: {
...listQuestions[quizId][totalIndex].content,
innerNameCheck: target.checked,
innerName: "",
},
})
}
/>
<InfoIcon /> <InfoIcon />
</Box> </Box>
{listQuestions[quizId][totalIndex].content.innerNameCheck && (
<CustomTextField
placeholder={"Внутреннее описание вопроса"}
text={listQuestions[quizId][totalIndex].content.innerName}
onChange={({ target }) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerName = target.value;
updateQuestionsList(quizId, totalIndex, {
content: clonContent,
});
}}
/>
)}
</Box> </Box>
); );
} }

@ -13,13 +13,13 @@ export default function SwitchPageOptions({
}: Props) { }: Props) {
switch (switchState) { switch (switchState) {
case "setting": case "setting":
return <SettingPageOptions />; return <SettingPageOptions totalIndex={totalIndex} />;
break; break;
case "help": case "help":
return <HelpQuestions totalIndex={totalIndex} />; return <HelpQuestions totalIndex={totalIndex} />;
break; break;
case "branching": case "branching":
return <BranchingQuestions totalIndex={totalIndex}/>; return <BranchingQuestions totalIndex={totalIndex} />;
break; break;
default: default:
return <></>; return <></>;

@ -2,6 +2,7 @@ import { useParams } from "react-router-dom";
import { Box, ButtonBase, Slider, Typography, useTheme } from "@mui/material"; import { Box, ButtonBase, Slider, Typography, useTheme } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox"; import CustomCheckbox from "@ui_kit/CustomCheckbox";
import CustomTextField from "@ui_kit/CustomTextField";
import { questionStore, updateQuestionsList } from "@root/questions"; import { questionStore, updateQuestionsList } from "@root/questions";
import InfoIcon from "../../../assets/icons/InfoIcon"; import InfoIcon from "../../../assets/icons/InfoIcon";
@ -109,8 +110,43 @@ export default function SettingSlider({ totalIndex }: SettingSliderProps) {
</Box> </Box>
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px" }}>
<Typography>Настройки вопросов</Typography> <Typography>Настройки вопросов</Typography>
<CustomCheckbox label={"Необязательный вопрос"} /> <CustomCheckbox
<CustomCheckbox label={"Внутреннее название вопроса"} /> <InfoIcon /> label={"Необязательный вопрос"}
checked={!listQuestions[quizId][totalIndex].required}
handleChange={(e) => {
updateQuestionsList(quizId, totalIndex, {
required: !e.target.checked,
});
}}
/>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CustomCheckbox
label={"Внутреннее название вопроса"}
checked={listQuestions[quizId][totalIndex].content.innerNameCheck}
handleChange={(e) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerNameCheck = e.target.checked;
if (!e.target.checked) {
clonContent.innerName = "";
}
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>{" "}
<InfoIcon />
</Box>
{listQuestions[quizId][totalIndex].content.innerNameCheck && (
<CustomTextField
placeholder={"Развёрнутое описание вопроса"}
text={listQuestions[quizId][totalIndex].content.innerName}
onChange={({ target }) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerName = target.value;
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
)}
</Box> </Box>
</Box> </Box>
); );

@ -1,6 +1,7 @@
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox"; import CustomCheckbox from "@ui_kit/CustomCheckbox";
import CustomTextField from "@ui_kit/CustomTextField";
import InfoIcon from "../../../assets/icons/InfoIcon"; import InfoIcon from "../../../assets/icons/InfoIcon";
import { questionStore, updateQuestionsList } from "@root/questions"; import { questionStore, updateQuestionsList } from "@root/questions";
@ -28,8 +29,43 @@ export default function SettingSlider({ totalIndex }: SettingSliderProps) {
</Box> </Box>
<Box sx={{ padding: "20px" }}> <Box sx={{ padding: "20px" }}>
<Typography>Настройки вопросов</Typography> <Typography>Настройки вопросов</Typography>
<CustomCheckbox label={"Необязательный вопрос"} /> <CustomCheckbox
<CustomCheckbox label={"Внутреннее название вопроса"} /> <InfoIcon /> label={"Необязательный вопрос"}
checked={!listQuestions[quizId][totalIndex].required}
handleChange={(e) => {
updateQuestionsList(quizId, totalIndex, {
required: !e.target.checked,
});
}}
/>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CustomCheckbox
label={"Внутреннее название вопроса"}
checked={listQuestions[quizId][totalIndex].content.innerNameCheck}
handleChange={(e) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerNameCheck = e.target.checked;
if (!e.target.checked) {
clonContent.innerName = "";
}
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>{" "}
<InfoIcon />
</Box>
{listQuestions[quizId][totalIndex].content.innerNameCheck && (
<CustomTextField
placeholder={"Развёрнутое описание вопроса"}
text={listQuestions[quizId][totalIndex].content.innerName}
onChange={({ target }) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerName = target.value;
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
)}
</Box> </Box>
</Box> </Box>
); );

@ -1,6 +1,7 @@
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
import { Box, Typography } from "@mui/material"; import { Box, Typography } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox"; import CustomCheckbox from "@ui_kit/CustomCheckbox";
import CustomTextField from "@ui_kit/CustomTextField";
import { questionStore, updateQuestionsList } from "@root/questions"; import { questionStore, updateQuestionsList } from "@root/questions";
@ -26,8 +27,43 @@ export default function SettingsUpload({ totalIndex }: SettingsUploadProps) {
updateQuestionsList(quizId, totalIndex, { content: clonContent }); updateQuestionsList(quizId, totalIndex, { content: clonContent });
}} }}
/> />
<CustomCheckbox label={"Необязательный вопрос"} /> <CustomCheckbox
<CustomCheckbox label={"Внутреннее название вопроса"} /> <InfoIcon /> label={"Необязательный вопрос"}
checked={!listQuestions[quizId][totalIndex].required}
handleChange={(e) => {
updateQuestionsList(quizId, totalIndex, {
required: !e.target.checked,
});
}}
/>
<Box sx={{ display: "flex", alignItems: "center" }}>
<CustomCheckbox
label={"Внутреннее название вопроса"}
checked={listQuestions[quizId][totalIndex].content.innerNameCheck}
handleChange={(e) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerNameCheck = e.target.checked;
if (!e.target.checked) {
clonContent.innerName = "";
}
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>{" "}
<InfoIcon />
</Box>
{listQuestions[quizId][totalIndex].content.innerNameCheck && (
<CustomTextField
placeholder={"Развёрнутое описание вопроса"}
text={listQuestions[quizId][totalIndex].content.innerName}
onChange={({ target }) => {
let clonContent = listQuestions[quizId][totalIndex].content;
clonContent.innerName = target.value;
updateQuestionsList(quizId, totalIndex, { content: clonContent });
}}
/>
)}
</Box> </Box>
); );
} }

@ -14,7 +14,13 @@ export default function ResponseSettings({ totalIndex }: Props) {
const { listQuestions } = questionStore(); const { listQuestions } = questionStore();
return ( return (
<Box sx={{ display: "flex" }}> <Box
sx={{
display: "flex",
justifyContent: "space-between",
marginRight: "30px",
}}
>
<Box sx={{ padding: "20px", display: "flex", flexDirection: "column" }}> <Box sx={{ padding: "20px", display: "flex", flexDirection: "column" }}>
<Typography>Настройки ответов</Typography> <Typography>Настройки ответов</Typography>
<CustomCheckbox <CustomCheckbox
@ -61,7 +67,7 @@ export default function ResponseSettings({ totalIndex }: Props) {
}); });
}} }}
/> />
<Box sx={{ display: "flex" }}> <Box sx={{ display: "flex", alignItems: "center" }}>
<CustomCheckbox <CustomCheckbox
label={"Внутреннее название вопроса"} label={"Внутреннее название вопроса"}
checked={listQuestions[quizId][totalIndex].content.innerNameCheck} checked={listQuestions[quizId][totalIndex].content.innerNameCheck}