feat(hk): persist named table views for staff accounts
CI / check (push) Failing after 55s
CI / deploy (push) Skipped
CI / publish-container (push) Skipped

This commit is contained in:
Simo committed 2026-09-11 00:32:15 +02:00
1 parent 74223984dc
commit a647b5451f
7 files changed
+480

No files matched your search

+24
View File
@@ -16,6 +16,7 @@ import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useTranslations } from "next-intl";
import { useEffect, useRef, useState, useTransition } from "react";
import { toast } from "sonner";
import { TableSavedViews } from "@/components/admin/table-saved-views";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
@@ -327,6 +328,29 @@ export function DataTable<T extends { id: number | string }>({
/>
</div>
<TableSavedViews
path={pathname}
query={searchParams.toString()}
hidden={[...hiddenColumns]}
onApply={(view) => {
setHiddenColumns(
() =>
new Set(
view.state.hidden.filter((key) =>
columns.some((column) => column.key === key),
),
),
);
const params = new URLSearchParams(view.state.params);
params.set("page", "1");
startTransition(() =>
router.replace(`${pathname}?${params.toString()}`, {
scroll: false,
}),
);
}}
/>
{/* Column Filters */}
{filterColumns.length > 0 && (
<Popover>