2024-06-19 20:22:37 +00:00
|
|
|
|
import type { QuizQuestionImages, QuizQuestionVariant } from "@frontend/squzanswerer";
|
2024-05-29 16:41:41 +00:00
|
|
|
|
import { Box, Button, Typography, useMediaQuery, useTheme } from "@mui/material";
|
2024-02-26 15:56:07 +00:00
|
|
|
|
import { updateQuestion } from "@root/questions/actions";
|
2023-03-30 18:39:59 +00:00
|
|
|
|
import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
2024-02-29 11:23:52 +00:00
|
|
|
|
import { memo } from "react";
|
2024-11-24 13:53:15 +00:00
|
|
|
|
import FormatIcon1 from "@/assets/icons/questionsPage/FormatIcon1";
|
|
|
|
|
import FormatIcon2 from "@/assets/icons/questionsPage/FormatIcon2";
|
|
|
|
|
import ProportionsIcon11 from "@/assets/icons/questionsPage/ProportionsIcon11";
|
|
|
|
|
import ProportionsIcon12 from "@/assets/icons/questionsPage/ProportionsIcon12";
|
|
|
|
|
import ProportionsIcon21 from "@/assets/icons/questionsPage/ProportionsIcon21";
|
|
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
|
|
|
|
import { useAddAnswer } from "@/utils/hooks/useAddAnswer";
|
2023-10-03 14:03:57 +00:00
|
|
|
|
|
2024-06-21 21:43:00 +00:00
|
|
|
|
type Proportion = "1:1" | "1:2" | "2:1";
|
2023-10-04 11:35:02 +00:00
|
|
|
|
|
|
|
|
|
type ProportionItem = {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
value: Proportion;
|
|
|
|
|
icon: (props: { color: string }) => JSX.Element;
|
2023-10-04 11:35:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const PROPORTIONS: ProportionItem[] = [
|
2023-12-31 02:53:25 +00:00
|
|
|
|
{ value: "1:1", icon: ProportionsIcon11 },
|
2024-06-21 21:43:00 +00:00
|
|
|
|
{ value: "1:2", icon: ProportionsIcon21 },
|
|
|
|
|
{ value: "2:1", icon: ProportionsIcon12 },
|
2023-08-28 09:31:34 +00:00
|
|
|
|
];
|
|
|
|
|
|
2024-05-29 16:41:41 +00:00
|
|
|
|
type Format = "carousel" | "masonry";
|
|
|
|
|
|
|
|
|
|
type FormatItem = {
|
|
|
|
|
value: Format;
|
|
|
|
|
icon: (props: { color: string }) => JSX.Element;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const FORMATS: FormatItem[] = [
|
2024-06-21 21:43:00 +00:00
|
|
|
|
{ value: "carousel", icon: FormatIcon2 },
|
|
|
|
|
{ value: "masonry", icon: FormatIcon1 },
|
2024-05-29 16:41:41 +00:00
|
|
|
|
];
|
|
|
|
|
|
2024-11-24 13:53:15 +00:00
|
|
|
|
type SettingOptionsPictProps = {
|
|
|
|
|
question: QuizQuestionVariant;
|
2024-02-29 11:23:52 +00:00
|
|
|
|
questionId: string;
|
|
|
|
|
isRequired: boolean;
|
2024-05-29 16:41:41 +00:00
|
|
|
|
isMulti: boolean;
|
|
|
|
|
isOwn: boolean;
|
|
|
|
|
proportions: Proportion;
|
|
|
|
|
format: Format;
|
2024-11-24 13:53:15 +00:00
|
|
|
|
ownPlaceholder?: boolean;
|
|
|
|
|
isLargeCheck?: boolean;
|
2023-11-16 16:41:25 +00:00
|
|
|
|
};
|
2023-03-30 18:39:59 +00:00
|
|
|
|
|
2024-11-24 13:53:15 +00:00
|
|
|
|
const SettingOptionsPict = memo<SettingOptionsPictProps>(function ({
|
|
|
|
|
question,
|
2024-02-29 11:23:52 +00:00
|
|
|
|
questionId,
|
|
|
|
|
isRequired,
|
2024-11-24 13:53:15 +00:00
|
|
|
|
ownPlaceholder, isMulti, isLargeCheck,
|
2024-05-29 16:41:41 +00:00
|
|
|
|
isOwn,
|
|
|
|
|
proportions,
|
|
|
|
|
format,
|
2024-02-29 11:23:52 +00:00
|
|
|
|
}) {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isTablet = useMediaQuery(theme.breakpoints.down(985));
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
|
|
|
|
const isFigmaTablte = useMediaQuery(theme.breakpoints.down(990));
|
2024-11-24 13:53:15 +00:00
|
|
|
|
|
|
|
|
|
const setOwnPlaceholder = (replText: string) => {
|
|
|
|
|
updateQuestion(questionId, (question) => {
|
|
|
|
|
if (question.type !== "varimg") return;
|
|
|
|
|
|
|
|
|
|
question.content.ownPlaceholder = replText;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
const {switchOwn} = useAddAnswer();
|
2023-09-25 13:43:15 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
return (
|
2024-02-29 11:23:52 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
flexDirection: isTablet ? "column" : null,
|
|
|
|
|
marginRight: isFigmaTablte ? (isMobile ? "0" : "0px") : "30px",
|
2024-05-29 16:41:41 +00:00
|
|
|
|
pb: "20px",
|
|
|
|
|
pl: "20px",
|
|
|
|
|
pt: isTablet ? "5px" : "0px",
|
2024-02-29 11:23:52 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-11-24 13:53:15 +00:00
|
|
|
|
<Box sx={{ display: "flex", flexDirection: "column", width: "100%" }}>
|
|
|
|
|
{/* <Box
|
2024-05-29 16:41:41 +00:00
|
|
|
|
sx={{
|
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
pt: "20px",
|
|
|
|
|
pr: isFigmaTablte ? "19px" : "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "14px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
}}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
>
|
2024-05-29 16:41:41 +00:00
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
height: isMobile ? "18px" : "auto",
|
|
|
|
|
fontWeight: "500",
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
color: " #4D4D4D",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Пропорции
|
|
|
|
|
</Typography>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
gap: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{PROPORTIONS.map((proportionItem, index) => (
|
|
|
|
|
<SelectIconButton
|
|
|
|
|
key={index}
|
|
|
|
|
Icon={proportionItem.icon}
|
|
|
|
|
isActive={proportionItem.value === proportions}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
updateQuestion<QuizQuestionImages>(questionId, (question) => {
|
|
|
|
|
if (question.type !== "images") return;
|
|
|
|
|
question.content.xy = proportionItem.value;
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
2024-11-24 13:53:15 +00:00
|
|
|
|
</Box> */}
|
2024-05-29 16:41:41 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
pt: "20px",
|
|
|
|
|
pr: isFigmaTablte ? "19px" : "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "14px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
height: isMobile ? "18px" : "auto",
|
|
|
|
|
fontWeight: "500",
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
color: " #4D4D4D",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Настройки ответов
|
|
|
|
|
</Typography>
|
2024-11-24 13:53:15 +00:00
|
|
|
|
{/* <CustomCheckbox
|
|
|
|
|
dataCy="checkbox-long-text-answer"
|
|
|
|
|
sx={{ mr: isMobile ? "0px" : "16px" }}
|
|
|
|
|
label={"Многострочный ответ"}
|
|
|
|
|
checked={isLargeCheck}
|
|
|
|
|
handleChange={({ target }) => {
|
|
|
|
|
updateQuestion<QuizQuestionVariant>(questionId, (question) => {
|
|
|
|
|
question.content.largeCheck = target.checked;
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/> */}
|
2024-05-29 16:41:41 +00:00
|
|
|
|
<CustomCheckbox
|
|
|
|
|
dataCy="checkbox-multiple-answers"
|
|
|
|
|
sx={{ mr: isMobile ? "0px" : "16px" }}
|
|
|
|
|
label={"Можно несколько"}
|
|
|
|
|
checked={isMulti}
|
|
|
|
|
handleChange={({ target }) => {
|
|
|
|
|
updateQuestion<QuizQuestionVariant>(questionId, (question) => {
|
|
|
|
|
question.content.multi = target.checked;
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<CustomCheckbox
|
|
|
|
|
dataCy="checkbox-own-answer"
|
|
|
|
|
sx={{ mr: isMobile ? "0px" : "16px" }}
|
|
|
|
|
label={'Вариант "свой ответ"'}
|
|
|
|
|
checked={isOwn}
|
|
|
|
|
handleChange={({ target }) => {
|
2024-11-24 13:53:15 +00:00
|
|
|
|
switchOwn({question, checked:target.checked})
|
2024-05-29 16:41:41 +00:00
|
|
|
|
}}
|
|
|
|
|
/>
|
2024-11-24 13:53:15 +00:00
|
|
|
|
{/* <Box sx={{ mt: isMobile ? "11px" : "6px", width: "100%" }}>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
height: isMobile ? "18px" : "auto",
|
|
|
|
|
fontWeight: "500",
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
color: " #4D4D4D",
|
|
|
|
|
mb: "14px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Подсказка "своего ответа"
|
|
|
|
|
</Typography>
|
|
|
|
|
<CustomTextField
|
|
|
|
|
sx={{
|
|
|
|
|
maxWidth: "330px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
mr: isMobile ? "0px" : "16px",
|
|
|
|
|
}}
|
|
|
|
|
maxLength={60}
|
|
|
|
|
placeholder={"мой ответ: три"}
|
|
|
|
|
value={ownPlaceholder}
|
|
|
|
|
onChange={({ target }) => setOwnPlaceholder(target.value)}
|
|
|
|
|
/>
|
|
|
|
|
</Box> */}
|
2024-05-29 16:41:41 +00:00
|
|
|
|
</Box>
|
2024-11-24 13:53:15 +00:00
|
|
|
|
</Box>
|
2024-05-29 16:41:41 +00:00
|
|
|
|
<Box sx={{ display: "flex", flexDirection: "column", width: "100%" }}>
|
2024-07-07 17:12:27 +00:00
|
|
|
|
{/* <Box
|
2024-05-29 16:41:41 +00:00
|
|
|
|
sx={{
|
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
pt: "20px",
|
|
|
|
|
pr: isFigmaTablte ? "19px" : "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "14px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
height: isMobile ? "18px" : "auto",
|
|
|
|
|
fontWeight: "500",
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
color: " #4D4D4D",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Формат
|
|
|
|
|
</Typography>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
gap: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{FORMATS.map((formatItem, index) => (
|
|
|
|
|
<SelectIconButton
|
|
|
|
|
key={index}
|
|
|
|
|
Icon={formatItem.icon}
|
|
|
|
|
isActive={formatItem.value === format}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
updateQuestion<QuizQuestionImages>(questionId, (question) => {
|
|
|
|
|
if (question.type !== "images") return;
|
|
|
|
|
question.content.format = formatItem.value;
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
2024-07-07 17:12:27 +00:00
|
|
|
|
</Box> */}
|
2024-05-29 16:41:41 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
pt: "20px",
|
|
|
|
|
pr: isFigmaTablte ? (isMobile ? "20px" : "0px") : "28px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "14px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography sx={{ fontWeight: "500", fontSize: "18px", color: " #4D4D4D" }}>Настройки вопросов</Typography>
|
|
|
|
|
<CustomCheckbox
|
|
|
|
|
dataCy="checkbox-optional-question"
|
|
|
|
|
sx={{ alignItems: isMobile ? "flex-start" : "" }}
|
|
|
|
|
label={"Необязательный вопрос"}
|
|
|
|
|
checked={!isRequired}
|
|
|
|
|
handleChange={({ target }) =>
|
|
|
|
|
updateQuestion<QuizQuestionImages>(questionId, (question) => {
|
|
|
|
|
if (question.type !== "images") return;
|
|
|
|
|
|
|
|
|
|
question.content.required = !target.checked;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
2023-12-31 02:53:25 +00:00
|
|
|
|
</Box>
|
2024-02-29 11:23:52 +00:00
|
|
|
|
</Box>
|
2023-12-31 02:53:25 +00:00
|
|
|
|
);
|
2024-02-29 11:23:52 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
SettingOptionsPict.displayName = "SettingOptionsPict";
|
|
|
|
|
|
|
|
|
|
export default SettingOptionsPict;
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
|
|
|
|
interface Props {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
Icon: (props: { color: string }) => JSX.Element;
|
|
|
|
|
isActive?: boolean;
|
|
|
|
|
onClick: () => void;
|
2023-11-16 16:41:25 +00:00
|
|
|
|
}
|
2023-09-15 12:37:12 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
export function SelectIconButton({ Icon, isActive = false, onClick }: Props) {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
const theme = useTheme();
|
2023-08-28 09:31:34 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
variant="outlined"
|
2024-05-29 16:41:41 +00:00
|
|
|
|
startIcon={<Icon color={isActive ? theme.palette.navbarbg.main : theme.palette.brightPurple.main} />}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
sx={{
|
|
|
|
|
backgroundColor: isActive ? theme.palette.brightPurple.main : "#eee4fc",
|
|
|
|
|
|
|
|
|
|
borderRadius: 0,
|
|
|
|
|
border: "none",
|
2024-05-29 16:41:41 +00:00
|
|
|
|
color: isActive ? theme.palette.brightPurple.main : theme.palette.grey2.main,
|
2023-12-31 02:53:25 +00:00
|
|
|
|
p: "7px",
|
|
|
|
|
width: "40px",
|
|
|
|
|
height: "40px",
|
|
|
|
|
minWidth: 0,
|
|
|
|
|
"& .MuiButton-startIcon": {
|
|
|
|
|
mr: 0,
|
|
|
|
|
ml: 0,
|
|
|
|
|
},
|
|
|
|
|
"&:hover": {
|
|
|
|
|
border: "none",
|
2024-05-29 16:41:41 +00:00
|
|
|
|
borderColor: isActive ? theme.palette.brightPurple.main : theme.palette.grey2.main,
|
2023-12-31 02:53:25 +00:00
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2023-04-15 09:10:59 +00:00
|
|
|
|
}
|