@@ -20,6 +20,7 @@ import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
20
20
import Papa from "papaparse" ;
21
21
import { useCallback , useState } from "react" ;
22
22
import type { WalletUser } from "thirdweb/wallets" ;
23
+ import { SearchInput } from "./SearchInput" ;
23
24
24
25
const getUserIdentifier = ( accounts : WalletUser [ "linkedAccounts" ] ) => {
25
26
const mainDetail = accounts [ 0 ] ?. details ;
@@ -103,12 +104,38 @@ export function InAppWalletUsersPageContent(props: {
103
104
authToken : string ;
104
105
} ) {
105
106
const [ activePage , setActivePage ] = useState ( 1 ) ;
107
+ const [ searchValue , setSearchValue ] = useState ( "" ) ;
106
108
const walletsQuery = useEmbeddedWallets ( {
107
109
authToken : props . authToken ,
108
110
clientId : props . clientId ,
109
111
page : activePage ,
110
112
} ) ;
111
113
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 ;
112
139
const { mutateAsync : getAllEmbeddedWallets , isPending } =
113
140
useAllEmbeddedWallets ( {
114
141
authToken : props . authToken ,
@@ -146,7 +173,14 @@ export function InAppWalletUsersPageContent(props: {
146
173
< div >
147
174
< div className = "flex flex-col gap-4" >
148
175
{ /* 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 >
150
184
< Button
151
185
disabled = { wallets . length === 0 || isPending }
152
186
variant = "outline"
@@ -162,7 +196,7 @@ export function InAppWalletUsersPageContent(props: {
162
196
< div >
163
197
< TWTable
164
198
title = "in-app wallets"
165
- data = { wallets }
199
+ data = { filteredWallets }
166
200
columns = { columns }
167
201
isPending = { walletsQuery . isPending }
168
202
isFetched = { walletsQuery . isFetched }
0 commit comments