temporary code to fix loop

This commit is contained in:
2025-10-29 00:37:41 +03:00
parent ad9c9ce516
commit 096f131eaf

View File

@@ -5,30 +5,29 @@ import XIcon from "components/Icons/social/XIcon";
import { LanguageSwitch } from "components/LanguageSwitch/LanguageSwitch"; import { LanguageSwitch } from "components/LanguageSwitch/LanguageSwitch";
import ProText from "components/ProText"; import ProText from "components/ProText";
import ProTitle from "components/ProTitle"; import ProTitle from "components/ProTitle";
import { useAppSelector, useAppDispatch } from "redux/hooks"; import { useAppDispatch, useAppSelector } from "redux/hooks";
import styles from "./restaurant.module.css"; import styles from "./restaurant.module.css";
import RestaurantServices from "./RestaurantServices"; import RestaurantServices from "./RestaurantServices";
// Import the Client Component for localStorage handling // Import the Client Component for localStorage handling
import Ads1 from "components/Ads/Ads1"; import Ads1 from "components/Ads/Ads1";
import { Loader } from "components/Loader/Loader"; import { Loader } from "components/Loader/Loader";
import { useRestaurant } from "hooks/useRestaurant";
import { 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, Outlet,
useLocation, useLocation,
useParams,
useSearchParams, useSearchParams,
} from "react-router-dom"; } from "react-router-dom";
import { useGetRestaurantDetailsQuery } from "redux/api/others"; import { useGetRestaurantDetailsQuery } from "redux/api/others";
import LocalStorageHandler from "../menu/components/LocalStorageHandler"; 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() { export default function RestaurantPage() {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
@@ -48,13 +47,13 @@ export default function RestaurantPage() {
const urlOrderType = searchParams.get("orderType"); const urlOrderType = searchParams.get("orderType");
if (urlOrderType && urlOrderType !== orderType) if (urlOrderType && urlOrderType !== orderType)
dispatch(updateOrderType(urlOrderType as OrderType)); dispatch(updateOrderType(urlOrderType as OrderType));
else if ( // else if (
storedOrderType && // storedOrderType &&
storedOrderType !== "" && // storedOrderType !== "" &&
storedOrderType !== orderType // storedOrderType !== orderType
) // )
dispatch(updateOrderType(storedOrderType as OrderType)); // dispatch(updateOrderType(storedOrderType as OrderType));
}, [searchParams, orderType]); }, [searchParams, orderType, dispatch]);
if (isLoading) { if (isLoading) {
return <Loader />; return <Loader />;