'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _immutable = require('immutable');

var _constants = require('../../constants');

var defaultState = (0, _immutable.fromJS)({
  scoreReconciliation: 'new_score'
});

exports.default = function () {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
  var action = arguments[1];

  switch (action.type) {
    case _constants.REGRADE_TOGGLE_REGRADING_EDIT_MODE:
      if (state.get('regradeEditModeKey') === action.payload) {
        return state.remove('regradeEditModeKey');
      } else {
        return state.set('regradeEditModeKey', action.payload);
      }
    case _constants.REGRADE_SET_SCORE_RECONCILIATION:
      return state.set('scoreReconciliation', action.payload);
    case _constants.REGRADE_SET_PAYLOAD:
      return state.set('regradingPayload', action.payload);
    default:
      return state;
  }
};