frontPanel/src/pages/startPage/steptwo.tsx

98 lines
3.4 KiB
TypeScript
Raw Normal View History

2023-10-18 13:41:34 +00:00
import {
2023-11-13 18:04:51 +00:00
Box,
Button,
Typography,
useMediaQuery,
useTheme,
2023-10-18 13:41:34 +00:00
} from "@mui/material";
2023-11-13 18:04:51 +00:00
import { setQuizStartpageType } from "@root/quizes/actions";
import { useCurrentQuiz } from "@root/quizes/hooks";
import cardImage1 from "../../assets/card-1.png";
import cardImage2 from "../../assets/card-2.png";
import cardImage3 from "../../assets/card-3.png";
2023-11-13 18:04:51 +00:00
import CardWithImage from "./CardWithImage";
2023-03-01 22:59:51 +00:00
2023-10-18 13:41:34 +00:00
export default function Steptwo() {
2023-11-13 18:04:51 +00:00
const theme = useTheme();
const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1300));
2023-11-27 23:07:24 +00:00
const quiz = useCurrentQuiz();
2023-11-13 18:04:51 +00:00
const config = quiz?.config;
2023-11-14 13:10:41 +00:00
if (!config) return null; // TODO throw and catch with error boundary
2023-11-13 18:04:51 +00:00
return (
<Box sx={{ mt: "60px" }}>
<Typography variant="h5">Стартовая страница</Typography>
<Box
sx={{
overflowX: "scroll",
paddingBottom: "15px",
"&::-webkit-scrollbar": { width: 0 },
}}
>
<Box
sx={{
minWidth: "950px",
display: "flex",
gap: "20px",
mt: "40px",
padding: isSmallMonitor ? "0 15px 15px" : 0,
}}
>
<Button
variant="text"
data-cy="select-quiz-layout-standard"
onClick={() => {
2023-11-14 13:37:20 +00:00
setQuizStartpageType(quiz.id, "standard");
2023-11-13 18:04:51 +00:00
}}
>
<CardWithImage
image={cardImage1}
text="Standard"
border={
config.startpageType === "standard"
? "1px solid #7E2AEA"
: "none"
}
/>
</Button>
<Button
variant="text"
onClick={() => {
2023-11-14 13:37:20 +00:00
setQuizStartpageType(quiz.id, "expanded");
2023-11-13 18:04:51 +00:00
}}
>
<CardWithImage
image={cardImage2}
text="Expanded"
border={
config.startpageType === "expanded"
? "1px solid #7E2AEA"
: "none"
}
/>
</Button>
<Button
variant="text"
onClick={() => {
2023-11-14 13:37:20 +00:00
setQuizStartpageType(quiz.id, "centered");
2023-11-13 18:04:51 +00:00
}}
>
<CardWithImage
image={cardImage3}
text="Centered"
border={
config.startpageType === "centered"
? "1px solid #7E2AEA"
: "none"
}
/>
</Button>
</Box>
</Box>
</Box>
2023-11-13 18:04:51 +00:00
);
2023-10-18 13:41:34 +00:00
}