'use strict';

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

var _tools = require('views/utils/tools');

var _lodash = require('lodash');

function dataFromBody(body) {
  return {
    $ships: (0, _tools.indexify)(body.api_mst_ship),
    $shipTypes: (0, _tools.indexify)(body.api_mst_stype),
    $equips: (0, _tools.indexify)(body.api_mst_slotitem),
    $equipTypes: (0, _tools.indexify)(body.api_mst_slotitem_equiptype),
    $mapareas: (0, _tools.indexify)(body.api_mst_maparea),
    $maps: (0, _tools.indexify)(body.api_mst_mapinfo),
    $missions: (0, _tools.indexify)(body.api_mst_mission),
    $useitems: (0, _tools.indexify)(body.api_mst_useitem),
    $shipgraph: body.api_mst_shipgraph,
    $exslotEquips: body.api_mst_equip_exslot,
    $exslotEquipShips: (0, _lodash.keyBy)(body.api_mst_equip_exslot_ship, 'api_slotitem_id')
  };
}

function reducer(state = {}, { type, body }) {
  switch (type) {
    case '@@Response/kcsapi/api_start2':
      return dataFromBody(body);
  }
  return state;
}