From ce68b8b97844baefb49084cf2438edac2fbaf291 Mon Sep 17 00:00:00 2001 From: Mohammed Al-yaseen Date: Wed, 14 Jan 2026 21:30:32 +0300 Subject: [PATCH] fixes --- .../CancelOrderBottomSheet.tsx | 6 ++- src/components/InputCard.tsx | 5 ++- src/hooks/useRestaurant.ts | 21 +++++++++- .../components/CartMobileTabletLayout.tsx | 2 +- src/pages/checkout/page.tsx | 8 ++-- src/pages/order/page.tsx | 40 +++++++++---------- 6 files changed, 52 insertions(+), 30 deletions(-) diff --git a/src/components/CustomBottomSheet/CancelOrderBottomSheet.tsx b/src/components/CustomBottomSheet/CancelOrderBottomSheet.tsx index 39d8359..a0e8599 100644 --- a/src/components/CustomBottomSheet/CancelOrderBottomSheet.tsx +++ b/src/components/CustomBottomSheet/CancelOrderBottomSheet.tsx @@ -6,7 +6,7 @@ import CancelPopupIcon from "components/Icons/CancelPopupIcon"; import NextIcon from "components/Icons/NextIcon"; import { useState } from "react"; import { useTranslation } from "react-i18next"; -import { useParams } from "react-router-dom"; +import { useNavigate, useParams } from "react-router-dom"; import { useCancelOrderMutation } from "redux/api/others"; import { useAppSelector } from "redux/hooks"; import { ProBottomSheet } from "../ProBottomSheet/ProBottomSheet"; @@ -18,7 +18,8 @@ export function CancelOrderBottomSheet() { const { t } = useTranslation(); const [isOpen, setIsOpen] = useState(false); const { isRTL } = useAppSelector((state) => state.locale); - const { orderId } = useParams(); + const { orderId, subdomain } = useParams(); + const navigate = useNavigate(); const [cancelOrder] = useCancelOrderMutation(); @@ -31,6 +32,7 @@ export function CancelOrderBottomSheet() { message.error(res.error.data.message); } else { message.success(res.data.message); + navigate(`/${subdomain}`); } }); }; diff --git a/src/components/InputCard.tsx b/src/components/InputCard.tsx index 12226ed..007f091 100644 --- a/src/components/InputCard.tsx +++ b/src/components/InputCard.tsx @@ -8,6 +8,7 @@ interface InputCardProps { name: string; placeholder: string; value: string; + required?: boolean; } export default function InputCard({ @@ -15,6 +16,7 @@ export default function InputCard({ name, placeholder, value, + required = false, }: InputCardProps) { const dispatch = useAppDispatch(); const handleChange = (e: React.ChangeEvent) => { @@ -24,9 +26,8 @@ export default function InputCard({ <> { const dispatch = useAppDispatch(); + const previousRestaurantIdRef = useRef(null); useEffect(() => { if (restaurant) { + const currentRestaurantId = restaurant.restautantId; + + // Check if restaurant has changed + if ( + previousRestaurantIdRef.current !== null && + previousRestaurantIdRef.current !== currentRestaurantId + ) { + // Restaurant changed, clear the cart + dispatch(clearCart()); + } + + // Update the previous restaurant ID + previousRestaurantIdRef.current = currentRestaurantId; + + // Update restaurant in store dispatch(updateRestaurant(restaurant)); } }, [restaurant, dispatch]); diff --git a/src/pages/cart/components/CartMobileTabletLayout.tsx b/src/pages/cart/components/CartMobileTabletLayout.tsx index 70d8e73..5f8c59e 100644 --- a/src/pages/cart/components/CartMobileTabletLayout.tsx +++ b/src/pages/cart/components/CartMobileTabletLayout.tsx @@ -143,7 +143,7 @@ export default function CartMobileTabletLayout({ - + {/* */} diff --git a/src/pages/checkout/page.tsx b/src/pages/checkout/page.tsx index 7c4db58..8ce50b4 100644 --- a/src/pages/checkout/page.tsx +++ b/src/pages/checkout/page.tsx @@ -70,6 +70,7 @@ export default function CheckoutPage() { name="roomNumber" placeholder={t("address.roomNo")} value={order?.roomNumber} + required /> )} {orderType === OrderType.ToOffice && ( @@ -78,6 +79,7 @@ export default function CheckoutPage() { name="officeNumber" placeholder={t("address.officeNo")} value={order?.officeNumber} + required /> )} {orderType === OrderType.Redeem && } @@ -91,7 +93,7 @@ export default function CheckoutPage() { )} {/* Collection Method */} - {orderType === OrderType.Pickup && ( + {/* {orderType === OrderType.Pickup && ( - )} + )} */} {/* Reward Your Waiter */} {/* {orderType !== OrderType.Redeem && orderType !== OrderType.Gift && ( @@ -133,7 +135,7 @@ export default function CheckoutPage() { )} - + {/* */} diff --git a/src/pages/order/page.tsx b/src/pages/order/page.tsx index 69923ab..cf34c96 100644 --- a/src/pages/order/page.tsx +++ b/src/pages/order/page.tsx @@ -450,7 +450,7 @@ export default function OrderPage() { )} - + {/* */} {/* {/* inviteToBill */} - {!hasClosedStatus && ( + {/* {!hasClosedStatus && ( @@ -622,7 +622,7 @@ export default function OrderPage() { - )} + )} */} setIsOpen(false)} /> @@ -671,25 +671,25 @@ export default function OrderPage() { onClose={() => setIsRateOrderOpen(false)} /> - {!hasClosedStatus || - (hasCanceledByCustomerStatus && )} + {(!hasClosedStatus && !hasCanceledByCustomerStatus) && ( + + )} - {hasClosedStatus || - (hasCanceledByCustomerStatus && ( - - - - ))} + {(hasClosedStatus || hasCanceledByCustomerStatus) && ( + + + + )}