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 70 71 72 73 74 75 76 77 78 | 1x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x | import { useGetOfacCheckById } from "./useOFAC";
import { lastCheckMapper, useUpdateOFACCheck } from "./useUpdateOFACCheck";
import { formatTimestampWithTimezone } from "@utils/index";
import { TOFACStatusImproved } from "../components/types";
import { OFACTabType } from "@components/Merchants/MerchantPreview/OFAC/hooks/types";
type UseOFACDetailsProps = {
merchantId: number;
legalEntityId: number;
currentCheckId: number;
composed: string;
isEditAllowed: boolean;
activeTab: OFACTabType;
tabCategory?: string;
onUpdateSuccess?: (data: any) => void;
isEnterprisePanel: boolean;
enabled?: boolean;
};
export const useOFACDetails = ({
merchantId,
currentCheckId,
activeTab,
tabCategory = "",
onUpdateSuccess,
enabled = true,
}: UseOFACDetailsProps) => {
const { data: currentCheck, isLoading } = useGetOfacCheckById(
merchantId,
currentCheckId,
undefined,
enabled,
);
const statusName = currentCheck?.statusName as keyof typeof lastCheckMapper;
const ofacStatus = lastCheckMapper[statusName] as TOFACStatusImproved;
const time = formatTimestampWithTimezone(currentCheck?.updatedAt || 0);
const { handleSubmit } = useUpdateOFACCheck({
tab: tabCategory,
onSuccessCallback: onUpdateSuccess,
});
const isNRA =
currentCheck?.resourceCountryOfResidence &&
currentCheck.resourceCountryOfResidence !== "US";
const isNotUSResident =
currentCheck?.resourceCitizenship &&
currentCheck.resourceCitizenship !== "US";
const disclaimerMessageType =
activeTab === OFACTabType.PRIMARY_ACCOUNT_HOLDER
? "non_resident_pah"
: "non_resident_bo";
const citizenDisclaimerMessageType =
activeTab === OFACTabType.PRIMARY_ACCOUNT_HOLDER
? "non_citizen_pah"
: "non_citizen_bo";
const initialCheckDate = currentCheck
? formatTimestampWithTimezone(currentCheck.createdAt)
: "";
return {
currentCheck,
isLoading,
ofacStatus,
time,
handleSubmit,
isNRA,
isNotUSResident,
disclaimerMessageType,
citizenDisclaimerMessageType,
initialCheckDate,
};
};
|