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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 57x 1x 57x 57x 57x 57x 57x 57x 1x 57x 57x | import {
businessAddressParser,
feesParser,
merchantAgreementParser,
primaryAccountHolderParser,
useBusinessProfileParser,
useMerchantBankAccountsParser,
useMerchantBusinessOwnersParser,
useMerchantInfoParser,
} from "@components/Merchants/MerchantPreview/helpers/parsers";
import { customInstance } from "@services/api";
import { useQuery } from "react-query";
const getMerchantSnapshot = (id: number) => {
return customInstance({
url: `merchants/${id}/snapshot`,
method: "GET",
});
};
type Props = {
merchantId: number;
enabled?: boolean;
};
const useAgreementSnapshot = ({ merchantId, enabled = true }: Props) => {
const { merchantBankAccountsParser } = useMerchantBankAccountsParser();
const { businessProfileParser } = useBusinessProfileParser();
const { merchantInfoParser } = useMerchantInfoParser();
const { merchantBusinessOwnersParser } = useMerchantBusinessOwnersParser();
const { data, isLoading, isFetching } = useQuery(
["get_agreement_snapshot", merchantId],
async () => {
const snapshot = await getMerchantSnapshot(merchantId);
return snapshot;
},
{
refetchOnWindowFocus: false,
refetchOnMount: false,
enabled: Boolean(merchantId) && enabled,
},
);
const customData = {
merchantInfo: merchantInfoParser(data?.account),
businessProfile: businessProfileParser(data?.legal_entity),
businessAddress: businessAddressParser(data?.legal_entity?.address),
bankAccountList: merchantBankAccountsParser(
data?.bankAccount ? [data?.bankAccount] : [],
),
businessOwnersList: merchantBusinessOwnersParser(data?.principals),
primaryAccountHolder: primaryAccountHolderParser({ data: data?.owner }),
fees: feesParser({
feeConfig: data?.feeConfig,
...data?.account,
}),
merchantAgreement: merchantAgreementParser({
...data?.account,
owner: data?.owner,
}),
};
return { data: customData, isLoading: isLoading || isFetching };
};
export default useAgreementSnapshot;
|