All files / src/features/Merchants/MerchantSidePanel/components/UnderwriterRiskAnalystAssignCard/AssignmentSection AssignmentSection.tsx

90.9% Statements 10/11
90% Branches 9/10
100% Functions 2/2
100% Lines 10/10

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                  21x 88x   88x 88x 88x   88x                 88x       88x   88x           257x                              
import React from "react";
import GiveDivider from "@shared/GiveDivider/GiveDivider";
import { AssigneeSection } from "./AssigneeSection";
import { useMerchantSidePanelContext } from "@features/Merchants/MerchantSidePanel/Provider/MerchantSidePanelProvider";
import { getMerchantAssignees } from "@shared/MerchantAssignmentManager/helpers";
import { checkPortals } from "@utils/routing";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
import { QueryBoundary } from "../../QueryBoundary";
 
const AssignmentSection = () => {
  const { data, isProvider, queries } = useMerchantSidePanelContext();
  const { kybAssignee, sponsorAssignee, underwriterAssignee } =
    getMerchantAssignees(data?.status);
  const { isNewConversationsEnabled } = useGetFeatureFlagValues();
  const { isEnterprisePortal } = checkPortals();
 
  const baseSections = [
    { type: "KYB", data: kybAssignee },
    {
      type: "Underwriter",
      data: underwriterAssignee,
    },
  ];
 
  const sections =
    !isEnterprisePortal && !isProvider
      ? [...baseSections, { type: "Sponsor", data: sponsorAssignee }]
      : baseSections;
 
  Iif (sections.length === 0) return null;
 
  return (
    <QueryBoundary
      query={queries?.assigneesQuery}
      errorTitle="Assignees information could not be loaded"
    >
      {sections.map((section, i) => (
        <React.Fragment key={section.type}>
          <AssigneeSection
            type={section.type}
            data={section.data}
            merchantId={data?.status?.accID}
            hideMessageSection={isNewConversationsEnabled}
          />
          {isProvider && i === sections.length - 1 ? null : <GiveDivider />}
        </React.Fragment>
      ))}
    </QueryBoundary>
  );
};
 
export default AssignmentSection;