Skip to content

Commit cbde32e

Browse files
[Dashboard] add wallet user search (#7182)
1 parent 8ed5ef3 commit cbde32e

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use client";
2+
3+
import { Input } from "@/components/ui/input";
4+
import { SearchIcon } from "lucide-react";
5+
6+
export function SearchInput(props: {
7+
placeholder: string;
8+
value: string;
9+
onValueChange: (value: string) => void;
10+
}) {
11+
return (
12+
<div className="relative">
13+
<Input
14+
placeholder={props.placeholder}
15+
value={props.value}
16+
onChange={(e) => props.onValueChange(e.target.value)}
17+
className="bg-card pl-9"
18+
/>
19+
<SearchIcon className="-translate-y-1/2 absolute top-1/2 left-3 size-4 text-muted-foreground" />
20+
</div>
21+
);
22+
}

apps/dashboard/src/components/embedded-wallets/Users/index.tsx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react";
2020
import Papa from "papaparse";
2121
import { useCallback, useState } from "react";
2222
import type { WalletUser } from "thirdweb/wallets";
23+
import { SearchInput } from "./SearchInput";
2324

2425
const 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

Comments
 (0)