import { createReducer, on } from '@ngrx/store';
import { initialState } from './state';
import { regViewSuccess, regUpdateSuccess } from './actions';
import * as AuthenticationStore from '@app/store/account/authentication';

export const reducer = createReducer(
  initialState,
  on(regViewSuccess, (state, action) => {
    return {
      ...state,
      reg: action.res
    };
  }),
  on(regUpdateSuccess, (state, action) => {
    return {
      ...state,
      reg: action.res
    };
  }),
  on(AuthenticationStore.logoutInitialize, (state, action) => {
    return {
      ...initialState
    };
  })
);
