<%_ if(features.loginandsignup) { _%>
import { createReducer, completeReducer, completeState<%_ if(features.onboarding) { _%>, onReadValue<%_ } _%> } from 'redux-recompose';
import Immutable, { ImmutableObject } from 'seamless-immutable';
import { CurrentUser } from '@interfaces/authInterfaces';
import { Nullable } from '@interfaces/globalInterfaces';
import { Action, AuthState } from '@interfaces/reduxInterfaces';

import { actions } from './actions';

const stateDescription = {
  description: {
    currentUser: null
  },
  ignoredTargets: {
    initialLoading: true<%_ if(features.onboarding) { _%>,
      hasAccessOnBoarding: false
    <%_ }_%>
  }
};

export const initialState = completeState(stateDescription);

const reducerDescription = {
  primaryActions: [actions.LOGIN, actions.LOGOUT],
  override: {
  <%_ if(features.onboarding) { _%>
    [actions.HAS_ACCESS]: onReadValue(),
  <%_ } _%>
    [actions.AUTH_INIT]: (state: ImmutableObject<AuthState>, action: Action<Nullable<CurrentUser>>) =>
      state.merge({ initialLoading: false, [action.target as string]: action.payload<%_ if(features.onboarding) { _%>, hasAccessOnBoarding: action.hasAccessOnBoarding <%_ }_%> })
  }
};

export default createReducer(Immutable(initialState), completeReducer(reducerDescription));
<%_ } else if (features.onboarding) { _%>
import { createReducer, onReadValue } from 'redux-recompose';
import Immutable, { ImmutableObject } from 'seamless-immutable';
import { Action, AuthState } from '@interfaces/reduxInterfaces';

import { actions } from './actions';

const initialState = {
  hasAccessOnBoarding: false,
  initialLoading: true
};

const reducerDescription = {
  [actions.AUTH_INIT]: (state: ImmutableObject<AuthState>, action: Action<boolean>) =>
    state.merge({ initialLoading: false, [action.target as string]: action.payload }),
  [actions.HAS_ACCESS]: onReadValue()
};

export default createReducer(Immutable(initialState), reducerDescription);
<%_ } else { _%>
import { createReducer } from 'redux-recompose';
import Immutable, { ImmutableObject } from 'seamless-immutable';
import { AuthState } from '@interfaces/reduxInterfaces';

import { actions } from './actions';

const initialState = {
  initialLoading: true
};

const reducerDescription = {
  [actions.AUTH_INIT]: (state: ImmutableObject<AuthState>) => state.merge({ initialLoading: false })
};

export default createReducer(Immutable(initialState), reducerDescription);
<%_ } _%>
