All files / src/components/VirtualList/columns DescriptionColumn.tsx

0% Statements 0/9
0% Branches 0/11
0% Functions 0/2
0% Lines 0/9

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                                                                                                       
import { TruncateText } from "@common/Text";
import { feesArray } from "@components/ManageMoney/TransactionTable/transactions.types";
import { TransactionTableRow } from "@components/ManageMoney/TransactionTable/transactions.types";
import { textColor } from "@components/ManageMoney/TransactionTable/transactions.helpers";
import { Stack } from "@mui/material";
import { palette } from "@palette";
import { capitalizeCardType } from "@utils/index";
 
export const DescriptionColumn = ({ row }: { row: TransactionTableRow }) => {
  const isFee = feesArray.includes(row?.transactionType || "");
 
  const renderText = (type?: string) => {
    switch (type) {
      case "network_fees":
      case "other_fees":
      case "processor_fees":
        return "Network Fees";
      case "assessment_fees":
        return "Assessment Fees";
      default:
        return "Network Fees";
    }
  };
 
  const text = isFee
    ? renderText(row?.transactionType)
    : capitalizeCardType(row.detailedDescription?.[0]);
 
  return (
    <Stack direction="row">
      <TruncateText
        fontWeight="regular"
        color={textColor(row, palette.neutral[800])}
        lineClamp={1}
        maxWidth="auto"
      >
        {text}
      </TruncateText>
      {!isFee && (
        <TruncateText
          fontWeight="regular"
          color={textColor(row, palette.neutral[70])}
          lineClamp={1}
          maxWidth="auto"
        >
          ,&nbsp;{capitalizeCardType(row.detailedDescription?.[1])}
        </TruncateText>
      )}
    </Stack>
  );
};