redux: completed setters!

This commit is contained in:
muerwre 2018-11-26 13:51:47 +07:00
parent 0d47cd8773
commit 2656a9fad8
4 changed files with 62 additions and 25 deletions

View file

@ -5,3 +5,8 @@ export const setEditing = editing => ({ type: ACTIONS.SET_EDITING, editing });
export const setMode = mode => ({ type: ACTIONS.SET_MODE, mode });
export const setDistance = distance => ({ type: ACTIONS.SET_DISTANCE, distance });
export const setChanged = changed => ({ type: ACTIONS.SET_CHANGED, changed });
export const setRouterPoints = routerPoints => ({ type: ACTIONS.SET_ROUTER_POINTS, routerPoints });
export const setActiveSticker = activeSticker => ({ type: ACTIONS.SET_ACTIVE_STICKER, activeSticker });
export const setLogo = logo => ({ type: ACTIONS.SET_LOGO, logo });
export const setTitle = title => ({ type: ACTIONS.SET_TITLE, title });
export const setAddress = address => ({ type: ACTIONS.SET_ADDRESS, address });

View file

@ -5,4 +5,9 @@ export const ACTIONS = {
SET_MODE: 'SET_MODE',
SET_DISTANCE: 'SET_DISTANCE',
SET_CHANGED: 'SET_CHANGED',
SET_ROUTER_POINTS: 'SET_ROUTER_POINTS',
SET_ACTIVE_STICKER: 'SET_ACTIVE_STICKER',
SET_LOGO: 'SET_LOGO',
SET_TITLE: 'SET_TITLE',
SET_ADDRESS: 'SET_ADDRESS',
};

View file

@ -15,12 +15,23 @@ const setUser = (state, { user }) => ({
const setEditing = (state, { editing }) => ({ ...state, editing });
const setMode = (state, { mode }) => ({ ...state, mode });
const setDistance = (state, { distance }) => ({ ...state, distance });
const setRouterPoints = (state, { routerPoints }) => ({ ...state, routerPoints });
const setActiveSticker = (state, { activeSticker }) => ({ ...state, activeSticker });
const setLogo = (state, { logo }) => ({ ...state, logo });
const setTitle = (state, { title }) => ({ ...state, title });
const setAddress = (state, { address }) => ({ ...state, address });
const HANDLERS = {
[ACTIONS.SET_USER]: setUser,
[ACTIONS.SET_EDITING]: setEditing,
[ACTIONS.SET_MODE]: setMode,
[ACTIONS.SET_DISTANCE]: setDistance,
[ACTIONS.SET_ROUTER_POINTS]: setRouterPoints,
[ACTIONS.SET_ACTIVE_STICKER]: setActiveSticker,
[ACTIONS.SET_LOGO]: setLogo,
[ACTIONS.SET_TITLE]: setTitle,
[ACTIONS.SET_ADDRESS]: setAddress,
};
export const INITIAL_STATE = {