fix: clear store
This commit is contained in:
parent
751e4a2efe
commit
d78e8336f7
@ -17,6 +17,8 @@ import { logout } from "@root/api/auth";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { clearUserData, useUserStore } from "@root/stores/user";
|
||||
import { clearAuthToken, getMessageFromFetchError } from "@frontend/kitui";
|
||||
import { clearCustomTariffs } from "@root/stores/customTariffs";
|
||||
import { clearTickets } from "@root/stores/tickets";
|
||||
|
||||
import { currencyFormatter } from "@root/utils/currencyFormatter";
|
||||
|
||||
@ -41,6 +43,8 @@ export default function NavbarFull({ isLoggedIn, children }: Props) {
|
||||
await logout();
|
||||
clearAuthToken();
|
||||
clearUserData();
|
||||
clearCustomTariffs();
|
||||
clearTickets();
|
||||
navigate("/");
|
||||
} catch (error: any) {
|
||||
const message = getMessageFromFetchError(error, "Не удалось выйти");
|
||||
|
@ -1,5 +1,12 @@
|
||||
import { Link, useLocation, useNavigate } from "react-router-dom";
|
||||
import { Box, Button, Container, IconButton, Typography, useTheme } from "@mui/material";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Container,
|
||||
IconButton,
|
||||
Typography,
|
||||
useTheme,
|
||||
} from "@mui/material";
|
||||
import SectionWrapper from "../SectionWrapper";
|
||||
import LogoutIcon from "../icons/LogoutIcon";
|
||||
import WalletIcon from "../icons/WalletIcon";
|
||||
@ -12,6 +19,8 @@ import { enqueueSnackbar } from "notistack";
|
||||
import { clearUserData, useUserStore } from "@root/stores/user";
|
||||
import { clearAuthToken, getMessageFromFetchError } from "@frontend/kitui";
|
||||
import { currencyFormatter } from "@root/utils/currencyFormatter";
|
||||
import { clearCustomTariffs } from "@root/stores/customTariffs";
|
||||
import { clearTickets } from "@root/stores/tickets";
|
||||
|
||||
interface Props {
|
||||
isLoggedIn: boolean;
|
||||
@ -29,6 +38,8 @@ export default function NavbarFull({ isLoggedIn }: Props) {
|
||||
await logout();
|
||||
clearAuthToken();
|
||||
clearUserData();
|
||||
clearCustomTariffs();
|
||||
clearTickets();
|
||||
navigate("/");
|
||||
} catch (error: any) {
|
||||
const message = getMessageFromFetchError(error, "Не удалось выйти");
|
||||
@ -63,7 +74,10 @@ export default function NavbarFull({ isLoggedIn }: Props) {
|
||||
}}
|
||||
>
|
||||
<Drawers />
|
||||
<IconButton sx={{ p: 0, ml: "8px" }} onClick={() => navigate("/wallet")}>
|
||||
<IconButton
|
||||
sx={{ p: 0, ml: "8px" }}
|
||||
onClick={() => navigate("/wallet")}
|
||||
>
|
||||
<WalletIcon color={theme.palette.grey2.main} bgcolor="#F2F3F7" />
|
||||
</IconButton>
|
||||
<Box sx={{ ml: "8px", whiteSpace: "nowrap" }}>
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useMediaQuery, useTheme, Box, Link, Typography } from "@mui/material";
|
||||
import SectionWrapper from "@components/SectionWrapper";
|
||||
@ -7,12 +8,27 @@ import PieChartIcon from "@components/icons/PieChartIcon";
|
||||
import TariffCard from "./TariffCard";
|
||||
import WideTemplCard from "@components/wideTemplCard";
|
||||
import TemplCardPhoneLight from "@components/templCardPhoneLight";
|
||||
import { getMessageFromFetchError } from "@frontend/kitui";
|
||||
import { setCustomTariffs } from "@root/stores/customTariffs";
|
||||
import { useCustomTariffs } from "@root/utils/hooks/useCustomTariffs";
|
||||
|
||||
export default function Tariffs() {
|
||||
const theme = useTheme();
|
||||
const upMd = useMediaQuery(theme.breakpoints.up("md"));
|
||||
const navigate = useNavigate();
|
||||
|
||||
useCustomTariffs({
|
||||
url: "https://admin.pena.digital/strator/privilege/service",
|
||||
onNewUser: setCustomTariffs,
|
||||
onError: (error) => {
|
||||
const errorMessage = getMessageFromFetchError(
|
||||
error,
|
||||
"Не удалось получить кастомные тарифы"
|
||||
);
|
||||
if (errorMessage) enqueueSnackbar(errorMessage);
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<SectionWrapper
|
||||
maxWidth="lg"
|
||||
|
@ -1,4 +1,12 @@
|
||||
import { Box, Dialog, IconButton, Link, Typography, useMediaQuery, useTheme } from "@mui/material";
|
||||
import {
|
||||
Box,
|
||||
Dialog,
|
||||
IconButton,
|
||||
Link,
|
||||
Typography,
|
||||
useMediaQuery,
|
||||
useTheme,
|
||||
} from "@mui/material";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import { useFormik } from "formik";
|
||||
@ -27,7 +35,9 @@ const initialValues: Values = {
|
||||
};
|
||||
|
||||
const validationSchema = object({
|
||||
email: string().required("Поле обязательно").email("Введите корректный email"),
|
||||
email: string()
|
||||
.required("Поле обязательно")
|
||||
.email("Введите корректный email"),
|
||||
password: string().required("Поле обязательно"),
|
||||
});
|
||||
|
||||
@ -196,7 +206,9 @@ export default function SigninDialog() {
|
||||
mt: "auto",
|
||||
}}
|
||||
>
|
||||
<Typography sx={{ color: theme.palette.brightPurple.main, textAlign: "center" }}>
|
||||
<Typography
|
||||
sx={{ color: theme.palette.brightPurple.main, textAlign: "center" }}
|
||||
>
|
||||
Вы еще не присоединились?
|
||||
</Typography>
|
||||
<Link
|
||||
|
Loading…
Reference in New Issue
Block a user