2023-09-18 12:34:41 +00:00
|
|
|
|
import {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
Box,
|
|
|
|
|
Button,
|
|
|
|
|
Tooltip,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
2023-09-18 12:34:41 +00:00
|
|
|
|
} from "@mui/material";
|
2023-11-27 23:07:24 +00:00
|
|
|
|
import { setQuestionInnerName, updateQuestion } from "@root/questions/actions";
|
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-05-03 19:21:00 +00:00
|
|
|
|
import InfoIcon from "../../../assets/icons/InfoIcon";
|
|
|
|
|
import FormatIcon1 from "../../../assets/icons/questionsPage/FormatIcon1";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
import FormatIcon2 from "../../../assets/icons/questionsPage/FormatIcon2";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import ProportionsIcon11 from "../../../assets/icons/questionsPage/ProportionsIcon11";
|
|
|
|
|
import ProportionsIcon12 from "../../../assets/icons/questionsPage/ProportionsIcon12";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
import ProportionsIcon21 from "../../../assets/icons/questionsPage/ProportionsIcon21";
|
2023-10-03 14:03:57 +00:00
|
|
|
|
import type { QuizQuestionImages } from "../../../model/questionTypes/images";
|
|
|
|
|
|
2023-08-28 09:31:34 +00:00
|
|
|
|
|
2023-10-04 11:35:02 +00:00
|
|
|
|
type Proportion = "1:1" | "2:1" | "1:2";
|
|
|
|
|
|
|
|
|
|
type ProportionItem = {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
value: Proportion;
|
|
|
|
|
icon: (props: { color: string; }) => JSX.Element;
|
2023-10-04 11:35:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const PROPORTIONS: ProportionItem[] = [
|
2023-11-16 16:41:25 +00:00
|
|
|
|
{ value: "1:1", icon: ProportionsIcon11 },
|
|
|
|
|
{ value: "2:1", icon: ProportionsIcon21 },
|
|
|
|
|
{ value: "1:2", icon: ProportionsIcon12 },
|
2023-08-28 09:31:34 +00:00
|
|
|
|
];
|
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
type SettingOpytionsPictProps = {
|
|
|
|
|
question: QuizQuestionImages;
|
|
|
|
|
};
|
2023-03-30 18:39:59 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
export default function SettingOpytionsPict({ question }: SettingOpytionsPictProps) {
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isTablet = useMediaQuery(theme.breakpoints.down(985));
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
|
|
|
|
const isFigmaTablte = useMediaQuery(theme.breakpoints.down(990));
|
2023-09-25 13:43:15 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
const debounced = useDebouncedCallback((value) => {
|
|
|
|
|
setQuestionInnerName(question.id, value);
|
2023-11-27 23:07:24 +00:00
|
|
|
|
}, 200);
|
2023-03-30 18:39:59 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
const updateProportions = (proportions: Proportion) => {
|
2023-11-27 23:07:24 +00:00
|
|
|
|
updateQuestion(question.id, question => {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
if (question.type !== "images") return;
|
2023-08-28 09:31:34 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
question.content.xy = proportions;
|
|
|
|
|
});
|
|
|
|
|
};
|
2023-03-30 18:39:59 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
<Box
|
2023-11-16 16:41:25 +00:00
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
flexDirection: isTablet ? "column" : null,
|
|
|
|
|
marginRight: isFigmaTablte ? (isMobile ? "0" : "0px") : "30px",
|
|
|
|
|
}}
|
2023-09-25 13:43:15 +00:00
|
|
|
|
>
|
2023-12-14 10:37:45 +00:00
|
|
|
|
{/* <Box
|
2023-11-16 16:41:25 +00:00
|
|
|
|
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={question.content.xy === value}
|
|
|
|
|
Icon={icon}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{ fontWeight: "500", fontSize: "18px", color: " #4D4D4D" }}
|
|
|
|
|
>
|
|
|
|
|
Настройки ответов
|
|
|
|
|
</Typography>
|
|
|
|
|
|
|
|
|
|
<CustomCheckbox
|
|
|
|
|
sx={{ display: "block", mr: isMobile ? "0px" : "16px" }}
|
|
|
|
|
label={"Можно несколько"}
|
|
|
|
|
checked={question.content.multi}
|
|
|
|
|
dataCy="multiple-answers-checkbox"
|
2023-11-27 23:07:24 +00:00
|
|
|
|
handleChange={({ target }) => updateQuestion(question.id, question => {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
if (question.type !== "images") return;
|
|
|
|
|
|
|
|
|
|
question.content.multi = target.checked;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
{question.content.xy !== "1:1" &&
|
|
|
|
|
question.content.format !== "masonry" && (
|
|
|
|
|
<CustomCheckbox
|
|
|
|
|
sx={{ display: "block", mr: isMobile ? "0px" : "16px" }}
|
|
|
|
|
label={"Большие картинки"}
|
|
|
|
|
checked={question.content.largeCheck}
|
|
|
|
|
handleChange={({ target }) =>
|
2023-11-27 23:07:24 +00:00
|
|
|
|
updateQuestion(question.id, question => {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
if (question.type !== "images") return;
|
|
|
|
|
|
|
|
|
|
question.content.largeCheck = target.checked;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
<CustomCheckbox
|
|
|
|
|
sx={{ display: "block", mr: isMobile ? "0px" : "16px" }}
|
|
|
|
|
label={'Вариант "свой ответ"'}
|
|
|
|
|
checked={question.content.own}
|
2023-11-27 23:07:24 +00:00
|
|
|
|
handleChange={({ target }) => updateQuestion(question.id, question => {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
if (question.type !== "images") return;
|
|
|
|
|
|
|
|
|
|
question.content.own = target.checked;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
2023-12-14 10:37:45 +00:00
|
|
|
|
</Box> */}
|
2023-11-16 16:41:25 +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%",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-12-14 10:37:45 +00:00
|
|
|
|
{/* <Box
|
2023-11-16 16:41:25 +00:00
|
|
|
|
sx={{
|
|
|
|
|
marginBottom: "5px",
|
|
|
|
|
opacity: question.content.xy !== "1:1" ? 1 : 0,
|
|
|
|
|
display: isTablet
|
|
|
|
|
? question.content.xy === "1:1"
|
|
|
|
|
? "none"
|
|
|
|
|
: "block"
|
|
|
|
|
: "block",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
marginBottom: "15px",
|
|
|
|
|
fontWeight: "500",
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
color: " #4D4D4D",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Формат
|
|
|
|
|
</Typography>
|
|
|
|
|
<SelectIconButton
|
2023-11-27 23:07:24 +00:00
|
|
|
|
onClick={() => updateQuestion(question.id, question => {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
if (question.type !== "images") return;
|
|
|
|
|
|
|
|
|
|
question.content.format = "carousel";
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
isActive={question.content.format === "carousel"}
|
|
|
|
|
Icon={FormatIcon2}
|
|
|
|
|
/>
|
|
|
|
|
<SelectIconButton
|
2023-11-27 23:07:24 +00:00
|
|
|
|
onClick={() => updateQuestion(question.id, question => {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
if (question.type !== "images") return;
|
|
|
|
|
|
|
|
|
|
question.content.format = "masonry";
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
isActive={question.content.format === "masonry"}
|
|
|
|
|
Icon={FormatIcon1}
|
|
|
|
|
/>
|
2023-12-14 10:37:45 +00:00
|
|
|
|
</Box> */}
|
2023-11-16 16:41:25 +00:00
|
|
|
|
<Typography
|
|
|
|
|
sx={{ fontWeight: "500", fontSize: "18px", color: " #4D4D4D" }}
|
|
|
|
|
>
|
|
|
|
|
Настройки вопросов
|
|
|
|
|
</Typography>
|
|
|
|
|
<CustomCheckbox
|
|
|
|
|
sx={{ alignItems: isMobile ? "flex-start" : "" }}
|
|
|
|
|
label={"Необязательный вопрос"}
|
2023-12-13 18:19:12 +00:00
|
|
|
|
checked={!question.content.required}
|
|
|
|
|
handleChange={({ target }) => updateQuestion<QuizQuestionImages>(question.id, question => {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
if (question.type !== "images") return;
|
|
|
|
|
|
2023-12-13 18:19:12 +00:00
|
|
|
|
question.content.required = !target.checked;
|
2023-11-16 16:41:25 +00:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: isMobile ? "90%" : "auto",
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<CustomCheckbox
|
|
|
|
|
sx={{
|
|
|
|
|
height: isMobile ? "100%" : "26px",
|
|
|
|
|
alignItems: isMobile ? "flex-start" : "center",
|
|
|
|
|
}}
|
|
|
|
|
label={"Внутреннее название вопроса"}
|
|
|
|
|
checked={question.content.innerNameCheck}
|
2023-11-27 23:07:24 +00:00
|
|
|
|
handleChange={({ target }) => updateQuestion(question.id, question => {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
if (question.type !== "images") return;
|
|
|
|
|
|
|
|
|
|
question.content.innerNameCheck = target.checked;
|
|
|
|
|
question.content.innerName = "";
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<Tooltip
|
|
|
|
|
title="Будет отображаться как заголовок вопроса в приходящих заявках."
|
|
|
|
|
placement="top"
|
|
|
|
|
>
|
|
|
|
|
<Box>
|
|
|
|
|
<InfoIcon />
|
|
|
|
|
</Box>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</Box>
|
|
|
|
|
{question.content.innerNameCheck && (
|
|
|
|
|
<CustomTextField
|
|
|
|
|
placeholder={"Внутреннее описание вопроса"}
|
|
|
|
|
text={question.content.innerName}
|
|
|
|
|
onChange={({ target }) => debounced(target.value)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
2023-09-25 13:43:15 +00:00
|
|
|
|
</Box>
|
2023-11-16 16:41:25 +00:00
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
Icon: (props: { color: string; }) => JSX.Element;
|
|
|
|
|
// Icon: React.ElementType;
|
|
|
|
|
isActive?: boolean;
|
|
|
|
|
onClick: () => void;
|
|
|
|
|
}
|
2023-09-15 12:37:12 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
export function SelectIconButton({ Icon, isActive = false, onClick }: Props) {
|
|
|
|
|
const theme = useTheme();
|
2023-08-28 09:31:34 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
variant="outlined"
|
|
|
|
|
startIcon={
|
|
|
|
|
<Icon
|
|
|
|
|
color={
|
|
|
|
|
isActive
|
|
|
|
|
? theme.palette.navbarbg.main
|
|
|
|
|
: theme.palette.brightPurple.main
|
|
|
|
|
}
|
|
|
|
|
/>
|
2023-09-07 14:14:48 +00:00
|
|
|
|
}
|
2023-10-03 14:03:57 +00:00
|
|
|
|
sx={{
|
2023-11-16 16:41:25 +00:00
|
|
|
|
backgroundColor: isActive ? theme.palette.brightPurple.main : "#eee4fc",
|
|
|
|
|
|
|
|
|
|
borderRadius: 0,
|
|
|
|
|
border: "none",
|
|
|
|
|
color: isActive
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: theme.palette.grey2.main,
|
|
|
|
|
p: "7px",
|
|
|
|
|
width: "40px",
|
|
|
|
|
height: "40px",
|
|
|
|
|
minWidth: 0,
|
|
|
|
|
"& .MuiButton-startIcon": {
|
|
|
|
|
mr: 0,
|
|
|
|
|
ml: 0,
|
|
|
|
|
},
|
|
|
|
|
"&:hover": {
|
|
|
|
|
border: "none",
|
|
|
|
|
borderColor: isActive
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: theme.palette.grey2.main,
|
|
|
|
|
},
|
2023-10-03 14:03:57 +00:00
|
|
|
|
}}
|
2023-11-16 16:41:25 +00:00
|
|
|
|
/>
|
|
|
|
|
);
|
2023-04-15 09:10:59 +00:00
|
|
|
|
}
|