Started to work on filters

This commit is contained in:
Edin Dazdarevic
2017-04-04 03:00:04 +02:00
parent a6c5ee80e8
commit 0af6337132
8 changed files with 135 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
const setMinPrice = ({type, action}, component) => {
component.setState({
filters: {
...component.state.filters,
minPrice: parseFloat(action.minPrice) || 0
}
})
@@ -61,6 +62,20 @@ const searchPlaceChanged = ({type, action}, component) => {
});
}
const setRooms = ({type, action}, component) => {
const prevRooms = (component.state.filters.rooms || {});
component.setState({
filters: {
...component.state.filters,
rooms: {
...prevRooms,
[action.rooms]: !prevRooms[action.rooms]
}
}
});
}
const handlers = {
'SET_MIN_PRICE': setMinPrice,
'LISTINGS_LOADED': listingsLoaded,
@@ -69,6 +84,7 @@ const handlers = {
'NEXT_IMAGE': nextImage,
'VIEW_IMAGE': viewImage,
'SEARCH_PLACE_CHANGED': searchPlaceChanged,
'SET_ROOMS': setRooms,
'VIEW_LISTING_DETAILS': viewListingDetails
}