diff --git a/src/components/Dashboard/NewReport/MetricsTable/index.tsx b/src/components/Dashboard/NewReport/MetricsTable/index.tsx index 73a515a6b..b3a2ff745 100644 --- a/src/components/Dashboard/NewReport/MetricsTable/index.tsx +++ b/src/components/Dashboard/NewReport/MetricsTable/index.tsx @@ -3,6 +3,7 @@ import { flexRender, getCoreRowModel, getSortedRowModel, + SortingFn, sortingFns, useReactTable } from "@tanstack/react-table"; @@ -18,6 +19,20 @@ import { getSeverity } from "../utils"; import * as s from "./styles"; import { ColumnMeta, MetricsTableProps, Severity } from "./types"; +const sortImpactFn: SortingFn = (rowA, rowB) => { + const impactA = rowA.original.impact; + const impactB = rowB.original.impact; + + return impactA - impactB; +}; + +const sortIssuesFn: SortingFn = (rowA, rowB) => { + const issuesA = rowA.original.issues; + const issuesB = rowB.original.issues; + + return issuesA - issuesB; +}; + const IssuesLink = ({ children, onClick @@ -87,7 +102,7 @@ export const MetricsTable = ({ ); }, - sortingFn: sortingFns.alphanumeric, + sortingFn: sortIssuesFn, meta: { contentAlign: "center" }, @@ -105,7 +120,7 @@ export const MetricsTable = ({ {Math.round(info.getValue().impact * 100)} ), - sortingFn: sortingFns.alphanumeric, + sortingFn: sortImpactFn, enableSorting: true, meta: { contentAlign: "center"