Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 1x 6x 6x 6x 6x 6x 2x 2x 2x 1x 1x 1x 1x 2x 2x 1x 1x | import { getTransaction } from "@components/ManageMoney/TransactionTable/TransactionInfoModal/utils";
import NiceModal from "@ebay/nice-modal-react";
import { useUser } from "@hooks/common/useUser";
import { useGetUser } from "@services/api/onboarding/user";
import { RESOURCE_NOT_FOUND } from "modals/modal_names";
import { useEffect } from "react";
import { useLocation, useNavigate } from "react-router-dom";
export const useRedirectTransaction = () => {
const navigate = useNavigate();
const location = useLocation();
const { merchantData } = useGetUser();
const { isAcquirer, isMerchant } = useUser();
useEffect(() => {
Eif (merchantData) {
const path = isMerchant
? "/merchant/manage-money"
: isAcquirer
? `/acquirer/transactions`
: `/provider/transactions`;
const checkAccessToTransaction = async (transactionId: string) => {
try {
const transactionData = await getTransaction(transactionId);
navigate(path, { state: { transactionData } });
} catch (error) {
navigate(path);
NiceModal.show(RESOURCE_NOT_FOUND, {
secondaryText: `You can also log in to the provider or acquirer account responsible for this merchant.`,
});
}
};
const searchParams = new URLSearchParams(location.search);
if (searchParams.has("transactionId")) {
const transactionId = searchParams.get("transactionId") || "";
checkAccessToTransaction(transactionId);
}
}
}, [merchantData, location.search]);
};
|