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

import { StateSelector } from 'packages/core/ngrx/store';

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

import * as ListStore from './list';
import * as DetailStore from './detail';

export interface State {
  notifications: ListStore.State;
  notification: DetailStore.State;
}

export const REDUCERS = {
  notifications: ListStore.reducer,
  notification: DetailStore.reducer,
};

export const EFFECTS = [
  ListStore.Effects,
  DetailStore.Effects,
];

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

export const ReadAllByMemberSelector = new StateSelector<ListStore.State>(createSelector(
  selectNotificationState,
  (state: State) => state.notifications
));
export const ReadSelector = new StateSelector<DetailStore.State>(createSelector(
  selectNotificationState,
  (state: State) => state.notification
));
