All files / src/app/extensions/punchout/store/punchout-users punchout-users.selectors.ts

100% Statements 18/18
50% Branches 1/2
100% Functions 7/7
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 24 25 2614x   14x     14x   14x   14x   14x   14x   14x   14x 4x   14x     5x    
import { createSelector } from '@ngrx/store';
 
import { selectRouteParam } from 'ish-core/store/core/router';
 
import { PunchoutType } from '../../models/punchout-user/punchout-user.model';
import { getPunchoutState } from '../punchout-store';
 
import { initialState, punchoutUsersAdapter } from './punchout-users.reducer';
 
const getPunchoutUsersState = createSelector(getPunchoutState, state => (state ? state.punchoutUsers : initialState));
 
export const getPunchoutLoading = createSelector(getPunchoutUsersState, state => state.loading);
 
export const getPunchoutError = createSelector(getPunchoutUsersState, state => state.error);
 
const { selectAll, selectEntities } = punchoutUsersAdapter.getSelectors(getPunchoutUsersState);
 
export const getPunchoutUsers = (type: PunchoutType) =>
  createSelector(selectAll, users => users.filter(user => user.punchoutType === type));
 
export const getSelectedPunchoutUser = createSelector(
  selectRouteParam('PunchoutLogin'),
  selectEntities,
  (login, users) => users[login]
);