{"size": 906, "ext": "js", "max_stars_repo_path": "src/reducers/tap-list-reducer.js", "max_stars_repo_name": "michelle-morin/redux-taproom", "max_stars_repo_stars_event_min_datetime": "2020-05-21T06:22:36.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-21T06:22:36.000Z", "max_issues_repo_path": "src/reducers/tap-list-reducer.js", "max_issues_repo_name": "michelle-morin/redux-taproom", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/reducers/tap-list-reducer.js", "max_forks_repo_name": "michelle-morin/redux-taproom", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 30.2, "max_line_length": 100, "alphanum_fraction": 0.5816777042}
import * as c from './../actions/ActionTypes';

export default (state = {}, action) => {
  const { name, brewery, alcoholContent, ibu, price, pintQuantity, kegTappedDate, id } = action;
  switch(action.type) {
    case c.ADD_KEG:
      return Object.assign({}, state, {
        [id] : {
          name: name,
          brewery: brewery,
          alcoholContent: alcoholContent,
          ibu: ibu,
          price: price,
          pintQuantity: pintQuantity,
          kegTappedDate: kegTappedDate,
          id: id
        }
      });
    case c.DELETE_KEG:
      const newTapList = { ...state };
      delete newTapList[id];
      return newTapList;
    case c.SELL_KEG:
      const soldKegPintQuantity = state[id].pintQuantity - 1;
      const updatedTapList = { ...state, [id]: { ...state[id], pintQuantity: soldKegPintQuantity }};
      return updatedTapList;
    default:
      return state;
  }
};