All files / src/features/TransactionPanel/components/Summary TransactionRevenue.tsx

100% Statements 11/11
40% Branches 4/10
50% Functions 1/2
100% Lines 11/11

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                          52x 80x           80x 80x   80x 80x     80x                   80x   80x   80x                       52x          
import { Stack } from "@mui/material";
import GiveText from "@shared/Text/GiveText";
import { styled } from "@theme/v2/Provider";
import TransactionSummaryDetails from "../Summary/TransactionSummaryDetails";
import { SummaryContainerBase } from "../atoms";
import { useTransactionSummary } from "@features/TransactionPanel/hooks/useTransactionSummary";
import { getFormattedDescription } from "@components/ManageMoney/TransactionTable/transactions.helpers";
import { checkPortals } from "@utils/routing";
import { moveFundsArray } from "@components/ManageMoney/TransactionTable/transactions.types";
type Props = {
  data: any;
};
 
const TransactionRevenue = ({ data }: Props) => {
  const { section } = useTransactionSummary({
    data,
    handleSidePanelOpen: () => {},
    isRevenueSection: true,
  });
 
  const { isMerchantPortal } = checkPortals();
  const isProvider = data?.merchant?.type === "enterprise";
  const isAcquirerToMerchant =
    data?.sourceAccount?.user?.type === "acquirer";
  const transferLabel = isAcquirerToMerchant
    ? `Transfer from Acquirer to ${isProvider ? "Provider" : "Merchant"}`
    : `Transfer from ${isProvider ? "Provider" : "Merchant"} to Acquirer`;
  const formattedDescription = getFormattedDescription(
    data?.detailedDescription?.[0],
    data?.transactionType,
    isMerchantPortal,
    true,
    Boolean(data?.description)
      ? transferLabel
      : "", // for this section we need to show a const message instead of description
  );
 
  const isTransferFunds = moveFundsArray.includes(data?.transactionType);
 
  const title = isTransferFunds ? formattedDescription : "Revenue";
 
  return (
    <Stack spacing="21px">
      <Stack flex={1} spacing={1} direction="row" py="8px">
        <GiveText variant="bodyM">{title}</GiveText>
      </Stack>
      <SummaryContainer>
        <TransactionSummaryDetails list={section.items} isHideBorder={true} />
      </SummaryContainer>
    </Stack>
  );
};
 
const SummaryContainer = styled(SummaryContainerBase)({
  padding: "0 20px",
});
 
export default TransactionRevenue;