UNPKG

loop-modules

Version:

Shared modules for the Loop product suite.

37 lines (34 loc) 1.18 kB
import { LoopUserState, initialState } from '../states/loop-user.state'; import { Actions, ActionTypes } from '../actions/loop-user.action'; export function reducer( state: LoopUserState = initialState, action: Actions ): LoopUserState { switch (action.type) { case ActionTypes.AUTH: return (<any>Object).assign({}, state, { authUser: action.payload }); case ActionTypes.RESET_AUTH: return (<any>Object).assign({}, state, { authUser: undefined }); case ActionTypes.ENTRIES: return (<any>Object).assign({}, state, { entries: [...state.entries, ...action.payload] }); case ActionTypes.RESET_ENTRIES: return (<any>Object).assign({}, state, { entries: [] }); case ActionTypes.TOGGLE_SELECTED: return (<any>Object).assign({}, state, { }); case ActionTypes.RESET_SELECTED_ENTRIES: return (<any>Object).assign({}, state, { selectedEntries: [] }); default: return state; } }