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 48 49 50 51 | 75x 75x 75x 75x 75x 117x 117x 117x 117x 117x 1404x 163x | import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { ExternalDisplayPropertiesProvider, ProductContext, ProductContextDisplayProperties, } from 'ish-core/facades/product-context.facade'; import { ProductHelper } from 'ish-core/models/product/product.helper'; @Injectable({ providedIn: 'root' }) export class ProductContextDisplayPropertiesService implements ExternalDisplayPropertiesProvider { setup( context$: Observable<Pick<ProductContext, 'product' | 'prices'>> ): Observable<Partial<ProductContextDisplayProperties<false>>> { return context$.pipe( map(({ product, prices }) => { const canBeOrdered = !ProductHelper.isMasterProduct(product) && product?.available; const canBeOrderedWithPrice = canBeOrdered && (!!prices?.salePrice || ProductHelper.isRetailSet(product)); const canBeOrderedNotRetail = canBeOrdered && !ProductHelper.isRetailSet(product); const calc = { inventory: !ProductHelper.isRetailSet(product) && !ProductHelper.isMasterProduct(product), quantity: canBeOrderedNotRetail, variations: ProductHelper.isVariationProduct(product), bundleParts: ProductHelper.isProductBundle(product), retailSetParts: ProductHelper.isRetailSet(product), shipment: canBeOrderedNotRetail && Number.isInteger(product?.readyForShipmentMin) && Number.isInteger(product?.readyForShipmentMax), addToBasket: canBeOrderedWithPrice, addToWishlist: !ProductHelper.isMasterProduct(product), addToOrderTemplate: canBeOrdered, addToCompare: !ProductHelper.isMasterProduct(product), addToQuote: canBeOrdered, addToNotification: !ProductHelper.isRetailSet(product) && !ProductHelper.isMasterProduct(product), }; return ( Object.entries(calc) // eslint-disable-next-line @typescript-eslint/no-unnecessary-boolean-literal-compare .filter(([, v]) => v === false) .reduce((acc, [k, v]) => ({ ...acc, [k]: v as false }), {}) ); }) ); } } |