11"use client" ;
22
33import { WalletAddress } from "@/components/blocks/wallet-address" ;
4- import { PaginationButtons } from "@/components/pagination-buttons" ;
54import { Spinner } from "@/components/ui/Spinner/Spinner" ;
65import { Button } from "@/components/ui/button" ;
76import {
@@ -17,6 +16,7 @@ import {
1716import { createColumnHelper } from "@tanstack/react-table" ;
1817import { TWTable } from "components/shared/TWTable" ;
1918import { format } from "date-fns/format" ;
19+ import { ArrowLeft , ArrowRight } from "lucide-react" ;
2020import Papa from "papaparse" ;
2121import { useCallback , useState } from "react" ;
2222import type { WalletUser } from "thirdweb/wallets" ;
@@ -97,21 +97,18 @@ const columns = [
9797 } ) ,
9898] ;
9999
100- export const InAppWalletUsersPageContent = ( props : {
100+ export function InAppWalletUsersPageContent ( props : {
101101 clientId : string ;
102102 trackingCategory : string ;
103103 authToken : string ;
104- } ) => {
104+ } ) {
105105 const [ activePage , setActivePage ] = useState ( 1 ) ;
106106 const walletsQuery = useEmbeddedWallets ( {
107107 authToken : props . authToken ,
108108 clientId : props . clientId ,
109109 page : activePage ,
110110 } ) ;
111- const { users : wallets , totalPages } = walletsQuery ?. data || {
112- users : [ ] ,
113- totalPages : 1 ,
114- } ;
111+ const wallets = walletsQuery ?. data ?. users || [ ] ;
115112 const { mutateAsync : getAllEmbeddedWallets , isPending } =
116113 useAllEmbeddedWallets ( {
117114 authToken : props . authToken ,
@@ -123,7 +120,6 @@ export const InAppWalletUsersPageContent = (props: {
123120 }
124121 const usersWallets = await getAllEmbeddedWallets ( {
125122 clientId : props . clientId ,
126- totalPages,
127123 } ) ;
128124 const csv = Papa . unparse (
129125 usersWallets . map ( ( row ) => {
@@ -144,13 +140,13 @@ export const InAppWalletUsersPageContent = (props: {
144140 tempLink . href = csvUrl ;
145141 tempLink . setAttribute ( "download" , "download.csv" ) ;
146142 tempLink . click ( ) ;
147- } , [ wallets , props . clientId , totalPages , getAllEmbeddedWallets ] ) ;
143+ } , [ wallets , props . clientId , getAllEmbeddedWallets ] ) ;
148144
149145 return (
150146 < div >
151- < div className = "flex flex-col gap-6 " >
147+ < div className = "flex flex-col gap-4 " >
152148 { /* Top section */ }
153- < div className = "flex items-center justify-between " >
149+ < div className = "flex items-center justify-end " >
154150 < Button
155151 disabled = { wallets . length === 0 || isPending }
156152 variant = "outline"
@@ -161,35 +157,42 @@ export const InAppWalletUsersPageContent = (props: {
161157 { isPending && < Spinner className = "size-4" /> }
162158 Download as .csv
163159 </ Button >
164-
165- < div className = "flex items-center justify-end gap-2" >
166- { walletsQuery . isPlaceholderData && (
167- < >
168- < Spinner className = "size-4" />
169- < p className = "text-muted-foreground text-sm" >
170- Loading page { activePage } of { totalPages }
171- </ p >
172- </ >
173- ) }
174- </ div >
175160 </ div >
176161
177- < TWTable
178- title = "in-app wallets"
179- data = { wallets }
180- columns = { columns }
181- isPending = { walletsQuery . isPending }
182- isFetched = { walletsQuery . isFetched }
183- />
184-
185- { totalPages > 1 && (
186- < PaginationButtons
187- activePage = { activePage }
188- onPageClick = { setActivePage }
189- totalPages = { totalPages }
162+ < div >
163+ < TWTable
164+ title = "in-app wallets"
165+ data = { wallets }
166+ columns = { columns }
167+ isPending = { walletsQuery . isPending }
168+ isFetched = { walletsQuery . isFetched }
169+ tableContainerClassName = "rounded-b-none"
190170 />
191- ) }
171+
172+ < div className = "flex justify-center gap-3 rounded-b-lg border border-t-0 bg-card p-6" >
173+ < Button
174+ variant = "outline"
175+ size = "sm"
176+ className = "gap-2 bg-background"
177+ onClick = { ( ) => setActivePage ( ( p ) => Math . max ( 1 , p - 1 ) ) }
178+ disabled = { activePage === 1 || walletsQuery . isPending }
179+ >
180+ < ArrowLeft className = "size-4" />
181+ Previous
182+ </ Button >
183+ < Button
184+ variant = "outline"
185+ size = "sm"
186+ className = "gap-2 bg-background"
187+ onClick = { ( ) => setActivePage ( ( p ) => p + 1 ) }
188+ disabled = { wallets . length === 0 || walletsQuery . isPending }
189+ >
190+ Next
191+ < ArrowRight className = "size-4" />
192+ </ Button >
193+ </ div >
194+ </ div >
192195 </ div >
193196 </ div >
194197 ) ;
195- } ;
198+ }
0 commit comments