From f004eee952b0e74b81862c1f0db65fbbfd75d76e Mon Sep 17 00:00:00 2001 From: Vivian Plasencia Date: Mon, 2 Dec 2024 12:38:56 +0100 Subject: [PATCH] feat(explorer): add filter groups by admin re #23 --- apps/explorer/src/app/[network]/page.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/explorer/src/app/[network]/page.tsx b/apps/explorer/src/app/[network]/page.tsx index beabffe..7bf4008 100644 --- a/apps/explorer/src/app/[network]/page.tsx +++ b/apps/explorer/src/app/[network]/page.tsx @@ -34,8 +34,14 @@ export default function Network() { }, []) const filterGroups = useCallback( - (groupId: string) => { - const groups = allGroups.filter((group) => (!groupId ? true : group.id.includes(groupId))) + (groupIdOrAdmin: string) => { + let groups: GroupResponse[] + if (groupIdOrAdmin.startsWith("0x")) { + groupIdOrAdmin = groupIdOrAdmin.toLowerCase() + groups = allGroups.filter((group) => (!groupIdOrAdmin ? true : group.admin?.includes(groupIdOrAdmin))) + } else { + groups = allGroups.filter((group) => (!groupIdOrAdmin ? true : group.id.includes(groupIdOrAdmin))) + } setFilteredGroups(groups) }, @@ -49,7 +55,7 @@ export default function Network() { ) : ( allGroups && (
- +