mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
redux: fixed estimated
This commit is contained in:
parent
185fe80fc5
commit
5d2c534aa9
6 changed files with 30 additions and 38 deletions
|
@ -4,6 +4,11 @@ import { DEFAULT_USER } from '$constants/auth';
|
|||
import { MODES } from '$constants/modes';
|
||||
import { DEFAULT_LOGO } from '$constants/logos';
|
||||
|
||||
const getEstimated = distance => {
|
||||
const time = (distance && (distance / 15)) || 0;
|
||||
return (time && parseFloat(time.toFixed(1)));
|
||||
};
|
||||
|
||||
const setUser = (state, { user }) => ({
|
||||
...state,
|
||||
user: {
|
||||
|
@ -15,7 +20,12 @@ const setUser = (state, { user }) => ({
|
|||
const setEditing = (state, { editing }) => ({ ...state, editing });
|
||||
const setChanged = (state, { changed }) => ({ ...state, changed });
|
||||
const setMode = (state, { mode }) => ({ ...state, mode });
|
||||
const setDistance = (state, { distance }) => ({ ...state, distance });
|
||||
const setDistance = (state, { distance }) => ({
|
||||
...state,
|
||||
distance,
|
||||
estimated: getEstimated(distance),
|
||||
});
|
||||
|
||||
const setRouterPoints = (state, { routerPoints }) => ({ ...state, routerPoints });
|
||||
|
||||
const setActiveSticker = (state, { activeSticker }) => ({ ...state, activeSticker });
|
||||
|
@ -43,7 +53,7 @@ export const INITIAL_STATE = {
|
|||
logo: DEFAULT_LOGO,
|
||||
routerPoints: 0,
|
||||
distance: 0,
|
||||
estimateTime: 0,
|
||||
estimated: 0,
|
||||
activeSticker: null,
|
||||
title: 0,
|
||||
address: '',
|
||||
|
|
|
@ -126,6 +126,7 @@ function* setLogoSaga({ logo }) {
|
|||
yield put(setMode(MODES.NONE));
|
||||
}
|
||||
}
|
||||
|
||||
export function* userSaga() {
|
||||
// ASYNCHRONOUS!!! :-)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue