routes: added range rising

This commit is contained in:
muerwre 2018-12-13 14:05:30 +07:00
parent febe619e8c
commit ddb77e1245
5 changed files with 80 additions and 25 deletions

View file

@ -128,18 +128,42 @@ const searchSetTab = (state, { tab = 'mine' }) => ({
}
});
const searchPutRoutes = (state, { list = [], min, max }) => ({
...state,
routes: {
...state.routes,
list,
filter: {
...state.routes.filter,
min: min || state.routes.filter.min,
max: max || state.routes.filter.max,
}
const newDistCalc = ({ distance, min, max, filter }) => {
if (filter.min === filter.max) {
// slider was disabled
return [min, max];
}
});
// state.routes.filter.distance
};
const searchPutRoutes = (state, { list = [], min, max }) => {
console.log('a', state.routes.filter.distance[0], state.routes.filter.min);
return ({
...state,
routes: {
...state.routes,
list,
filter: {
...state.routes.filter,
distance: (state.routes.filter.min === state.routes.filter.max)
? [min, max]
: state.routes.filter.distance,
// distance:
// [
// (state.routes.filter.min > min && state.routes.filter.distance[0] <= state.routes.filter.min)
// ? min
// : state.routes.filter.distance[0],
// (state.routes.filter.max < max && state.routes.filter.distance[1] >= state.routes.filter.max)
// ? max
// : state.routes.filter.distance[1],
// ],
min,
max,
}
}
});
}
const searchSetLoading = (state, { loading = false }) => ({
...state,
@ -223,7 +247,7 @@ export const INITIAL_STATE = {
filter: {
title: '',
starred: false,
distance: [0, 300],
distance: [0, 99999],
author: '',
tab: 'mine',
min: 0,