From 53b1d0b03d61304b532fdef4f54864b222bd582d Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Wed, 23 Oct 2024 23:31:45 +0300 Subject: [PATCH] chore: remove unused variables for pagination --- .../details/ConfigDetailsChangesPage.tsx | 31 ++----------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/src/pages/config/details/ConfigDetailsChangesPage.tsx b/src/pages/config/details/ConfigDetailsChangesPage.tsx index 08c50e901..2b0cfcab1 100644 --- a/src/pages/config/details/ConfigDetailsChangesPage.tsx +++ b/src/pages/config/details/ConfigDetailsChangesPage.tsx @@ -3,17 +3,16 @@ import { ConfigChangeTable } from "@flanksource-ui/components/Configs/Changes/Co import { ConfigRelatedChangesFilters } from "@flanksource-ui/components/Configs/Changes/ConfigsRelatedChanges/FilterBar/ConfigRelatedChangesFilters"; import { ConfigDetailsTabs } from "@flanksource-ui/components/Configs/ConfigDetailsTabs"; import { InfoMessage } from "@flanksource-ui/components/InfoMessage"; -import { PaginationOptions } from "@flanksource-ui/ui/DataTable"; -import { useMemo } from "react"; import { useParams, useSearchParams } from "react-router-dom"; export function ConfigDetailsChangesPage() { const { id } = useParams(); - const [params, setParams] = useSearchParams({ + + const [params] = useSearchParams({ sortBy: "created_at", sortDirection: "desc" }); - const page = params.get("page") ?? "1"; + const pageSize = params.get("pageSize") ?? "200"; const { data, isLoading, error, refetch } = useGetConfigChangesByIDQuery({ @@ -33,30 +32,6 @@ export function ConfigDetailsChangesPage() { const totalChanges = data?.total ?? 0; const totalChangesPages = Math.ceil(totalChanges / parseInt(pageSize)); - const pagination = useMemo(() => { - const pagination: PaginationOptions = { - setPagination: (updater) => { - const newParams = - typeof updater === "function" - ? updater({ - pageIndex: parseInt(page) - 1, - pageSize: parseInt(pageSize) - }) - : updater; - params.set("page", (newParams.pageIndex + 1).toString()); - params.set("pageSize", newParams.pageSize.toString()); - setParams(params); - }, - pageIndex: parseInt(page) - 1, - pageSize: parseInt(pageSize), - pageCount: totalChangesPages, - remote: true, - enable: true, - loading: isLoading - }; - return pagination; - }, [page, pageSize, totalChangesPages, isLoading, params, setParams]); - if (error) { const errorMessage = typeof error === "symbol"