2023-12-07 22:56:31 +00:00
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
import { updateQuiz } from "@root/quizes/actions";
|
|
|
|
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
2023-12-07 22:56:31 +00:00
|
|
|
|
|
|
|
|
|
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 {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
Box,
|
|
|
|
|
IconButton,
|
|
|
|
|
Paper,
|
|
|
|
|
Button,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
|
|
|
|
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";
|
|
|
|
|
|
2024-01-10 16:53:37 +00:00
|
|
|
|
type WhenVariants = {
|
|
|
|
|
title: string;
|
|
|
|
|
value: "before" | "after";
|
2024-01-18 15:18:32 +00:00
|
|
|
|
id: string;
|
2024-01-10 16:53:37 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const whenValues: WhenVariants[] = [
|
2023-12-31 02:53:25 +00:00
|
|
|
|
{
|
|
|
|
|
title: "До формы контактов",
|
|
|
|
|
value: "before",
|
2024-01-18 15:18:32 +00:00
|
|
|
|
id: "before-contact-form",
|
2023-12-31 02:53:25 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "После формы контактов",
|
|
|
|
|
value: "after",
|
2024-01-18 15:18:32 +00:00
|
|
|
|
id: "after-the-contact-form",
|
2023-12-31 02:53:25 +00:00
|
|
|
|
},
|
2023-12-07 22:56:31 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
interface Props {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
quizExpand: boolean;
|
2023-12-07 22:56:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-30 21:54:59 +00:00
|
|
|
|
const InfoView = () => {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
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
|
2023-12-30 21:54:59 +00:00
|
|
|
|
sx={{
|
2023-12-31 02:53:25 +00:00
|
|
|
|
p: "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
flexDirection: "column",
|
2023-12-30 21:54:59 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-12-31 02:53:25 +00:00
|
|
|
|
<Typography>
|
|
|
|
|
Oтправка письма с результатом респонденту после отображения на
|
|
|
|
|
экране
|
|
|
|
|
</Typography>
|
|
|
|
|
</Paper>
|
|
|
|
|
</Popover>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
2023-12-30 21:54:59 +00:00
|
|
|
|
|
2023-12-07 22:56:31 +00:00
|
|
|
|
export const WhenCard = ({ quizExpand }: Props) => {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
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(() => {
|
2024-03-03 23:19:28 +00:00
|
|
|
|
setExpand(true);
|
2023-12-31 02:53:25 +00:00
|
|
|
|
}, [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",
|
2024-01-29 00:02:03 +00:00
|
|
|
|
padding: "20px",
|
2023-12-31 02:53:25 +00:00
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
minHeight: "40px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
margin: isMobile ? "10px 0" : 0,
|
|
|
|
|
color: expand ? "#9A9AAF" : "#000000",
|
|
|
|
|
}}
|
2023-12-07 22:56:31 +00:00
|
|
|
|
>
|
2023-12-31 02:53:25 +00:00
|
|
|
|
Показывать результат
|
|
|
|
|
</Typography>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "flex-end",
|
2024-01-29 00:02:03 +00:00
|
|
|
|
width: "auto",
|
2023-12-31 02:53:25 +00:00
|
|
|
|
position: "relative",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<IconButton
|
|
|
|
|
sx={{ padding: "0", margin: "5px" }}
|
|
|
|
|
disableRipple
|
|
|
|
|
data-cy="expand-question"
|
|
|
|
|
onClick={() => setExpand(!expand)}
|
|
|
|
|
>
|
|
|
|
|
{expand ? (
|
|
|
|
|
<ExpandLessIconBG />
|
|
|
|
|
) : (
|
|
|
|
|
<ExpandLessIcon
|
2023-12-07 22:56:31 +00:00
|
|
|
|
sx={{
|
2023-12-31 02:53:25 +00:00
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
fill: theme.palette.brightPurple.main,
|
|
|
|
|
background: "#FFF",
|
|
|
|
|
borderRadius: "6px",
|
|
|
|
|
height: "30px",
|
|
|
|
|
width: "30px",
|
2023-12-07 22:56:31 +00:00
|
|
|
|
}}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2024-01-10 16:53:37 +00:00
|
|
|
|
{expand && quiz && (
|
2023-12-31 02:53:25 +00:00
|
|
|
|
<>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
p: "33px 20px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: isSmallMonitor ? "column" : "row",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
gap: "20px",
|
|
|
|
|
mb: "20px",
|
|
|
|
|
}}
|
2023-12-07 22:56:31 +00:00
|
|
|
|
>
|
2024-01-18 15:18:32 +00:00
|
|
|
|
{whenValues.map(({ title, value, id }, index) => (
|
2023-12-31 02:53:25 +00:00
|
|
|
|
<Box display="flex">
|
|
|
|
|
<Button
|
2024-01-18 15:18:32 +00:00
|
|
|
|
id={id}
|
2024-01-10 16:53:37 +00:00
|
|
|
|
onClick={() => {
|
|
|
|
|
updateQuiz(quiz.id, (quiz) => {
|
|
|
|
|
quiz.config.resultInfo.showResultForm = value;
|
|
|
|
|
quiz.config;
|
|
|
|
|
});
|
|
|
|
|
}}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
key={title}
|
2023-12-07 22:56:31 +00:00
|
|
|
|
sx={{
|
2023-12-31 02:53:25 +00:00
|
|
|
|
bgcolor:
|
2024-01-10 16:53:37 +00:00
|
|
|
|
quiz?.config.resultInfo.showResultForm === value
|
2023-12-31 02:53:25 +00:00
|
|
|
|
? " #7E2AEA"
|
|
|
|
|
: "#F2F3F7",
|
|
|
|
|
color:
|
2024-01-10 16:53:37 +00:00
|
|
|
|
quiz?.config.resultInfo.showResultForm === value
|
2023-12-31 02:53:25 +00:00
|
|
|
|
? " white"
|
|
|
|
|
: "#9A9AAF",
|
2024-01-04 21:56:21 +00:00
|
|
|
|
minWidth: isSmallMonitor
|
|
|
|
|
? isMobile
|
|
|
|
|
? undefined
|
|
|
|
|
: "310px"
|
|
|
|
|
: "auto",
|
2023-12-31 02:53:25 +00:00
|
|
|
|
borderRadius: "8px",
|
2024-01-04 21:56:21 +00:00
|
|
|
|
width: isMobile ? "100%" : "220px",
|
2023-12-31 02:53:25 +00:00
|
|
|
|
height: "44px",
|
|
|
|
|
fontSize: "17px",
|
|
|
|
|
border:
|
2024-01-10 16:53:37 +00:00
|
|
|
|
quiz?.config.resultInfo.showResultForm === value
|
2023-12-31 02:53:25 +00:00
|
|
|
|
? "none"
|
|
|
|
|
: "1px solid #9A9AAF",
|
|
|
|
|
"&:hover": {
|
|
|
|
|
backgroundColor:
|
2024-01-10 16:53:37 +00:00
|
|
|
|
quiz?.config.resultInfo.showResultForm === value
|
2023-12-31 02:53:25 +00:00
|
|
|
|
? "#581CA7"
|
|
|
|
|
: "#7E2AEA",
|
|
|
|
|
color: "white",
|
|
|
|
|
},
|
2023-12-07 22:56:31 +00:00
|
|
|
|
}}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</Button>
|
2023-12-07 22:56:31 +00:00
|
|
|
|
</Box>
|
2023-12-31 02:53:25 +00:00
|
|
|
|
))}
|
2024-01-10 16:53:37 +00:00
|
|
|
|
<Box>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
updateQuiz(quiz.id, (quiz) => {
|
|
|
|
|
if (quiz.config.resultInfo.when) {
|
|
|
|
|
quiz.config.resultInfo.when = "";
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
quiz.config.resultInfo.when = "email";
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
updateQuiz(quiz?.id, (quiz) => {
|
|
|
|
|
quiz.config.formContact.fields["email"].used = true;
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
|
|
|
|
bgcolor:
|
|
|
|
|
quiz?.config.resultInfo.when === "email"
|
|
|
|
|
? " #7E2AEA"
|
|
|
|
|
: "#F2F3F7",
|
|
|
|
|
color:
|
|
|
|
|
quiz?.config.resultInfo.when === "email"
|
|
|
|
|
? " white"
|
|
|
|
|
: "#9A9AAF",
|
|
|
|
|
minWidth: isSmallMonitor
|
|
|
|
|
? isMobile
|
|
|
|
|
? undefined
|
|
|
|
|
: "310px"
|
|
|
|
|
: "auto",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
width: isMobile ? "100%" : "220px",
|
|
|
|
|
height: "44px",
|
|
|
|
|
fontSize: "17px",
|
|
|
|
|
border:
|
|
|
|
|
quiz?.config.resultInfo.when === "email"
|
|
|
|
|
? "none"
|
|
|
|
|
: "1px solid #9A9AAF",
|
|
|
|
|
"&:hover": {
|
|
|
|
|
backgroundColor:
|
|
|
|
|
quiz?.config.resultInfo.when === "email"
|
|
|
|
|
? "#581CA7"
|
|
|
|
|
: "#7E2AEA",
|
|
|
|
|
color: "white",
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Отправить на E-mail
|
|
|
|
|
</Button>
|
|
|
|
|
<InfoView />
|
|
|
|
|
</Box>
|
2023-12-07 22:56:31 +00:00
|
|
|
|
</Box>
|
2023-12-31 02:53:25 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</Paper>
|
|
|
|
|
);
|
|
|
|
|
};
|