Skip to content

Commit 81e6683

Browse files
Add external wallet search and display in user management
Co-authored-by: joaquim.verges <joaquim.verges@gmail.com>
1 parent aac187a commit 81e6683

File tree

5 files changed

+69
-1
lines changed

5 files changed

+69
-1
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/users/components/AdvancedSearchInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function AdvancedSearchInput(props: {
5555
<SelectItem value="phone">Phone</SelectItem>
5656
<SelectItem value="id">ID</SelectItem>
5757
<SelectItem value="address">Address</SelectItem>
58+
<SelectItem value="externalWallet">External Wallet</SelectItem>
5859
</SelectContent>
5960
</Select>
6061

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/users/components/SearchResults.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ export function SearchResults(props: {
5151
const mainDetail = user.linkedAccounts?.[0]?.details;
5252
const email = mainDetail?.email as string | undefined;
5353
const phone = mainDetail?.phone as string | undefined;
54+
55+
// Get external wallet addresses from linkedAccounts where type is 'siwe'
56+
const externalWalletAccounts = user.linkedAccounts?.filter(
57+
(account) => account.type === "siwe"
58+
) || [];
5459

5560
return (
5661
<Card key={user.id}>
@@ -96,6 +101,27 @@ export function SearchResults(props: {
96101
</div>
97102
)}
98103

104+
{externalWalletAccounts.length > 0 && (
105+
<div className="col-span-full">
106+
<p className="text-sm font-medium text-muted-foreground">
107+
External Wallets
108+
</p>
109+
<div className="space-y-1">
110+
{externalWalletAccounts.map((account, index) => {
111+
const address = account.details?.address as string | undefined;
112+
return address ? (
113+
<div key={`${user.id}-external-${index}`}>
114+
<WalletAddress
115+
address={address}
116+
client={props.client}
117+
/>
118+
</div>
119+
) : null;
120+
})}
121+
</div>
122+
</div>
123+
)}
124+
99125
{createdAt && (
100126
<div>
101127
<p className="text-sm font-medium text-muted-foreground">

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/users/components/index.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ const getUserIdentifier = (accounts: WalletUser["linkedAccounts"]) => {
3636
);
3737
};
3838

39+
const getExternalWallets = (accounts: WalletUser["linkedAccounts"]) => {
40+
return accounts?.filter((account) => account.type === "siwe") || [];
41+
};
42+
3943
const columnHelper = createColumnHelper<WalletUser>();
4044

4145
export function InAppWalletUsersPageContent(
@@ -69,6 +73,33 @@ export function InAppWalletUsersPageContent(
6973
header: "Address",
7074
id: "address",
7175
}),
76+
columnHelper.accessor("linkedAccounts", {
77+
cell: (cell) => {
78+
const externalWallets = getExternalWallets(cell.getValue());
79+
if (externalWallets.length === 0) {
80+
return <span className="text-muted-foreground text-xs">None</span>;
81+
}
82+
return (
83+
<div className="space-y-1">
84+
{externalWallets.slice(0, 2).map((account, index) => {
85+
const address = account.details?.address as string | undefined;
86+
return address ? (
87+
<div key={`external-${index}`} className="text-xs">
88+
<WalletAddress address={address} client={props.client} />
89+
</div>
90+
) : null;
91+
})}
92+
{externalWallets.length > 2 && (
93+
<span className="text-muted-foreground text-xs">
94+
+{externalWallets.length - 2} more
95+
</span>
96+
)}
97+
</div>
98+
);
99+
},
100+
header: "External Wallets",
101+
id: "external_wallets",
102+
}),
72103
columnHelper.accessor("wallets", {
73104
cell: (cell) => {
74105
const value = cell.getValue()[0]?.createdAt;
@@ -172,11 +203,18 @@ export function InAppWalletUsersPageContent(
172203
});
173204
const csv = Papa.unparse(
174205
usersWallets.map((row) => {
206+
const externalWallets = getExternalWallets(row.linkedAccounts);
207+
const externalWalletAddresses = externalWallets
208+
.map((account) => account.details?.address)
209+
.filter(Boolean)
210+
.join(", ");
211+
175212
return {
176213
address: row.wallets[0]?.address || "Uninitialized",
177214
created: row.wallets[0]?.createdAt
178215
? format(new Date(row.wallets[0].createdAt), "MMM dd, yyyy")
179216
: "Wallet not created yet",
217+
external_wallets: externalWalletAddresses || "None",
180218
login_methods: row.linkedAccounts.map((acc) => acc.type).join(", "),
181219
user_identifier: getUserIdentifier(row.linkedAccounts),
182220
};

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/wallets/users/components/searchUsers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export async function searchUsers(
3333
case "address":
3434
url.searchParams.append("address", query);
3535
break;
36+
case "externalWallet":
37+
url.searchParams.append("externalWalletAddress", query);
38+
break;
3639
}
3740

3841
const response = await fetch(url.toString(), {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type SearchType = "email" | "phone" | "id" | "address";
1+
export type SearchType = "email" | "phone" | "id" | "address" | "externalWallet";

0 commit comments

Comments
 (0)