order page: integration
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { message } from "antd";
|
||||
import { clearCart, selectCart } from "features/order/orderSlice";
|
||||
import { useCallback } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { useCreateOrderMutation } from "redux/api/others";
|
||||
import { useAppDispatch, useAppSelector } from "redux/hooks";
|
||||
@@ -8,6 +10,7 @@ import { Customer } from "../../otp/types";
|
||||
export default function useOrder() {
|
||||
const dispatch = useAppDispatch();
|
||||
const router = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const { id } = useParams();
|
||||
const restaurantID = localStorage.getItem("restaurantID");
|
||||
const { mobilenumber, user_uuid } = JSON.parse(
|
||||
@@ -59,11 +62,15 @@ export default function useOrder() {
|
||||
useWallet: 0,
|
||||
tip,
|
||||
})
|
||||
.then(() => {
|
||||
dispatch(clearCart());
|
||||
router(`/${id}/order`);
|
||||
.then((res: any) => {
|
||||
if (res.error)
|
||||
message.error(res.error.data.message || t("order.createOrderFailed"));
|
||||
else {
|
||||
dispatch(clearCart());
|
||||
router(`/${id}/order/${res.data.result.orderID}`);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: any) => {
|
||||
console.error("Create Order failed:", error);
|
||||
});
|
||||
}, [
|
||||
@@ -80,6 +87,7 @@ export default function useOrder() {
|
||||
user_uuid,
|
||||
estimateTime,
|
||||
tip,
|
||||
t,
|
||||
dispatch,
|
||||
router,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user