Guest User

Untitled

a guest
Nov 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import {
  2. CREATE_ORDER,
  3. MOVE_ORDER_TO_FARM
  4. } from "./../actions/marketTypes.js";
  5. import { MOVE_ORDER_TO_CUSTOMER } from "./../actions/farmTypes.js";
  6. const budget = (
  7. state = {
  8. profit: 0,
  9. marketExpanse: 0,
  10. farmExpanse: 0,
  11. deliveryExpanse: 0
  12. },
  13. action
  14. ) => {
  15. switch (action.type) {
  16. case "CREATE_ORDER":
  17. return {
  18. ...state,
  19. profit: state.profit + action.payload.price,
  20. marketExpanse: state.marketExpanse + 20
  21. };
  22. case "MOVE_ORDER_TO_FARM":
  23. return {
  24. ...state,
  25. farmExpanse: state.farmExpanse + 100
  26. };
  27. case "MOVE_ORDER_TO_CUSTOMER":
  28. return {
  29. ...state,
  30. deliveryExpanse: state.deliveryExpanse + 20
  31. };
  32. default:
  33. return { ...state };
  34. }
  35. };
  36. export default budget;
  37. export const getBudget = state => state.budget;
Add Comment
Please, Sign In to add comment