@@ -30,6 +30,17 @@ export function TokenHoldings({
3030 isLoading,
3131} : TokenHoldingsProps ) {
3232 const [ activeTab , setActiveTab ] = useState < "erc20" | "nft" > ( "erc20" ) ;
33+ const [ currentPage , setCurrentPage ] = useState ( 1 ) ;
34+ const itemsPerPage = 5 ; // Set items per page
35+
36+ // Calculate the index of the last token on the current page
37+ const lastIndex = currentPage * itemsPerPage ;
38+ // Calculate the index of the first token on the current page
39+ const firstIndex = lastIndex - itemsPerPage ;
40+ // Get the current tokens to display
41+ const currentTokens = tokens . slice ( firstIndex , lastIndex ) ;
42+ // Calculate total pages
43+ const totalPages = Math . ceil ( tokens . length / itemsPerPage ) ;
3344
3445 return (
3546 < Card >
@@ -58,7 +69,35 @@ export function TokenHoldings({
5869 { isLoading ? (
5970 < Spinner />
6071 ) : activeTab === "erc20" ? (
61- < ERC20Table chain = { chain } tokens = { tokens } isLoading = { isLoading } />
72+ < >
73+ < ERC20Table chain = { chain } tokens = { currentTokens } isLoading = { isLoading } />
74+ { /* Pagination Controls */ }
75+ < div className = "pagination" >
76+ < TabButtons
77+ tabs = { [
78+ {
79+ name : "Previous" ,
80+ isActive : currentPage === 1 ,
81+ isEnabled : currentPage > 1 ,
82+ onClick : ( ) => setCurrentPage ( ( prev ) => Math . max ( prev - 1 , 1 ) ) ,
83+ } ,
84+ {
85+ name : `Page ${ currentPage } of ${ totalPages } ` ,
86+ isActive : true ,
87+ isEnabled : false ,
88+ onClick : ( ) => { } , // No action needed
89+ } ,
90+ {
91+ name : "Next" ,
92+ isActive : currentPage === totalPages ,
93+ isEnabled : currentPage < totalPages ,
94+ onClick : ( ) => setCurrentPage ( ( prev ) => Math . min ( prev + 1 , totalPages ) ) ,
95+ } ,
96+ ] }
97+ tabClassName = "font-medium !text-sm"
98+ />
99+ </ div >
100+ </ >
62101 ) : activeTab === "nft" ? (
63102 < div className = "mt-4 grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4" >
64103 { nfts . map ( ( nft , idx ) => (
0 commit comments