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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | 129x 129x 129x 129x 129x 143x 143x 143x 143x 143x 143x 95x 48x 48x 39x 9x 16x 22x 10x 16x 22x 22x 22x 2x 2x 22x 16x 4x 16x 2x 16x 22x 22x 22x 22x 22x 22x 22x 44x 22x 44x 2x 2x 2x 2x 2x 22x 22x 22x 22x 22x 16x 48x 230x 230x 16x 16x 172x 172x 172x 9x 5x 2x | import { Box, Skeleton, Stack } from "@mui/material";
import GiveLink from "@shared/Link/GiveLink";
import GiveText from "@shared/Text/GiveText";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import { FieldConfig, ModalMerchantData, TaskActionType } from "../types";
import { Grid } from "@mui/material";
import { TaskContentConfig, TaskName, RiskLevel } from "../types";
import {
AttachmentsUpload,
BadgeContentCircle,
InfoItem,
MerchantImage,
RiskStatusDisplay,
SignatureSection,
StyledBadge,
StyledTextareaContainer,
UploadElement,
UrlWithCopy,
} from "./Sections.atoms";
import { TMerchantDocument } from "@components/Merchants/MerchantPreview/data.types";
import GiveUploadStack from "@shared/FileUpload/GiveUploadStack";
import { isFunction } from "lodash";
import AgreementStatusCard from "@features/Merchants/MerchantSidePanel/AgreementAndSnapshot/Agreement/components/AgreementStatusCard";
import AgreementCardPDFLink from "@features/Merchants/MerchantSidePanel/AgreementAndSnapshot/Agreement/components/PDFLink";
import GiveButton from "@shared/Button/GiveButton";
import { GIVE_MERCHANT_AGREEMENT_MODAL } from "modals/modal_names";
import NiceModal from "@ebay/nice-modal-react";
import useAgreementSnapshot from "@components/Merchants/MerchantPreview/MerchantAgreement/AgreementSnapshot/hooks/useAgreementSnapshot";
import { CountryFlag } from "@common/CountryFlag";
import { GiveInput } from "@shared/GiveInputs/GiveInput";
import { useFormContext } from "react-hook-form";
import { TFileAttachmentType } from "@hooks/upload-api/uploadHooks";
import {
GiveUploadItemProps,
UploadStackProps,
} from "@shared/FileUpload/types";
import { useGetAgreementData } from "../../AgreementAndSnapshot/Agreement/useGetAgreementData";
import { useIsFetching } from "react-query";
import {
MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS,
processorMap,
SHOW_RISK_CATEGORY,
} from "@features/Merchants/MerchantSidePanel/constants";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
import {
ConversationMenu,
ButtonWrapperBadge,
} from "@features/GiveConversation/components/ConversationMenu";
import { MouseEventHandler } from "react";
import { ChatsCircleIcon } from "@phosphor-icons/react";
import { getCounterVariant } from "@features/GiveConversation/utils";
import { checkPortals } from "@utils/routing";
import { useParseDocumentsList } from "../../GiveMerchantFile/components/DocumentsSection";
import { Accept } from "react-dropzone/.";
export function MerchantInfoContent({
imageURL,
name,
legalName,
taxID,
actions,
hasUnreadMessages,
didMerchantReply,
merchantID,
images,
taskID,
threadName,
predefinedMessage,
unreadMessagesCount,
isMentioned,
threadID,
internalThreadID,
}: {
hasUnreadMessages?: boolean;
didMerchantReply?: boolean;
imageURL?: string;
name: string;
legalName?: string;
taxID?: string;
actions?: TaskActionType[];
merchantID: number;
images?: string[];
taskID?: number;
threadName: string;
predefinedMessage?: string;
unreadMessagesCount?: number;
isMentioned?: boolean;
threadID?: number;
internalThreadID?: number;
}) {
const { isMobileView } = useCustomThemeV2();
const { isNewConversationsEnabled } = useGetFeatureFlagValues();
const fetchNumber = useIsFetching({
queryKey: [
MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS.GET_LEGAL_ENTITY,
merchantID,
],
});
const isFetching = fetchNumber > 0;
return (
<Stack gap="16px">
<Stack direction="row" gap="12px" alignItems="center">
{!isMobileView && <MerchantImage imageURL={imageURL} />}
<Stack direction="column" gap="8px" flex={1}>
<GiveText variant="bodyM">{name}</GiveText>
{isFetching && <Skeleton height="14px" width="120px" />}
{legalName && taxID && !isFetching && (
<GiveText variant="bodyS" color="secondary">
{legalName} - {taxID}
</GiveText>
)}
</Stack>
{isMobileView && (
<StyledBadge
invisible={
(!hasUnreadMessages && !didMerchantReply) ||
isNewConversationsEnabled
}
overlap="circular"
badgeContent={<BadgeContentCircle blue={didMerchantReply} />}
>
<MerchantImage imageURL={imageURL} />
</StyledBadge>
)}
</Stack>
{isMobileView &&
(isNewConversationsEnabled ? (
<ConversationMenu
images={images}
taskID={taskID}
threadName={threadName}
threadID={threadID}
internalThreadID={internalThreadID}
merchantData={{
imageURL: imageURL,
name: name,
id: merchantID,
}}
messageCount={unreadMessagesCount}
counterVariant={getCounterVariant({
didMerchantReply: !!didMerchantReply,
isMentioned: !!isMentioned,
})}
containerWidth="max"
predefinedMessage={predefinedMessage}
showAvatarsOnMobile
CustomFrontButton={({
onClick,
disabled,
}: {
onClick: MouseEventHandler<HTMLButtonElement>;
disabled?: boolean;
}) => (
<GiveButton
sx={{
minWidth: "fit-content",
".MuiButton-startIcon": {
marginRight: "4px",
marginLeft: "0px",
},
}}
startIcon={
<ButtonWrapperBadge
counterVariant={
unreadMessagesCount
? getCounterVariant({
didMerchantReply: !!didMerchantReply,
isMentioned: !!isMentioned,
unreadMessagesCount,
})
: undefined
}
>
<Box
height="18px"
width="18px"
alignItems="center"
display="flex"
>
<ChatsCircleIcon size="18px" />
</Box>
</ButtonWrapperBadge>
}
label="Message"
size="large"
variant="outline"
onClick={onClick}
disabled={disabled}
/>
)}
/>
) : (
<Stack direction="row" gap="16px" alignItems="center">
{actions?.map((action, i) => {
if (action?.hidden) return null;
return (
<GiveLink
key={i}
onClick={action.onClick}
Icon={action.Icon}
color="secondary"
component="button"
>
{action?.title}
</GiveLink>
);
})}
</Stack>
))}
</Stack>
);
}
export function AttachmentsContent({
files,
isEnterprise = false,
merchantID,
taskID,
handleCustomUpload,
attachmentType = "underwriting_profile",
uploadedItems,
enableUploadOnNonEmpty,
uploadStackProps,
acceptedFileTypes,
maxSizeInBytes,
}: {
files?: TMerchantDocument[];
isEnterprise?: boolean;
merchantID?: number;
taskID?: number;
handleCustomUpload?: (file: File | File[]) => void;
attachmentType?: TFileAttachmentType;
uploadedItems?: GiveUploadItemProps[];
enableUploadOnNonEmpty?: boolean;
uploadStackProps?: Partial<UploadStackProps>;
acceptedFileTypes?: Accept;
maxSizeInBytes?: number;
}) {
const hasFiles = files && files.length > 0;
const hasUploadedItems = uploadedItems && uploadedItems.length > 0;
const { isMobileView } = useCustomThemeV2();
const { parseDocumentsList } = useParseDocumentsList();
const parsedData = hasFiles
? parseDocumentsList({
documents: files,
id: merchantID,
})
: [];
if ((!hasFiles || parsedData.length < 1) && !hasUploadedItems) {
return (
<AttachmentsUpload
merchantID={merchantID}
taskID={taskID}
isEnterprise={isEnterprise}
customElement={<UploadElement isMobile={isMobileView} />}
handleCustomUpload={handleCustomUpload}
attachmentType={attachmentType}
acceptedFileTypes={acceptedFileTypes}
maxSizeInBytes={maxSizeInBytes}
sx={{
backgroundColor: "transparent",
padding: "20px 0",
height: "auto",
}}
/>
);
}
const content = (
<GiveUploadStack
items={(hasFiles ? parsedData : uploadedItems) || []}
isHideDelete
hideAllButtons
customStyles={{
border: "none",
width: "100%",
borderBottomLeftRadius: "20px",
borderBottomRightRadius: "20px",
}}
{...uploadStackProps}
/>
);
if (!enableUploadOnNonEmpty) {
return content;
}
return (
<AttachmentsUpload
merchantID={merchantID}
taskID={taskID}
isEnterprise={isEnterprise}
customElement={null}
acceptedFileTypes={acceptedFileTypes}
>
{content}
</AttachmentsUpload>
);
}
const getMccConfig = ({ showProcessing }: { showProcessing: boolean }) => {
return {
title: "Merchant Category Verification",
fields: [
...(showProcessing
? [
{
label: "Processor",
value: (data: ModalMerchantData) =>
data?.merchantInfo?.processor
? processorMap[data?.merchantInfo?.processor]
: "N/A",
span: 6,
},
]
: []),
{
label: "Merchant Category Code (MCC)",
value: (data: ModalMerchantData) =>
data?.merchantInfo?.category && data?.merchantInfo.categoryCodeName
? `${data?.merchantInfo.category} - ${data?.merchantInfo.categoryCodeName}`
: "N/A",
span: 6,
},
SHOW_RISK_CATEGORY && {
label: "Merchant Risk Category",
span: 6,
component: ({ data }: { data: ModalMerchantData }) => (
<RiskStatusDisplay
status={
data?.merchantInfo?.merchantRiskStatus?.toLowerCase() as RiskLevel
}
/>
),
},
],
};
};
const useGetMerchantPurposeConfig = () => {
const { isAcquirerEnterprises } = checkPortals();
const getMerchantPurposeConfig = () => {
return {
title: "Merchant File",
fields: [
{
label: "Goods and/or Services Description",
span: 6,
value: (data: ModalMerchantData) =>
data?.merchantInfo?.description || "-",
},
...(!isAcquirerEnterprises
? [
{
label: "Merchant Category Code (MCC)",
value: (data: ModalMerchantData) =>
data?.merchantInfo?.category &&
data?.merchantInfo.categoryCodeName
? `${data?.merchantInfo.category} - ${data?.merchantInfo.categoryCodeName}`
: "-",
span: 6,
},
]
: []),
],
};
};
return { getMerchantPurposeConfig };
};
const websiteConfig = {
title: "Website Verification",
fields: [
{
label: "Business Website",
span: 12,
component: UrlWithCopy,
},
{
label: "Business Social Media",
span: 12,
component: ({ data }: { data: ModalMerchantData }) => (
<UrlWithCopy data={data} type="social" />
),
hiddenOnProvider: true,
},
],
};
const billingDescriptorConfig = {
title: "Billing Descriptor",
fields: [
{
label: "Billing Descriptor",
span: 12,
component: ({ data }: { data: ModalMerchantData }) => (
<GiveText variant="bodyS">
<GiveText component="span" variant="bodyS" color="secondary">
{data?.merchantInfo?.billingDescriptorPrefix || "-"}*
</GiveText>
{data?.merchantInfo?.billingDescriptor || "-"}
</GiveText>
),
},
],
};
const useTaskContentConfig = () => {
const { getMerchantPurposeConfig } = useGetMerchantPurposeConfig();
const { isAcquirerEnterprises, isEnterprisePortal } = checkPortals();
const { isMerchantProcessorEnabled } = useGetFeatureFlagValues();
const mccConfig = getMccConfig({
showProcessing:
!isAcquirerEnterprises &&
!isEnterprisePortal &&
isMerchantProcessorEnabled,
});
const getContentConfig = () => {
const merchantPurposeConfig = getMerchantPurposeConfig();
const filteredWebsiteConfig = {
...websiteConfig,
fields: websiteConfig.fields.filter(
(item) => !isAcquirerEnterprises || !item.hiddenOnProvider,
),
};
return {
merchant_category_code_mcc: mccConfig,
merchant_category_verification: mccConfig,
merchant_purpose_or_mission: merchantPurposeConfig,
goods_or_services: merchantPurposeConfig,
negative_news_screening: {
title: "Negative News Screening",
fields: [
...filteredWebsiteConfig.fields.map((item) => ({
...item,
span: 6,
})),
{
label: "Doing Business As",
value: (data: ModalMerchantData) =>
data?.businessProfile?.dba || "-",
span: 6,
},
],
},
verify_billing_descriptor: billingDescriptorConfig,
billing_descriptor: billingDescriptorConfig,
website_verification: filteredWebsiteConfig,
website: filteredWebsiteConfig,
volume_assessment: {
title: "Volume Assessment",
fields: [
{
label: "Estimated Annual Revenue (USD)",
value: (data: ModalMerchantData) =>
`$${
data?.merchantInfo?.estimatedAnnualRevenue?.toLocaleString() ||
500000
}`,
span: 6,
},
{
label: "Average Ticket Amount (USD)",
value: (data: ModalMerchantData) =>
`$${
data?.merchantInfo?.averageTicketAmount?.toLocaleString() || 200
}`,
span: 6,
},
{
label: "High Ticket Amount (USD)",
value: (data: ModalMerchantData) =>
`$${
data?.merchantInfo?.highTicketAmount?.toLocaleString() || 1000
}`,
span: 6,
},
],
},
countries_serviced_allowed: {
title: "Countries Serviced",
fields: [
{
label: "Countries Serviced",
value: (data: ModalMerchantData) =>
data?.merchantInfo?.countriesServicedOutside || "USA and Canada",
},
],
},
classification: {
title: "Classification",
fields: [
{
label: "Classification",
value: (data: ModalMerchantData) => {
const classification = data?.merchantInfo?.classification || "-";
if (typeof classification === "string") return classification;
else return classification.displayName || "-";
},
},
],
},
} as TaskContentConfig;
};
return { getContentConfig };
};
interface MerchantFileContentProps {
taskName: TaskName;
merchantData: ModalMerchantData;
}
export function MerchantFileContent({
taskName,
merchantData,
}: MerchantFileContentProps) {
const { getContentConfig } = useTaskContentConfig();
const taskContentConfig = getContentConfig();
const config = taskContentConfig[taskName as keyof typeof taskContentConfig];
return <CustomGrid data={merchantData} itemsList={config.fields} />;
}
export const CustomGrid = ({
itemsList,
data,
}: {
itemsList: FieldConfig[];
data?: any;
}) => {
return (
<Grid container columnSpacing="20px" rowSpacing="20px">
{itemsList?.map((field) => {
const { label, value, isPhoneNumber, span } = field;
return (
<Grid
key={label}
item
xs={12}
sm={span || 6}
sx={{
display: "flex",
flexDirection: "column",
}}
>
<GiveText
mb="8px"
textAlign="left"
fontSize="14px"
color="secondary"
>
{label}
</GiveText>
<Stack alignItems="center" gap="8px" flexDirection="row">
{isPhoneNumber && typeof value === "string" && (
<CountryFlag height={20} width={20} phoneNumber={value} />
)}
{field.component ? (
<field.component data={data} />
) : (
<GiveText variant="bodyS">
{isFunction(field.value) ? field.value(data) : field.value}
</GiveText>
)}
</Stack>
</Grid>
);
})}
</Grid>
);
};
export const DescriptionContent = ({
description,
}: {
description?: string;
}) => {
return (
<Grid container columnSpacing="20px">
<Grid
item
xs={12}
sx={{
display: "flex",
flexDirection: "column",
}}
my="10px"
>
<GiveText
variant="bodyS"
sx={{ wordBreak: "break-all", whiteSpace: "pre-line" }}
>
{description || "-"}
</GiveText>
</Grid>
</Grid>
);
};
export const AgreementContent = ({ data }: { data: ModalMerchantData }) => {
const {
msaHadAgreed,
tcVersion = "1.1.5",
msaLastAcceptedAt,
signedBy,
signatureURL,
} = data?.merchantAgreement || {};
const statusInfo = useGetAgreementData(data?.merchantAgreement);
const statusName = data?.primaryAccountHolder?.statusName as any;
const infoItems = [
{ label: "Signed by", value: signedBy?.trim() || "-" },
{ label: "Signed at", value: statusInfo.signedOn || "-" },
{ label: "Version", value: tcVersion || "-" },
];
const shouldFetchSnapshot = statusName === "approved" && msaHadAgreed;
const { data: snapshot, isLoading: isSnapshotLoading } = useAgreementSnapshot(
{
merchantId: data?.merchantInfo?.merchantID || 0,
enabled: shouldFetchSnapshot,
},
);
const lastTcVersion = snapshot?.merchantAgreement?.tcVersion;
const lastTcVersionUpdatedAt =
snapshot?.merchantAgreement?.tcVersionUpdatedAt;
const updatedSnapshot = {
...snapshot,
merchantAgreement: {
...snapshot?.merchantAgreement,
tcVersion: lastTcVersion,
tcVersionUpdatedAt: lastTcVersionUpdatedAt,
},
merchantInfo: {
...snapshot?.merchantInfo,
processor: data?.merchantInfo?.processor,
},
};
const snapshotData = statusName === "approved" ? updatedSnapshot : data;
const handleSignAgreement = () => {
NiceModal.show(GIVE_MERCHANT_AGREEMENT_MODAL, {
data,
merchantId: data?.merchantInfo?.merchantID,
});
};
return (
<Stack alignItems="start" spacing={1}>
<AgreementStatusCard
statusInfo={statusInfo}
merchantId={data?.merchantInfo?.merchantID}
merchantData={data}
/>
<Grid container spacing={2}>
{infoItems.map((item, index) => (
<Grid item xs={index === 2 ? 12 : 6} key={item.label}>
<InfoItem label={item.label} value={item.value} />
</Grid>
))}
</Grid>
{!!msaLastAcceptedAt && (
<>
<SignatureSection
isTooltipEnabled={false}
isSigned={!!msaLastAcceptedAt}
isRequiredSignature={!signatureURL}
rawSignatureUrl={signatureURL}
/>
<Stack direction="row" gap="16px" width="100%">
{statusInfo.status === "newVersion" && (
<GiveButton
size="large"
label="Resign Agreement"
fullWidth
onClick={handleSignAgreement}
/>
)}
<AgreementCardPDFLink
isSnapshotLoading={isSnapshotLoading}
snapshotData={snapshotData}
/>
</Stack>
</>
)}
</Stack>
);
};
export interface NoteContentProps {
inputRef: any;
setIsNotesFocused: (val: boolean) => void;
name?: string;
placeholder?: string;
maxLength?: number;
minHeight?: number;
maxHeight?: number;
}
export function NotesContent({
inputRef,
setIsNotesFocused,
name = "reason",
placeholder = "Add a note",
maxLength,
minHeight,
maxHeight,
}: NoteContentProps) {
const { setValue, watch } = useFormContext();
const value = watch(name);
return (
<StyledTextareaContainer minHeight={minHeight} maxHeight={maxHeight}>
<GiveInput
name={name}
placeholder={placeholder}
multiline
onChange={(e) =>
setValue(name, e.target.value, {
shouldDirty: true,
shouldTouch: true,
shouldValidate: true,
})
}
value={value}
inputRef={inputRef}
onFocus={() => setIsNotesFocused(true)}
onBlur={() => setIsNotesFocused(false)}
controlSx={{
"& .MuiInputBase-root.MuiOutlinedInput-root.MuiInputBase-formControl":
{
padding: "0 !important",
},
}}
maxLength={maxLength}
/>
</StyledTextareaContainer>
);
}
|