gift: enhance items flow

This commit is contained in:
2026-01-12 00:18:55 +03:00
parent 167b26e0b9
commit f988fd3a4e
6 changed files with 70 additions and 55 deletions

View File

@@ -6,6 +6,7 @@ import GiftItemsBtnIcon from "components/Icons/GiftItemsBtnIcon";
import GiftBalanceBtnIcon from "components/Icons/GiftBalanceBtnIcon"; import GiftBalanceBtnIcon from "components/Icons/GiftBalanceBtnIcon";
import GiftItemsAndBalanceBtnIcon from "components/Icons/GiftItemsAndBalanceBtnIcon"; import GiftItemsAndBalanceBtnIcon from "components/Icons/GiftItemsAndBalanceBtnIcon";
import ProText from "components/ProText"; import ProText from "components/ProText";
import { useParams, useNavigate } from "react-router-dom";
interface GiftTypeBottomSheetProps { interface GiftTypeBottomSheetProps {
isOpen: boolean; isOpen: boolean;
@@ -13,6 +14,12 @@ interface GiftTypeBottomSheetProps {
onSave?: () => void; onSave?: () => void;
} }
export enum GiftType {
Items = "items",
Vouchers = "vouchers",
ItemsAndVouchers = "itemsAndVouchers",
}
export function GiftTypeBottomSheet({ export function GiftTypeBottomSheet({
isOpen, isOpen,
onClose, onClose,
@@ -20,11 +27,15 @@ export function GiftTypeBottomSheet({
}: GiftTypeBottomSheetProps) { }: GiftTypeBottomSheetProps) {
const { t } = useTranslation(); const { t } = useTranslation();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { subdomain } = useParams();
const handleSave = (giftType: string) => { const navigate = useNavigate();
dispatch(updateGiftDetails({ giftType: giftType })); const handleSave = (giftType: GiftType) => {
dispatch(updateGiftDetails({ giftType }));
onClose(); onClose();
onSave?.(); onSave?.();
if (giftType !== GiftType.Vouchers)
navigate(`/${subdomain}/menu?orderType=gift`);
else navigate(`/${subdomain}/e-gift-cards`);
}; };
const handleCancel = () => { const handleCancel = () => {
@@ -40,6 +51,7 @@ export function GiftTypeBottomSheet({
textAlign: "center", textAlign: "center",
color: "#86858E", color: "#86858E",
}; };
return ( return (
<ProBottomSheet <ProBottomSheet
isOpen={isOpen} isOpen={isOpen}
@@ -59,19 +71,22 @@ export function GiftTypeBottomSheet({
padding: 24, padding: 24,
}} }}
> >
<div style={{ width: 60 }} onClick={() => handleSave("items")}> <div style={{ width: 60 }} onClick={() => handleSave(GiftType.Items)}>
<GiftItemsBtnIcon /> <GiftItemsBtnIcon />
<br /> <br />
<ProText style={textStyle}>{t("gift.items")}</ProText> <ProText style={textStyle}>{t("gift.items")}</ProText>
</div> </div>
<div style={{ width: 60 }} onClick={() => handleSave("vouchers")}> <div
style={{ width: 60 }}
onClick={() => handleSave(GiftType.Vouchers)}
>
<GiftBalanceBtnIcon /> <GiftBalanceBtnIcon />
<br /> <br />
<ProText style={textStyle}>{t("gift.balance")}</ProText> <ProText style={textStyle}>{t("gift.balance")}</ProText>
</div> </div>
<div <div
style={{ width: 60 }} style={{ width: 60 }}
onClick={() => handleSave("itemsAndVouchers")} onClick={() => handleSave(GiftType.ItemsAndVouchers)}
> >
<GiftItemsAndBalanceBtnIcon /> <GiftItemsAndBalanceBtnIcon />
<br /> <br />

View File

@@ -16,6 +16,7 @@ import TimeEstimateCard from "pages/cart/components/timeEstimate/TimeEstimateCar
import { useNavigate, useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import GiftAmountCard from "./components/GiftAmountCard/GiftAmountCard"; import GiftAmountCard from "./components/GiftAmountCard/GiftAmountCard";
import { GiftAmountBottomSheet } from "./components/GiftAmountBottomSheet"; import { GiftAmountBottomSheet } from "./components/GiftAmountBottomSheet";
import PickupTimeCard from "pages/checkout/components/pickupEstimate/TimeEstimateCard";
export default function CardDetailsPage() { export default function CardDetailsPage() {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -168,7 +169,7 @@ export default function CardDetailsPage() {
)} )}
<ReceivernformationCard /> <ReceivernformationCard />
<SenderformationCard /> <SenderformationCard />
<TimeEstimateCard /> <PickupTimeCard />
</Form> </Form>
</Layout.Content> </Layout.Content>
<Layout.Footer className={styles.checkoutButtonContainer}> <Layout.Footer className={styles.checkoutButtonContainer}>

View File

@@ -15,6 +15,7 @@ import { useMemo, useState } from "react";
import CardAmountIcon from "components/Icons/CardAmountIcon"; import CardAmountIcon from "components/Icons/CardAmountIcon";
import ArabicPrice from "components/ArabicPrice"; import ArabicPrice from "components/ArabicPrice";
import { GiftAmountBottomSheet } from "pages/CardDetails/components/GiftAmountBottomSheet"; import { GiftAmountBottomSheet } from "pages/CardDetails/components/GiftAmountBottomSheet";
import { GiftType } from "components/CustomBottomSheet/GiftTypeBottomSheet";
export function GiftCard() { export function GiftCard() {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -32,6 +33,8 @@ export function GiftCard() {
const [isGiftAmountBottomSheetOpen, setIsGiftAmountBottomSheetOpen] = const [isGiftAmountBottomSheetOpen, setIsGiftAmountBottomSheetOpen] =
useState(false); useState(false);
console.log(giftDetails?.giftType);
return ( return (
<> <>
<ProInputCard title={t("address.giftDetails")}> <ProInputCard title={t("address.giftDetails")}>
@@ -108,10 +111,12 @@ export function GiftCard() {
</div> </div>
{isRTL ? <BackIcon iconSize={24} /> : <NextIcon iconSize={24} />} {isRTL ? <BackIcon iconSize={24} /> : <NextIcon iconSize={24} />}
</div> </div>
<Divider style={{ margin: "10px 0" }} /> <Divider style={{ margin: "10px 0" }} />
{giftDetails?.giftType === "vouchers" || {(giftDetails?.giftType === GiftType.Vouchers ||
(giftDetails?.giftType === "itemsAndVouchers" && ( giftDetails?.giftType === GiftType.ItemsAndVouchers) && (
<>
<div <div
className={styles.orderNotes} className={styles.orderNotes}
onClick={() => { onClick={() => {
@@ -164,11 +169,14 @@ export function GiftCard() {
</div> </div>
{isRTL ? <BackIcon iconSize={24} /> : <NextIcon iconSize={24} />} {isRTL ? <BackIcon iconSize={24} /> : <NextIcon iconSize={24} />}
</div> </div>
))} {giftDetails?.giftType === GiftType.ItemsAndVouchers && (
<Divider style={{ margin: "10px 0" }} /> <Divider style={{ margin: "10px 0" }} />
{giftDetails?.giftType === "items" || )}
(giftDetails?.giftType === "itemsAndVouchers" && ( </>
)}
{(giftDetails?.giftType === GiftType.Items ||
giftDetails?.giftType === GiftType.ItemsAndVouchers) && (
<div <div
style={{ style={{
display: "flex", display: "flex",
@@ -203,7 +211,7 @@ export function GiftCard() {
</ProText> </ProText>
{isRTL ? <BackIcon /> : <NextIcon />} {isRTL ? <BackIcon /> : <NextIcon />}
</div> </div>
))} )}
</ProInputCard> </ProInputCard>
<GiftAmountBottomSheet <GiftAmountBottomSheet
isOpen={isGiftAmountBottomSheetOpen} isOpen={isGiftAmountBottomSheetOpen}

View File

@@ -85,7 +85,7 @@ export default function CheckoutPage() {
<OfficeDetails /> */} <OfficeDetails /> */}
{/* <GiftDetails /> */} {/* <GiftDetails /> */}
{/* <BriefMenu /> */} {/* <BriefMenu /> */}
{orderType !== OrderType.Redeem && <CouponCard />} {orderType !== OrderType.Redeem && orderType !== OrderType.Gift && <CouponCard />}
{/* Collection Method */} {/* Collection Method */}
{orderType === OrderType.Pickup && ( {orderType === OrderType.Pickup && (
@@ -123,7 +123,7 @@ export default function CheckoutPage() {
)} )}
{/* Reward Your Waiter */} {/* Reward Your Waiter */}
{orderType !== OrderType.Redeem && <RewardWaiterCard />} {orderType !== OrderType.Redeem && orderType !== OrderType.Gift && <RewardWaiterCard />}
<BriefMenuCard /> <BriefMenuCard />
<Ads1 /> <Ads1 />
<OrderSummary /> <OrderSummary />

View File

@@ -44,13 +44,7 @@ export function MenuFooter() {
}} }}
> >
<Link <Link
to={ to={totalItems === 0 ? "#" : `/${subdomain}/cart`}
totalItems === 0
? "#"
: orderType === OrderType.Pay
? `/${subdomain}/pay`
: `/${subdomain}/cart`
}
onClick={(e) => { onClick={(e) => {
if (totalItems === 0) { if (totalItems === 0) {
e.preventDefault(); e.preventDefault();
@@ -106,9 +100,7 @@ export function MenuFooter() {
margin: "0 10px", margin: "0 10px",
}} }}
> >
{orderType === OrderType.Pay {t("menu.viewCart")}
? t("menu.pay")
: t("menu.viewCart")}
</ProText> </ProText>
</Button> </Button>
<div <div

View File

@@ -260,7 +260,6 @@ export default function RestaurantServices() {
onClose={() => setIsGiftTypeBottomSheetOpen(false)} onClose={() => setIsGiftTypeBottomSheetOpen(false)}
onSave={() => { onSave={() => {
setIsGiftTypeBottomSheetOpen(false); setIsGiftTypeBottomSheetOpen(false);
navigate(`/${subdomain}/menu?orderType=${OrderType.Gift}`);
}} }}
/> />
</div> </div>