From f988fd3a4e895a96e738f65c42efc3ee8c49f798 Mon Sep 17 00:00:00 2001 From: Mohammed Al-yaseen Date: Mon, 12 Jan 2026 00:18:55 +0300 Subject: [PATCH] gift: enhance items flow --- .../CustomBottomSheet/GiftTypeBottomSheet.tsx | 27 +++++-- src/pages/CardDetails/CardDetails.tsx | 3 +- src/pages/checkout/components/GiftCard.tsx | 78 ++++++++++--------- src/pages/checkout/page.tsx | 4 +- .../menu/components/MenuFooter/MenuFooter.tsx | 12 +-- src/pages/restaurant/RestaurantServices.tsx | 1 - 6 files changed, 70 insertions(+), 55 deletions(-) diff --git a/src/components/CustomBottomSheet/GiftTypeBottomSheet.tsx b/src/components/CustomBottomSheet/GiftTypeBottomSheet.tsx index c11f7c1..b01c900 100644 --- a/src/components/CustomBottomSheet/GiftTypeBottomSheet.tsx +++ b/src/components/CustomBottomSheet/GiftTypeBottomSheet.tsx @@ -6,6 +6,7 @@ import GiftItemsBtnIcon from "components/Icons/GiftItemsBtnIcon"; import GiftBalanceBtnIcon from "components/Icons/GiftBalanceBtnIcon"; import GiftItemsAndBalanceBtnIcon from "components/Icons/GiftItemsAndBalanceBtnIcon"; import ProText from "components/ProText"; +import { useParams, useNavigate } from "react-router-dom"; interface GiftTypeBottomSheetProps { isOpen: boolean; @@ -13,6 +14,12 @@ interface GiftTypeBottomSheetProps { onSave?: () => void; } +export enum GiftType { + Items = "items", + Vouchers = "vouchers", + ItemsAndVouchers = "itemsAndVouchers", +} + export function GiftTypeBottomSheet({ isOpen, onClose, @@ -20,11 +27,15 @@ export function GiftTypeBottomSheet({ }: GiftTypeBottomSheetProps) { const { t } = useTranslation(); const dispatch = useAppDispatch(); - - const handleSave = (giftType: string) => { - dispatch(updateGiftDetails({ giftType: giftType })); + const { subdomain } = useParams(); + const navigate = useNavigate(); + const handleSave = (giftType: GiftType) => { + dispatch(updateGiftDetails({ giftType })); onClose(); onSave?.(); + if (giftType !== GiftType.Vouchers) + navigate(`/${subdomain}/menu?orderType=gift`); + else navigate(`/${subdomain}/e-gift-cards`); }; const handleCancel = () => { @@ -40,6 +51,7 @@ export function GiftTypeBottomSheet({ textAlign: "center", color: "#86858E", }; + return ( -
handleSave("items")}> +
handleSave(GiftType.Items)}>
{t("gift.items")}
-
handleSave("vouchers")}> +
handleSave(GiftType.Vouchers)} + >
{t("gift.balance")}
handleSave("itemsAndVouchers")} + onClick={() => handleSave(GiftType.ItemsAndVouchers)} >
diff --git a/src/pages/CardDetails/CardDetails.tsx b/src/pages/CardDetails/CardDetails.tsx index 2f823b2..2c5290c 100644 --- a/src/pages/CardDetails/CardDetails.tsx +++ b/src/pages/CardDetails/CardDetails.tsx @@ -16,6 +16,7 @@ import TimeEstimateCard from "pages/cart/components/timeEstimate/TimeEstimateCar import { useNavigate, useParams } from "react-router-dom"; import GiftAmountCard from "./components/GiftAmountCard/GiftAmountCard"; import { GiftAmountBottomSheet } from "./components/GiftAmountBottomSheet"; +import PickupTimeCard from "pages/checkout/components/pickupEstimate/TimeEstimateCard"; export default function CardDetailsPage() { const { t } = useTranslation(); @@ -168,7 +169,7 @@ export default function CardDetailsPage() { )} - + diff --git a/src/pages/checkout/components/GiftCard.tsx b/src/pages/checkout/components/GiftCard.tsx index b54159b..90c62cb 100644 --- a/src/pages/checkout/components/GiftCard.tsx +++ b/src/pages/checkout/components/GiftCard.tsx @@ -15,6 +15,7 @@ import { useMemo, useState } from "react"; import CardAmountIcon from "components/Icons/CardAmountIcon"; import ArabicPrice from "components/ArabicPrice"; import { GiftAmountBottomSheet } from "pages/CardDetails/components/GiftAmountBottomSheet"; +import { GiftType } from "components/CustomBottomSheet/GiftTypeBottomSheet"; export function GiftCard() { const { t } = useTranslation(); @@ -32,6 +33,8 @@ export function GiftCard() { const [isGiftAmountBottomSheetOpen, setIsGiftAmountBottomSheetOpen] = useState(false); + console.log(giftDetails?.giftType); + return ( <> @@ -108,10 +111,12 @@ export function GiftCard() {
{isRTL ? : }
+ - {giftDetails?.giftType === "vouchers" || - (giftDetails?.giftType === "itemsAndVouchers" && ( + {(giftDetails?.giftType === GiftType.Vouchers || + giftDetails?.giftType === GiftType.ItemsAndVouchers) && ( + <>
{ @@ -164,46 +169,49 @@ export function GiftCard() {
{isRTL ? : }
- ))} + {giftDetails?.giftType === GiftType.ItemsAndVouchers && ( + + )} + + )} - - {giftDetails?.giftType === "items" || - (giftDetails?.giftType === "itemsAndVouchers" && ( -
{ + navigate(`/${subdomain}/cart`); + }} + > + { - navigate(`/${subdomain}/cart`); + fontWeight: 400, + fontStyle: "Regular", + fontSize: 12, + lineHeight: "140%", + letterSpacing: "0%", + color: "#777580", + cursor: "pointer", }} > - - - - - {t("checkout.viewOrder")} ( {totalItems} {t("cart.items")} ) - - {isRTL ? : } -
- ))} + + + {t("checkout.viewOrder")} ( {totalItems} {t("cart.items")} ) + + {isRTL ? : } + + )} */} {/* */} {/* */} - {orderType !== OrderType.Redeem && } + {orderType !== OrderType.Redeem && orderType !== OrderType.Gift && } {/* Collection Method */} {orderType === OrderType.Pickup && ( @@ -123,7 +123,7 @@ export default function CheckoutPage() { )} {/* Reward Your Waiter */} - {orderType !== OrderType.Redeem && } + {orderType !== OrderType.Redeem && orderType !== OrderType.Gift && } diff --git a/src/pages/menu/components/MenuFooter/MenuFooter.tsx b/src/pages/menu/components/MenuFooter/MenuFooter.tsx index 66750e4..85e600c 100644 --- a/src/pages/menu/components/MenuFooter/MenuFooter.tsx +++ b/src/pages/menu/components/MenuFooter/MenuFooter.tsx @@ -44,13 +44,7 @@ export function MenuFooter() { }} > { if (totalItems === 0) { e.preventDefault(); @@ -106,9 +100,7 @@ export function MenuFooter() { margin: "0 10px", }} > - {orderType === OrderType.Pay - ? t("menu.pay") - : t("menu.viewCart")} + {t("menu.viewCart")}
setIsGiftTypeBottomSheetOpen(false)} onSave={() => { setIsGiftTypeBottomSheetOpen(false); - navigate(`/${subdomain}/menu?orderType=${OrderType.Gift}`); }} />