Filters done
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user