From 096f131eafd827aabcaf12f73f17d1aa7263412c Mon Sep 17 00:00:00 2001 From: Mohammed Al-yaseen Date: Wed, 29 Oct 2025 00:37:41 +0300 Subject: [PATCH] temporary code to fix loop --- src/pages/restaurant/page.tsx | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/pages/restaurant/page.tsx b/src/pages/restaurant/page.tsx index 0243b2f..d1212b2 100644 --- a/src/pages/restaurant/page.tsx +++ b/src/pages/restaurant/page.tsx @@ -5,30 +5,29 @@ import XIcon from "components/Icons/social/XIcon"; import { LanguageSwitch } from "components/LanguageSwitch/LanguageSwitch"; import ProText from "components/ProText"; import ProTitle from "components/ProTitle"; -import { useAppSelector, useAppDispatch } from "redux/hooks"; +import { useAppDispatch, useAppSelector } from "redux/hooks"; import styles from "./restaurant.module.css"; import RestaurantServices from "./RestaurantServices"; // Import the Client Component for localStorage handling import Ads1 from "components/Ads/Ads1"; import { Loader } from "components/Loader/Loader"; -import { useRestaurant } from "hooks/useRestaurant"; import { - useParams, + updateOrderType +} from "features/order/orderSlice.ts"; +import { useRestaurant } from "hooks/useRestaurant"; +import { OrderType } from "pages/checkout/hooks/types.ts"; +import { useEffect } from "react"; +import { Outlet, useLocation, + useParams, useSearchParams, } from "react-router-dom"; import { useGetRestaurantDetailsQuery } from "redux/api/others"; import LocalStorageHandler from "../menu/components/LocalStorageHandler"; -import { useEffect } from "react"; -import { - updateOrderType, - CART_STORAGE_KEYS, -} from "features/order/orderSlice.ts"; -import { OrderType } from "pages/checkout/hooks/types.ts"; -const storedOrderType = localStorage.getItem(CART_STORAGE_KEYS.ORDER_TYPE); +// const storedOrderType = localStorage.getItem(CART_STORAGE_KEYS.ORDER_TYPE); export default function RestaurantPage() { const dispatch = useAppDispatch(); @@ -48,13 +47,13 @@ export default function RestaurantPage() { const urlOrderType = searchParams.get("orderType"); if (urlOrderType && urlOrderType !== orderType) dispatch(updateOrderType(urlOrderType as OrderType)); - else if ( - storedOrderType && - storedOrderType !== "" && - storedOrderType !== orderType - ) - dispatch(updateOrderType(storedOrderType as OrderType)); - }, [searchParams, orderType]); + // else if ( + // storedOrderType && + // storedOrderType !== "" && + // storedOrderType !== orderType + // ) + // dispatch(updateOrderType(storedOrderType as OrderType)); + }, [searchParams, orderType, dispatch]); if (isLoading) { return ;