@@ -20,6 +20,7 @@ import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
2020import Papa from "papaparse" ;
2121import { useCallback , useState } from "react" ;
2222import type { WalletUser } from "thirdweb/wallets" ;
23+ import { SearchInput } from "./SearchInput" ;
2324
2425const getUserIdentifier = ( accounts : WalletUser [ "linkedAccounts" ] ) => {
2526 const mainDetail = accounts [ 0 ] ?. details ;
@@ -103,12 +104,38 @@ export function InAppWalletUsersPageContent(props: {
103104 authToken : string ;
104105} ) {
105106 const [ activePage , setActivePage ] = useState ( 1 ) ;
107+ const [ searchValue , setSearchValue ] = useState ( "" ) ;
106108 const walletsQuery = useEmbeddedWallets ( {
107109 authToken : props . authToken ,
108110 clientId : props . clientId ,
109111 page : activePage ,
110112 } ) ;
111113 const wallets = walletsQuery ?. data ?. users || [ ] ;
114+ const filteredWallets = searchValue
115+ ? wallets . filter ( ( wallet ) => {
116+ const term = searchValue . toLowerCase ( ) ;
117+ if ( wallet . id . toLowerCase ( ) . includes ( term ) ) {
118+ return true ;
119+ }
120+ if (
121+ wallet . wallets ?. some ( ( w ) => w . address ?. toLowerCase ( ) . includes ( term ) )
122+ ) {
123+ return true ;
124+ }
125+ if (
126+ wallet . linkedAccounts ?. some ( ( acc ) => {
127+ return Object . values ( acc . details ) . some (
128+ ( detail ) =>
129+ typeof detail === "string" &&
130+ detail . toLowerCase ( ) . includes ( term ) ,
131+ ) ;
132+ } )
133+ ) {
134+ return true ;
135+ }
136+ return false ;
137+ } )
138+ : wallets ;
112139 const { mutateAsync : getAllEmbeddedWallets , isPending } =
113140 useAllEmbeddedWallets ( {
114141 authToken : props . authToken ,
@@ -146,7 +173,14 @@ export function InAppWalletUsersPageContent(props: {
146173 < div >
147174 < div className = "flex flex-col gap-4" >
148175 { /* Top section */ }
149- < div className = "flex items-center justify-end" >
176+ < div className = "flex items-center justify-end gap-3" >
177+ < div className = "w-full max-w-xs" >
178+ < SearchInput
179+ placeholder = "Search"
180+ value = { searchValue }
181+ onValueChange = { setSearchValue }
182+ />
183+ </ div >
150184 < Button
151185 disabled = { wallets . length === 0 || isPending }
152186 variant = "outline"
@@ -162,7 +196,7 @@ export function InAppWalletUsersPageContent(props: {
162196 < div >
163197 < TWTable
164198 title = "in-app wallets"
165- data = { wallets }
199+ data = { filteredWallets }
166200 columns = { columns }
167201 isPending = { walletsQuery . isPending }
168202 isFetched = { walletsQuery . isFetched }
0 commit comments