Filters done

This commit is contained in:
Edin Dazdarevic
2017-04-05 02:02:43 +02:00
parent d2ee02b6df
commit 15dc596f3d
10 changed files with 150 additions and 30 deletions

View File

@@ -99,7 +99,6 @@ const searchPlaceChanged = ({ type, action }, component) => {
const setRooms = ({ type, action }, component) => {
const prevRooms = component.state.filters.rooms || {};
console.log('BERORE ROOMS');
component.setState(
{
@@ -112,14 +111,12 @@ const setRooms = ({ type, action }, component) => {
}
},
() => {
console.log('after rooms');
component.refreshListings();
}
);
};
const updateSearch = ({ type, action }, component) => {
console.log("updating search");
component.setState(
{
filters: {
@@ -134,6 +131,26 @@ const updateSearch = ({ type, action }, component) => {
);
};
const setCategory = ({type, action}, component) => {
const prevCategory = component.state.filters.category || {};
component.setState(
{
filters: {
...component.state.filters,
category: {
...prevCategory,
[action.category]: !prevCategory[action.category]
}
}
},
() => {
component.refreshListings();
}
);
}
const handlers = {
SET_MIN_PRICE: setMinPrice,
SET_MAX_PRICE: setMaxPrice,
@@ -147,7 +164,8 @@ const handlers = {
SEARCH_PLACE_CHANGED: searchPlaceChanged,
SET_ROOMS: setRooms,
VIEW_LISTING_DETAILS: viewListingDetails,
UPDATE_SEARCH: updateSearch
UPDATE_SEARCH: updateSearch,
SET_CATEGORY: setCategory
};
export const handleMessage = ({ type, action }, component) => {