/*
 *
 * CreativesContainer reducer
 *
 */

import { fromJS } from 'immutable';
import {
  DEFAULT_ACTION,
  SHOW_CONTANER_LOADER,
  HIDE_CONTAINER_LOADER,
  STORE_LOYALTY_TAG_PROPS,
} from './constants';

const initialState = fromJS({containerLoader: true});

function creativesContainerReducer(state = initialState, action) {
  if (!action || !action.type) {
    return state;
  }
  switch (action.type) {
    case DEFAULT_ACTION:
      return state;
    case SHOW_CONTANER_LOADER:
      return state.set('containerLoader', true);
    case HIDE_CONTAINER_LOADER:
      return state.set('containerLoader', false);
    case STORE_LOYALTY_TAG_PROPS:
      return state.set('loyaltyTagProps', action.props);
    default:
      return state;
  }
}

export default creativesContainerReducer;
