feat(hk): persist named table views for staff accounts
This commit is contained in:
1 parent
74223984dc
commit
a647b5451f
7 files changed
+480
No files matched your search
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user