frontPanel/src/pages/createQuize/MyQuizzesFull.tsx

89 lines
2.3 KiB
TypeScript
Raw Normal View History

2023-10-18 12:46:59 +00:00
import {
Typography,
Box,
Button,
SxProps,
Theme,
useTheme,
useMediaQuery,
} from "@mui/material";
import ComplexNavText from "./ComplexNavText";
import QuizCard from "./QuizCard";
import SectionWrapper from "@ui_kit/SectionWrapper";
import React from "react";
2023-10-18 12:46:59 +00:00
import { quizStore } from "@root/quizes";
import FirstQuiz from "./FirstQuiz";
2023-10-18 12:46:59 +00:00
import { useNavigate } from "react-router-dom";
2023-11-02 16:45:28 +00:00
import { createQuiz } from "@root/quizesV2";
interface Props {
2023-10-18 12:46:59 +00:00
outerContainerSx?: SxProps<Theme>;
children?: React.ReactNode;
}
2022-12-09 11:48:15 +00:00
2023-10-18 12:46:59 +00:00
export default function MyQuizzesFull({
outerContainerSx: sx,
children,
}: Props) {
const { listQuizes, updateQuizesList, removeQuiz, createBlank } = quizStore();
const navigate = useNavigate();
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down(500));
2023-10-18 12:46:59 +00:00
return (
<>
{Object.keys(listQuizes).length === 0 ? (
<FirstQuiz />
) : (
<SectionWrapper maxWidth="lg">
<ComplexNavText text1="Кабинет квизов" />
<Box
sx={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
mt: "20px",
mb: "30px",
}}
>
<Typography variant="h4">Мои квизы</Typography>
<Button
variant="contained"
sx={{
padding: isMobile ? "10px" : "10px 47px",
minWidth: "44px",
}}
2023-11-02 16:45:28 +00:00
onClick={() => createQuiz(navigate)}
2023-10-18 12:46:59 +00:00
>
{isMobile ? "+" : "Создать +"}
</Button>
</Box>
<Box
sx={{
py: "10px",
display: "flex",
flexWrap: "wrap",
gap: "40px",
mb: "60px",
}}
>
2023-10-31 11:29:15 +00:00
{Object.values(listQuizes).map(({ id, name }) => (
2023-10-18 12:46:59 +00:00
<QuizCard
2023-10-31 11:29:15 +00:00
key={id}
name={name}
2023-10-18 12:46:59 +00:00
openCount={0}
applicationCount={0}
conversionPercent={0}
onClickDelete={() => {
2023-10-31 11:29:15 +00:00
removeQuiz(id);
2023-10-18 12:46:59 +00:00
}}
2023-10-31 11:29:15 +00:00
onClickEdit={() => navigate(`/setting/${id}`)}
2023-10-18 12:46:59 +00:00
/>
))}
</Box>
{children}
</SectionWrapper>
)}
</>
);
}