All files / components/Alias AliasTable.js

100% Statements 8/8
100% Branches 6/6
100% Functions 4/4
100% Lines 8/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        21x   21x       30x         5x           5x         21x 3x         18x    
import React from "react";
import OurTable, { ButtonColumn } from "main/components/OurTable";
 
export default function AliasTable({ aliases, onApprove, onReject }) {
  const testid = "AliasTable";
 
  const columns = [
    {
      Header: "Proposed Alias",
      accessor: "proposedAlias",
      Cell: ({ value }) => value || "(No proposed alias)",
    },
    ButtonColumn(
      "Approve",
      "primary",
      (cell) => onApprove(cell.row.original),
      testid,
    ),
    ButtonColumn(
      "Reject",
      "danger",
      (cell) => onReject(cell.row.original),
      testid,
    ),
  ];
 
  if (!aliases || aliases.length === 0) {
    return (
      <div data-testid={`${testid}-empty`}>No aliases awaiting approval</div>
    );
  }
 
  return <OurTable data={aliases} columns={columns} testid={testid} />;
}