add datasize helper and add correct sorting to sitestable

This commit is contained in:
Thijs van Loef
2025-06-08 00:07:49 +02:00
parent 0e4f35e87a
commit 26207bd951
2 changed files with 24 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ import { formatAxiosError } from "@app/lib/api";
import { createApiClient } from "@app/lib/api";
import { useEnvContext } from "@app/hooks/useEnvContext";
import CreateSiteFormModal from "./CreateSiteModal";
import { parseDataSize } from '@app/lib/dataSize';
export type SiteRow = {
id: number;
@@ -197,7 +198,12 @@ export default function SitesTable({ sites, orgId }: SitesTableProps) {
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
}
},
sortingFn: (rowA, rowB) => {
const a = parseDataSize(rowA.original.mbIn);
const b = parseDataSize(rowB.original.mbIn);
return a > b ? 1 : a < b ? -1 : 0;
},
},
{
accessorKey: "mbOut",
@@ -213,7 +219,12 @@ export default function SitesTable({ sites, orgId }: SitesTableProps) {
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
}
},
sortingFn: (rowA, rowB) => {
const a = parseDataSize(rowA.original.mbOut);
const b = parseDataSize(rowB.original.mbOut);
return a > b ? 1 : a < b ? -1 : 0;
},
},
{
accessorKey: "type",