diff --git a/src/components/CustomBottomSheet/CancelOrderBottomSheet.tsx b/src/components/CustomBottomSheet/CancelOrderBottomSheet.tsx index 9da0efe..4c13355 100644 --- a/src/components/CustomBottomSheet/CancelOrderBottomSheet.tsx +++ b/src/components/CustomBottomSheet/CancelOrderBottomSheet.tsx @@ -18,14 +18,14 @@ export function CancelOrderBottomSheet() { const { t } = useTranslation(); const [isOpen, setIsOpen] = useState(false); const { isRTL } = useAppSelector((state) => state.locale); - const { orderID } = useParams(); + const { orderId } = useParams(); const [cancelOrder] = useCancelOrderMutation(); const handleCancelOrder = () => { setIsOpen(false); cancelOrder({ - orderID: orderID, + orderID: orderId || "", }).then((res: any) => { if (res.error) { message.error(res.error.data.message); @@ -89,6 +89,7 @@ export function CancelOrderBottomSheet() { alignItems: "center", justifyContent: "center", gap: 10, + marginTop: 15, }} > diff --git a/src/pages/restaurant/page.tsx b/src/pages/restaurant/page.tsx index e8c6c37..0f43644 100644 --- a/src/pages/restaurant/page.tsx +++ b/src/pages/restaurant/page.tsx @@ -24,6 +24,7 @@ import { OrderType } from "pages/checkout/hooks/types.ts"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { + Link, Outlet, useLocation, useParams, @@ -113,15 +114,21 @@ export default function RestaurantPage() {
- -
+ + + + + + + -
+ + {/* Order Details Bottom Sheet - Moved outside the container */} diff --git a/src/redux/api/others.ts b/src/redux/api/others.ts index 82381ef..81acca5 100644 --- a/src/redux/api/others.ts +++ b/src/redux/api/others.ts @@ -5,13 +5,15 @@ import { ORDER_DETAILS_URL, ORDERS_URL, PRODUCTS_AND_CATEGORIES_URL, + RATE_ORDER_URL, RESTAURANT_DETAILS_URL, TABLES_URL, + USER_DETAILS_URL, } from "utils/constants"; import { OrderDetails } from "pages/checkout/hooks/types"; import menuParser from "pages/menu/helper"; -import { DiscountResultType, RestaurantDetails } from "utils/types/appTypes"; +import { DiscountResultType, RestaurantDetails, UserType } from "utils/types/appTypes"; import { baseApi } from "./apiSlice"; export const branchApi = baseApi.injectEndpoints({ @@ -55,10 +57,12 @@ export const branchApi = baseApi.injectEndpoints({ invalidatesTags: ["Orders", "Restaurant"], }), cancelOrder: builder.mutation({ - query: (body: any) => ({ + query: ({ orderID }: { orderID: string }) => ({ url: CANCEL_ORDER_URL, method: "POST", - body, + body: { + order_id: orderID, + }, }), invalidatesTags: ["Orders", "Restaurant"], }), @@ -103,7 +107,7 @@ export const branchApi = baseApi.injectEndpoints({ }, }), getDiscount: builder.mutation< - DiscountResultType, + DiscountResultType, { discountCode: string; restaurantID: string } >({ query: ({ @@ -113,13 +117,48 @@ export const branchApi = baseApi.injectEndpoints({ discountCode: string; restaurantID: string; }) => ({ - url: `${DISCOUNT_URL}/${discountCode}/${restaurantID}`, + url: `${DISCOUNT_URL}/${discountCode}/${restaurantID}`, method: "GET", }), transformResponse: (response: any) => { return response.result; }, }), + getUserDetails: builder.query< + UserType, + void + >({ + query: () => ({ + url: `${USER_DETAILS_URL}`, + method: "GET", + }), + transformResponse: (response: any) => { + return response.result; + }, + }), + rateOrder: builder.mutation({ + query: ({ + orderID, + rating, + comment, + userID, + }: { + orderID: string; + rating: number; + comment: string; + userID: string; + }) => ({ + url: RATE_ORDER_URL, + method: "POST", + body: { + order_id: orderID, + rating, + comment, + user_id: userID, + }, + }), + invalidatesTags: ["Orders", "Restaurant"], + }), }), }); export const { @@ -130,5 +169,7 @@ export const { useGetTablesQuery, useGetOrderDetailsQuery, useCancelOrderMutation, - useGetDiscountMutation + useGetDiscountMutation, + useRateOrderMutation, + useGetUserDetailsQuery, } = branchApi; diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 32e6827..44d7745 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -99,8 +99,10 @@ export const PRODUCT_DETAILS_URL = `${BASE_URL}getOptionsForItem/`; export const ORDERS_URL = `${BASE_URL}customer_orders`; export const ORDER_DETAILS_URL = `${BASE_URL}restaurant/getOneOrderForWebmenu`; export const CREATE_ORDER_URL = `${BASE_URL}create_order_webmenu`; -export const CANCEL_ORDER_URL = `${BASE_URL}restaurant/cancelOrder`; +export const CANCEL_ORDER_URL = `${BASE_URL}cancelOrder`; +export const RATE_ORDER_URL = `${BASE_URL}rate_order`; export const TABLES_URL = `${BASE_URL}restaurant/getTables`; +export const USER_DETAILS_URL = `${BASE_URL}user_profile`; export const LOGIN_URL = `${API_BASE_URL}login`; export const SEND_OTP_URL = `${API_BASE_URL}sendOtp`; export const CONFIRM_OTP_URL = `${API_BASE_URL}confirmOtp`;