1- import React from 'react' ;
1+ import React , { useState } from 'react' ;
22import {
33 Typography ,
44 FormControl ,
@@ -13,7 +13,8 @@ import EligibilityOverviewTag from './EligibilityOverviewTag';
1313import RegularButton from '@/ui/shared-components/buttons/RegularButton' ;
1414import theme from '@/theme' ;
1515
16- const EligibilityOverviewFilter = ( { t, filterOptions, filters, onChangeFilters } ) => {
16+ const EligibilityOverviewFilter = ( { t, filterOptions, isDesktop, filters, onChangeFilters } ) => {
17+ const [ open , setOpen ] = useState ( false ) ;
1718 const handleChange = ( key ) => ( event ) => {
1819 onChangeFilters ( prev => ( {
1920 ...prev ,
@@ -44,30 +45,44 @@ const EligibilityOverviewFilter = ({ t, filterOptions, filters, onChangeFilters
4445 < Typography variant = "h4" sx = { { color : 'blue.main' , fontWeight : '400' } } >
4546 { t ( 'app.browseAll.filter.title' ) }
4647 </ Typography >
47- < HBox sx = { { gap : 4 , flexWrap : 'wrap' } } >
48- { Object . keys ( filterOptions ) . length > 0 && (
49- Object . keys ( filterOptions ) . map ( ( key , index ) => (
50- < FormControl key = { index } sx = { { minWidth : 200 } } >
51- < InputLabel id = { `${ key } -label` } > { t ( `app.browseAll.filter.${ key } ` ) } </ InputLabel >
52- < Select
53- labelId = { `${ key } -label` }
54- multiple
55- value = { filters [ key ] || [ ] }
56- onChange = { handleChange ( key ) }
57- label = { t ( `app.browseAll.filter.${ key } ` ) }
58- renderValue = { ( ) => t ( `app.browseAll.filter.${ key } ` ) }
59- sx = { { borderRadius : theme . shape . borderRadius } }
60- >
61- { filterOptions [ key ] . map ( item => (
62- < MenuItem key = { item . id } value = { item . id } >
63- < Checkbox checked = { ! ! filters [ key ] ?. includes ( item . id ) } /> < ListItemText primary = { item . label } />
64- </ MenuItem >
65- ) ) }
66- </ Select >
67- </ FormControl >
68- ) )
69- ) }
70- </ HBox >
48+ {
49+ ! isDesktop && (
50+ < RegularButton
51+ onClick = { ( ) => setOpen ( ! open ) }
52+ variant = { 'whiteOutlinedBlue' }
53+ text = { open ? 'app.browseAll.filter.btnClose' : 'app.browseAll.filter.btn' }
54+ size = { 'small' }
55+ />
56+ )
57+ }
58+ {
59+ ( isDesktop || open ) && (
60+ < HBox sx = { { gap : 4 , flexWrap : 'wrap' } } >
61+ { Object . keys ( filterOptions ) . length > 0 && (
62+ Object . keys ( filterOptions ) . map ( ( key , index ) => (
63+ < FormControl key = { index } sx = { { minWidth : 200 } } >
64+ < InputLabel id = { `${ key } -label` } > { t ( `app.browseAll.filter.${ key } ` ) } </ InputLabel >
65+ < Select
66+ labelId = { `${ key } -label` }
67+ multiple
68+ value = { filters [ key ] || [ ] }
69+ onChange = { handleChange ( key ) }
70+ label = { t ( `app.browseAll.filter.${ key } ` ) }
71+ renderValue = { ( ) => t ( `app.browseAll.filter.${ key } ` ) }
72+ sx = { { borderRadius : theme . shape . borderRadius } }
73+ >
74+ { filterOptions [ key ] . map ( item => (
75+ < MenuItem key = { item . id } value = { item . id } >
76+ < Checkbox checked = { ! ! filters [ key ] ?. includes ( item . id ) } /> < ListItemText primary = { item . label } />
77+ </ MenuItem >
78+ ) ) }
79+ </ Select >
80+ </ FormControl >
81+ ) )
82+ ) }
83+ </ HBox >
84+ )
85+ }
7186 </ HBox >
7287 {
7388 Object . entries ( groupedSelected ) . length > 0 && (
@@ -84,14 +99,18 @@ const EligibilityOverviewFilter = ({ t, filterOptions, filters, onChangeFilters
8499 </ HBox >
85100 )
86101 }
87- < HBox sx = { { justifyContent : 'flex-end' } } >
88- < RegularButton
89- text = { 'Clear filters' }
90- variant = { 'greyContained' }
91- onClick = { ( ) => onChangeFilters ( ( ) => ( { } ) ) }
92- size = 'xsmall'
93- />
94- </ HBox >
102+ {
103+ ( isDesktop || open ) && (
104+ < HBox sx = { { justifyContent : 'flex-end' } } >
105+ < RegularButton
106+ text = { 'Clear filters' }
107+ variant = { 'greyContained' }
108+ onClick = { ( ) => onChangeFilters ( ( ) => ( { } ) ) }
109+ size = 'xsmall'
110+ />
111+ </ HBox >
112+ )
113+ }
95114 </ VBox >
96115 ) ;
97116} ;
0 commit comments