Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. //actions
  2. export const TimesheetActions = {
  3. timesheetRequestAction,
  4. timesheetSuccessAction,
  5. timesheetFailureAction,
  6. };
  7.  
  8. const actions = union(TimesheetActions);
  9.  
  10. export type ActionsUnion = typeof actions;
  11.  
  12. //reducer
  13. export function laborReducer(state = initialState, action: ActionsUnion): State {
  14. switch(action.type) {
  15. case TimesheetActions.timesheetRequestAction.type:
  16. return {
  17. ...state,
  18. error: null,
  19. isLoading: true
  20. };
  21. case TimesheetActions.timesheetSuccessAction.type:
  22. return {
  23. ...state,
  24. timesheet: action.timesheet,
  25. error: null,
  26. isLoading: false,
  27. pulledToRefresh: false,
  28. activeMode: state.activeMode === ActiveMode.WeeklyExpanded ? ActiveMode.Weekly : state.activeMode
  29. };
  30. default: {
  31. return state;
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement