Created
June 19, 2018 21:50
-
-
Save jplemieux66/430bc431f38d12d89205ba2f74fb780c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ProjectsDetails } from '../../../shared/model/user-projects-details'; | |
import * as actions from './../actions/projects'; | |
export interface State extends ProjectsDetails { | |
error: any; | |
} | |
export const initialState: State = { | |
projects: [], | |
projectsUsers: [], | |
timeEntries: [], | |
error: null, | |
}; | |
export function reducer( | |
state = initialState, | |
action: actions.Actions | |
): State { | |
switch(action.type) { | |
case actions.LOAD_PROJECTS_DETAILS_SUCCESS: { | |
return { | |
...state, | |
...action.payload, | |
}; | |
} | |
case actions.LOAD_PROJECTS_DETAILS_ERROR: { | |
return { | |
...state, | |
error: action.error, | |
}; | |
} | |
default: | |
return state; | |
} | |
} | |
export const getProjects = (state: State) => state.projects; | |
export const getProjectsUsers = (state: State) => state.projectsUsers; | |
export const getTimeEntries = (state: State) => state.timeEntries; | |
export const getError = (state: State) => state.error; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment