'use strict';

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

var _immutable = require('immutable');

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

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

  switch (action.type) {
    case _constants.CLEAR_ALT_TEXT:
      return state.delete('altText');
    case _constants.CLEAR_FILES:
      return state.delete('files');
    case _constants.FILE_RECEIVED:
      // TODO: Have an option for adding multiple files
      return state.set('files', action.payload.file);
    case _constants.FILE_UPLOAD_CALL:
      return state.set('files', action.payload.file);
    case _constants.FILE_UPLOAD_STATUS:
      return state.set('status', action.payload.status);
    case _constants.SET_ALT_TEXT:
      return state.set('altText', action.payload.altText);
    default:
      return state;
  }
};