Skip to content

Commit

Permalink
Use param filter utils
Browse files Browse the repository at this point in the history
  • Loading branch information
abefernan committed Oct 23, 2024
1 parent e8fbfef commit a117390
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/txs-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { useTxs } from "@/hooks/api";
import { useDebounce } from "@/hooks/use-debounce";
import { getFiltersFromParams, setParamsFromFilters } from "@/lib/params";
import { Span, Tx } from "@/types/txs";
import {
ColumnDef,
Expand All @@ -16,6 +17,7 @@ import {
getSortedRowModel,
useReactTable,
} from "@tanstack/react-table";
import { useSearchParams } from "next/navigation";
import { useEffect, useMemo, useState } from "react";
import { DataTable } from "../data-table";
import { DataTableColumnHeader } from "../data-table/data-table-column-header";
Expand All @@ -25,10 +27,13 @@ import { txsColumns } from "./txs-columns";
import { DataTableToolbar } from "./txs-table-toolbar";

export function TxsTable() {
const params = useSearchParams();
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({
tags: false,
});
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>(
getFiltersFromParams(params),
);
const [sorting, setSorting] = useState<SortingState>([]);

const operationNameValue = columnFilters.find(
Expand Down Expand Up @@ -101,6 +106,10 @@ export function TxsTable() {
table.setPageSize(15);
}, [table]);

useEffect(() => {
setParamsFromFilters(columnFilters);
}, [columnFilters]);

return (
<div className="space-y-4">
<DataTableToolbar table={table} />
Expand Down

0 comments on commit a117390

Please sign in to comment.