2023-08-28 09:31:34 +00:00
|
|
|
|
import { useEffect } from "react";
|
2023-09-06 13:20:12 +00:00
|
|
|
|
import { useParams } from "react-router-dom";
|
2023-09-25 13:43:15 +00:00
|
|
|
|
import { Box, Button, Typography, Tooltip, useMediaQuery, useTheme } from "@mui/material";
|
2023-03-30 18:39:59 +00:00
|
|
|
|
import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
2023-09-07 14:14:48 +00:00
|
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
2023-09-20 09:07:33 +00:00
|
|
|
|
import { useDebouncedCallback } from "use-debounce";
|
2023-08-28 09:31:34 +00:00
|
|
|
|
|
|
|
|
|
import { questionStore, updateQuestionsList } from "@root/questions";
|
|
|
|
|
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import InfoIcon from "../../../assets/icons/InfoIcon";
|
|
|
|
|
import FormatIcon2 from "../../../assets/icons/questionsPage/FormatIcon2";
|
|
|
|
|
import FormatIcon1 from "../../../assets/icons/questionsPage/FormatIcon1";
|
|
|
|
|
import ProportionsIcon11 from "../../../assets/icons/questionsPage/ProportionsIcon11";
|
|
|
|
|
import ProportionsIcon21 from "../../../assets/icons/questionsPage/ProportionsIcon21";
|
|
|
|
|
import ProportionsIcon12 from "../../../assets/icons/questionsPage/ProportionsIcon12";
|
2023-03-30 18:39:59 +00:00
|
|
|
|
|
|
|
|
|
interface Props {
|
2023-04-15 09:10:59 +00:00
|
|
|
|
Icon: React.ElementType;
|
|
|
|
|
isActive?: boolean;
|
|
|
|
|
onClick: () => void;
|
2023-03-30 18:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-28 09:31:34 +00:00
|
|
|
|
type SettingOpytionsPictProps = {
|
|
|
|
|
totalIndex: number;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const PROPORTIONS = [
|
|
|
|
|
{ value: "1:1", icon: ProportionsIcon11 },
|
|
|
|
|
{ value: "2:1", icon: ProportionsIcon21 },
|
|
|
|
|
{ value: "1:2", icon: ProportionsIcon12 },
|
|
|
|
|
];
|
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
export function SelectIconButton({ Icon, isActive = false, onClick }: Props) {
|
|
|
|
|
const theme = useTheme();
|
2023-09-15 12:37:12 +00:00
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
return (
|
2023-05-10 17:35:30 +00:00
|
|
|
|
<Button
|
2023-04-15 09:10:59 +00:00
|
|
|
|
onClick={onClick}
|
|
|
|
|
variant="outlined"
|
2023-09-25 13:43:15 +00:00
|
|
|
|
startIcon={<Icon color={isActive ? theme.palette.navbarbg.main : theme.palette.brightPurple.main} />}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
sx={{
|
|
|
|
|
backgroundColor: isActive ? theme.palette.brightPurple.main : "#eee4fc",
|
2023-09-25 13:43:15 +00:00
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
borderRadius: 0,
|
|
|
|
|
border: "none",
|
2023-09-25 13:43:15 +00:00
|
|
|
|
color: isActive ? theme.palette.brightPurple.main : theme.palette.grey2.main,
|
2023-04-15 09:10:59 +00:00
|
|
|
|
p: "7px",
|
2023-09-25 13:43:15 +00:00
|
|
|
|
width: "40px",
|
|
|
|
|
height: "40px",
|
2023-04-15 09:10:59 +00:00
|
|
|
|
minWidth: 0,
|
|
|
|
|
"& .MuiButton-startIcon": {
|
|
|
|
|
mr: 0,
|
|
|
|
|
ml: 0,
|
|
|
|
|
},
|
|
|
|
|
"&:hover": {
|
2023-04-23 08:39:34 +00:00
|
|
|
|
border: "none",
|
2023-09-25 13:43:15 +00:00
|
|
|
|
borderColor: isActive ? theme.palette.brightPurple.main : theme.palette.grey2.main,
|
2023-04-15 09:10:59 +00:00
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2023-03-30 18:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-25 13:43:15 +00:00
|
|
|
|
export default function SettingOpytionsPict({ totalIndex }: SettingOpytionsPictProps) {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const quizId = Number(useParams().quizId);
|
2023-08-28 09:31:34 +00:00
|
|
|
|
const { listQuestions } = questionStore();
|
2023-09-15 12:37:12 +00:00
|
|
|
|
const theme = useTheme();
|
2023-09-25 13:43:15 +00:00
|
|
|
|
const isTablet = useMediaQuery(theme.breakpoints.down(985));
|
2023-09-15 12:37:12 +00:00
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
2023-09-25 13:43:15 +00:00
|
|
|
|
const isFigmaTablte = useMediaQuery(theme.breakpoints.down(990));
|
|
|
|
|
|
2023-09-20 09:07:33 +00:00
|
|
|
|
const debounced = useDebouncedCallback((value) => {
|
|
|
|
|
let clonContent = listQuestions[quizId][totalIndex].content;
|
|
|
|
|
clonContent.innerName = value;
|
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: clonContent,
|
|
|
|
|
});
|
|
|
|
|
}, 1000);
|
2023-03-30 18:39:59 +00:00
|
|
|
|
|
2023-08-28 09:31:34 +00:00
|
|
|
|
useEffect(() => {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
if (!listQuestions[quizId][totalIndex].content.xy) {
|
2023-08-28 09:31:34 +00:00
|
|
|
|
updateProportions("1:1");
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const updateProportions = (proportions: string) => {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const clonContent = listQuestions[quizId][totalIndex].content;
|
2023-08-28 09:31:34 +00:00
|
|
|
|
clonContent.xy = proportions;
|
2023-09-06 13:20:12 +00:00
|
|
|
|
updateQuestionsList(quizId, totalIndex, { content: clonContent });
|
2023-08-28 09:31:34 +00:00
|
|
|
|
};
|
2023-03-30 18:39:59 +00:00
|
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
2023-09-08 13:42:52 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
2023-09-15 12:37:12 +00:00
|
|
|
|
flexDirection: isTablet ? "column" : null,
|
2023-09-25 13:43:15 +00:00
|
|
|
|
marginRight: isFigmaTablte ? (isMobile ? "0" : "0px") : "30px",
|
2023-09-08 13:42:52 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
pt: isMobile ? "25px" : "20px",
|
|
|
|
|
pb: isMobile ? "25px" : "20px",
|
|
|
|
|
pl: "20px",
|
|
|
|
|
pr: isFigmaTablte ? (isMobile ? "20px" : "0px") : "28px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "14px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box sx={{ pb: isMobile ? "11px" : "6px" }}>
|
|
|
|
|
<Typography sx={{ fontWeight: "500", fontSize: "18px", color: " #4D4D4D", mb: isMobile ? "10px" : "14px" }}>
|
|
|
|
|
Пропорции
|
|
|
|
|
</Typography>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
gap: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{PROPORTIONS.map(({ value, icon }, index) => (
|
|
|
|
|
<SelectIconButton
|
|
|
|
|
key={index}
|
|
|
|
|
onClick={() => updateProportions(value)}
|
|
|
|
|
isActive={listQuestions[quizId][totalIndex].content.xy === value}
|
|
|
|
|
Icon={icon}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
2023-09-15 12:37:12 +00:00
|
|
|
|
|
2023-09-25 13:43:15 +00:00
|
|
|
|
<Typography sx={{ fontWeight: "500", fontSize: "18px", color: " #4D4D4D" }}>Настройки ответов</Typography>
|
2023-08-28 09:31:34 +00:00
|
|
|
|
|
|
|
|
|
<CustomCheckbox
|
2023-09-21 07:00:08 +00:00
|
|
|
|
sx={{ display: "block", mr: isMobile ? "0px" : "16px" }}
|
2023-08-28 09:31:34 +00:00
|
|
|
|
label={"Можно несколько"}
|
2023-09-06 13:20:12 +00:00
|
|
|
|
checked={listQuestions[quizId][totalIndex].content.multi}
|
2023-09-07 14:14:48 +00:00
|
|
|
|
handleChange={({ target }) =>
|
2023-09-06 13:20:12 +00:00
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
2023-08-28 09:31:34 +00:00
|
|
|
|
content: {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
...listQuestions[quizId][totalIndex].content,
|
2023-09-07 14:14:48 +00:00
|
|
|
|
multi: target.checked,
|
2023-08-28 09:31:34 +00:00
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
2023-09-25 12:35:12 +00:00
|
|
|
|
{listQuestions[quizId][totalIndex].content.xy !== "1:1" &&
|
|
|
|
|
listQuestions[quizId][totalIndex].content.format !== "masonry" && (
|
|
|
|
|
<CustomCheckbox
|
|
|
|
|
sx={{ display: "block", mr: isMobile ? "0px" : "16px" }}
|
|
|
|
|
label={"Большие картинки"}
|
|
|
|
|
checked={listQuestions[quizId][totalIndex].content.largeCheck}
|
|
|
|
|
handleChange={({ target }) =>
|
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: {
|
|
|
|
|
...listQuestions[quizId][totalIndex].content,
|
|
|
|
|
largeCheck: target.checked,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2023-09-07 14:14:48 +00:00
|
|
|
|
<CustomCheckbox
|
2023-09-21 07:00:08 +00:00
|
|
|
|
sx={{ display: "block", mr: isMobile ? "0px" : "16px" }}
|
2023-09-07 14:14:48 +00:00
|
|
|
|
label={'Вариант "свой ответ"'}
|
|
|
|
|
checked={listQuestions[quizId][totalIndex].content.own}
|
|
|
|
|
handleChange={({ target }) =>
|
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: {
|
|
|
|
|
...listQuestions[quizId][totalIndex].content,
|
|
|
|
|
own: target.checked,
|
2023-08-28 09:31:34 +00:00
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
pt: isMobile ? "0px" : "20px",
|
|
|
|
|
pb: "20px",
|
|
|
|
|
pl: isTablet ? "20px" : "",
|
|
|
|
|
pr: isFigmaTablte ? "30px" : "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: isMobile ? "13px" : "14px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box sx={{ pb: isMobile ? "11px" : "6px" }}>
|
|
|
|
|
<Typography sx={{ fontWeight: "500", fontSize: "18px", color: " #4D4D4D", mb: isMobile ? "10px" : "14px" }}>
|
|
|
|
|
Формат
|
|
|
|
|
</Typography>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
gap: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<SelectIconButton
|
|
|
|
|
onClick={() =>
|
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: {
|
|
|
|
|
...listQuestions[quizId][totalIndex].content,
|
|
|
|
|
format: "carousel",
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
isActive={listQuestions[quizId][totalIndex].content.format === "carousel"}
|
|
|
|
|
Icon={FormatIcon2}
|
|
|
|
|
/>
|
|
|
|
|
<SelectIconButton
|
|
|
|
|
onClick={() =>
|
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: {
|
|
|
|
|
...listQuestions[quizId][totalIndex].content,
|
|
|
|
|
format: "masonry",
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
isActive={listQuestions[quizId][totalIndex].content.format === "masonry"}
|
|
|
|
|
Icon={FormatIcon1}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
<Typography sx={{ fontWeight: "500", fontSize: "18px", color: " #4D4D4D" }}>Настройки вопросов</Typography>
|
2023-09-07 14:14:48 +00:00
|
|
|
|
<CustomCheckbox
|
|
|
|
|
label={"Необязательный вопрос"}
|
|
|
|
|
checked={listQuestions[quizId][totalIndex].content.required}
|
|
|
|
|
handleChange={({ target }) =>
|
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: {
|
|
|
|
|
...listQuestions[quizId][totalIndex].content,
|
|
|
|
|
required: target.checked,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
2023-09-25 12:35:12 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: isMobile ? "90%" : "auto",
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-09-07 14:14:48 +00:00
|
|
|
|
<CustomCheckbox
|
|
|
|
|
label={"Внутреннее название вопроса"}
|
|
|
|
|
checked={listQuestions[quizId][totalIndex].content.innerNameCheck}
|
|
|
|
|
handleChange={({ target }) =>
|
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: {
|
|
|
|
|
...listQuestions[quizId][totalIndex].content,
|
|
|
|
|
innerNameCheck: target.checked,
|
|
|
|
|
innerName: "",
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
<Tooltip title="Будет отображаться как заголовок вопроса в приходящих заявках." placement="top">
|
2023-09-18 12:34:41 +00:00
|
|
|
|
<Box>
|
|
|
|
|
<InfoIcon />
|
|
|
|
|
</Box>
|
|
|
|
|
</Tooltip>
|
2023-09-07 14:14:48 +00:00
|
|
|
|
</Box>
|
|
|
|
|
{listQuestions[quizId][totalIndex].content.innerNameCheck && (
|
|
|
|
|
<CustomTextField
|
|
|
|
|
placeholder={"Внутреннее описание вопроса"}
|
|
|
|
|
text={listQuestions[quizId][totalIndex].content.innerName}
|
2023-09-20 09:07:33 +00:00
|
|
|
|
onChange={({ target }) => debounced(target.value)}
|
2023-09-07 14:14:48 +00:00
|
|
|
|
/>
|
|
|
|
|
)}
|
2023-04-15 09:10:59 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|