2023-08-30 13:17:29 +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-08-16 14:03:45 +00:00
|
|
|
|
import { useLocation } from "react-router-dom";
|
|
|
|
|
import { usePrevLocation } from "@root/utils/hooks/handleCustomBackNavigation";
|
2023-03-10 15:38:27 +00:00
|
|
|
|
|
2023-08-12 14:55:41 +00:00
|
|
|
|
export default function Cart() {
|
2023-08-10 11:55:49 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const upMd = useMediaQuery(theme.breakpoints.up("md"));
|
2023-08-23 13:24:47 +00:00
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(550));
|
2023-09-01 08:27:14 +00:00
|
|
|
|
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
2023-08-10 11:55:49 +00:00
|
|
|
|
const cart = useCart();
|
2023-08-16 14:03:45 +00:00
|
|
|
|
const location = useLocation();
|
2023-07-14 12:47:36 +00:00
|
|
|
|
|
2023-08-12 14:44:39 +00:00
|
|
|
|
const totalPriceBeforeDiscounts = cart.priceBeforeDiscounts;
|
|
|
|
|
const totalPriceAfterDiscounts = cart.priceAfterDiscounts;
|
2023-03-24 15:30:58 +00:00
|
|
|
|
|
2023-08-16 14:03:45 +00:00
|
|
|
|
const handleCustomBackNavigation = usePrevLocation(location);
|
|
|
|
|
|
2023-08-30 13:17:29 +00:00
|
|
|
|
console.log(cart.services);
|
|
|
|
|
|
2023-08-10 11:55:49 +00:00
|
|
|
|
return (
|
|
|
|
|
<SectionWrapper
|
|
|
|
|
maxWidth="lg"
|
|
|
|
|
sx={{
|
|
|
|
|
mt: upMd ? "25px" : "20px",
|
2023-09-01 08:27:14 +00:00
|
|
|
|
px: isTablet ? "40px" : "20px",
|
2023-08-10 11:55:49 +00:00
|
|
|
|
mb: upMd ? "70px" : "37px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
mt: "20px",
|
|
|
|
|
mb: upMd ? "40px" : "20px",
|
|
|
|
|
display: "flex",
|
2023-08-23 13:24:47 +00:00
|
|
|
|
alignItems: "center",
|
2023-08-10 11:55:49 +00:00
|
|
|
|
gap: "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-08-23 13:24:47 +00:00
|
|
|
|
{isMobile && (
|
2023-08-30 13:17:29 +00:00
|
|
|
|
<IconButton onClick={handleCustomBackNavigation} sx={{ p: 0, height: "28px", width: "28px", color: "black" }}>
|
2023-08-10 11:55:49 +00:00
|
|
|
|
<ArrowBackIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
)}
|
2023-08-23 13:24:47 +00:00
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: isMobile ? "24px" : "36px",
|
|
|
|
|
fontWeight: "500",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-08-10 11:55:49 +00:00
|
|
|
|
Корзина
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
mt: upMd ? "27px" : "10px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-08-30 13:17:29 +00:00
|
|
|
|
{cart.services.map((serviceData, index) => (
|
2023-08-23 13:24:47 +00:00
|
|
|
|
<CustomWrapper
|
|
|
|
|
key={serviceData.serviceKey}
|
|
|
|
|
serviceData={serviceData}
|
2023-08-30 13:17:29 +00:00
|
|
|
|
first={index === 0}
|
|
|
|
|
last={index === cart.services.length - 1}
|
2023-08-23 13:24:47 +00:00
|
|
|
|
/>
|
2023-08-10 11:55:49 +00:00
|
|
|
|
))}
|
|
|
|
|
</Box>
|
2023-08-30 13:17:29 +00:00
|
|
|
|
<TotalPrice priceBeforeDiscounts={totalPriceBeforeDiscounts} priceAfterDiscounts={totalPriceAfterDiscounts} />
|
2023-08-10 11:55:49 +00:00
|
|
|
|
</SectionWrapper>
|
|
|
|
|
);
|
2023-03-27 12:45:44 +00:00
|
|
|
|
}
|