fix take "orderType" from url
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user