UNPKG

loop-modules

Version:

Shared modules for the Loop product suite.

32 lines (31 loc) 1.08 kB
import { initialState } from '../states/loop-user.state'; import { ActionTypes } from '../actions/loop-user.action'; export function reducer(state, action) { if (state === void 0) { state = initialState; } switch (action.type) { case ActionTypes.AUTH: return Object.assign({}, state, { authUser: action.payload }); case ActionTypes.RESET_AUTH: return Object.assign({}, state, { authUser: undefined }); case ActionTypes.ENTRIES: return Object.assign({}, state, { entries: state.entries.concat(action.payload) }); case ActionTypes.RESET_ENTRIES: return Object.assign({}, state, { entries: [] }); case ActionTypes.TOGGLE_SELECTED: return Object.assign({}, state, {}); case ActionTypes.RESET_SELECTED_ENTRIES: return Object.assign({}, state, { selectedEntries: [] }); default: return state; } }