All files / src/components/BankAccounts/Table ExpandedRow.tsx

0% Statements 0/8
0% Branches 0/28
0% Functions 0/2
0% Lines 0/7

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                                                                                                                                                                                                                                                                                                                                                                       
import * as React from "react";
import { palette } from "@palette";
// @mui
import { Box, Grid, Stack, styled } from "@mui/material";
// components
import { KeyVal } from "@common/KeyVal";
import { Text } from "@common/Text";
// assets
import { InfoIcon } from "@assets/icons";
import { getStatusMessage } from "@components/BankAccounts/utils";
import { Button } from "@common/Button";
import { ExternalLinkIcon } from "@assets/rebrandIcons";
import { IMerchantBankAccount } from "@components/Merchants/MerchantPreview/data.types";
import NiceModal from "@ebay/nice-modal-react";
import { PLAID_ACCOUNT_INFO } from "modals/modal_names";
 
type ExpandedRowProps = {
  rowData: IMerchantBankAccount;
  pinkBorder?: boolean;
};
 
export const ExpandedRow: React.FC<ExpandedRowProps> = ({ rowData }) => {
  const handleViewPlaidInfo = () => {
    if (!rowData?.authPlaidInfo) return;
    NiceModal.show(PLAID_ACCOUNT_INFO, { data: rowData.authPlaidInfo });
  };
 
  return (
    <Container>
      <Stack p={1} gap={2} mb={1} direction="row" alignItems="center">
        <InfoIcon height={20} width={20} path_fill={palette.gray[100]} />
        <Text
          fontSize={14}
          variant="body"
          fontWeight="light"
          lineHeight="16.8px"
          color={palette.neutral[80]}
        >
          {getStatusMessage({ data: rowData })}
        </Text>
      </Stack>
 
      {rowData?.authPlaidInfo && (
        <Box display="flex" alignItems="center" sx={{ marginY: "18.5px" }}>
          <Text fontSize={16} fontWeight="light" color={palette.neutral[80]}>
            Linked through Plaid
          </Text>
          <Text
            fontWeight="book"
            color={palette.neutral[80]}
            sx={{ ml: 1, mr: 3 }}
          >
            {rowData?.created}
          </Text>
          <Button
            background="tertiary"
            size="small"
            endIcon={<ExternalLinkIcon />}
            onClick={handleViewPlaidInfo}
          >
            <Text>View Plaid info</Text>
          </Button>
        </Box>
      )}
 
      <Grid container spacing={2}>
        {!rowData?.authPlaidInfo && (
          <Grid item xs={12} sm={6}>
            <KeyVal keyName="Created" value={rowData?.created} />
          </Grid>
        )}
        <Grid item xs={12} sm={6}>
          <KeyVal
            align={rowData?.authPlaidInfo ? "left" : "right"}
            keyName="Business name on account"
            value={
              <Text sx={nameStyle} data-testid="name-on-account">
                {rowData?.name}
              </Text>
            }
          />
        </Grid>
        <Grid item xs={12} sm={6}>
          <KeyVal
            align={rowData?.authPlaidInfo ? "right" : "left"}
            keyName="Account type"
            value={
              <Text
                sx={nameStyle}
                textTransform="capitalize"
                color={palette.neutral[800]}
                data-testid="account-type"
              >
                {rowData?.type}
              </Text>
            }
          />
        </Grid>
        <Grid item xs={12} sm={6}>
          <KeyVal
            align={rowData?.authPlaidInfo ? "left" : "right"}
            keyName="Routing number"
            value={rowData?.routingNumber}
          />
        </Grid>
        <Grid item xs={12} sm={6}>
          <KeyVal
            align={rowData?.authPlaidInfo ? "right" : "left"}
            keyName="Account number"
            value={`********${rowData?.accountNumber?.slice(-4)}`}
          />
        </Grid>
        {rowData?.bankName && (
          <Grid item xs={12} sm={6}>
            <KeyVal
              align={rowData?.authPlaidInfo ? "left" : "right"}
              keyName="Bank name"
              value={rowData?.bankName}
            />
          </Grid>
        )}
        {rowData?.notes && (
          <Grid
            maxWidth="100%"
            overflow="hidden"
            item
            xs={12}
            sm={rowData?.bankName ? 12 : 6}
          >
            <KeyVal
              align={rowData?.authPlaidInfo ? "left" : "right"}
              keyName="Notes"
              value={rowData?.notes}
              keyProps={{
                align: rowData?.bankName ? "center" : "right",
              }}
              valProps={{
                align: rowData?.bankName ? "center" : "right",
                textTransform: undefined,
                sx: {
                  wordWrap: "break-word",
                  overflowWrap: "break-word",
                },
              }}
            />
          </Grid>
        )}
      </Grid>
    </Container>
  );
};
 
const Container = styled(Box)({
  display: "flex",
  flexDirection: "column",
  padding: "16px",
  background: "white",
  borderRadius: 12,
  "& .keyVal-key": {
    fontSize: 14,
    lineHeight: "16.8px",
    color: palette.neutral[70],
    fontWeight: 350,
  },
  "& .keyVal-value": {
    fontSize: 14,
    lineHeight: "16.8px",
    color: palette.neutral[80],
    fontWeight: 350,
  },
});
 
const nameStyle = {
  fontWeight: 350,
  maxWidth: "100%",
  whiteSpace: "nowrap",
  overflow: "hidden",
  textOverflow: "ellipsis",
};