Sorting & showing date
This commit is contained in:
@@ -17,7 +17,8 @@ export const loadProperties = ({
|
||||
rooms = {},
|
||||
category = {},
|
||||
page = 1,
|
||||
pins = false
|
||||
pins = false,
|
||||
sort = ''
|
||||
}) => {
|
||||
const allRooms = Object
|
||||
.keys(rooms)
|
||||
@@ -31,7 +32,7 @@ export const loadProperties = ({
|
||||
|
||||
// TODO: handle errors
|
||||
//return fetch(process.env.API_URL + '/api/search', {
|
||||
let url = `http://localhost:3001/api/search/listings?bounds=${bounds}&minPrice=${minPrice}&maxPrice=${maxPrice}&rooms=${allRooms}&minSize=${minSize}&maxSize=${maxSize}&category=${allCategories}&page=${page}&pins=${pins}`
|
||||
let url = `http://localhost:3001/api/search/listings?bounds=${bounds}&minPrice=${minPrice}&maxPrice=${maxPrice}&rooms=${allRooms}&minSize=${minSize}&maxSize=${maxSize}&category=${allCategories}&page=${page}&pins=${pins}&sort=${sort}`
|
||||
|
||||
return fetch(url, {
|
||||
//credentials: 'include'
|
||||
|
||||
@@ -246,6 +246,15 @@ const mapIdle = ({type, action}, component) => {
|
||||
})
|
||||
}
|
||||
|
||||
const sortChange = ({type, action}, component) => {
|
||||
component.setState({
|
||||
sort: action.sort,
|
||||
page: 0
|
||||
}, () => {
|
||||
component.refreshListings();
|
||||
});
|
||||
}
|
||||
|
||||
const handlers = {
|
||||
SET_MIN_PRICE: setMinPrice,
|
||||
SET_MAX_PRICE: setMaxPrice,
|
||||
@@ -265,7 +274,8 @@ const handlers = {
|
||||
BACK_TO_RESULTS: backToResults,
|
||||
LOAD_MORE_LISTINGS: loadMoreListings,
|
||||
MAP_IDLE: mapIdle,
|
||||
PINS_LOADED: pinsLoaded
|
||||
PINS_LOADED: pinsLoaded,
|
||||
SORT_CHANGE: sortChange
|
||||
};
|
||||
|
||||
export const handleMessage = ({ type, action }, component) => {
|
||||
|
||||
Reference in New Issue
Block a user