From 124658ca1279d577939b02c94659d5250b5a107c Mon Sep 17 00:00:00 2001 From: Mohammed Al-yaseen Date: Mon, 6 Oct 2025 11:14:07 +0300 Subject: [PATCH] cart refactor code --- .../cart/components/CartDesktopLayout.tsx | 77 ++----------------- .../components/CartMobileTabletLayout.tsx | 69 ++--------------- .../cart/components/cartFooter/CartFooter.tsx | 61 +++++++++++++++ .../components/cartFooter/footer.module.css | 23 ++++++ 4 files changed, 98 insertions(+), 132 deletions(-) create mode 100644 src/pages/cart/components/cartFooter/CartFooter.tsx create mode 100644 src/pages/cart/components/cartFooter/footer.module.css diff --git a/src/pages/cart/components/CartDesktopLayout.tsx b/src/pages/cart/components/CartDesktopLayout.tsx index 071f1b0..08c224f 100644 --- a/src/pages/cart/components/CartDesktopLayout.tsx +++ b/src/pages/cart/components/CartDesktopLayout.tsx @@ -1,5 +1,5 @@ import styles from "pages/cart/cart.module.css"; -import { Row, Col, Button, Card, Divider, Space } from "antd"; +import { Row, Col, Button, Card } from "antd"; import ProTitle from "components/ProTitle.tsx"; import { colors } from "ThemeConstants.ts"; import ProText from "components/ProText.tsx"; @@ -10,7 +10,7 @@ import ArabicPrice from "components/ArabicPrice"; import CartActionsButtons from "components/CartActionsButtons/CartActionsButtons.tsx"; import { CartItem } from "utils/types/appTypes.ts"; -import { selectCart, selectCartTotal } from "features/order/orderSlice.ts"; +import { selectCart } from "features/order/orderSlice.ts"; import { useTranslation } from "react-i18next"; import { useAppSelector } from "redux/hooks.ts"; import SpecialRequestCard from "pages/cart/components/SpecialRequestCard.tsx"; @@ -20,19 +20,17 @@ import TableNumberCard from "pages/cart/components/TableNumberCard.tsx"; import CarPlateCard from "pages/cart/components/CarPlateCard.tsx"; import YouMightAlsoLike from "pages/cart/components/YouMightAlsoLike.tsx"; import TimeEstimateCard from "pages/cart/components/timeEstimate/TimeEstimateCard.tsx"; +import OrderSummary from "components/OrderSummary/OrderSummary.tsx"; +import CartFooter from "pages/cart/components/cartFooter/CartFooter.tsx"; export default function CartDesktopLayout() { const { t } = useTranslation(); const { items } = useAppSelector(selectCart); const orderType = localStorage.getItem("orderType"); - const subtotal = useAppSelector(selectCartTotal); - const tax = subtotal * 0.1; // 10% tax - const total = subtotal + tax; - return ( <> -
+
{/* Main Content Column */} @@ -213,72 +211,13 @@ export default function CartDesktopLayout() { className={`${styles.desktopOrderSummary} ${styles.desktopSidebarCard}`} style={{ "--animation-order": 4 } as React.CSSProperties} > - - {t("orderSummary")} - - - - - -
- {t("basketTotal")} - -
-
- {t("discount")} - -
-
- {t("riderTip")} - -
- - - -
- - {t("totalAmount")} - - - - -
-
+ - - {/* Checkout Button */} -
+ +
); diff --git a/src/pages/cart/components/CartMobileTabletLayout.tsx b/src/pages/cart/components/CartMobileTabletLayout.tsx index 143fd58..3d38209 100644 --- a/src/pages/cart/components/CartMobileTabletLayout.tsx +++ b/src/pages/cart/components/CartMobileTabletLayout.tsx @@ -1,9 +1,9 @@ import ProHeader from "components/ProHeader/ProHeader.tsx"; import styles from "pages/cart/cart.module.css"; -import { Space, Card, Divider, Button } from "antd"; +import { Space, Card, Divider } from "antd"; import ProTitle from "components/ProTitle.tsx"; import { Link, useParams } from "react-router-dom"; -import { colors, ProBlack2 } from "ThemeConstants.ts"; +import { colors } from "ThemeConstants.ts"; import { PlusOutlined } from "@ant-design/icons"; import ProText from "components/ProText.tsx"; import ArabicPrice from "components/ArabicPrice"; @@ -28,6 +28,7 @@ import RewardWaiterCard from "pages/cart/components/RewardWaiterCard.tsx"; import CarPlateCard from "pages/cart/components/CarPlateCard.tsx"; import TableNumberCard from "pages/cart/components/TableNumberCard.tsx"; import TimeEstimateCard from "pages/cart/components/timeEstimate/TimeEstimateCard.tsx"; +import CartFooter from "pages/cart/components/cartFooter/CartFooter.tsx"; export default function CartMobileTabletLayout() { const { t } = useTranslation(); @@ -38,7 +39,6 @@ export default function CartMobileTabletLayout() { const getResponsiveClass = () => (isTablet ? "tablet" : "mobile"); - const { themeName } = useAppSelector((state) => state.theme); const orderType = localStorage.getItem("orderType"); const getMenuItemImageStyle = () => { @@ -259,68 +259,11 @@ export default function CartMobileTabletLayout() { {/* Invoice Summary */} + {/* space keeper*/} +
- -
- - - - - - - -
- - {/* Mobile/Tablet Bottom Sheets */} + ); } diff --git a/src/pages/cart/components/cartFooter/CartFooter.tsx b/src/pages/cart/components/cartFooter/CartFooter.tsx new file mode 100644 index 0000000..a31d573 --- /dev/null +++ b/src/pages/cart/components/cartFooter/CartFooter.tsx @@ -0,0 +1,61 @@ +import { colors } from "ThemeConstants.ts"; +import { Link, useParams } from "react-router-dom"; +import { Button } from "antd"; +import { useAppSelector } from "redux/hooks.ts"; +import useBreakPoint from "hooks/useBreakPoint.ts"; +import { useTranslation } from "react-i18next"; +import { selectCart } from "features/order/orderSlice.ts"; +import styles from "./footer.module.css"; + +export default function CartFooter() { + const { t } = useTranslation(); + const { items } = useAppSelector(selectCart); + const { id } = useParams(); + const { isMobile, isTablet } = useBreakPoint(); + const orderType = localStorage.getItem("orderType"); + + return ( +
+ + + + + + + +
+ ); +} diff --git a/src/pages/cart/components/cartFooter/footer.module.css b/src/pages/cart/components/cartFooter/footer.module.css new file mode 100644 index 0000000..0a615da --- /dev/null +++ b/src/pages/cart/components/cartFooter/footer.module.css @@ -0,0 +1,23 @@ +.cartFooter { + width: 100%; + padding: 16px 16px 0; + position: fixed; + bottom: 0; + left: 0; + height: 10vh; + display: flex; + flex-direction: row; + justify-content: space-around; + gap: 1rem; + background-color: var(--background); + box-shadow: none; +} +/* :global(.darkApp) .cartFooter { + background-color: var(--background) !important; +} */ +@media (min-width: 992px) { + .cartFooter { + position: absolute; + height: 12vh; + } +}