frontPanel/src/pages/createQuize/CreateButtons.tsx

65 lines
2.3 KiB
TypeScript
Raw Normal View History

import { Link, useNavigate } from "react-router-dom";
import { Box, Button, Typography, useMediaQuery, useTheme } from "@mui/material";
import { ReactComponent as TemplateIcon } from "@/assets/quiz-templates/template.svg";
import { createQuiz, resetEditConfig } from "@root/quizes/actions";
2024-05-28 20:39:21 +00:00
import React from "react";
import { useUserStore } from "@/stores/user";
2024-05-28 20:39:21 +00:00
export default function CreateButtons({ mt }: string) {
2024-05-28 20:39:21 +00:00
const navigate = useNavigate();
const theme = useTheme();
const user = useUserStore();
2024-05-28 20:39:21 +00:00
const isMobile = useMediaQuery(theme.breakpoints.down(500));
return (
2024-05-28 20:39:21 +00:00
<Box
sx={{
display: "flex",
gap: "20px",
flexWrap: "wrap",
marginTop: mt,
}}
>
{
user?.user?._id === "6692e068983ee77f8e1e682e" &&
<Link to="/gallery" style={{ textDecoration: "none" }}>
<Button
sx={{
display: "flex",
gap: "10px",
padding: "13px",
borderRadius: "8px",
background: "#9A9AAF17",
color: theme.palette.brightPurple.main,
transition: ".2s",
"&:hover": {
color: theme.palette.background.paper,
background: theme.palette.brightPurple.main,
"& svg path": { stroke: theme.palette.background.paper },
},
}}
>
<TemplateIcon />
{!isMobile && <Typography>Посмотреть шаблоны</Typography>}
</Button>
</Link>
}
2024-05-28 20:39:21 +00:00
<Button
variant="contained"
sx={{
padding: isMobile ? "10px" : "10px 47px",
minWidth: "44px",
}}
onClick={() => {
resetEditConfig();
createQuiz(navigate);
}}
data-cy="create-quiz"
>
{isMobile ? "+" : "Создать +"}
</Button>
</Box>
)
}