@@ -77,10 +77,12 @@ export function ControlUnits({
77
77
dispatch ( dashboardActions . setControlUnitsFilters ( { key : 'type' , value : nextValue } ) )
78
78
}
79
79
80
+ const hasChildren = ! ! ( controlUnitResults && controlUnitResults ?. length > 5 )
81
+
80
82
return (
81
83
< div >
82
84
< Accordion isExpanded = { isExpanded } setExpandedAccordion = { setExpandedAccordion } title = "Unités" >
83
- < Wrapper $hasChildren = { ! ! ( controlUnitResults && controlUnitResults ?. length > 1 ) } >
85
+ < Wrapper $hasChildren = { hasChildren } >
84
86
< StyledTextInput
85
87
Icon = { Icon . Search }
86
88
isLabelHidden
@@ -91,10 +93,7 @@ export function ControlUnits({
91
93
placeholder = "Rechercher une unité"
92
94
value = { filters ?. query }
93
95
/>
94
- < SelectFilters
95
- $hasChildren = { ! ! ( controlUnitResults && controlUnitResults ?. length > 1 ) }
96
- $isExpanded = { isExpanded }
97
- >
96
+ < SelectFilters $hasChildren = { hasChildren } $isExpanded = { isExpanded } >
98
97
< StyledSelect
99
98
isLabelHidden
100
99
isTransparent
@@ -130,13 +129,10 @@ export function ControlUnits({
130
129
value = { filters ?. stationId }
131
130
/>
132
131
</ SelectFilters >
133
- { controlUnitResults && controlUnitResults . length > 0 && (
134
- < ResultList >
135
- { controlUnitResults . map ( controlUnit => (
136
- < Item key = { controlUnit . id } controlUnit = { controlUnit } />
137
- ) ) }
138
- </ ResultList >
139
- ) }
132
+ < ResultList $hasResults = { hasChildren } >
133
+ { controlUnitResults &&
134
+ controlUnitResults . map ( controlUnit => < Item key = { controlUnit . id } controlUnit = { controlUnit } /> ) }
135
+ </ ResultList >
140
136
</ Wrapper >
141
137
</ Accordion >
142
138
< SelectedControlUnits controlUnits = { controlUnits } isSelectedAccordionOpen = { isSelectedAccordionOpen } />
@@ -150,7 +146,6 @@ const Wrapper = styled.div<{ $hasChildren: boolean }>`
150
146
flex-direction: column;
151
147
gap: 16px;
152
148
padding: 16px 24px;
153
- ${ ( { $hasChildren } ) => ! $hasChildren && 'padding-bottom: 58px;' }
154
149
`
155
150
156
151
const StyledTextInput = styled ( TextInput ) `
@@ -179,11 +174,12 @@ const SelectFilters = styled.div<{ $hasChildren: boolean; $isExpanded: boolean }
179
174
} }
180
175
${ ( { $hasChildren } ) => ! $hasChildren && 'position: absolute; margin-top: 41px; width: 27%;' }
181
176
`
182
- const ResultList = styled . ul `
177
+ const ResultList = styled . ul < { $hasResults : boolean } > `
183
178
display: flex;
184
179
flex-direction: column;
185
180
gap: 8px;
186
181
list-style-type: none;
187
182
padding: 0px;
188
183
width: 100%;
184
+ ${ ( { $hasResults } ) => ! $hasResults && 'margin-top: 37px;' }
189
185
`
0 commit comments