From a5418b372422518aaceccfca7706ea5deb40020c Mon Sep 17 00:00:00 2001 From: Mohammed Al-yaseen Date: Sat, 18 Oct 2025 16:32:22 +0300 Subject: [PATCH] fixes --- src/pages/cart/components/TableNumberCard.tsx | 5 ++- .../menu/components/LocalStorageHandler.tsx | 43 ++++++++++--------- src/pages/menu/page.tsx | 6 +-- src/pages/order/page.tsx | 7 ++- src/pages/restaurant/page.tsx | 1 - 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/pages/cart/components/TableNumberCard.tsx b/src/pages/cart/components/TableNumberCard.tsx index ae80c8b..f70ac45 100644 --- a/src/pages/cart/components/TableNumberCard.tsx +++ b/src/pages/cart/components/TableNumberCard.tsx @@ -38,7 +38,10 @@ export default function TableNumberCard() { mode="multiple" placeholder={t("cart.tableNumber")} size="large" - options={tableList} + options={tableList?.map((table: any) => ({ + label: table.name, + value: table.id, + }))} style={{ width: "100%", height: 50, diff --git a/src/pages/menu/components/LocalStorageHandler.tsx b/src/pages/menu/components/LocalStorageHandler.tsx index 46ac70f..a718a67 100644 --- a/src/pages/menu/components/LocalStorageHandler.tsx +++ b/src/pages/menu/components/LocalStorageHandler.tsx @@ -4,24 +4,24 @@ import { useEffect } from "react"; // Cart storage keys - same as in CartContext const CART_STORAGE_KEYS = { - ITEMS: 'fascano_cart_items', - SPECIAL_REQUEST: 'fascano_special_request', - COUPON: 'fascano_coupon', - TIP: 'fascano_tip', - TABLES: 'fascano_tables', - LOCATION: 'fascano_location', - ROOM_DETAILS: 'fascano_room_details', - OFFICE_DETAILS: 'fascano_office_details', - GIFT_DETAILS: 'fascano_gift_details', - ESTIMATE_TIME: 'fascano_estimate_time', - ESTIMATE_TIME_DATE: 'fascano_estimate_time_date', - ESTIMATE_TIME_TIME: 'fascano_estimate_time_time', - COLLECTION_METHOD: 'fascano_collection_method', + ITEMS: "fascano_cart_items", + SPECIAL_REQUEST: "fascano_special_request", + COUPON: "fascano_coupon", + TIP: "fascano_tip", + TABLES: "fascano_tables", + LOCATION: "fascano_location", + ROOM_DETAILS: "fascano_room_details", + OFFICE_DETAILS: "fascano_office_details", + GIFT_DETAILS: "fascano_gift_details", + ESTIMATE_TIME: "fascano_estimate_time", + ESTIMATE_TIME_DATE: "fascano_estimate_time_date", + ESTIMATE_TIME_TIME: "fascano_estimate_time_time", + COLLECTION_METHOD: "fascano_collection_method", } as const; const clearCartFromLocalStorage = () => { // Clear all cart-related data from localStorage - Object.values(CART_STORAGE_KEYS).forEach(key => { + Object.values(CART_STORAGE_KEYS).forEach((key) => { localStorage.removeItem(key); }); }; @@ -29,26 +29,27 @@ const clearCartFromLocalStorage = () => { export default function LocalStorageHandler({ restaurantID, restaurantName, - orderType, }: { restaurantID: string; restaurantName: string; - orderType: string; }) { useEffect(() => { // Check if restaurant has changed const currentStoredRestaurantID = localStorage.getItem("restaurantID"); - + // If there's a stored restaurant ID and it's different from the current one, clear the cart - if (currentStoredRestaurantID && currentStoredRestaurantID !== restaurantID) { + if ( + currentStoredRestaurantID && + currentStoredRestaurantID !== restaurantID + ) { clearCartFromLocalStorage(); } - + // Update localStorage with new values localStorage.setItem("restaurantID", restaurantID); localStorage.setItem("restaurantName", restaurantName); - localStorage.setItem("orderType", orderType); - }, [restaurantID, restaurantName, orderType]); + // localStorage.setItem("orderType", orderType); + }, [restaurantID, restaurantName]); return null; } diff --git a/src/pages/menu/page.tsx b/src/pages/menu/page.tsx index 1028e16..f9e9426 100644 --- a/src/pages/menu/page.tsx +++ b/src/pages/menu/page.tsx @@ -8,7 +8,7 @@ import ProTitle from "components/ProTitle"; import { useScrollHandler } from "contexts/ScrollHandlerContext"; import useBreakPoint from "hooks/useBreakPoint"; import { useTranslation } from "react-i18next"; -import { useParams, useSearchParams } from "react-router-dom"; +import { useParams } from "react-router-dom"; import { useGetMenuQuery, useGetRestaurantDetailsQuery, @@ -28,8 +28,6 @@ import styles from "./menu.module.css"; function MenuPage() { const { id } = useParams(); - const [searchParams] = useSearchParams(); - const orderType = searchParams.get("orderType"); const { isRTL } = useAppSelector((state) => state.locale); const { t } = useTranslation(); const { data: restaurantDetails, isLoading: isLoadingRestaurant } = @@ -45,7 +43,6 @@ function MenuPage() { ); const { categoryRefs } = useScrollHandler(); const { isMobile, isTablet, isDesktop } = useBreakPoint(); - const isLoading = isLoadingRestaurant || isLoadingMenu; return ( @@ -53,7 +50,6 @@ function MenuPage() { {isLoading ? ( diff --git a/src/pages/order/page.tsx b/src/pages/order/page.tsx index 9a5e82f..81c7a56 100644 --- a/src/pages/order/page.tsx +++ b/src/pages/order/page.tsx @@ -10,6 +10,7 @@ import ProHeader from "components/ProHeader/ProHeader"; import ProInputCard from "components/ProInputCard/ProInputCard"; import ProText from "components/ProText"; import ProTitle from "components/ProTitle"; +import dayjs from "dayjs"; import { useTranslation } from "react-i18next"; import { useParams } from "react-router-dom"; import { useGetOrderDetailsQuery } from "redux/api/others"; @@ -71,6 +72,7 @@ export default function OrderPage() { className={styles.profileImage} width={50} height={50} + preview={false} />
@@ -105,7 +107,10 @@ export default function OrderPage() { - ordered :- Today - {orderDetails?.status[0]?.pivot?.created_at.split(" ")[1]} PM + ordered :- Today -{" "} + {dayjs(orderDetails?.status[0]?.pivot?.created_at).format( + "h:mm A", + )}
diff --git a/src/pages/restaurant/page.tsx b/src/pages/restaurant/page.tsx index 7278588..79418be 100644 --- a/src/pages/restaurant/page.tsx +++ b/src/pages/restaurant/page.tsx @@ -87,7 +87,6 @@ export default function RestaurantPage() { );