apply call waiter api

This commit is contained in:
2026-01-17 12:14:19 +03:00
parent f97b83062c
commit 5cb681c4a8
6 changed files with 34 additions and 7 deletions

View File

@@ -178,7 +178,9 @@
"wednesday": "الأربعاء",
"thursday": "الخميس",
"friday": "الجمعة",
"saturday": "السبت"
"saturday": "السبت",
"selectYourTable": "اختر طاولتك",
"calledWaiterSuccess": "تم اتصال الرادير بنجاح"
},
"cart": {
"addSpecialRequestOptional": "إضافة طلب خاص (اختياري)",

View File

@@ -190,7 +190,9 @@
"wednesday": "Wednesday",
"thursday": "Thursday",
"friday": "Friday",
"saturday": "Saturday"
"saturday": "Saturday",
"selectYourTable": "Select your table",
"calledWaiterSuccess": "Waiter has been called successfully"
},
"cart": {
"remainingToPay": "Remaining to Pay",

View File

@@ -872,8 +872,6 @@ export const selectGrandTotal = (state: RootState) => {
? Number(state.order.restaurant?.delivery_fees) || 0
: 0;
console.log(subtotal, totalDiscount, taxAmount, deliveryFee);
return (
subtotal -
totalDiscount +

View File

@@ -1,5 +1,5 @@
import { StarFilled } from "@ant-design/icons";
import { Button, Image, Select, Space } from "antd";
import { Button, Image, message, Select, Space } from "antd";
import { FloatingButton } from "components/FloatingButton/FloatingButton";
import LogoContainerIcon from "components/Icons/LogoContainerIcon";
import ImageWithFallback from "components/ImageWithFallback";
@@ -12,6 +12,7 @@ import { OrderType } from "pages/checkout/hooks/types.ts";
import { useTranslation } from "react-i18next";
import { useParams } from "react-router-dom";
import {
useCallWaiterMutation,
useGetMenuQuery,
useGetRestaurantDetailsQuery,
} from "redux/api/others";
@@ -37,7 +38,7 @@ import { OrderTypesBottomSheet } from "components/CustomBottomSheet/OrderTypesBo
function MenuPage() {
const { subdomain } = useParams();
const { isRTL } = useAppSelector((state) => state.locale);
const { orderType } = useAppSelector((state) => state.order);
const { orderType, table } = useAppSelector((state) => state.order);
const { token } = useAppSelector((state) => state.auth);
const { t } = useTranslation();
const { data: restaurant, isLoading: isLoadingRestaurant } =
@@ -56,6 +57,7 @@ function MenuPage() {
const [isOpeningTimesOpen, setIsOpeningTimesOpen] = useState(false);
const [isOrderTypesOpen, setIsOrderTypesOpen] = useState(false);
const orderTypeOptions = enumToSelectOptions(OrderType, t, "orderTypes");
const [callWaiter] = useCallWaiterMutation()
// Automatically load restaurant taxes when restaurant data is available
useRestaurant(restaurant);
@@ -203,6 +205,19 @@ function MenuPage() {
backgroundColor: "#EBEBEC",
border: "none",
}}
onClick={() => {
if (table) callWaiter({
table_id: table,
call_reason: "call_waiter",
}).unwrap().then(() => {
message.success(t("menu.calledWaiterSuccess"));
}).catch((err) => {
message.error(err.data.message);
})
else
message.info(t("menu.selectYourTable"));
}
}
>
<ProText
style={{

View File

@@ -13,6 +13,7 @@ import {
REDEEM_DETAILS_URL,
LOYALTY_HISTORY_URL,
CREATE_GIFT_AMOUNT_URL,
CALL_WAITER_URL,
OPENING_TIMES_URL,
} from "utils/constants";
@@ -221,6 +222,13 @@ export const branchApi = baseApi.injectEndpoints({
return response.result;
},
}),
callWaiter: builder.mutation({
query: (body: any) => ({
url: CALL_WAITER_URL,
method: "POST",
body,
}),
}),
}),
});
export const {
@@ -239,4 +247,5 @@ export const {
useGetLoyaltyHistoryQuery,
useCreateGiftAmountMutation,
useGetOpeningTimesQuery,
useCallWaiterMutation
} = branchApi;

View File

@@ -112,4 +112,5 @@ export const EGIFT_CARDS_URL = `${BASE_URL}gift/cards`;
export const REDEEM_DETAILS_URL = `${BASE_URL}gift/getGiftOrderByVoucherCode`;
export const LOYALTY_HISTORY_URL = `${BASE_URL}loyaltyHistory`;
export const CREATE_GIFT_AMOUNT_URL = `${BASE_URL}gift/addGiftAmount`;
export const OPENING_TIMES_URL = `${BASE_URL}restaurant/getWorkingHours`;
export const OPENING_TIMES_URL = `${BASE_URL}restaurant/getWorkingHours`;
export const CALL_WAITER_URL = `${BASE_URL}call_waiter`;