add rstaurant opening hours
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { PlusOutlined } from "@ant-design/icons";
|
||||
import { Button } from "antd";
|
||||
import { Button, message } from "antd";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useAppSelector } from "redux/hooks.ts";
|
||||
import { useGetRestaurantDetailsQuery } from "redux/api/others";
|
||||
import { colors } from "ThemeConstants.ts";
|
||||
import styles from "./AddToCartButton.module.css";
|
||||
|
||||
@@ -12,6 +13,17 @@ export function AddToCartButton() {
|
||||
|
||||
const { subdomain } = useParams();
|
||||
const navigate = useNavigate();
|
||||
const { data: restaurant } = useGetRestaurantDetailsQuery(subdomain, {
|
||||
skip: !subdomain,
|
||||
});
|
||||
|
||||
const handleClick = () => {
|
||||
if (restaurant && !restaurant.isOpened) {
|
||||
message.warning(t("menu.restaurantIsClosed"));
|
||||
return;
|
||||
}
|
||||
navigate(`/${subdomain}/menu`);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button
|
||||
@@ -20,9 +32,7 @@ export function AddToCartButton() {
|
||||
iconPosition="start"
|
||||
icon={<PlusOutlined title="add" className={styles.plusIcon} />}
|
||||
size="small"
|
||||
onClick={() => {
|
||||
navigate(`/${subdomain}/menu`);
|
||||
}}
|
||||
onClick={handleClick}
|
||||
className={`${styles.addButton} ${isRTL ? styles.addButtonRTL : styles.addButtonLTR}`}
|
||||
style={{ backgroundColor: colors.primary }}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user