All files / src/features/Merchants/MerchantsTable/hooks useApprovedColumns.tsx

87.5% Statements 7/8
0% Branches 0/2
66.66% Functions 2/3
87.5% Lines 7/8

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                  33x 4003x 4003x 4003x   4003x 1203x                                             4003x    
import { useMemo } from "react";
import { MerchantData } from "@hooks/enterprise-api/account/types";
import { selectMerchantTab } from "@redux/slices/enterprise/merchants";
import { useAppSelector } from "@redux/hooks";
import GiveText from "@shared/Text/GiveText";
import { useFormatDateInTimezone } from "@utils/date.helpers";
import GiveDateTooltip from "@shared/Tooltip/GiveDateTooltip";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
 
export const useApprovedColumns = () => {
  const { formatInTimezone } = useFormatDateInTimezone();
  const { isWideView } = useCustomThemeV2();
  const tab = useAppSelector(selectMerchantTab);
 
  const approvalDateCol = useMemo(() => {
    return {
      key: "approvedAt,-accID",
      sortable: true,
      title: "Approved",
      columnWidth: 1.4,
      hideColumn: !isWideView,
      renderColumn: (row: MerchantData) => {
        return (
          <GiveDateTooltip>
            <GiveText
              data-testid={`give-row-approved-date-${row.approvedAt}`}
              variant="bodyS"
            >
              {row?.approvedAt
                ? formatInTimezone(row?.approvedAt, "MMM dd, yyyy")
                : ""}
            </GiveText>
          </GiveDateTooltip>
        );
      },
    };
  }, [tab, isWideView]);
 
  return { approvalDateCol };
};