Compare commits
2 Commits
e95411460f
...
41605781f4
| Author | SHA1 | Date | |
|---|---|---|---|
| 41605781f4 | |||
| a337ee11e2 |
@@ -9,6 +9,7 @@ import LoyaltyAndRewardIcon from "components/Icons/LoyaltyAndRewardIcon";
|
|||||||
import MyOrderIcon from "components/Icons/MyOrderIcon";
|
import MyOrderIcon from "components/Icons/MyOrderIcon";
|
||||||
import { logoutThunk } from "features/auth/authSlice";
|
import { logoutThunk } from "features/auth/authSlice";
|
||||||
import { setLocale, setLocalesThunk } from "features/locale/localeSlice";
|
import { setLocale, setLocalesThunk } from "features/locale/localeSlice";
|
||||||
|
import { clearCart } from "features/order/orderSlice";
|
||||||
import { toggleTheme } from "features/theme/themeSlice";
|
import { toggleTheme } from "features/theme/themeSlice";
|
||||||
import i18n from "i18n/i18n";
|
import i18n from "i18n/i18n";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -106,6 +107,7 @@ export default function useHeaderMenu() {
|
|||||||
label: <div>{t("common.logout")}</div>,
|
label: <div>{t("common.logout")}</div>,
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
dispatch(logoutThunk());
|
dispatch(logoutThunk());
|
||||||
|
dispatch(clearCart());
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
import { Button } from "antd";
|
import { Button } from "antd";
|
||||||
import BackIcon from "components/Icons/BackIcon";
|
import BackIcon from "components/Icons/BackIcon";
|
||||||
import NextIcon from "components/Icons/NextIcon";
|
import NextIcon from "components/Icons/NextIcon";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
import { useAppSelector } from "redux/hooks";
|
import { useAppSelector } from "redux/hooks";
|
||||||
|
|
||||||
interface BackButtonProps {
|
interface BackButtonProps {
|
||||||
navigateBack?: boolean; // true = use router.back(), false = just clear state
|
customRoute?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function BackButton({ navigateBack = true }: BackButtonProps) {
|
export default function BackButton({ customRoute }: BackButtonProps) {
|
||||||
|
const router = useNavigate();
|
||||||
const handleBack = () => {
|
const handleBack = () => {
|
||||||
if (navigateBack) window.history.back();
|
if (customRoute) {
|
||||||
|
router(customRoute);
|
||||||
|
} else {
|
||||||
|
router(-1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const { isRTL } = useAppSelector((state) => state.locale);
|
const { isRTL } = useAppSelector((state) => state.locale);
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ function MenuPage() {
|
|||||||
const { subdomain } = useParams();
|
const { subdomain } = useParams();
|
||||||
const { isRTL } = useAppSelector((state) => state.locale);
|
const { isRTL } = useAppSelector((state) => state.locale);
|
||||||
const { orderType } = useAppSelector((state) => state.order);
|
const { orderType } = useAppSelector((state) => state.order);
|
||||||
|
const { token } = useAppSelector((state) => state.auth);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { data: restaurant, isLoading: isLoadingRestaurant } =
|
const { data: restaurant, isLoading: isLoadingRestaurant } =
|
||||||
useGetRestaurantDetailsQuery(subdomain, {
|
useGetRestaurantDetailsQuery(subdomain, {
|
||||||
@@ -91,7 +92,9 @@ function MenuPage() {
|
|||||||
<div
|
<div
|
||||||
className={`${styles.headerFloatingBtn} ${styles.backButtonContainer}`}
|
className={`${styles.headerFloatingBtn} ${styles.backButtonContainer}`}
|
||||||
>
|
>
|
||||||
<BackButton />
|
<BackButton
|
||||||
|
{...(token ? { customRoute: `/${subdomain}` } : {})}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className={`${styles.headerFloatingBtn} ${styles.orderTypeSelectContainer} order-type-select-container`}
|
className={`${styles.headerFloatingBtn} ${styles.orderTypeSelectContainer} order-type-select-container`}
|
||||||
|
|||||||
Reference in New Issue
Block a user