Skip to content

Commit 170f14f

Browse files
[Dashboard] Add pagination to server wallets page (#7070)
1 parent da2a2a0 commit 170f14f

File tree

3 files changed

+91
-2
lines changed

3 files changed

+91
-2
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/engine/cloud/server-wallets/page.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { ServerWalletsTable } from "./wallet-table/wallet-table";
88

99
export default async function TransactionsServerWalletsPage(props: {
1010
params: Promise<{ team_slug: string; project_slug: string }>;
11+
searchParams: Promise<{ page?: string }>;
1112
}) {
1213
const vaultClient = await createVaultClient({
1314
baseUrl: NEXT_PUBLIC_THIRDWEB_VAULT_URL,
1415
});
1516

1617
const { team_slug, project_slug } = await props.params;
18+
const { page } = await props.searchParams;
1719
const [authToken, project] = await Promise.all([
1820
getAuthToken(),
1921
getProject(team_slug, project_slug),
@@ -30,17 +32,23 @@ export default async function TransactionsServerWalletsPage(props: {
3032
const managementAccessToken =
3133
projectEngineCloudService?.managementAccessToken;
3234

35+
const pageSize = 10;
36+
const currentPage = Number.parseInt(page ?? "1");
3337
const eoas = managementAccessToken
3438
? await listEoas({
3539
client: vaultClient,
3640
request: {
3741
auth: {
3842
accessToken: managementAccessToken,
3943
},
40-
options: {},
44+
options: {
45+
page: currentPage - 1,
46+
// @ts-expect-error - TODO: fix this
47+
page_size: pageSize,
48+
},
4149
},
4250
})
43-
: { data: { items: [] }, error: null, success: true };
51+
: { data: { items: [], totalRecords: 0 }, error: null, success: true };
4452

4553
return (
4654
<>
@@ -50,6 +58,9 @@ export default async function TransactionsServerWalletsPage(props: {
5058
<div className="flex flex-col gap-8">
5159
<ServerWalletsTable
5260
wallets={eoas.data.items as Wallet[]}
61+
totalRecords={eoas.data.totalRecords}
62+
currentPage={currentPage}
63+
totalPages={Math.ceil(eoas.data.totalRecords / pageSize)}
5364
project={project}
5465
teamSlug={team_slug}
5566
managementAccessToken={managementAccessToken ?? undefined}

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/engine/cloud/server-wallets/wallet-table/wallet-table-ui.client.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,21 @@ import { useQuery } from "@tanstack/react-query";
1919
import { formatDistanceToNowStrict } from "date-fns";
2020
import { format } from "date-fns/format";
2121
import { SendIcon } from "lucide-react";
22+
import Link from "next/link";
2223
import { useState } from "react";
2324
import {
2425
DEFAULT_ACCOUNT_FACTORY_V0_7,
2526
predictSmartAccountAddress,
2627
} from "thirdweb/wallets/smart";
2728
import { Button } from "../../../../../../../../../@/components/ui/button";
29+
import {
30+
Pagination,
31+
PaginationContent,
32+
PaginationItem,
33+
PaginationLink,
34+
PaginationNext,
35+
PaginationPrevious,
36+
} from "../../../../../../../../../@/components/ui/pagination";
2837
import { useThirdwebClient } from "../../../../../../../../../@/constants/thirdweb.client";
2938
import { useDashboardRouter } from "../../../../../../../../../@/lib/DashboardRouter";
3039
import { useV5DashboardChain } from "../../../../../../../../../lib/v5-adapter";
@@ -36,11 +45,17 @@ export function ServerWalletsTableUI({
3645
project,
3746
teamSlug,
3847
managementAccessToken,
48+
totalRecords,
49+
currentPage,
50+
totalPages,
3951
}: {
4052
wallets: Wallet[];
4153
project: Project;
4254
teamSlug: string;
4355
managementAccessToken: string | undefined;
56+
totalRecords: number;
57+
currentPage: number;
58+
totalPages: number;
4459
}) {
4560
const [showSigners, setShowSigners] = useState(false);
4661
return (
@@ -121,6 +136,60 @@ export function ServerWalletsTableUI({
121136
</TableBody>
122137
</Table>
123138
</TableContainer>
139+
<div className="flex flex-col items-center p-6">
140+
<div className="mb-4 text-muted-foreground text-sm">
141+
Found {totalRecords} server wallets
142+
</div>
143+
<Pagination>
144+
<PaginationContent>
145+
<PaginationItem>
146+
<Link
147+
href={`/team/${teamSlug}/${project.slug}/engine/cloud/server-wallets?page=${
148+
currentPage > 1 ? currentPage - 1 : 1
149+
}`}
150+
passHref
151+
legacyBehavior
152+
>
153+
<PaginationPrevious
154+
className={
155+
currentPage <= 1 ? "pointer-events-none opacity-50" : ""
156+
}
157+
/>
158+
</Link>
159+
</PaginationItem>
160+
{Array.from({ length: totalPages }, (_, i) => i + 1).map(
161+
(pageNumber) => (
162+
<PaginationItem key={`page-${pageNumber}`}>
163+
<Link
164+
href={`/team/${teamSlug}/${project.slug}/engine/cloud/server-wallets?page=${pageNumber}`}
165+
passHref
166+
>
167+
<PaginationLink isActive={currentPage === pageNumber}>
168+
{pageNumber}
169+
</PaginationLink>
170+
</Link>
171+
</PaginationItem>
172+
),
173+
)}
174+
<PaginationItem>
175+
<Link
176+
href={`/team/${teamSlug}/${project.slug}/engine/cloud/server-wallets?page=${
177+
currentPage < totalPages ? currentPage + 1 : totalPages
178+
}`}
179+
passHref
180+
>
181+
<PaginationNext
182+
className={
183+
currentPage >= totalPages
184+
? "pointer-events-none opacity-50"
185+
: ""
186+
}
187+
/>
188+
</Link>
189+
</PaginationItem>
190+
</PaginationContent>
191+
</Pagination>
192+
</div>
124193
</div>
125194
);
126195
}

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/engine/cloud/server-wallets/wallet-table/wallet-table.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@ export function ServerWalletsTable({
66
wallets,
77
project,
88
teamSlug,
9+
currentPage,
10+
totalPages,
11+
totalRecords,
912
managementAccessToken,
1013
}: {
1114
wallets: Wallet[];
1215
project: Project;
1316
teamSlug: string;
1417
managementAccessToken: string | undefined;
18+
totalRecords: number;
19+
currentPage: number;
20+
totalPages: number;
1521
}) {
1622
return (
1723
<ServerWalletsTableUI
1824
wallets={wallets}
25+
totalRecords={totalRecords}
26+
currentPage={currentPage}
27+
totalPages={totalPages}
1928
project={project}
2029
teamSlug={teamSlug}
2130
managementAccessToken={managementAccessToken}

0 commit comments

Comments
 (0)