Skip to content

Commit

Permalink
- fix pagination bug
Browse files Browse the repository at this point in the history
- update default size constant to 20 per page
  • Loading branch information
Jennievon committed Jul 1, 2024
1 parent 4711cee commit 66b5e8f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
7 changes: 4 additions & 3 deletions tools/tenscan/frontend/api/rollups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ export const fetchLatestRollups = async (
});
};

export const fetchRollups = async (): Promise<
ResponseDataInterface<RollupsResponse>
> => {
export const fetchRollups = async (
payload?: Record<string, any>
): Promise<ResponseDataInterface<RollupsResponse>> => {
return await httpRequest<ResponseDataInterface<RollupsResponse>>({
method: "get",
url: pathToUrl(apiRoutes.getRollups),
searchParams: payload,
});
};

Expand Down
17 changes: 11 additions & 6 deletions tools/tenscan/frontend/pages/batches/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { DataTable } from "@/src/components/modules/common/data-table/data-table
import Layout from "@/src/components/layouts/default-layout";
import { Metadata } from "next";
import { useBatchesService } from "@/src/services/useBatchesService";
import { formatNumber } from "@/src/lib/utils";

export const metadata: Metadata = {
title: "Batches",
description: "A table of Batches.",
};

export default function Batches() {
const { batches, refetchBatches, setNoPolling } = useBatchesService();
const { batches, refetchBatches, isBatchesLoading, setNoPolling } =
useBatchesService();
const { BatchesData, Total } = batches?.result || {
BatchesData: [],
Total: 0,
Expand All @@ -33,10 +33,14 @@ export default function Batches() {
<div className="flex items-center justify-between space-y-2">
<div>
<h2 className="text-2xl font-bold tracking-tight">Batches</h2>
{/* uncomment the following line when total count feature is implemented */}
{/* <p className="text-sm text-muted-foreground">
{formatNumber(Total)} Batch(es) found.
</p> */}
{BatchesData.length > 0 && (
<p className="text-sm text-muted-foreground">
Showing batches #{BatchesData[0]?.height} to #
{BatchesData[BatchesData.length - 1]?.height}
{/* uncomment the following line when total count feature is implemented */}
{/* of {formatNumber(Total)} batches. */}
</p>
)}
</div>
</div>
{BatchesData ? (
Expand All @@ -45,6 +49,7 @@ export default function Batches() {
data={BatchesData}
refetch={refetchBatches}
total={+Total}
isLoading={isBatchesLoading}
/>
) : (
<p>Loading...</p>
Expand Down
13 changes: 8 additions & 5 deletions tools/tenscan/frontend/pages/blocks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { DataTable } from "@/src/components/modules/common/data-table/data-table
import Layout from "@/src/components/layouts/default-layout";
import { Metadata } from "next";
import { useBlocksService } from "@/src/services/useBlocksService";
import { formatNumber } from "@/src/lib/utils";

export const metadata: Metadata = {
title: "Blocks",
Expand All @@ -31,10 +30,14 @@ export default function Blocks() {
<div className="flex items-center justify-between space-y-2">
<div>
<h2 className="text-2xl font-bold tracking-tight">Blocks</h2>
{/* uncomment the following line when total count feature is implemented */}
{/* <p className="text-sm text-muted-foreground">
{formatNumber(Total)} Blocks found.
</p> */}
{BlocksData.length > 0 && (
<p className="text-sm text-muted-foreground">
Showing blocks #{BlocksData[0]?.height} to #
{BlocksData[BlocksData.length - 1]?.height}
{/* uncomment the following line when total count feature is implemented */}
{/* of {formatNumber(Total)} blocks. */}
</p>
)}
</div>
</div>
{BlocksData ? (
Expand Down
13 changes: 8 additions & 5 deletions tools/tenscan/frontend/pages/rollups/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { DataTable } from "@/src/components/modules/common/data-table/data-table
import Layout from "@/src/components/layouts/default-layout";
import { useRollupsService } from "@/src/services/useRollupsService";
import { Metadata } from "next";
import { formatNumber } from "@/src/lib/utils";
import { columns } from "@/src/components/modules/rollups/columns";

export const metadata: Metadata = {
Expand Down Expand Up @@ -34,10 +33,14 @@ export default function Rollups() {
<div className="flex items-center justify-between space-y-2">
<div>
<h2 className="text-2xl font-bold tracking-tight">Rollups</h2>
{/* uncomment the following line when total count feature is implemented */}
{/* <p className="text-sm text-muted-foreground">
{formatNumber(Total)} Rollups found.
</p> */}
{RollupsData.length > 0 && (
<p className="text-sm text-muted-foreground">
Showing rollups #{RollupsData[0]?.ID} to #
{RollupsData[RollupsData.length - 1]?.ID}
{/* uncomment the following line when total count feature is implemented */}
{/* of {formatNumber(Total)} rollups. */}
</p>
)}
</div>
</div>
{RollupsData ? (
Expand Down
2 changes: 1 addition & 1 deletion tools/tenscan/frontend/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getOptions = (query: {
const options = {
offset: Number.isNaN(offset) ? 0 : offset,
size: Number.isNaN(parseInt(query.size as string, 10))
? 10
? 20
: parseInt(query.size as string, 10),
// sort: query.sort ? (query.sort as string) : "blockNumber",
// order: query.order ? (query.order as string) : "desc",
Expand Down
2 changes: 1 addition & 1 deletion tools/tenscan/frontend/src/services/useRollupsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const useRollupsService = () => {
refetch: refetchRollups,
} = useQuery({
queryKey: ["rollups"],
queryFn: () => fetchRollups(),
queryFn: () => fetchRollups(options),
refetchInterval: noPolling ? false : pollingInterval,
});

Expand Down

0 comments on commit 66b5e8f

Please sign in to comment.