apply order cancaltion
This commit is contained in:
@@ -18,14 +18,14 @@ export function CancelOrderBottomSheet() {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const { isRTL } = useAppSelector((state) => state.locale);
|
const { isRTL } = useAppSelector((state) => state.locale);
|
||||||
const { orderID } = useParams();
|
const { orderId } = useParams();
|
||||||
|
|
||||||
const [cancelOrder] = useCancelOrderMutation();
|
const [cancelOrder] = useCancelOrderMutation();
|
||||||
|
|
||||||
const handleCancelOrder = () => {
|
const handleCancelOrder = () => {
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
cancelOrder({
|
cancelOrder({
|
||||||
orderID: orderID,
|
orderID: orderId || "",
|
||||||
}).then((res: any) => {
|
}).then((res: any) => {
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
message.error(res.error.data.message);
|
message.error(res.error.data.message);
|
||||||
@@ -89,6 +89,7 @@ export function CancelOrderBottomSheet() {
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
gap: 10,
|
gap: 10,
|
||||||
|
marginTop: 15,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CancelPopupIcon />
|
<CancelPopupIcon />
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { OrderType } from "pages/checkout/hooks/types.ts";
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
|
Link,
|
||||||
Outlet,
|
Outlet,
|
||||||
useLocation,
|
useLocation,
|
||||||
useParams,
|
useParams,
|
||||||
@@ -113,15 +114,21 @@ export default function RestaurantPage() {
|
|||||||
<div className={styles.promotionContainer}>
|
<div className={styles.promotionContainer}>
|
||||||
<Ads1 />
|
<Ads1 />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.socialIconsContainer}>
|
<div className={styles.socialIconsContainer}>
|
||||||
|
<Link to={`https://www.instagram.com/${restaurant?.instagram}`}>
|
||||||
<InstagramIcon className={styles.socialIcon} />
|
<InstagramIcon className={styles.socialIcon} />
|
||||||
|
</Link>
|
||||||
|
<Link to="https://x.com/">
|
||||||
<XIcon className={styles.socialIcon} />
|
<XIcon className={styles.socialIcon} />
|
||||||
|
</Link>
|
||||||
|
<Link to="https://www.snapchat.com/">
|
||||||
<SnapIcon className={styles.socialIcon} />
|
<SnapIcon className={styles.socialIcon} />
|
||||||
|
</Link>
|
||||||
|
<Link to="https://www.jordan.com/">
|
||||||
<JIcon className={styles.socialIcon} />
|
<JIcon className={styles.socialIcon} />
|
||||||
</div>
|
</Link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Order Details Bottom Sheet - Moved outside the container */}
|
{/* Order Details Bottom Sheet - Moved outside the container */}
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ import {
|
|||||||
ORDER_DETAILS_URL,
|
ORDER_DETAILS_URL,
|
||||||
ORDERS_URL,
|
ORDERS_URL,
|
||||||
PRODUCTS_AND_CATEGORIES_URL,
|
PRODUCTS_AND_CATEGORIES_URL,
|
||||||
|
RATE_ORDER_URL,
|
||||||
RESTAURANT_DETAILS_URL,
|
RESTAURANT_DETAILS_URL,
|
||||||
TABLES_URL,
|
TABLES_URL,
|
||||||
|
USER_DETAILS_URL,
|
||||||
} from "utils/constants";
|
} from "utils/constants";
|
||||||
|
|
||||||
import { OrderDetails } from "pages/checkout/hooks/types";
|
import { OrderDetails } from "pages/checkout/hooks/types";
|
||||||
import menuParser from "pages/menu/helper";
|
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";
|
import { baseApi } from "./apiSlice";
|
||||||
|
|
||||||
export const branchApi = baseApi.injectEndpoints({
|
export const branchApi = baseApi.injectEndpoints({
|
||||||
@@ -55,10 +57,12 @@ export const branchApi = baseApi.injectEndpoints({
|
|||||||
invalidatesTags: ["Orders", "Restaurant"],
|
invalidatesTags: ["Orders", "Restaurant"],
|
||||||
}),
|
}),
|
||||||
cancelOrder: builder.mutation({
|
cancelOrder: builder.mutation({
|
||||||
query: (body: any) => ({
|
query: ({ orderID }: { orderID: string }) => ({
|
||||||
url: CANCEL_ORDER_URL,
|
url: CANCEL_ORDER_URL,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body,
|
body: {
|
||||||
|
order_id: orderID,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
invalidatesTags: ["Orders", "Restaurant"],
|
invalidatesTags: ["Orders", "Restaurant"],
|
||||||
}),
|
}),
|
||||||
@@ -103,7 +107,7 @@ export const branchApi = baseApi.injectEndpoints({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
getDiscount: builder.mutation<
|
getDiscount: builder.mutation<
|
||||||
DiscountResultType,
|
DiscountResultType,
|
||||||
{ discountCode: string; restaurantID: string }
|
{ discountCode: string; restaurantID: string }
|
||||||
>({
|
>({
|
||||||
query: ({
|
query: ({
|
||||||
@@ -113,13 +117,48 @@ export const branchApi = baseApi.injectEndpoints({
|
|||||||
discountCode: string;
|
discountCode: string;
|
||||||
restaurantID: string;
|
restaurantID: string;
|
||||||
}) => ({
|
}) => ({
|
||||||
url: `${DISCOUNT_URL}/${discountCode}/${restaurantID}`,
|
url: `${DISCOUNT_URL}/${discountCode}/${restaurantID}`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
}),
|
}),
|
||||||
transformResponse: (response: any) => {
|
transformResponse: (response: any) => {
|
||||||
return response.result;
|
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 {
|
export const {
|
||||||
@@ -130,5 +169,7 @@ export const {
|
|||||||
useGetTablesQuery,
|
useGetTablesQuery,
|
||||||
useGetOrderDetailsQuery,
|
useGetOrderDetailsQuery,
|
||||||
useCancelOrderMutation,
|
useCancelOrderMutation,
|
||||||
useGetDiscountMutation
|
useGetDiscountMutation,
|
||||||
|
useRateOrderMutation,
|
||||||
|
useGetUserDetailsQuery,
|
||||||
} = branchApi;
|
} = branchApi;
|
||||||
|
|||||||
@@ -99,8 +99,10 @@ export const PRODUCT_DETAILS_URL = `${BASE_URL}getOptionsForItem/`;
|
|||||||
export const ORDERS_URL = `${BASE_URL}customer_orders`;
|
export const ORDERS_URL = `${BASE_URL}customer_orders`;
|
||||||
export const ORDER_DETAILS_URL = `${BASE_URL}restaurant/getOneOrderForWebmenu`;
|
export const ORDER_DETAILS_URL = `${BASE_URL}restaurant/getOneOrderForWebmenu`;
|
||||||
export const CREATE_ORDER_URL = `${BASE_URL}create_order_webmenu`;
|
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 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 LOGIN_URL = `${API_BASE_URL}login`;
|
||||||
export const SEND_OTP_URL = `${API_BASE_URL}sendOtp`;
|
export const SEND_OTP_URL = `${API_BASE_URL}sendOtp`;
|
||||||
export const CONFIRM_OTP_URL = `${API_BASE_URL}confirmOtp`;
|
export const CONFIRM_OTP_URL = `${API_BASE_URL}confirmOtp`;
|
||||||
|
|||||||
Reference in New Issue
Block a user