Skip to content

Commit 1d38e04

Browse files
committed
hook make sure string filters update state
1 parent f0bdf8e commit 1d38e04

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/components/Filter/Filter.jsx

+16-18
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ const Filter = () => {
7979
const filterContainer = []
8080

8181
if (_selectedProductData?.queryables?.properties == null) return null
82-
for (const constraintName of Object.keys( _selectedProductData.queryables.properties)) {
83-
const constraint = _selectedProductData.queryables.properties[constraintName]
82+
for (const constraintName of Object.keys(
83+
_selectedProductData.queryables.properties
84+
)) {
85+
const constraint =
86+
_selectedProductData.queryables.properties[constraintName]
8487
if (constraint.type === 'integer') {
8588
filterContainer.push(
8689
<FormControl key={constraintName} sx={{ marginTop: 4 }}>
@@ -105,6 +108,9 @@ const Filter = () => {
105108
})
106109
)
107110
}}
111+
required={_selectedProductData.queryables.required.includes(
112+
constraintName
113+
)}
108114
/>
109115
<FormHelperText sx={{ color: '#FFF', paddingTop: 3.5 }}>
110116
{constraint.description}
@@ -159,6 +165,13 @@ const Filter = () => {
159165
id={constraintName}
160166
name={constraintName}
161167
aria-describedby={constraintName}
168+
required={_selectedProductData.queryables.required.includes(constraintName)}
169+
onChange={(event, newValue) => {
170+
store.dispatch(
171+
setSelectedProductFilters({
172+
..._selectedProductFilters,
173+
[constraintName]: event.target.value
174+
}))}}
162175
/>
163176
<FormHelperText>{constraint.description}</FormHelperText>
164177
</FormControl>
@@ -229,21 +242,6 @@ const Filter = () => {
229242

230243
function processSearchBtn(formEvent) {
231244
formEvent.preventDefault()
232-
/*
233-
const keys = Object.keys(formEvent.target).slice(0, -2)
234-
let res = {}
235-
console.log(_selectedProductFilters)
236-
237-
for (const key of keys) {
238-
if (formEvent.target[key].value) {
239-
console.log(formEvent.formEvent.target[key])
240-
241-
res = {
242-
...res,
243-
[formEvent.target[key].name]: formEvent.target[key].value
244-
}
245-
}
246-
} */
247245

248246
console.log('Parameters: ', _selectedProductFilters)
249247
newSearch(_selectedProductFilters)
@@ -258,7 +256,7 @@ const Filter = () => {
258256

259257
<div className="" style={{ marginTop: 24 }}>
260258
<button className={`actionButton searchButton`} type="submit">
261-
Search
259+
Find Opportunities
262260
</button>
263261
</div>
264262
</form>

0 commit comments

Comments
 (0)