11import React , { useState } from "react" ;
2- import styled , { css } from "styled-components" ;
3- import { landscapeStyle } from "styles/landscapeStyle" ;
42import { useNavigate , useParams , useSearchParams } from "react-router-dom" ;
53import { useDebounce } from "react-use" ;
64import { Searchbar , DropdownSelect , Button } from "@kleros/ui-components-library" ;
@@ -9,68 +7,14 @@ import PaperIcon from "svgs/icons/paper.svg";
97import PlusIcon from "svgs/icons/plus.svg" ;
108import { List_filters } from "consts/filters" ;
119
12- const Container = styled . div `
13- display: flex;
14- flex-direction: column;
15- gap: 16px;
16- margin-bottom: 16px;
17- flex-wrap: wrap;
18-
19- ${ landscapeStyle (
20- ( ) =>
21- css `
22- flex-direction: row;
23- `
24- ) }
25- ` ;
26-
27- const SearchBarContainer = styled . div `
28- display: flex;
29- flex: 1;
30- flex-wrap: wrap;
31- gap: 8px;
32- z-index: 0;
33- ` ;
34-
35- const StyledSearchbar = styled ( Searchbar ) `
36- flex: 1;
37- flex-basis: 310px;
38- input {
39- font-size: 16px;
40- height: 45px;
41- padding-top: 0px;
42- padding-bottom: 0px;
43- }
44- ` ;
45-
46- const StyledPaperIcon = styled ( PaperIcon ) `
47- path {
48- fill: ${ ( { theme } ) => theme . whiteBackground } ;
49- }
50- ` ;
51-
52- const StyledPlusIcon = styled ( PlusIcon ) `
53- path {
54- fill: ${ ( { theme } ) => theme . whiteBackground } ;
55- }
56- ` ;
57-
58- const StyledDropdownSelect = styled ( DropdownSelect ) `
59- [class*="button__Container"] {
60- [class*="base-item__Item"] {
61- border-left: 1px solid transparent;
62- }
63- }
64- ` ;
65-
6610const Search : React . FC < { isList ?: Boolean } > = ( { isList } ) => {
6711 const { page, order, filter, id } = useParams ( ) ;
6812 const location = useListRootPath ( ) ;
6913 const [ searchParams ] = useSearchParams ( ) ;
7014 const keywords = searchParams . get ( "keywords" ) ;
7115
7216 const decodedFilter = decodeListURIFilter ( filter ?? "all" ) ;
73- const [ search , setSearch ] = useState ( keywords ) ;
17+ const [ search , setSearch ] = useState ( keywords ?? undefined ) ;
7418 const navigate = useNavigate ( ) ;
7519
7620 useDebounce (
@@ -91,37 +35,59 @@ const Search: React.FC<{ isList?: Boolean }> = ({ isList }) => {
9135 } ;
9236
9337 return (
94- < Container >
95- < SearchBarContainer >
96- < StyledSearchbar
38+ < div className = "flex flex-col flex-wrap gap-4 mb-4 lg:flex-row" >
39+ < div className = "flex flex-1 flex-wrap gap-2 z-0" >
40+ < Searchbar
41+ className = "flex-1 basis-[310px] [&_input]:py-0"
9742 type = "text"
9843 placeholder = "Search by keywords"
9944 value = { search }
100- onChange = { ( e ) => setSearch ( e . target . value ) }
45+ onChange = { ( value ) => setSearch ( value ) }
10146 />
102- </ SearchBarContainer >
103- < StyledDropdownSelect
47+ </ div >
48+ < DropdownSelect
10449 items = { [
105- { text : "All Status" , dot : "grey" , value : JSON . stringify ( { } ) } ,
106- { text : "Active" , dot : "orange" , value : JSON . stringify ( List_filters . Active ) } ,
50+ { id : JSON . stringify ( { } ) , text : "All Status" , dot : "grey" , itemValue : JSON . stringify ( { } ) } ,
10751 {
52+ id : JSON . stringify ( List_filters . Active ) ,
53+ text : "Active" ,
54+ dot : "orange" ,
55+ itemValue : JSON . stringify ( List_filters . Active ) ,
56+ } ,
57+ {
58+ id : JSON . stringify ( List_filters . Pending ) ,
10859 text : "Pending" ,
10960 dot : "blue" ,
110- value : JSON . stringify ( List_filters . Pending ) ,
61+ itemValue : JSON . stringify ( List_filters . Pending ) ,
62+ } ,
63+ {
64+ id : JSON . stringify ( List_filters . Disputed ) ,
65+ text : "Disputed" ,
66+ dot : "purple" ,
67+ itemValue : JSON . stringify ( List_filters . Disputed ) ,
68+ } ,
69+ {
70+ id : JSON . stringify ( List_filters . Included ) ,
71+ text : "Included" ,
72+ dot : "green" ,
73+ itemValue : JSON . stringify ( List_filters . Included ) ,
74+ } ,
75+ {
76+ id : JSON . stringify ( List_filters . Removed ) ,
77+ text : "Removed" ,
78+ dot : "red" ,
79+ itemValue : JSON . stringify ( List_filters . Removed ) ,
11180 } ,
112- { text : "Disputed" , dot : "purple" , value : JSON . stringify ( List_filters . Disputed ) } ,
113- { text : "Included" , dot : "green" , value : JSON . stringify ( List_filters . Included ) } ,
114- { text : "Removed" , dot : "red" , value : JSON . stringify ( List_filters . Removed ) } ,
11581 ] }
116- defaultValue = { JSON . stringify ( decodedFilter ) }
117- callback = { handleStatusChange }
82+ defaultSelectedKey = { JSON . stringify ( decodedFilter ) }
83+ callback = { ( item ) => handleStatusChange ( item . itemValue ) }
11884 />
11985 { isList ? (
120- < Button text = "Create New List" Icon = { StyledPaperIcon } onClick = { ( ) => navigate ( "/submit-list" ) } />
86+ < Button text = "Create New List" Icon = { PaperIcon } onClick = { ( ) => navigate ( "/submit-list" ) } />
12187 ) : (
122- < Button Icon = { StyledPlusIcon } text = "Submit Item" onClick = { ( ) => navigate ( `/submit-item/${ id } ` ) } />
88+ < Button Icon = { PlusIcon } text = "Submit Item" onClick = { ( ) => navigate ( `/submit-item/${ id } ` ) } />
12389 ) }
124- </ Container >
90+ </ div >
12591 ) ;
12692} ;
12793
0 commit comments