fix take "orderType" from url

This commit is contained in:
2025-10-29 15:07:25 +03:00
parent e50d34c8f5
commit 144cfa3f3a

View File

@@ -27,11 +27,13 @@ import {
CART_STORAGE_KEYS,
} from "features/order/orderSlice.ts";
import { OrderType } from "pages/checkout/hooks/types.ts";
import { useTranslation } from "react-i18next";
const storedOrderType = localStorage.getItem(CART_STORAGE_KEYS.ORDER_TYPE);
export default function RestaurantPage() {
const dispatch = useAppDispatch();
const { t } = useTranslation();
const param = useParams();
const [searchParams] = useSearchParams();
const { pathname } = useLocation();
@@ -48,21 +50,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
)
else if (storedOrderType && !orderType)
dispatch(updateOrderType(storedOrderType as OrderType));
}, [searchParams, orderType]);
if (isLoading) {
return <Loader />;
}
if (isLoading) return <Loader />;
if (!restaurant) {
return <div>Restaurant not found</div>;
}
if (!restaurant) return <div>{t("Restaurant not found")}</div>;
if (restaurant) {
localStorage.setItem("restaurantID", restaurant.restautantId);