@@ -21,8 +21,21 @@ export default function Sidebar(props) {
2121 products,
2222 isLoadingProducts,
2323 isErrorProducts,
24+ userParams,
25+ setUserParams,
26+ providers
2427 } = useAppContext ( ) ;
25- console . log ( '🚀 ~ file: Sidebar.js:24 ~ Sidebar ~ products:' , products )
28+
29+ function providerSelectHandler ( e ) {
30+ setUserParams ( {
31+ ...userParams ,
32+ provider : e . target . value
33+ } )
34+ }
35+
36+ function isProviderSelected ( provider ) {
37+ return provider === userParams . provider ;
38+ }
2639
2740 const filterButtonClass = openFilters
2841 ? styles . filterButtonOpen
@@ -34,35 +47,62 @@ export default function Sidebar(props) {
3447 < >
3548 < div className = { styles . topBar } >
3649 < h3 className = { styles . heading } > Opportunities</ h3 >
37- < Button className = { filterButtonClass } onClick = { ( ) => setOpenFilters ( ! openFilters ) } >
50+ < Button
51+ className = { filterButtonClass }
52+ onClick = { ( ) => setOpenFilters ( ! openFilters ) }
53+ >
3854 < HorizontalSlidersLines size = { 12 } />
3955 </ Button >
4056 < Button className = { styles . sortButton } >
41- Sort
57+ Sort
4258 < AlignJustifyDown size = { 12 } className = { styles . sortIcon } />
4359 </ Button >
4460 </ div >
4561
46- { ! errorOpps && (
47- < OpportunityList />
48- ) }
62+ { ! errorOpps && < OpportunityList /> }
4963
5064 { ! ! errorOpps && < div > There was error</ div > }
51-
65+
5266 { ! ! openFilters && (
5367 < div className = { styles . filtersFlyout } >
5468 < div className = { styles . filtersTopBar } >
5569 < h4 > Filters</ h4 >
56- < Button className = { styles . closeButton } onClick = { ( ) => setOpenFilters ( false ) } >
70+ < Button
71+ className = { styles . closeButton }
72+ onClick = { ( ) => setOpenFilters ( false ) }
73+ >
5774 < ArrowRightLine size = { 12 } />
5875 </ Button >
5976 </ div >
6077 < div className = { styles . filtersBody } >
61- { products . length && ( < select >
62- { products . map ( ( { title, id } ) => {
63- return ( < option key = { id } value = { id } > { title } </ option > )
64- } ) }
65- </ select > ) }
78+ < div >
79+ < span > Providers: </ span >
80+ < select onChange = { providerSelectHandler } >
81+ { providers . map ( ( provider ) => (
82+ < option
83+ value = { provider . id }
84+ key = { provider . id }
85+ selected = { isProviderSelected ( provider . id ) }
86+ >
87+ { provider . name }
88+ </ option >
89+ ) ) }
90+ </ select >
91+ </ div >
92+ < div >
93+ < div className = { styles . blockLabel } > Products: </ div >
94+ { products . length && (
95+ < select >
96+ { products . map ( ( { title, id } ) => {
97+ return (
98+ < option key = { id } value = { id } >
99+ { title }
100+ </ option >
101+ ) ;
102+ } ) }
103+ </ select >
104+ ) }
105+ </ div >
66106 </ div >
67107 </ div >
68108 ) }
0 commit comments