import { Selector, createSelector } from '@ngrx/store';
import { Dashboard } from 'src/modules/dashboard/model/Dashboard';

export interface State {
  dashboards: Dashboard[] | null;
  currentDashboard: Dashboard | null;
}

export const initialState: State = {
  dashboards: null,
  currentDashboard: null
};

export function getSelectors<S>(selector: Selector<any, State>) {
  return {
    selectDashboards: createSelector(
      selector,
      (state: State) => state.dashboards
    ),
    selectCurrentDashboard: createSelector(
      selector,
      (state: State) => state.currentDashboard
    )
  };
}
