All files / projects/requisition-management/src/app/store/requisitions requisitions.selectors.ts

90.47% Statements 19/21
100% Branches 0/0
77.77% Functions 7/9
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2432x     32x   32x   32x   32x   32x   32x   32x   32x 1x 2x     32x  
import { createSelector } from '@ngrx/store';
 
import { RequisitionStatus, RequisitionViewer } from '../../models/requisition/requisition.model';
import { getRequisitionManagementState } from '../requisition-management-store';
 
import { requisitionsAdapter } from './requisitions.reducer';
 
const getRequisitionsState = createSelector(getRequisitionManagementState, state => state.requisitions);
 
export const getRequisitionsLoading = createSelector(getRequisitionsState, state => state.loading);
 
export const getRequisitionsError = createSelector(getRequisitionsState, state => state.error);
 
const getRequisitionsFilters = createSelector(getRequisitionsState, state => state.filters);
 
export const { selectEntities } = requisitionsAdapter.getSelectors(getRequisitionsState);
 
export const getRequisitions = (view: RequisitionViewer, status: RequisitionStatus) =>
  createSelector(selectEntities, getRequisitionsFilters, (requisitions, filters: { [k: string]: string[] }) =>
    filters[view + status].map(id => requisitions[id])
  );
 
export const getRequisition = (id: string) => createSelector(selectEntities, requisitions => requisitions[id]);