import { useState, useRef, useCallback } from "react"; import { Typography, Drawer, useMediaQuery, useTheme, Box, IconButton, Badge, } from "@mui/material"; import ArrowBackIcon from "@mui/icons-material/ArrowBack"; import { useTickets } from "@frontend/kitui"; import SectionWrapper from "./SectionWrapper"; import CustomWrapperDrawer from "./CustomWrapperDrawer"; import CustomButton from "./CustomButton"; import { NotificationsModal } from "./NotificationsModal"; import { useNavigate } from "react-router"; import { useCart } from "@root/utils/hooks/useCart"; import { currencyFormatter } from "@root/utils/currencyFormatter"; import { closeCartDrawer, openCartDrawer, useCartStore, } from "@root/stores/cart"; import { useUserStore } from "@root/stores/user"; import { updateTickets, setTicketCount, useTicketStore, } from "@root/stores/tickets"; import { ReactComponent as BellIcon } from "@root/assets/Icons/bell.svg"; import { ReactComponent as CartIcon } from "@root/assets/Icons/cart.svg"; import { ReactComponent as CrossIcon } from "@root/assets/Icons/cross.svg"; export default function Drawers() { const [openNotificationsModal, setOpenNotificationsModal] = useState(false); const bellRef = useRef(null); const navigate = useNavigate(); const theme = useTheme(); const upMd = useMediaQuery(theme.breakpoints.up("md")); const isTablet = useMediaQuery(theme.breakpoints.down(1000)); const isDrawerOpen = useCartStore((state) => state.isDrawerOpen); const cart = useCart(); const userAccount = useUserStore((state) => state.userAccount); const { tickets, apiPage, ticketsPerPage } = useTicketStore((state) => state); useTickets({ url: "https://hub.pena.digital/heruvym/getTickets", ticketsPerPage, ticketApiPage: apiPage, onNewTickets: useCallback((result) => { if (result.data) updateTickets(result.data); setTicketCount(result.count); }, []), onError: () => {}, }); const notificationsCount = tickets.filter( ({ user, top_message }) => user !== top_message.user_id && top_message.shown.me !== 1 ).length; const totalPriceBeforeDiscounts = cart.priceBeforeDiscounts; const totalPriceAfterDiscounts = cart.priceAfterDiscounts; return ( setOpenNotificationsModal((isOpened) => !isOpened)} sx={{ cursor: "pointer", borderRadius: "6px", background: openNotificationsModal ? theme.palette.brightPurple.main : theme.palette.background.default, "& .MuiBadge-badge": { background: openNotificationsModal ? theme.palette.background.default : theme.palette.brightPurple.main, color: openNotificationsModal ? theme.palette.brightPurple.main : theme.palette.background.default, }, "& svg > path:first-child": { fill: openNotificationsModal ? "#FFFFFF" : "#9A9AAF", }, "& svg > path:last-child": { stroke: openNotificationsModal ? "#FFFFFF" : "#9A9AAF", }, "&:hover": { background: theme.palette.brightPurple.main, "& .MuiBox-root": { background: theme.palette.brightPurple.main, }, "& .MuiBadge-badge": { background: theme.palette.background.default, color: theme.palette.brightPurple.main, }, "& svg > path:first-child": { fill: "#FFFFFF" }, "& svg > path:last-child": { stroke: "#FFFFFF" }, }, }} > user !== top_message.user_id) .map((ticket) => ({ text: "У вас новое сообщение от техподдержки", date: new Date(ticket.updated_at).toLocaleDateString(), url: `/support/${ticket.id}`, watched: ticket.user === ticket.top_message.user_id || ticket.top_message.shown.me === 1, }))} /> path:nth-child(1)": { fill: "#FFFFFF" }, "& svg > path:nth-child(2)": { fill: "#FFFFFF" }, "& svg > path:nth-child(3)": { stroke: "#FFFFFF" }, }, }} > {!upMd && ( )} Корзина {cart.services.map((serviceData) => ( ))} Итоговая цена Текст-заполнитель — это текст, который имеет Текст-заполнитель — это текст, который имеет Текст-заполнитель — это текст, который имеет Текст-заполнитель — это текст, который имеет Текст-заполнитель {currencyFormatter.format(totalPriceBeforeDiscounts / 100)} {currencyFormatter.format(totalPriceAfterDiscounts / 100)} navigate("/cart")} sx={{ mt: "25px", backgroundColor: theme.palette.brightPurple.main, }} > Оплатить ); }