All files / components/AliasApproval AliasApprovalTable.jsx

100% Statements 6/6
100% Branches 6/6
100% Functions 4/4
100% Lines 6/6

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        27x   27x       70x         2x           2x         27x                
import React from "react";
import OurTable, { ButtonColumn } from "main/components/OurTable";
 
export default function AliasApprovalTable({ aliases, onApprove, onReject }) {
  const testid = "AliasApprovalTable";
 
  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} />;
}