All files / src/app/core/store/customer/user user.selectors.ts

100% Statements 34/34
100% Branches 11/11
100% Functions 15/15
100% Lines 21/21

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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48415x   415x 415x   415x   415x   415x   12x     415x   415x   415x   415x   415x   415x   415x   415x   415x   415x   415x             9x 9x       415x  
import { createSelector } from '@ngrx/store';
 
import { getServerConfigParameter } from 'ish-core/store/core/server-config';
import { getCustomerState } from 'ish-core/store/customer/customer-store';
 
const getUserState = createSelector(getCustomerState, state => state.user);
 
export const getLoggedInCustomer = createSelector(getUserState, state => state.customer);
 
export const isBusinessCustomer = createSelector(
  getLoggedInCustomer,
  customer => !!customer && customer.isBusinessCustomer
);
 
export const getLoggedInUser = createSelector(getUserState, state => state.user);
 
export const getUserAuthorized = createSelector(getUserState, state => state.authorized);
 
export const getUserCostCenters = createSelector(getUserState, state => state.costCenters);
 
export const getUserPaymentMethods = createSelector(getUserState, state => state.paymentMethods);
 
export const getUserLoading = createSelector(getUserState, state => state.loading);
 
export const getUserError = createSelector(getUserState, state => state.error);
 
export const getPGID = createSelector(getUserState, state => state.pgid);
 
export const getPasswordReminderSuccess = createSelector(getUserState, state => state.passwordReminderSuccess);
 
export const getPasswordReminderError = createSelector(getUserState, state => state.passwordReminderError);
 
export const getCustomerApprovalEmail = createSelector(getUserState, state => state.customerApprovalEmail);
 
export const getPriceDisplayType = createSelector(
  getUserAuthorized,
  isBusinessCustomer,
  getServerConfigParameter<'PRIVATE' | 'SMB'>('pricing.defaultCustomerTypeForPriceDisplay'),
  getServerConfigParameter<'gross' | 'net'>('pricing.privateCustomerPriceDisplayType'),
  getServerConfigParameter<'gross' | 'net'>('pricing.smbCustomerPriceDisplayType'),
  (loggedIn, businessCustomer, defaultCustomer, b2c, b2b): 'gross' | 'net' => {
    const isB2B = (!loggedIn && defaultCustomer === 'SMB') || businessCustomer;
    return isB2B ? b2b || 'net' : b2c || 'gross';
  }
);
 
export const getNewsletterSubscriptionStatus = createSelector(getUserState, state => state.subscribedToNewsletter);