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";
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
IconButton,
|
|
|
|
|
Paper,
|
|
|
|
|
Button,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
|
|
|
|
} 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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) => (
|
|
|
|
|
<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",
|
|
|
|
|
minWidth: isSmallMonitor ? "300px" : "auto",
|
|
|
|
|
borderRadius: "8px",
|
|
|
|
|
width: "237px",
|
|
|
|
|
height: "44px",
|
|
|
|
|
border: quiz?.config.resultInfo.when === value ? "none" : "1px solid #9A9AAF",
|
|
|
|
|
"&:hover": {
|
|
|
|
|
backgroundColor: quiz?.config.resultInfo.when === value ? "#581CA7" : "#7E2AEA",
|
|
|
|
|
color: "white"
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{title}
|
|
|
|
|
</Button>
|
|
|
|
|
))}
|
|
|
|
|
</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>
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
}
|