genkid2020

Untitled

Aug 25th, 2020
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import { GET_PRODUCTS } from 'app/main/nomenclature/store/actionTypes';
  2.  
  3. const initialState = {
  4. products: [],
  5. isProductsPending: false
  6. };
  7. export default function (state = initialState, action) {
  8. const { type, payload } = action;
  9. switch (type) {
  10. case GET_PRODUCTS.PENDING:
  11. return {
  12. ...state,
  13. isProductsPending: true
  14. };
  15. case GET_PRODUCTS.SUCCESS:
  16. return {
  17. ...state,
  18. isProductsPending: false,
  19. products: payload
  20. };
  21. case GET_PRODUCTS.ERROR:
  22. return {
  23. ...state,
  24. isProductsPending: false
  25. };
  26. default: {
  27. return state;
  28. }
  29. }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment