Skip to content

Commit 26d94cb

Browse files
committed
implement allocation filter
1 parent 580cf09 commit 26d94cb

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

apps/events/src/routes/bounties.lazy.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
import { Bounty } from '@/schema';
22
import { useEntities } from '@graphprotocol/hypergraph-react';
33
import { createLazyFileRoute } from '@tanstack/react-router';
4+
import { useState } from 'react';
45

56
export const Route = createLazyFileRoute('/bounties')({
67
component: RouteComponent,
78
});
89

9-
const PERSON_ENTITY_ID = '7728d2458ae842d3a90a37e0bb8ee676';
10+
type AllocationFilter = 'all' | 'allocated' | 'unallocated';
1011

1112
function RouteComponent() {
13+
const [allocationFilter, setAllocationFilter] = useState<AllocationFilter>('all');
14+
const filter = allocationFilter === 'all' ? undefined : { allocated: { exists: allocationFilter === 'allocated' } };
15+
1216
const {
1317
data: bounties,
1418
isLoading,
1519
isError,
1620
} = useEntities(Bounty, {
1721
mode: 'public',
1822
spaces: 'all',
19-
filter: {
20-
interestedIn: { entityId: PERSON_ENTITY_ID },
21-
},
23+
filter,
2224
include: {
2325
allocated: {},
2426
},
@@ -27,7 +29,19 @@ function RouteComponent() {
2729
return (
2830
<div className="flex flex-col gap-4 max-w-(--breakpoint-sm) mx-auto py-8">
2931
<h1 className="text-2xl font-bold">Bounties</h1>
30-
<p className="text-sm text-gray-500">Bounties where person {PERSON_ENTITY_ID} expressed interest</p>
32+
<p className="text-sm text-gray-500">Filter bounties by allocation status</p>
33+
<label className="text-sm text-gray-700 flex flex-col gap-1">
34+
Allocation status
35+
<select
36+
className="border rounded px-2 py-1 bg-white"
37+
value={allocationFilter}
38+
onChange={(event) => setAllocationFilter(event.target.value as AllocationFilter)}
39+
>
40+
<option value="all">All</option>
41+
<option value="allocated">Allocated (at least one person)</option>
42+
<option value="unallocated">Unallocated (no one)</option>
43+
</select>
44+
</label>
3145

3246
{isLoading && <div>Loading...</div>}
3347
{isError && <div>Error loading bounties</div>}
@@ -38,7 +52,7 @@ function RouteComponent() {
3852
{bounties.map((bounty) => (
3953
<li key={bounty.id} className="border rounded p-4">
4054
<h2 className="font-semibold">{bounty.name}</h2>
41-
{bounty.description && <p className="text-sm text-gray-600">{bounty.description}</p>}
55+
{bounty.description && <p className="text-sm text-gray-600">{bounty.description.substring(0, 100)}...</p>}
4256
<p className="text-xs text-gray-400 mt-1">{bounty.id}</p>
4357
<p className="text-xs text-gray-400 mt-1">
4458
Allocated to: {bounty.allocated.map((allocated) => allocated.name).join(', ')}

0 commit comments

Comments
 (0)