update restaurant details source & add loyalty icon

This commit is contained in:
2025-10-20 21:42:48 +03:00
parent c7f5620f5a
commit 6a6f92aefc
15 changed files with 305 additions and 205 deletions

View File

@@ -5,7 +5,7 @@ import {
ORDERS_URL,
PRODUCTS_AND_CATEGORIES_URL,
RESTAURANT_DETAILS_URL,
TABLES_URL
TABLES_URL,
} from "utils/constants";
import { OrderDetails } from "pages/checkout/hooks/types";
@@ -16,10 +16,15 @@ import { baseApi } from "./apiSlice";
export const branchApi = baseApi.injectEndpoints({
endpoints: (builder) => ({
getRestaurantDetails: builder.query<RestaurantDetails, string | void>({
query: (restaurantId: string) =>
`${RESTAURANT_DETAILS_URL}${restaurantId}`,
query: (restaurantId: string) => ({
url: RESTAURANT_DETAILS_URL,
method: "POST",
body: {
restaurant_id: restaurantId,
},
}),
transformResponse: (response: any) => {
return response.result;
return response?.result?.restaurants?.[0];
},
}),
getMenu: builder.query<any, string | void>({
@@ -55,10 +60,7 @@ export const branchApi = baseApi.injectEndpoints({
}),
invalidatesTags: ["Orders"],
}),
getTables: builder.query<
any,
{ restaurantID: string; tableType: string }
>({
getTables: builder.query<any, { restaurantID: string; tableType: string }>({
query: ({
restaurantID,
tableType,
@@ -77,8 +79,17 @@ export const branchApi = baseApi.injectEndpoints({
return response.result.data;
},
}),
getOrderDetails: builder.query<OrderDetails, { orderID: string; restaurantID: string }>({
query: ({ orderID, restaurantID }: { orderID: string; restaurantID: string }) => ({
getOrderDetails: builder.query<
OrderDetails,
{ orderID: string; restaurantID: string }
>({
query: ({
orderID,
restaurantID,
}: {
orderID: string;
restaurantID: string;
}) => ({
url: `${ORDER_DETAILS_URL}/${orderID}`,
method: "POST",
body: {
@@ -98,5 +109,5 @@ export const {
useGetOrdersQuery,
useGetTablesQuery,
useGetOrderDetailsQuery,
useCancelOrderMutation
useCancelOrderMutation,
} = branchApi;