import { Alert, Box, Typography, useMediaQuery, useTheme } from "@mui/material"; import CustomButton from "./CustomButton"; import { currencyFormatter } from "@root/utils/currencyFormatter"; import { patchCurrency, payCart } from "@root/api/cart"; import { changeUserCurrency, setUserAccount } from "@root/stores/user"; import { isAxiosError } from "axios"; import { useState } from "react"; import { getMessageFromFetchError } from "@frontend/kitui"; import { enqueueSnackbar } from "notistack"; import { setNotEnoughMoneyAmount, useCartStore } from "@root/stores/cart"; import { useNavigate } from "react-router-dom"; interface Props { price: number; priceWithDiscounts: number; } export default function TotalPrice({ price, priceWithDiscounts }: Props) { const theme = useTheme(); const upMd = useMediaQuery(theme.breakpoints.up("md")); const notEnoughMoneyAmount = useCartStore(state => state.notEnoughMoneyAmount); const navigate = useNavigate(); function handlePayClick() { // payCart().then(result => { // setUserAccount(result); // }).catch(error => { // if (isAxiosError(error) && error.response?.status === 402) { // console.log("response", error.response); // // TODO // // setNotEnoughMoneyAmount(error.response.data?.???) // } else { // const message = getMessageFromFetchError(error); // if (message) enqueueSnackbar(message); // } // }); } function handleReplenishWallet() { navigate("/wallet"); } return ( Итоговая цена Текст-заполнитель — это текст, который имеет Текст-заполнитель — это текст, который имеет Текст-заполнитель — это текст, который имеет Текст-заполнитель — это текст, который имеет Текст-заполнитель {currencyFormatter.format(price / 100)} {currencyFormatter.format(priceWithDiscounts / 100)} {notEnoughMoneyAmount > 0 && Нехватает {currencyFormatter.format(notEnoughMoneyAmount / 100)} } {notEnoughMoneyAmount === 0 ? "Оплатить" : "Пополнить"} ); }