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

import { StateSelector } from '@overflow/core/ngrx/store';

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

import * as ProbeEntityStore from './entity/probe';
import * as ProbeListContainerStore from './container/probe-list';
import * as ProbeDetailContainerStore from './container/probe-detail';

export interface State {
  probe: ProbeEntityStore.State;
  probe_list_container: ProbeListContainerStore.State;
  probe_detail_container: ProbeDetailContainerStore.State;
}

export const REDUCERS = {
  probe: ProbeEntityStore.reducer,
  probe_list_container: ProbeListContainerStore.reducer,
  probe_detail_container: ProbeDetailContainerStore.reducer
};

export const EFFECTS = [
  ProbeEntityStore.Effects,
];

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

export const ProbeEntitySelector = ProbeEntityStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.probe
));

export const ProbeListContainerSelector = ProbeListContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.probe_list_container
));

export const ProbeDetailContainerSelector = ProbeDetailContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.probe_detail_container
));
