2023-03-20 19:46:28 +00:00
|
|
|
|
import { Box, IconButton, Typography, useMediaQuery, useTheme } from "@mui/material";
|
2023-03-21 18:52:19 +00:00
|
|
|
|
import SectionWrapper from "@components/SectionWrapper";
|
2023-03-10 15:38:27 +00:00
|
|
|
|
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
2023-03-21 18:52:19 +00:00
|
|
|
|
import TotalPrice from "@components/TotalPrice";
|
|
|
|
|
import CustomWrapper from "./CustomWrapper";
|
2023-06-30 15:35:31 +00:00
|
|
|
|
import { useCart } from "@root/utils/hooks/useCart";
|
2023-07-14 12:47:36 +00:00
|
|
|
|
import { useCustomTariffsStore } from "@root/stores/customTariffs";
|
2023-03-10 15:38:27 +00:00
|
|
|
|
|
|
|
|
|
|
2023-03-27 12:45:44 +00:00
|
|
|
|
export default function Basket() {
|
2023-06-30 15:35:31 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const upMd = useMediaQuery(theme.breakpoints.up("md"));
|
|
|
|
|
const cart = useCart();
|
2023-07-14 12:47:36 +00:00
|
|
|
|
const summaryPriceBeforeDiscountsMap = useCustomTariffsStore(state => state.summaryPriceBeforeDiscountsMap);
|
|
|
|
|
const summaryPriceAfterDiscountsMap = useCustomTariffsStore(state => state.summaryPriceAfterDiscountsMap);
|
|
|
|
|
|
|
|
|
|
const basePrice = Object.values(summaryPriceBeforeDiscountsMap).reduce((a, e) => a + e, 0);
|
|
|
|
|
const discountedPrice = Object.values(summaryPriceAfterDiscountsMap).reduce((a, e) => a + e, 0);
|
|
|
|
|
|
|
|
|
|
const totalPriceBeforeDiscounts = cart.priceBeforeDiscounts + basePrice;
|
|
|
|
|
const totalPriceAfterDiscounts = cart.priceAfterDiscounts + discountedPrice;
|
2023-03-24 15:30:58 +00:00
|
|
|
|
|
2023-06-30 15:35:31 +00:00
|
|
|
|
return (
|
|
|
|
|
<SectionWrapper
|
|
|
|
|
maxWidth="lg"
|
|
|
|
|
sx={{
|
|
|
|
|
mt: upMd ? "25px" : "20px",
|
|
|
|
|
mb: upMd ? "70px" : "37px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
mt: "20px",
|
|
|
|
|
mb: upMd ? "40px" : "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
gap: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{!upMd && (
|
|
|
|
|
<IconButton sx={{ p: 0, height: "28px", width: "28px", color: "black" }}>
|
|
|
|
|
<ArrowBackIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
)}
|
|
|
|
|
<Typography component="h4" variant="h4">
|
|
|
|
|
Корзина
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box sx={{
|
|
|
|
|
mt: upMd ? "27px" : "10px",
|
|
|
|
|
}}>
|
|
|
|
|
{cart.services.map(serviceData =>
|
|
|
|
|
<CustomWrapper
|
|
|
|
|
key={serviceData.serviceKey}
|
|
|
|
|
serviceData={serviceData}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
2023-07-14 12:47:36 +00:00
|
|
|
|
<TotalPrice priceBeforeDiscounts={totalPriceBeforeDiscounts} priceAfterDiscounts={totalPriceAfterDiscounts} />
|
2023-06-30 15:35:31 +00:00
|
|
|
|
</SectionWrapper>
|
|
|
|
|
);
|
2023-03-27 12:45:44 +00:00
|
|
|
|
}
|