diff --git a/CHANGELOG.md b/CHANGELOG.md index cf3ee5c..a418336 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed +- Spotprice not showing up +- Error when the component loads before the content exists at the PDP ## [1.7.4] - 2021-05-14 ### Fixed diff --git a/react/AddProductBtn.tsx b/react/AddProductBtn.tsx index 464879f..1d3a65f 100644 --- a/react/AddProductBtn.tsx +++ b/react/AddProductBtn.tsx @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ /* eslint-disable @typescript-eslint/no-use-before-define */ import React, { FC, @@ -145,9 +146,10 @@ const AddBtn: FC = () => { const { showToast } = useContext(ToastContext) const { product } = useContext(ProductContext) as any const sessionResponse: any = useSessionResponse() - const [productId] = String(product.productId).split('-') const [handleCheck, { data, loading, called }] = useLazyQuery(checkItem) + const [productId] = String(product?.productId).split('-') + const toastMessage = (messsageKey: string) => { let action: any if (messsageKey === 'notLogged') { diff --git a/react/WishlistAdmin.tsx b/react/WishlistAdmin.tsx index 13e541e..49db33a 100644 --- a/react/WishlistAdmin.tsx +++ b/react/WishlistAdmin.tsx @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ /* eslint-disable no-await-in-loop */ /* eslint-disable no-loop-func */ import React, { FC, useState } from 'react' diff --git a/react/queries/productById.gql b/react/queries/productById.gql index a2bba76..fc728fe 100644 --- a/react/queries/productById.gql +++ b/react/queries/productById.gql @@ -118,6 +118,7 @@ query productsByIdentifier($ids: [ID!]) { Name } AvailableQuantity + spotPrice Price PriceWithoutDiscount ListPrice diff --git a/react/utils/normalize.ts b/react/utils/normalize.ts index 3721fae..d04806a 100644 --- a/react/utils/normalize.ts +++ b/react/utils/normalize.ts @@ -86,6 +86,17 @@ export function mapCatalogProductToProductSummary( wishlistId, } const items = normalizedProduct.items || [] + + items.forEach((eachSku: any, skuIndex: number) => { + eachSku.sellers.forEach((eachSeller: any, sellerIndex: number) => { + const skuSpotPrice = eachSeller.commertialOffer.spotPrice + const skuPrice = eachSeller.commertialOffer.Price + if (skuSpotPrice && skuSpotPrice === skuPrice) { + delete items[skuIndex].sellers[sellerIndex].commertialOffer.spotPrice + } + }) + }) + const sku = items.find(findAvailableProduct) || items[0] if (sku) { const [seller = defaultSeller] = sku.sellers ?? []