All files / components/Courses CoursesTable.jsx

100% Statements 5/5
100% Branches 4/4
100% Functions 3/3
100% Lines 5/5

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          4x                                                   7x   20x         15x                   7x    
import OurTable from "main/components/Common/OurTable";
import { Tooltip, OverlayTrigger, Button, Spinner } from "react-bootstrap";
import { Link } from "react-router";
import LinkToScaffold from "../Scaffold/LinkToScaffold";
 
const baseColumns = [
  {
    header: "id",
    accessorKey: "id", // accessor is the "key" in the data
  },
  {
    header: "Course Name",
    accessorKey: "courseName",
  },
  {
    header: "Term",
    accessorKey: "term",
  },
  {
    header: "School",
    id: "school",
    accessorKey: "school.displayName",
  },
];
 
export default function CoursesTable({
  courses,
  testId,
  isLoading,
  courseNameLinkPrefix,
}) {
  const columns = courseNameLinkPrefix
    ? baseColumns.map((column) =>
        column.accessorKey === "courseName"
          ? {
              ...column,
              id: "courseName",
              cell: ({ cell }) => (
                <LinkToScaffold
                  course={cell.row.original}
                  testId={`${testId}-cell-row-${cell.row.index}-col-${cell.column.id}-link`}
                />
              ),
            }
          : column,
      )
    : baseColumns;
 
  return <OurTable data={courses} columns={columns} testid={testId} />;
}