Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(explorer): add filter groups by admin #24

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions apps/explorer/src/app/[network]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand All @@ -49,7 +55,7 @@ export default function Network() {
) : (
allGroups && (
<div className="mx-auto max-w-7xl px-4 lg:px-8 pt-20">
<SearchBar className="mb-6" placeholder="Group ID" onChange={filterGroups} />
<SearchBar className="mb-6" placeholder="Group ID, Admin" onChange={filterGroups} />

<div className="flex justify-center flex-col pb-10 font-[family-name:var(--font-geist-sans)]">
<ul className="divide-y divide-gray-300 min-w-xl">
Expand Down