2023-12-31 02:53:25 +00:00
|
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
Button,
|
|
|
|
|
SxProps,
|
|
|
|
|
Theme,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
|
|
|
|
} from "@mui/material";
|
2024-01-19 19:41:45 +00:00
|
|
|
|
import { createQuiz, updateQuiz } from "@root/quizes/actions";
|
2023-12-13 17:16:03 +00:00
|
|
|
|
import { useQuizes } from "@root/quizes/hooks";
|
2023-05-10 11:40:39 +00:00
|
|
|
|
import SectionWrapper from "@ui_kit/SectionWrapper";
|
|
|
|
|
import React from "react";
|
2023-10-18 12:46:59 +00:00
|
|
|
|
import { useNavigate } from "react-router-dom";
|
2023-12-17 23:29:31 +00:00
|
|
|
|
import { resetEditConfig } from "@root/quizes/actions";
|
2023-11-13 18:04:51 +00:00
|
|
|
|
import FirstQuiz from "./FirstQuiz";
|
|
|
|
|
import QuizCard from "./QuizCard";
|
2024-01-04 00:12:12 +00:00
|
|
|
|
import HeaderFull from "@ui_kit/Header/HeaderFull";
|
2024-01-19 19:41:45 +00:00
|
|
|
|
import QuizgenegationName from "@utils/quizgenegationName";
|
2023-11-13 18:04:51 +00:00
|
|
|
|
|
2023-05-10 11:40:39 +00:00
|
|
|
|
interface Props {
|
2023-12-15 22:46:57 +00:00
|
|
|
|
outerContainerSx?: SxProps<Theme>;
|
|
|
|
|
children?: React.ReactNode;
|
2023-05-10 11:40:39 +00:00
|
|
|
|
}
|
2022-12-09 11:48:15 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
export default function MyQuizzesFull({
|
|
|
|
|
outerContainerSx: sx,
|
|
|
|
|
children,
|
|
|
|
|
}: Props) {
|
2023-12-15 22:46:57 +00:00
|
|
|
|
const { quizes } = useQuizes();
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(500));
|
2023-05-20 20:36:33 +00:00
|
|
|
|
|
2023-12-15 22:46:57 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
2024-01-04 00:12:12 +00:00
|
|
|
|
<HeaderFull />
|
2023-12-15 22:46:57 +00:00
|
|
|
|
{quizes.length === 0 ? (
|
|
|
|
|
<FirstQuiz />
|
|
|
|
|
) : (
|
2024-01-04 15:18:29 +00:00
|
|
|
|
<SectionWrapper
|
|
|
|
|
maxWidth="lg"
|
|
|
|
|
sx={{ padding: isMobile ? "0 16px" : "20px" }}
|
|
|
|
|
>
|
2023-12-15 22:46:57 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
mt: "20px",
|
|
|
|
|
mb: "30px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-12-30 20:31:49 +00:00
|
|
|
|
<Typography variant="h4">Мои quiz</Typography>
|
2023-12-15 22:46:57 +00:00
|
|
|
|
<Button
|
|
|
|
|
variant="contained"
|
|
|
|
|
sx={{
|
|
|
|
|
padding: isMobile ? "10px" : "10px 47px",
|
|
|
|
|
minWidth: "44px",
|
|
|
|
|
}}
|
2023-12-17 23:29:31 +00:00
|
|
|
|
onClick={() => {
|
|
|
|
|
resetEditConfig();
|
2023-12-31 02:53:25 +00:00
|
|
|
|
createQuiz(navigate);
|
2023-12-17 23:29:31 +00:00
|
|
|
|
}}
|
2023-12-15 22:46:57 +00:00
|
|
|
|
data-cy="create-quiz"
|
|
|
|
|
>
|
|
|
|
|
{isMobile ? "+" : "Создать +"}
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
py: "10px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexWrap: "wrap",
|
|
|
|
|
gap: "40px",
|
|
|
|
|
mb: "60px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-01-06 20:06:31 +00:00
|
|
|
|
{quizes.map((quiz) => {
|
2024-01-19 19:41:45 +00:00
|
|
|
|
if (quiz.name.length === 0 || quiz.name === " ") {
|
|
|
|
|
updateQuiz(quiz.id, (quiz) => {
|
|
|
|
|
quiz.name = QuizgenegationName({ quiz });
|
|
|
|
|
});
|
|
|
|
|
}
|
2024-01-25 01:26:58 +00:00
|
|
|
|
|
2024-01-07 19:17:41 +00:00
|
|
|
|
return (
|
|
|
|
|
<QuizCard
|
|
|
|
|
key={quiz.id}
|
|
|
|
|
quiz={quiz}
|
2024-01-23 13:14:42 +00:00
|
|
|
|
openCount={quiz.session_count}
|
2024-01-07 19:17:41 +00:00
|
|
|
|
applicationCount={quiz.passed_count}
|
|
|
|
|
conversionPercent={
|
2024-01-23 13:14:42 +00:00
|
|
|
|
quiz.session_count
|
2024-01-07 19:17:41 +00:00
|
|
|
|
? (
|
2024-01-23 13:14:42 +00:00
|
|
|
|
(quiz.passed_count / quiz.session_count) *
|
2024-01-07 19:17:41 +00:00
|
|
|
|
100
|
|
|
|
|
).toFixed(1)
|
|
|
|
|
: 0
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2024-01-06 20:06:31 +00:00
|
|
|
|
})}
|
2023-12-15 22:46:57 +00:00
|
|
|
|
</Box>
|
|
|
|
|
{children}
|
|
|
|
|
</SectionWrapper>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
2023-05-20 20:36:33 +00:00
|
|
|
|
}
|