sanjay555

Untitled

Jun 14th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // dispatching action  in  function
  2. const { dispatch, acctions, assignment } = this.props;
  3. const assignmentId = assignment._id;
  4. dispatch(acctions.getLiveLocation(assignmentId));
  5.  
  6. // in assigment reducer function
  7. export function getLiveLocation(id) {
  8.   return {
  9.     type: GET_LIVE_LOCATION_DATA,
  10.     promise: {
  11.       method: 'GET',
  12.       path: `/assignment/trackingInfo?assignmentId=${id}`,
  13.     },
  14.   };
  15. }
  16.  
  17. // switch case in assignment reducer
  18. case GET_LIVE_LOCATION_DATA_REQUEST:
  19.       console.log('request');
  20.       return {
  21.         ...state,
  22.         requesting: true,
  23.       };
  24.     case GET_LIVE_LOCATION_DATA_SUCCESS:
  25.       console.log('response');
  26.  
  27.       return {
  28.         ...state,
  29.         liveLocationData: action.response.data,
  30.         error: undefined,
  31.         requesting: false,
  32.       };
  33.     case GET_LIVE_LOCATION_DATA_FAILURE:
  34.       console.log('failure');
  35.  
  36.       return {
  37.         ...state,
  38.         error: action.response.error,
  39.         requesting: false,
  40.       };
Add Comment
Please, Sign In to add comment