add loader upon redirect to thawani online payment third part
This commit is contained in:
@@ -106,24 +106,39 @@ export default function useOrder() {
|
|||||||
}
|
}
|
||||||
: {}),
|
: {}),
|
||||||
})
|
})
|
||||||
.then((res: any) => {
|
.then((res: unknown) => {
|
||||||
if (res.error)
|
const mutationResult = res as {
|
||||||
message.error(res.error.data.message || t("order.createOrderFailed"));
|
data?: { result?: { orderID?: string } };
|
||||||
|
error?: { data?: { message?: string } };
|
||||||
|
};
|
||||||
|
if (mutationResult.error)
|
||||||
|
message.error(
|
||||||
|
mutationResult.error.data?.message || t("order.createOrderFailed"),
|
||||||
|
);
|
||||||
else {
|
else {
|
||||||
if (orderType === "gift")
|
const redirectMessageKey = "order-redirect-loader";
|
||||||
// navigate(`/${PAYMENT_CONFIRMATION_URL}/${res.data.result.orderID}`, {
|
if (orderType === OrderType.Gift && mutationResult.data?.result?.orderID) {
|
||||||
// replace: false,
|
message.loading({
|
||||||
// });
|
content: t("order.redirectingToPayment", {
|
||||||
window.location.href = `${PAYMENT_CONFIRMATION_URL}/${res.data.result.orderID}`;
|
defaultValue: "Redirecting to payment...",
|
||||||
// window.open(
|
}),
|
||||||
// `${PAYMENT_CONFIRMATION_URL}/${res.data.result.orderID}`,
|
key: redirectMessageKey,
|
||||||
// );
|
duration: 0,
|
||||||
else navigate(`/${subdomain}/order/${res.data.result.orderID}`);
|
});
|
||||||
|
window.location.href = `${PAYMENT_CONFIRMATION_URL}/${mutationResult.data.result.orderID}`;
|
||||||
|
} else {
|
||||||
|
message.destroy(redirectMessageKey);
|
||||||
|
if (mutationResult.data?.result?.orderID) {
|
||||||
|
navigate(`/${subdomain}/order/${mutationResult.data.result.orderID}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
dispatch(clearCart());
|
dispatch(clearCart());
|
||||||
localStorage.setItem("orderID", res.data.result.orderID);
|
if (mutationResult.data?.result?.orderID) {
|
||||||
|
localStorage.setItem("orderID", mutationResult.data.result.orderID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: unknown) => {
|
||||||
console.error("Create Order failed:", error);
|
console.error("Create Order failed:", error);
|
||||||
});
|
});
|
||||||
}, [
|
}, [
|
||||||
|
|||||||
Reference in New Issue
Block a user