@@ -31,15 +31,28 @@ import type { SearchType } from "./types";
3131const getAuthIdentifier = ( accounts : WalletUser [ "linkedAccounts" ] ) => {
3232 const mainDetail = accounts [ 0 ] ?. details ;
3333 return (
34+ mainDetail ?. id ??
3435 mainDetail ?. email ??
3536 mainDetail ?. phone ??
36- mainDetail ?. address ??
37- mainDetail ?. id
37+ mainDetail ?. address
3838 ) ;
3939} ;
4040
41- const getExternalWallets = ( accounts : WalletUser [ "linkedAccounts" ] ) => {
42- return accounts ?. filter ( ( account ) => account . type === "siwe" ) || [ ] ;
41+ const getPrimaryEmail = ( accounts : WalletUser [ "linkedAccounts" ] ) => {
42+ const emailFromPrimary = accounts [ 0 ] ?. details ?. email ;
43+ if ( emailFromPrimary ) {
44+ return emailFromPrimary ;
45+ }
46+
47+ const emailAccount = accounts . find ( ( account ) => {
48+ return typeof account . details ?. email === "string" && account . details . email ;
49+ } ) ;
50+
51+ if ( emailAccount && typeof emailAccount . details . email === "string" ) {
52+ return emailAccount . details . email ;
53+ }
54+
55+ return undefined ;
4356} ;
4457
4558const columnHelper = createColumnHelper < WalletUser > ( ) ;
@@ -118,33 +131,24 @@ export function InAppWalletUsersPageContent(
118131 } ) ,
119132 columnHelper . accessor ( "linkedAccounts" , {
120133 cell : ( cell ) => {
121- const externalWallets = getExternalWallets ( cell . getValue ( ) ) ;
122- if ( externalWallets . length === 0 ) {
123- return < span className = "text-muted-foreground text-sm" > None</ span > ;
134+ const email = getPrimaryEmail ( cell . getValue ( ) ) ;
135+
136+ if ( ! email ) {
137+ return < span className = "text-muted-foreground text-sm" > N/A</ span > ;
124138 }
139+
125140 return (
126- < div className = "space-y-1" >
127- { externalWallets . slice ( 0 , 2 ) . map ( ( account ) => {
128- const address = account . details ?. address as string | undefined ;
129- return address ? (
130- < div
131- key = { `external-${ address } -${ account . details ?. id } ` }
132- className = "text-xs"
133- >
134- < WalletAddress address = { address } client = { props . client } />
135- </ div >
136- ) : null ;
137- } ) }
138- { externalWallets . length > 2 && (
139- < span className = "text-muted-foreground text-xs" >
140- +{ externalWallets . length - 2 } more
141- </ span >
142- ) }
143- </ div >
141+ < CopyTextButton
142+ textToShow = { email }
143+ textToCopy = { email }
144+ tooltip = "Copy Email"
145+ copyIconPosition = "left"
146+ variant = "ghost"
147+ />
144148 ) ;
145149 } ,
146- header : "External Wallets " ,
147- id : "external_wallets " ,
150+ header : "Email " ,
151+ id : "email " ,
148152 } ) ,
149153 columnHelper . accessor ( "wallets" , {
150154 cell : ( cell ) => {
@@ -254,18 +258,14 @@ export function InAppWalletUsersPageContent(
254258 } ) ;
255259 const csv = Papa . unparse (
256260 usersWallets . map ( ( row ) => {
257- const externalWallets = getExternalWallets ( row . linkedAccounts ) ;
258- const externalWalletAddresses = externalWallets
259- . map ( ( account ) => account . details ?. address )
260- . filter ( Boolean )
261- . join ( ", " ) ;
261+ const email = getPrimaryEmail ( row . linkedAccounts ) ;
262262
263263 return {
264264 address : row . wallets [ 0 ] ?. address || "Uninitialized" ,
265265 created : row . wallets [ 0 ] ?. createdAt
266266 ? new Date ( row . wallets [ 0 ] . createdAt ) . toISOString ( )
267267 : "Wallet not created yet" ,
268- external_wallets : externalWalletAddresses || "None " ,
268+ email : email || "N/A " ,
269269 login_methods : row . linkedAccounts . map ( ( acc ) => acc . type ) . join ( ", " ) ,
270270 auth_identifier : getAuthIdentifier ( row . linkedAccounts ) || "N/A" ,
271271 user_identifier : row . id || "N/A" ,
0 commit comments