import {
  createSelector,
  createFeatureSelector,
} from '@ngrx/store';

import { MODULE } from '../member.constant';

import * as MemberEntityStore from './entity/member';
import * as MemberTOTPEntityStore from './entity/member-totp';

import * as MemberSignupContainerStore from './container/signup';
import * as MemberSigninContainerStore from './container/signin';
import * as MemberModifyPasswordContainerStore from './container/modify-password';
import * as MemberResetPasswordContainerStore from './container/reset-password';
import * as MemberModifyContainerStore from './container/modify';
import * as MemberSignoutContainerStore from './container/signout';


export interface State {
  member_signup_container: MemberSignupContainerStore.State;
  member_signin_container: MemberSigninContainerStore.State;
  member_modify_password_container: MemberModifyPasswordContainerStore.State;
  member_reset_password_container: MemberResetPasswordContainerStore.State;
  member_modify_container: MemberModifyContainerStore.State;
  member_signout_container: MemberSignoutContainerStore.State;
}

export const REDUCERS = {
  member_signup_container: MemberSignupContainerStore.reducer,
  member_signin_container: MemberSigninContainerStore.reducer,
  member_modify_password_container: MemberModifyPasswordContainerStore.reducer,
  member_reset_password_container: MemberResetPasswordContainerStore.reducer,
  member_modify_container: MemberModifyContainerStore.reducer,
  member_signout_container: MemberSignoutContainerStore.reducer,
};

export const EFFECTS = [
  MemberEntityStore.Effects,
  MemberTOTPEntityStore.Effects,
];

export const selectState = createFeatureSelector<State>(MODULE.name);

export const MemberSignupContainerSelector = MemberSignupContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.member_signup_container
));

export const MemberSigninContainerSelector = MemberSigninContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.member_signin_container
));

export const MemberModifyPasswordContainerSelector = MemberModifyPasswordContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.member_modify_password_container
));

export const MemberResetPasswordContainerSelector = MemberResetPasswordContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.member_reset_password_container
));

export const MemberModifyContainerSelector = MemberModifyContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.member_modify_container
));

export const MemberSignoutContainerSelector = MemberSignoutContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.member_signout_container
));
