@@ -4,7 +4,7 @@ import { useDebounce } from "react-use";
44import styled from "styled-components" ;
55import Skeleton from "react-loading-skeleton" ;
66import { Searchbar , DropdownCascader } from "@kleros/ui-components-library" ;
7- import { rootCourtToItems , useCourtTree } from "hooks/ queries/useCourtTree" ;
7+ import { rootCourtToItems , useCourtTree } from "queries/useCourtTree" ;
88import { isUndefined } from "utils/index" ;
99import { decodeURIFilter , encodeURIFilter , useRootPath } from "utils/uri" ;
1010
@@ -44,10 +44,14 @@ const Search: React.FC = () => {
4444 [ search ]
4545 ) ;
4646 const { data : courtTreeData } = useCourtTree ( ) ;
47- const items = useMemo (
48- ( ) => ! isUndefined ( courtTreeData ) && [ rootCourtToItems ( courtTreeData . court , "id" ) ] ,
49- [ courtTreeData ]
50- ) ;
47+ const items = useMemo ( ( ) => {
48+ if ( ! isUndefined ( courtTreeData ) ) {
49+ const items = [ rootCourtToItems ( courtTreeData . court ! , "id" ) ] ;
50+ items . push ( { label : "All Courts" , value : "all" } ) ;
51+ return items ;
52+ }
53+ return undefined ;
54+ } , [ courtTreeData ] ) ;
5155
5256 return (
5357 < div >
@@ -63,7 +67,11 @@ const Search: React.FC = () => {
6367 < DropdownCascader
6468 items = { items }
6569 placeholder = { "Select Court" }
66- onSelect = { ( value ) => navigate ( `${ location } /${ page } /${ order } /${ { ...filterObject , court : value } } ` ) }
70+ onSelect = { ( value ) => {
71+ const { court : _ , ...filterWithoutCourt } = decodedFilter ;
72+ const newFilter = value === "all" ? filterWithoutCourt : { ...decodedFilter , court : value . toString ( ) } ;
73+ navigate ( `${ location } /${ page } /${ order } /${ encodeURIFilter ( newFilter ) } ` ) ;
74+ } }
6775 />
6876 ) : (
6977 < Skeleton width = { 240 } height = { 42 } />
0 commit comments