From f55c007b31c66981a6693e92d74458f4e4ac1ab8 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 28 May 2025 19:48:34 +1200 Subject: [PATCH] [Dashboard] add search filter for in-app wallet users --- .../embedded-wallets/Users/SearchInput.tsx | 22 +++++++++++ .../embedded-wallets/Users/index.tsx | 38 ++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 apps/dashboard/src/components/embedded-wallets/Users/SearchInput.tsx diff --git a/apps/dashboard/src/components/embedded-wallets/Users/SearchInput.tsx b/apps/dashboard/src/components/embedded-wallets/Users/SearchInput.tsx new file mode 100644 index 00000000000..921b002e0c0 --- /dev/null +++ b/apps/dashboard/src/components/embedded-wallets/Users/SearchInput.tsx @@ -0,0 +1,22 @@ +"use client"; + +import { Input } from "@/components/ui/input"; +import { SearchIcon } from "lucide-react"; + +export function SearchInput(props: { + placeholder: string; + value: string; + onValueChange: (value: string) => void; +}) { + return ( +
+ props.onValueChange(e.target.value)} + className="bg-card pl-9" + /> + +
+ ); +} diff --git a/apps/dashboard/src/components/embedded-wallets/Users/index.tsx b/apps/dashboard/src/components/embedded-wallets/Users/index.tsx index ecd8027e4de..773937df1fd 100644 --- a/apps/dashboard/src/components/embedded-wallets/Users/index.tsx +++ b/apps/dashboard/src/components/embedded-wallets/Users/index.tsx @@ -20,6 +20,7 @@ import { ArrowLeftIcon, ArrowRightIcon } from "lucide-react"; import Papa from "papaparse"; import { useCallback, useState } from "react"; import type { WalletUser } from "thirdweb/wallets"; +import { SearchInput } from "./SearchInput"; const getUserIdentifier = (accounts: WalletUser["linkedAccounts"]) => { const mainDetail = accounts[0]?.details; @@ -103,12 +104,38 @@ export function InAppWalletUsersPageContent(props: { authToken: string; }) { const [activePage, setActivePage] = useState(1); + const [searchValue, setSearchValue] = useState(""); const walletsQuery = useEmbeddedWallets({ authToken: props.authToken, clientId: props.clientId, page: activePage, }); const wallets = walletsQuery?.data?.users || []; + const filteredWallets = searchValue + ? wallets.filter((wallet) => { + const term = searchValue.toLowerCase(); + if (wallet.id.toLowerCase().includes(term)) { + return true; + } + if ( + wallet.wallets?.some((w) => w.address?.toLowerCase().includes(term)) + ) { + return true; + } + if ( + wallet.linkedAccounts?.some((acc) => { + return Object.values(acc.details).some( + (detail) => + typeof detail === "string" && + detail.toLowerCase().includes(term), + ); + }) + ) { + return true; + } + return false; + }) + : wallets; const { mutateAsync: getAllEmbeddedWallets, isPending } = useAllEmbeddedWallets({ authToken: props.authToken, @@ -146,7 +173,14 @@ export function InAppWalletUsersPageContent(props: {
{/* Top section */} -
+
+
+ +