add loader upon redirect to thawani online payment third part

This commit is contained in:
2025-11-12 23:26:04 +03:00
parent 3c6835c678
commit c1f2f1a6a6

View File

@@ -106,24 +106,39 @@ export default function useOrder() {
}
: {}),
})
.then((res: any) => {
if (res.error)
message.error(res.error.data.message || t("order.createOrderFailed"));
.then((res: unknown) => {
const mutationResult = res as {
data?: { result?: { orderID?: string } };
error?: { data?: { message?: string } };
};
if (mutationResult.error)
message.error(
mutationResult.error.data?.message || t("order.createOrderFailed"),
);
else {
if (orderType === "gift")
// navigate(`/${PAYMENT_CONFIRMATION_URL}/${res.data.result.orderID}`, {
// replace: false,
// });
window.location.href = `${PAYMENT_CONFIRMATION_URL}/${res.data.result.orderID}`;
// window.open(
// `${PAYMENT_CONFIRMATION_URL}/${res.data.result.orderID}`,
// );
else navigate(`/${subdomain}/order/${res.data.result.orderID}`);
const redirectMessageKey = "order-redirect-loader";
if (orderType === OrderType.Gift && mutationResult.data?.result?.orderID) {
message.loading({
content: t("order.redirectingToPayment", {
defaultValue: "Redirecting to payment...",
}),
key: redirectMessageKey,
duration: 0,
});
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());
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);
});
}, [