frontPanel/src/pages/createQuize/MyQuizzesFull.tsx

79 lines
3.0 KiB
TypeScript
Raw Normal View History

import {Typography, Box, Button, SxProps, Theme} from "@mui/material";
import ComplexNavText from "./ComplexNavText";
import QuizCard from "./QuizCard";
import SectionWrapper from "@ui_kit/SectionWrapper";
import React from "react";
import {quizStore} from "@root/quizes";
import FirstQuiz from "./FirstQuiz";
import {useNavigate} from "react-router-dom";
interface Props {
outerContainerSx?: SxProps<Theme>;
children?: React.ReactNode;
}
2022-12-09 11:48:15 +00:00
export default function MyQuizzesFull({outerContainerSx: sx, children}: Props) {
const {listQuizes, updateQuizesList, removeQuiz, createBlank} = quizStore()
const navigate = useNavigate()
2022-12-09 11:48:15 +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: "10px 47px"}}
onClick={() => {
2023-10-10 13:33:21 +00:00
navigate(`/setting/${createBlank()}`);
}}
>Создать +</Button>
</Box>
<Box
sx={{
py: "10px",
display: "flex",
flexWrap: "wrap",
gap: "40px",
mb: "60px",
}}
>
{Object.values(listQuizes).map((e, i) =>(
<QuizCard name={e.name}
openCount={0}
applicationCount={0}
conversionPercent={0}
onClickDelete={() => {
removeQuiz(e.id)
}}
onClickEdit={() =>
2023-10-10 13:33:21 +00:00
navigate(`/setting/${e.id}`)
}
/>
)
)}
</Box>
{children}
</SectionWrapper>
}
</>
)
}