2024-03-03 07:57:12 +00:00
|
|
|
|
import { CircularProgress, Typography } from "@mui/material";
|
2024-02-22 14:12:50 +00:00
|
|
|
|
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
2024-03-03 07:57:12 +00:00
|
|
|
|
import { LocalizationProvider } from "@mui/x-date-pickers/LocalizationProvider";
|
2024-02-22 14:12:50 +00:00
|
|
|
|
|
|
|
|
|
import { CreatePromocodeForm } from "./CreatePromocodeForm";
|
2024-03-03 07:57:12 +00:00
|
|
|
|
import { PromocodesList } from "./PromocodesList";
|
2024-02-22 14:12:50 +00:00
|
|
|
|
|
2024-03-03 07:57:12 +00:00
|
|
|
|
import { usePromocodes } from "@root/api/promocode/swr";
|
2024-02-22 14:12:50 +00:00
|
|
|
|
import theme from "@root/theme";
|
|
|
|
|
|
2024-03-03 07:57:12 +00:00
|
|
|
|
export const PromocodeManagement = () => {
|
|
|
|
|
const { data, error, isLoading } = usePromocodes();
|
|
|
|
|
|
|
|
|
|
if (error) return <Typography>Ошибка загрузки промокодов</Typography>;
|
|
|
|
|
if (isLoading) return <CircularProgress />;
|
|
|
|
|
if (!data) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
|
|
|
<Typography
|
|
|
|
|
variant="subtitle1"
|
|
|
|
|
sx={{
|
|
|
|
|
width: "90%",
|
|
|
|
|
height: "60px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
textTransform: "uppercase",
|
|
|
|
|
color: theme.palette.secondary.main,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Создание промокода
|
|
|
|
|
</Typography>
|
|
|
|
|
<CreatePromocodeForm />
|
|
|
|
|
<PromocodesList promocodes={data} />
|
|
|
|
|
</LocalizationProvider>
|
|
|
|
|
);
|
|
|
|
|
};
|