import type { ColumnSort } from "@tanstack/react-table"; import { useCallback } from "react"; import { useHistory } from "react-router-dom"; import lazyWithRetry from "@shared/utils/lazyWithRetry"; import type { Props as TableProps, RowData } from "./Table"; const Table = lazyWithRetry(() => import("~/components/Table")); export type Props = Omit, "onChangeSort">; export function SortableTable(props: Props) { const history = useHistory(); const handleChangeSort = useCallback( (sort: ColumnSort) => { const { pathname, search } = history.location; const params = new URLSearchParams(search); params.set("sort", sort.id); params.set("direction", sort.desc ? "desc" : "asc"); history.replace({ pathname, search: params.toString(), }); }, [history] ); return ; }