/*
 *
 * Edit reducer
 *
 */

import { fromJS } from 'immutable';
import * as types from './constants';

const initialState = fromJS({});

function editReducer(state = initialState, action) {
  switch (action.type) {
    case types.DEFAULT_ACTION:
      return state;
    case types.GET_TEMPLATE_DETAILS_REQUEST:
      return state.set('getTemplateDetailsInProgress', true);
    case types.GET_TEMPLATE_DETAILS_SUCCESS:
      return state.set('getTemplateDetailsInProgress', false)
        .set('templateDetails', action.data);
    case types.GET_TEMPLATE_DETAILS_FAILURE:
      return state.set('getTemplateDetailsInProgress', false);
    default:
      return state;
  }
}

export default editReducer;
