All files / src/app/extensions/tacton/store/tacton-config tacton-config.selectors.ts

73.33% Statements 11/15
0% Branches 0/5
20% Functions 1/5
83.33% Lines 10/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 26 27 2816x 16x       16x 16x   16x   16x   16x   16x           16x   16x          
import { createSelector } from '@ngrx/store';
import { v4 as uuid } from 'uuid';
 
import { Customer } from 'ish-core/models/customer/customer.model';
import { User } from 'ish-core/models/user/user.model';
import { getLoggedInCustomer, getLoggedInUser } from 'ish-core/store/customer/user';
import { getSelectedProduct } from 'ish-core/store/shopping/products';
 
import { getTactonState } from '../tacton-store';
 
export const getTactonConfig = createSelector(getTactonState, state => state?.tactonConfig);
 
export const getSelfServiceApiConfiguration = createSelector(getTactonConfig, config => config?.selfService);
 
export const getNewExternalId = createSelector(
  getLoggedInCustomer,
  getLoggedInUser,
  (customer: Customer, user: User) => customer && user && `${customer.companyName}(${user.login}) - ${uuid()}`
);
 
const productMappings = createSelector(getTactonConfig, state => state?.productMappings || {});
 
export const getTactonProductForSelectedProduct = createSelector(
  productMappings,
  getSelectedProduct,
  (mappings, product) => mappings[product?.sku]
);