Make price filtering work
This commit is contained in:
@@ -1,8 +1,19 @@
|
||||
const setMaxPrice = ({type, action}, component) => {
|
||||
component.setState({
|
||||
filters: {
|
||||
...component.state.filters,
|
||||
maxPrice: parseFloat(action.maxPrice),
|
||||
dirty: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const setMinPrice = ({type, action}, component) => {
|
||||
component.setState({
|
||||
filters: {
|
||||
...component.state.filters,
|
||||
minPrice: parseFloat(action.minPrice) || 0
|
||||
minPrice: parseFloat(action.minPrice),
|
||||
dirty: true
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -73,11 +84,26 @@ const setRooms = ({type, action}, component) => {
|
||||
[action.rooms]: !prevRooms[action.rooms]
|
||||
}
|
||||
}
|
||||
}, () => {
|
||||
component.refreshListings();
|
||||
});
|
||||
}
|
||||
|
||||
const updateSearch = ({type, action}, component) => {
|
||||
console.log('updating search');
|
||||
component.setState({
|
||||
filters: {
|
||||
...component.state.filters,
|
||||
dirty: false
|
||||
}
|
||||
}, () => {
|
||||
component.refreshListings();
|
||||
});
|
||||
}
|
||||
|
||||
const handlers = {
|
||||
'SET_MIN_PRICE': setMinPrice,
|
||||
'SET_MAX_PRICE': setMaxPrice,
|
||||
'LISTINGS_LOADED': listingsLoaded,
|
||||
'EXPAND_DESCRIPTION': expandDescription,
|
||||
'PREV_IMAGE': prevImage,
|
||||
@@ -85,7 +111,8 @@ const handlers = {
|
||||
'VIEW_IMAGE': viewImage,
|
||||
'SEARCH_PLACE_CHANGED': searchPlaceChanged,
|
||||
'SET_ROOMS': setRooms,
|
||||
'VIEW_LISTING_DETAILS': viewListingDetails
|
||||
'VIEW_LISTING_DETAILS': viewListingDetails,
|
||||
'UPDATE_SEARCH': updateSearch
|
||||
}
|
||||
|
||||
export const handleMessage = ({type, action}, component) => {
|
||||
|
||||
Reference in New Issue
Block a user