Skip to content

Instantly share code, notes, and snippets.

@jplemieux66
Created June 19, 2018 21:50
Show Gist options
  • Save jplemieux66/430bc431f38d12d89205ba2f74fb780c to your computer and use it in GitHub Desktop.
Save jplemieux66/430bc431f38d12d89205ba2f74fb780c to your computer and use it in GitHub Desktop.
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