2023-12-07 22:56:31 +00:00
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
|
|
|
|
|
import { updateQuiz } from "@root/quizes/actions"
|
|
|
|
|
import { useCurrentQuiz } from "@root/quizes/hooks"
|
|
|
|
|
|
|
|
|
|
import { SwitchSetting } from "../SwichResult";
|
|
|
|
|
|
2023-12-30 21:54:59 +00:00
|
|
|
|
import Info from "@icons/Info";
|
2023-12-07 22:56:31 +00:00
|
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
IconButton,
|
|
|
|
|
Paper,
|
|
|
|
|
Button,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
2023-12-30 21:54:59 +00:00
|
|
|
|
Popover,
|
2023-12-07 22:56:31 +00:00
|
|
|
|
} from "@mui/material";
|
|
|
|
|
|
|
|
|
|
import ExpandLessIconBG from "@icons/ExpandLessIconBG";
|
|
|
|
|
import ExpandLessIcon from "@mui/icons-material/ExpandLess";
|
|
|
|
|
import ShareNetwork from "@icons/ShareNetwork.svg";
|
|
|
|
|
import ArrowCounterClockWise from "@icons/ArrowCounterClockWise.svg";
|
|
|
|
|
|
|
|
|
|
const whenValues = [
|
|
|
|
|
{
|
|
|
|
|
title: "До формы контактов",
|
|
|
|
|
value: "before",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "После формы контактов",
|
|
|
|
|
value: "after",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "Отправить на E-mail",
|
|
|
|
|
value: "email",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
quizExpand: boolean
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-30 21:54:59 +00:00
|
|
|
|
const InfoView = () => {
|
|
|
|
|
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(
|
|
|
|
|
null
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
|
|
|
setAnchorEl(event.currentTarget);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleClose = () => {
|
|
|
|
|
setAnchorEl(null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const open = Boolean(anchorEl);
|
|
|
|
|
const id = open ? "simple-popover" : undefined;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Info
|
|
|
|
|
sx={{
|
|
|
|
|
"MuiIconButton-root": {
|
|
|
|
|
boxShadow: "0 0 10px 10px red",
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
onClick={handleClick}
|
|
|
|
|
/>
|
|
|
|
|
<Popover
|
|
|
|
|
id={id}
|
|
|
|
|
open={open}
|
|
|
|
|
anchorEl={anchorEl}
|
|
|
|
|
onClose={handleClose}
|
|
|
|
|
anchorOrigin={{
|
|
|
|
|
vertical: "bottom",
|
|
|
|
|
horizontal: "left",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Paper
|
|
|
|
|
sx={{
|
|
|
|
|
p: "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography>
|
|
|
|
|
Oтправка письма с результатом респонденту после отображения на экране
|
|
|
|
|
</Typography>
|
|
|
|
|
</Paper>
|
|
|
|
|
</Popover>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-07 22:56:31 +00:00
|
|
|
|
export const WhenCard = ({ quizExpand }: Props) => {
|
|
|
|
|
const quiz = useCurrentQuiz()
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
|
|
|
|
const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1100));
|
|
|
|
|
|
|
|
|
|
const [expand, setExpand] = useState(true)
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setExpand(false)
|
|
|
|
|
}, [quizExpand])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Paper
|
|
|
|
|
data-cy="quiz-question-card"
|
|
|
|
|
sx={{
|
|
|
|
|
maxWidth: "796px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
borderRadius: "12px",
|
|
|
|
|
backgroundColor: expand ? "white" : "#EEE4FC",
|
|
|
|
|
border: expand ? "none" : "1px solid #9A9AAF",
|
|
|
|
|
boxShadow: "0px 10px 30px #e7e7e7",
|
|
|
|
|
m: "20px 0"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
padding: isMobile ? "10px" : "20px",
|
|
|
|
|
flexDirection: isMobile ? "column" : null,
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
minHeight: "40px",
|
|
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
margin: isMobile ? "10px 0" : 0,
|
|
|
|
|
color: expand ? "#9A9AAF" : "#000000",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Показывать результат
|
|
|
|
|
</Typography>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "flex-end",
|
|
|
|
|
width: isMobile ? "100%" : "auto",
|
|
|
|
|
position: "relative",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<IconButton
|
|
|
|
|
sx={{ padding: "0", margin: "5px" }}
|
|
|
|
|
disableRipple
|
|
|
|
|
data-cy="expand-question"
|
|
|
|
|
onClick={() => setExpand(!expand)}
|
|
|
|
|
>
|
|
|
|
|
{expand ? (
|
|
|
|
|
<ExpandLessIconBG />
|
|
|
|
|
) : (
|
|
|
|
|
<ExpandLessIcon
|
|
|
|
|
sx={{
|
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
fill: theme.palette.brightPurple.main,
|
|
|
|
|
background: "#FFF",
|
|
|
|
|
borderRadius: "6px",
|
|
|
|
|
height: "30px",
|
|
|
|
|
width: "30px",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
{expand && (
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
p: "33px 20px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: isSmallMonitor ? "column" : "row",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
gap: "20px",
|
|
|
|
|
mb: "20px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{whenValues.map(({ title, value }, index) => (
|
2023-12-30 21:54:59 +00:00
|
|
|
|
<Box display="flex">
|
2023-12-07 22:56:31 +00:00
|
|
|
|
<Button
|
|
|
|
|
onClick={() => updateQuiz(quiz.id, (quiz) => quiz.config.resultInfo.when = value)}
|
|
|
|
|
key={title}
|
|
|
|
|
sx={{
|
|
|
|
|
bgcolor: quiz?.config.resultInfo.when === value ? " #7E2AEA" : "#F2F3F7",
|
|
|
|
|
color: quiz?.config.resultInfo.when === value ? " white" : "#9A9AAF",
|
2023-12-30 21:54:59 +00:00
|
|
|
|
minWidth: isSmallMonitor ? "310px" : "auto",
|
2023-12-07 22:56:31 +00:00
|
|
|
|
borderRadius: "8px",
|
2023-12-30 21:54:59 +00:00
|
|
|
|
width: "220px",
|
2023-12-07 22:56:31 +00:00
|
|
|
|
height: "44px",
|
2023-12-30 21:54:59 +00:00
|
|
|
|
fontSize: "17px",
|
2023-12-07 22:56:31 +00:00
|
|
|
|
border: quiz?.config.resultInfo.when === value ? "none" : "1px solid #9A9AAF",
|
|
|
|
|
"&:hover": {
|
|
|
|
|
backgroundColor: quiz?.config.resultInfo.when === value ? "#581CA7" : "#7E2AEA",
|
|
|
|
|
color: "white"
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</Button>
|
2023-12-30 21:54:59 +00:00
|
|
|
|
{value === "email" && <InfoView/>}
|
|
|
|
|
</Box>
|
2023-12-07 22:56:31 +00:00
|
|
|
|
))}
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
|
2023-12-16 20:17:42 +00:00
|
|
|
|
{/* {
|
2023-12-07 22:56:31 +00:00
|
|
|
|
(quiz?.config.resultInfo.when !== "email") && <SwitchSetting
|
|
|
|
|
icon={ShareNetwork}
|
|
|
|
|
text="Поделиться результатами"
|
|
|
|
|
onClick={(event) => updateQuiz(quiz.id, (quiz) => quiz.config.resultInfo.share = event.target.checked)}
|
|
|
|
|
value={quiz?.config.resultInfo.share}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
quiz?.config.resultInfo.when === "before" && <SwitchSetting
|
|
|
|
|
icon={ArrowCounterClockWise}
|
|
|
|
|
text="Кнопка `Пройти тест заново`"
|
|
|
|
|
onClick={(event) => updateQuiz(quiz.id, (quiz) => quiz.config.resultInfo.replay = event.target.checked)}
|
|
|
|
|
value={quiz?.config.resultInfo.replay}
|
|
|
|
|
/>
|
2023-12-16 20:17:42 +00:00
|
|
|
|
} */}
|
2023-12-07 22:56:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</Box>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Paper>
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
}
|