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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | 23x 48x 48x 48x 24x 18x 18x 48x 48x 48x 48x 24x 24x 48x 23x 251x 251x 251x | import { useEnterprisePermissions } from "@components/AcquirerEnterprises/CreateEnterprise/hooks/useEnterprisePermissions";
import { businessProfileDefaultValues } from "@validation/merchant";
import { IParsedData } from "@components/Merchants/MerchantPreview/data.types";
import { shouldBeHidden } from "@constants/constants";
import { NEW_ACTION_DENY_MESSAGE } from "@constants/permissions";
import {
BankIcon,
BriefcaseIcon,
CertificateIcon,
FileTextIcon,
IdentificationBadgeIcon,
TagIcon,
GearSixIcon,
} from "@phosphor-icons/react";
import { isEmpty } from "lodash";
import {
CREATE_BUSINESS_PROFILE_MODAL,
GIVE_CREATE_MERCHANT_AGREEMENT_MODAL,
EDIT_BUSINESS_OWNER_MODAL,
EDIT_ENTERPRISE_MCC_MODAL,
ENTERPRISE_CONFIGURATION_MODAL,
INVITE_PAH_MODAL,
EDIT_PRIMARY_ACCOUNT_HOLDER_V2,
} from "modals/modal_names";
import { useMemo } from "react";
import { useCreationPermissions } from "features/Merchants/GiveCreateMerchantPanel/hooks/useCreationPermissions";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
import { capitalizeFirstLetter } from "@utils/index";
import { useMerchantSidePanelContext } from "../../Provider/MerchantSidePanelProvider";
import { FormType } from "@components/Merchants/CreateMerchantPanel/modals/CreateBusinessProfileModal";
import GiveEditBankAccountModal from "@components/Merchants/MerchantPreview/modals/GiveEditBankAccountModal";
const useMerchantPlaceholders = (data: IParsedData) => {
const { modify_merchant, b_profile_linking } = useEnterprisePermissions();
const { isOnboardingLinkBPEnabled } =
useGetFeatureFlagValues();
const totalOwnerships = useMemo(() => {
return (
data?.businessOwnersList?.reduce((acc, owner) => {
const _ownership = owner.ownership ? +owner.ownership : 0;
return acc + _ownership;
}, 0) || 0
);
}, [data?.businessOwnersList]);
const { isProvider } = useMerchantSidePanelContext();
const {
isAllowedCreatePAH,
isAllowedCreateBusinessOwner,
isAllowedCreateBankAccount,
isAllowedCreateBusinessProfile,
isUpdateAllowed,
} = useCreationPermissions();
const showWarning =
data?.merchantInfo?.pendingLegalEntityStatus === "rejected";
const placeholdersList = useMemo(() => {
const placeholdersStaticData = getPlaceholdersStaticData({
isProvider,
});
return [
{
...placeholdersStaticData.pah,
hidden: Boolean(data?.primaryAccountHolder.email) || !modify_merchant,
modal: isEmpty(data?.primaryAccountHolder?.owner)
? INVITE_PAH_MODAL
: EDIT_PRIMARY_ACCOUNT_HOLDER_V2,
merchantId: data?.merchantInfo.merchantID,
data: data?.primaryAccountHolder,
isEnterprise: isProvider,
tooltipProps: {
show: !isAllowedCreatePAH,
message: NEW_ACTION_DENY_MESSAGE,
},
},
{
...placeholdersStaticData.businessProfile,
hidden: showWarning
? false
: Boolean(
data?.businessProfile.taxID ||
data?.businessProfile?.ssn ||
(isOnboardingLinkBPEnabled &&
data?.businessProfile?.pendingLegalEntityID),
) ||
(!modify_merchant && !b_profile_linking),
data: businessProfileDefaultValues,
merchantId: data?.merchantInfo.merchantID,
merchantName: data?.merchantInfo.merchantName,
isEnterprise: isProvider,
tooltipProps: {
show: !isAllowedCreateBusinessProfile,
message: NEW_ACTION_DENY_MESSAGE,
},
...(isProvider && {
formType: FormType.CREATE_ENTERPRISE,
}),
},
{
...placeholdersStaticData.businessOwner,
hidden: data?.businessOwnersList?.length !== 0 || !modify_merchant,
noController:
!data?.businessProfile.taxID && !data?.businessProfile.ssn,
merchantId: data?.merchantInfo.merchantID,
legalEntityID: data?.businessProfile.id,
isIndividualSoleProprietorship:
data?.businessProfile?.businessType ===
"individual_sole_proprietorship",
isEnterprise: isProvider,
totalOwnerships,
businessType: data?.businessProfile?.businessType,
tooltipProps: {
show: !isAllowedCreateBusinessOwner,
message: NEW_ACTION_DENY_MESSAGE,
},
},
{
...placeholdersStaticData.bankAccount,
warning: data?.bankAccountList.length === 0,
hidden: data?.bankAccountList?.length !== 0 || !modify_merchant,
isDefault: true,
merchantId: data?.merchantInfo.merchantID,
parentAccID: data?.merchantInfo.enterpriseID,
isEnterprise: isProvider,
tooltipProps: {
show: !isAllowedCreateBankAccount,
message: NEW_ACTION_DENY_MESSAGE,
},
},
{
...placeholdersStaticData.agreement,
hidden: isProvider
? data?.merchantAgreement.msaHadAgreed
: data?.merchantAgreement.msaPCICompliant ||
shouldBeHidden.merchantAgreement ||
!modify_merchant,
warning: !data?.status.approvedAgreement,
merchantId: data?.merchantInfo.merchantID,
tooltipProps: {
show: !isUpdateAllowed,
message: NEW_ACTION_DENY_MESSAGE,
},
data: {
...data?.merchantAgreement,
isEnterprise: isProvider,
processor: isProvider ? undefined : data?.merchantInfo.processor,
},
merchantData: data,
},
];
}, [
data,
isAllowedCreatePAH,
isUpdateAllowed,
isAllowedCreateBankAccount,
isAllowedCreateBusinessOwner,
isAllowedCreateBusinessProfile,
]);
return {
placeholdersList,
};
};
type PlaceholdersStaticDataProps = {
isProvider?: boolean;
};
export const getPlaceholdersStaticData = ({
isProvider,
}: PlaceholdersStaticDataProps) => {
const merchantOrProvider = isProvider ? "provider" : "merchant";
const capitalizedMerchantOrProvider =
capitalizeFirstLetter(merchantOrProvider);
return {
pah: {
icon: <IdentificationBadgeIcon size={24} />,
title: "Primary Account Holder",
description: `The Primary Account Holder is the person who has managerial control of the ${merchantOrProvider}.`,
modal: INVITE_PAH_MODAL,
testId: "pah-card",
},
businessProfile: {
icon: <FileTextIcon size={24} />,
title: "Business Profile",
description: `The business profile is the legal entity the ${merchantOrProvider} is operating under.`,
modal: CREATE_BUSINESS_PROFILE_MODAL,
testId: "bp-card",
},
businessOwner: {
icon: <BriefcaseIcon size={24} />,
title: "Business Ownership",
description: "Add any individual who owns 10% or more of this business.",
modal: EDIT_BUSINESS_OWNER_MODAL,
testId: "bo-card",
},
agreement: {
icon: <CertificateIcon size={24} />,
title: `${
isProvider ? "" : capitalizedMerchantOrProvider + " "
}Agreement`,
description: `The ${merchantOrProvider} agreement outlines the terms and conditions governing the contractual relationship between the ${merchantOrProvider} and the payment processor.`,
modal: GIVE_CREATE_MERCHANT_AGREEMENT_MODAL,
isProvider: isProvider,
testId: "agreement-card",
},
bankAccount: {
icon: <BankIcon size={24} />,
title: "Bank Accounts",
description: `The DDA account of the ${capitalizedMerchantOrProvider}.`,
modal: GiveEditBankAccountModal,
testId: "ba-card",
},
mcc: {
icon: <TagIcon size={24} />,
title: "Merchant Category Codes (MCC)",
description:
"Choose the categories this provider can assign to its merchants.",
modal: EDIT_ENTERPRISE_MCC_MODAL,
testId: "mcc-card",
},
configuration: {
icon: <GearSixIcon size={24} />,
title: "Configuration",
description: "Customize provider fees and permissions.",
modal: ENTERPRISE_CONFIGURATION_MODAL,
testId: "configuration-card",
},
};
};
export default useMerchantPlaceholders;
|