apply order cancaltion

This commit is contained in:
2025-11-24 00:05:25 +03:00
parent b9c5ab69e6
commit 6e8305f9c2
4 changed files with 63 additions and 12 deletions

View File

@@ -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,
}}
>
<CancelPopupIcon />

View File

@@ -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,14 +114,20 @@ export default function RestaurantPage() {
<div className={styles.promotionContainer}>
<Ads1 />
</div>
</div>
<div className={styles.socialIconsContainer}>
<Link to={`https://www.instagram.com/${restaurant?.instagram}`}>
<InstagramIcon className={styles.socialIcon} />
</Link>
<Link to="https://x.com/">
<XIcon className={styles.socialIcon} />
</Link>
<Link to="https://www.snapchat.com/">
<SnapIcon className={styles.socialIcon} />
</Link>
<Link to="https://www.jordan.com/">
<JIcon className={styles.socialIcon} />
</Link>
</div>
</div>

View File

@@ -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"],
}),
@@ -120,6 +124,41 @@ export const branchApi = baseApi.injectEndpoints({
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;

View File

@@ -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`;