Skip to content

Commit

Permalink
chore: remove unused variables for pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
mainawycliffe committed Oct 23, 2024
1 parent 66458f2 commit 5d9b951
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions src/pages/config/details/ConfigDetailsChangesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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"
Expand Down

0 comments on commit 5d9b951

Please sign in to comment.