import { Selector, createSelector } from '@ngrx/store';
import {
  AuthResponse,
  DeptInfo,
  UserInfoSS
} from '@ucap-webmessenger/protocol-query';

export interface State {
  auth?: AuthResponse;

  departmentInfoList: DeptInfo[] | null;

  myDepartmentUserInfoList: UserInfoSS[] | null;
}

export const initialState: State = {
  auth: null,
  departmentInfoList: null,
  myDepartmentUserInfoList: null
};

export function selectors<S>(selector: Selector<any, State>) {
  return {
    auth: createSelector(selector, (state: State) => state.auth),
    departmentInfoList: createSelector(
      selector,
      (state: State) => state.departmentInfoList
    ),
    myDepartmentUserInfoList: createSelector(
      selector,
      (state: State) => state.myDepartmentUserInfoList
    )
  };
}
