11import { useEntities } from '@graphprotocol/hypergraph-react' ;
22import { createLazyFileRoute } from '@tanstack/react-router' ;
3+ import { useState } from 'react' ;
34import { Bounty } from '@/schema' ;
45
56export const Route = createLazyFileRoute ( '/bounties' ) ( {
67 component : RouteComponent ,
78} ) ;
89
9- const PERSON_ENTITY_ID = '7728d2458ae842d3a90a37e0bb8ee676 ' ;
10+ type AllocationFilter = 'all' | 'allocated' | 'unallocated ';
1011
1112function 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 } ,
23+ filter,
24+ include : {
25+ allocated : { } ,
2126 } ,
2227 } ) ;
2328
2429 return (
2530 < div className = "flex flex-col gap-4 max-w-(--breakpoint-sm) mx-auto py-8" >
2631 < h1 className = "text-2xl font-bold" > Bounties</ h1 >
27- < 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 >
2845
2946 { isLoading && < div > Loading...</ div > }
3047 { isError && < div > Error loading bounties</ div > }
@@ -35,8 +52,11 @@ function RouteComponent() {
3552 { bounties . map ( ( bounty ) => (
3653 < li key = { bounty . id } className = "border rounded p-4" >
3754 < h2 className = "font-semibold" > { bounty . name } </ h2 >
38- { 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 > }
3956 < p className = "text-xs text-gray-400 mt-1" > { bounty . id } </ p >
57+ < p className = "text-xs text-gray-400 mt-1" >
58+ Allocated to: { bounty . allocated . map ( ( allocated ) => allocated . name ) . join ( ', ' ) }
59+ </ p >
4060 </ li >
4161 ) ) }
4262 </ ul >
0 commit comments