@@ -77,159 +77,153 @@ const Filter = () => {
77
77
} )
78
78
79
79
const filterContainer = [ ]
80
- console . log ( _selectedProductData )
81
80
82
- if ( _selectedProductData ?. queryables ?. properties ) {
83
- for ( const constraintName of Object . keys (
84
- _selectedProductData . queryables . properties
85
- ) ) {
86
- const constraint =
87
- _selectedProductData . queryables . properties [ constraintName ]
88
- console . log ( constraint )
89
- if ( constraint . type === 'integer' ) {
90
- filterContainer . push (
91
- < FormControl key = { constraintName } sx = { { marginTop : 4 } } >
92
- < InputLabel
93
- htmlFor = { constraintName }
94
- sx = { { color : '#FFF' , paddingTop : 2 } }
95
- >
96
- { constraint . title }
97
- </ InputLabel >
98
- < Slider
99
- id = { constraintName }
100
- name = { constraintName }
101
- valueLabelDisplay = "on"
102
- min = { constraint . minimum }
103
- max = { constraint . maximum }
104
- value = { _selectedProductFilters [ constraintName ] || 0 }
105
- onChange = { ( event , newValue ) => {
106
- store . dispatch (
107
- setSelectedProductFilters ( {
108
- ..._selectedProductFilters ,
109
- [ constraintName ] : newValue
110
- } )
111
- )
112
- } }
113
- />
114
- < FormHelperText sx = { { color : '#FFF' , paddingTop : 3.5 } } >
115
- { constraint . description }
116
- </ FormHelperText >
117
- </ FormControl >
118
- )
119
- continue
120
- }
121
-
122
- if ( constraint . type === 'number' ) {
123
- filterContainer . push (
124
- < FormControl key = { constraintName } sx = { { marginTop : 4 } } >
125
- < InputLabel
126
- htmlFor = { constraintName }
127
- sx = { { color : '#FFF' , paddingTop : 2 } }
128
- >
129
- { constraint . title }
130
- </ InputLabel >
131
- < Slider
132
- id = { constraintName }
133
- name = { constraintName }
134
- valueLabelDisplay = "on"
135
- min = { constraint . minimum }
136
- max = { constraint . maximum }
137
- value = { _selectedProductFilters [ constraintName ] || [ 0 , 0 ] } // TODO: this should be managed by redux, but it's not working right now :) (the other controls should also be added on redux)
138
- onChange = { ( event , newValue ) => {
139
- store . dispatch (
140
- setSelectedProductFilters ( {
141
- ..._selectedProductFilters ,
142
- [ constraintName ] : newValue
143
- } )
144
- )
145
- } }
146
- />
147
- < FormHelperText sx = { { color : '#FFF' , paddingTop : 3.5 } } >
148
- { constraint . description }
149
- </ FormHelperText >
150
- </ FormControl >
151
- )
152
- continue
153
- }
154
- if ( constraint . type === 'string' ) {
155
- filterContainer . push (
156
- < FormControl key = { constraintName } >
157
- < InputLabel
158
- htmlFor = { constraintName }
159
- sx = { { color : '#FFF' , paddingTop : 0 } }
160
- >
161
- { constraint . title }
162
- </ InputLabel >
163
- < Input
164
- id = { constraintName }
165
- name = { constraintName }
166
- aria-describedby = { constraintName }
167
- />
168
- < FormHelperText > { constraint . description } </ FormHelperText >
169
- </ FormControl >
170
- )
171
- continue
172
- }
81
+ if ( _selectedProductData ?. queryables ?. properties == null ) return null
82
+ for ( const constraintName of Object . keys ( _selectedProductData . queryables . properties ) ) {
83
+ const constraint = _selectedProductData . queryables . properties [ constraintName ]
84
+ if ( constraint . type === 'integer' ) {
85
+ filterContainer . push (
86
+ < FormControl key = { constraintName } sx = { { marginTop : 4 } } >
87
+ < InputLabel
88
+ htmlFor = { constraintName }
89
+ sx = { { color : '#FFF' , paddingTop : 2 } }
90
+ >
91
+ { constraint . title }
92
+ </ InputLabel >
93
+ < Slider
94
+ id = { constraintName }
95
+ name = { constraintName }
96
+ valueLabelDisplay = "on"
97
+ min = { constraint . minimum }
98
+ max = { constraint . maximum }
99
+ value = { _selectedProductFilters [ constraintName ] || 0 }
100
+ onChange = { ( event , newValue ) => {
101
+ store . dispatch (
102
+ setSelectedProductFilters ( {
103
+ ..._selectedProductFilters ,
104
+ [ constraintName ] : newValue
105
+ } )
106
+ )
107
+ } }
108
+ />
109
+ < FormHelperText sx = { { color : '#FFF' , paddingTop : 3.5 } } >
110
+ { constraint . description }
111
+ </ FormHelperText >
112
+ </ FormControl >
113
+ )
114
+ continue
115
+ }
173
116
174
- if ( constraint . type === 'boolean' ) {
175
- console . log ( constraint )
176
- filterContainer . push (
177
- < FormControl key = { constraintName } >
178
- < InputLabel
179
- htmlFor = { constraintName }
180
- sx = { { color : '#FFF' , paddingTop : 0 } }
181
- >
182
- { constraint . title }
183
- </ InputLabel >
184
- < Switch
185
- id = { constraintName }
186
- name = { constraintName }
187
- aria-describedby = { constraintName }
188
- />
189
- < FormHelperText > { constraint . description } </ FormHelperText >
190
- </ FormControl >
191
- )
192
- continue
193
- }
117
+ if ( constraint . type === 'number' ) {
118
+ filterContainer . push (
119
+ < FormControl key = { constraintName } sx = { { marginTop : 4 } } >
120
+ < InputLabel
121
+ htmlFor = { constraintName }
122
+ sx = { { color : '#FFF' , paddingTop : 2 } }
123
+ >
124
+ { constraint . title }
125
+ </ InputLabel >
126
+ < Slider
127
+ id = { constraintName }
128
+ name = { constraintName }
129
+ valueLabelDisplay = "on"
130
+ min = { constraint . minimum }
131
+ max = { constraint . maximum }
132
+ value = { _selectedProductFilters [ constraintName ] || [ 0 , 0 ] } // TODO: this should be managed by redux, but it's not working right now :) (the other controls should also be added on redux)
133
+ onChange = { ( event , newValue ) => {
134
+ store . dispatch (
135
+ setSelectedProductFilters ( {
136
+ ..._selectedProductFilters ,
137
+ [ constraintName ] : newValue
138
+ } )
139
+ )
140
+ } }
141
+ />
142
+ < FormHelperText sx = { { color : '#FFF' , paddingTop : 3.5 } } >
143
+ { constraint . description }
144
+ </ FormHelperText >
145
+ </ FormControl >
146
+ )
147
+ continue
148
+ }
149
+ if ( constraint . type === 'string' ) {
150
+ filterContainer . push (
151
+ < FormControl key = { constraintName } >
152
+ < InputLabel
153
+ htmlFor = { constraintName }
154
+ sx = { { color : '#FFF' , paddingTop : 0 } }
155
+ >
156
+ { constraint . title }
157
+ </ InputLabel >
158
+ < Input
159
+ id = { constraintName }
160
+ name = { constraintName }
161
+ aria-describedby = { constraintName }
162
+ />
163
+ < FormHelperText > { constraint . description } </ FormHelperText >
164
+ </ FormControl >
165
+ )
166
+ continue
167
+ }
194
168
195
- if ( constraint . type === 'array' ) {
196
- // TODO for umbras case we need to add a check for the $ref property, if it exists we need to get the enum values from the $ref object
197
- // and populate the dropdown with those values
198
- // otherwise just take the enum values from the parameter properties
199
- // its not working for the last umbra json but maybe after the changes it will?
169
+ if ( constraint . type === 'boolean' ) {
170
+ console . log ( constraint )
171
+ filterContainer . push (
172
+ < FormControl key = { constraintName } >
173
+ < InputLabel
174
+ htmlFor = { constraintName }
175
+ sx = { { color : '#FFF' , paddingTop : 0 } }
176
+ >
177
+ { constraint . title }
178
+ </ InputLabel >
179
+ < Switch
180
+ id = { constraintName }
181
+ name = { constraintName }
182
+ aria-describedby = { constraintName }
183
+ />
184
+ < FormHelperText > { constraint . description } </ FormHelperText >
185
+ </ FormControl >
186
+ )
187
+ continue
188
+ }
200
189
201
- let refItem = { }
202
- if ( constraint . items . $ref ) {
203
- const refName = constraint . items . $ref . split ( '/' ) . pop ( )
204
- refItem = _selectedProductData . parameters . $defs [ refName ]
205
- }
190
+ if ( constraint . type === 'array' ) {
191
+ // TODO for umbras case we need to add a check for the $ref property, if it exists we need to get the enum values from the $ref object
192
+ // and populate the dropdown with those values
193
+ // otherwise just take the enum values from the parameter properties
194
+ // its not working for the last umbra json but maybe after the changes it will?
206
195
207
- const options = [ ]
196
+ let refItem = { }
197
+ if ( constraint . items . $ref ) {
198
+ const refName = constraint . items . $ref . split ( '/' ) . pop ( )
199
+ refItem = _selectedProductData . parameters . $defs [ refName ]
200
+ }
208
201
209
- for ( const option of refItem ?. enum || [ ] ) {
210
- options . push (
211
- < MenuItem key = { option } value = { option } >
212
- { option }
213
- </ MenuItem >
214
- )
215
- }
202
+ const options = [ ]
216
203
217
- filterContainer . push (
218
- < FormControl key = { constraintName } >
219
- < InputLabel
220
- htmlFor = { constraintName }
221
- sx = { { color : '#FFF' , paddingTop : 0 } }
222
- >
223
- { constraint . title }
224
- </ InputLabel >
225
- < Select id = { constraintName } name = { constraintName } >
226
- { options }
227
- </ Select >
228
- < FormHelperText > { constraint . description } </ FormHelperText >
229
- </ FormControl >
204
+ for ( const option of refItem ?. enum || [ ] ) {
205
+ options . push (
206
+ < MenuItem key = { option } value = { option } >
207
+ { option }
208
+ </ MenuItem >
230
209
)
231
- continue
232
210
}
211
+
212
+ filterContainer . push (
213
+ < FormControl key = { constraintName } >
214
+ < InputLabel
215
+ htmlFor = { constraintName }
216
+ sx = { { color : '#FFF' , paddingTop : 0 } }
217
+ >
218
+ { constraint . title }
219
+ </ InputLabel >
220
+ < Select id = { constraintName } name = { constraintName } >
221
+ { options }
222
+ </ Select >
223
+ < FormHelperText > { constraint . description } </ FormHelperText >
224
+ </ FormControl >
225
+ )
226
+ continue
233
227
}
234
228
}
235
229
0 commit comments