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/BD,EAAQC,SAGXmB,OAAOC,aAAanB,YAAWoB,EAAAA,EAAA,GAC5BF,OAAOC,aAAanB,aAAe,IACnCF,EAAQE,iCCzEnBqB,EAAOC,QAAU5F,2BCAjB2F,EAAOC,QAAUC","sources":["webpack://bestseller.commerce.online/./src/modules/ext-product-page-summary/ext-product-page-summary.action.ts?ee9e","webpack://bestseller.commerce.online/./src/modules/ext-product-page-summary/ext-product-page-summary.tsx?ed14","webpack://bestseller.commerce.online/./lib/ext-product-page-summary/module-registration.js?fde0","webpack://bestseller.commerce.online/external var \"React\"?0d3b","webpack://bestseller.commerce.online/external var \"ReactDOM\"?853b"],"sourcesContent":["/*!\r\n * Copyright (c) Microsoft Corporation.\r\n * All rights reserved. See LICENSE in the project root for license information.\r\n */\r\n\r\n/* eslint-disable no-duplicate-imports */\r\nimport {\r\n CacheType,\r\n createObservableDataAction,\r\n getCatalogId,\r\n IAction,\r\n IActionContext,\r\n IActionInput,\r\n ICommerceApiSettings,\r\n ICreateActionContext,\r\n IRequestContext\r\n} from '@msdyn365-commerce/core';\r\nimport { ProductPrice, ProjectionDomain, SimpleProduct } from '@msdyn365-commerce/retail-proxy';\r\nimport {\r\n getActivePricesAsync,\r\n getAttributeValuesAsync,\r\n getByIdsAsync\r\n} from '@msdyn365-commerce/retail-proxy/dist/DataActions/ProductsDataActions.g';\r\nimport {\r\n ArrayExtensions,\r\n generateCacheKey,\r\n generateImageUrl,\r\n getProductUrlSync,\r\n getSelectedProductIdFromActionInput,\r\n QueryResultSettingsProxy,\r\n removeDomainQspFromUrl\r\n} from '@msdyn365-commerce-modules/retail-actions';\r\n\r\nimport { IPageSummaryData } from '@msdyn365-commerce-modules/page-summary';\r\nimport { IExtProductPageSummaryConfig } from './ext-product-page-summary.props.autogenerated';\r\n//import { getLocalizedStringsAsync } from '@msdyn365-commerce/retail-proxy/dist/DataActions/StoreOperationsDataActions.g';\r\n\r\n/**\r\n * Product Page Summary Input.\r\n */\r\nexport class ProductPageSummaryInput implements IActionInput {\r\n public apiSettings: ICommerceApiSettings;\r\n\r\n public config: IExtProductPageSummaryConfig;\r\n\r\n public productId: number;\r\n\r\n public catalogId?: number;\r\n\r\n public constructor(\r\n config: IExtProductPageSummaryConfig,\r\n apiSettings: ICommerceApiSettings,\r\n productId: number,\r\n requestContext?: IRequestContext\r\n ) {\r\n this.config = config || {};\r\n this.apiSettings = apiSettings;\r\n this.productId = productId;\r\n\r\n if (requestContext) {\r\n this.catalogId = getCatalogId(requestContext);\r\n }\r\n }\r\n\r\n public getCacheObjectType = (): string => 'ProductPageSummary';\r\n\r\n public getCacheKey = (): string =>\r\n generateCacheKey(\r\n this.apiSettings,\r\n { key: 'Key', value: 'ProductPageSummary' },\r\n { key: 'Title', value: this.config.title },\r\n { key: 'ProductId', value: this.productId },\r\n { key: 'CatalogId', value: this.catalogId }\r\n );\r\n\r\n public dataCacheType = (): CacheType => 'application';\r\n}\r\n\r\nexport interface IProductPageSummary extends IPageSummaryData {\r\n price?: number;\r\n productId?: number;\r\n masterProductId?: number;\r\n productBrand?: string;\r\n category?: string;\r\n}\r\n\r\nconst createInput = (args: ICreateActionContext) => {\r\n const productId = getSelectedProductIdFromActionInput(args);\r\n\r\n if (productId) {\r\n return new ProductPageSummaryInput(\r\n args.config,\r\n args.requestContext.apiSettings,\r\n +productId,\r\n args.requestContext\r\n );\r\n }\r\n throw new Error('Unable to create ProductPageSummaryAction input, no productId found on module config or query');\r\n};\r\n\r\ninterface Attributes {\r\n brand?: string;\r\n category?: string;\r\n}\r\n\r\n// Checks product attributes for the presence of brand attribute to extract the brand name for product metadata\r\nconst getProductAttributes = async (\r\n context: IActionContext,\r\n recordId: number,\r\n channelId: number,\r\n catalogId: number\r\n): Promise => {\r\n const productAttributes = await getAttributeValuesAsync(\r\n {\r\n callerContext: context,\r\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context)\r\n },\r\n recordId,\r\n channelId,\r\n catalogId\r\n );\r\n const attributes: Attributes = {};\r\n for (const productAttribute of productAttributes) {\r\n if (productAttribute.Name === 'Brand') {\r\n attributes.brand = productAttribute.TextValue;\r\n } else if (productAttribute.Name === 'Category') {\r\n attributes.category = productAttribute.TextValue;\r\n }\r\n }\r\n\r\n return attributes;\r\n};\r\n\r\nconst action = async (input: ProductPageSummaryInput, context: IActionContext): Promise => {\r\n const { config, productId, apiSettings } = input;\r\n let simpleProductsData: SimpleProduct[] | undefined;\r\n try {\r\n simpleProductsData = ArrayExtensions.validValues(\r\n await getByIdsAsync(\r\n {\r\n callerContext: context,\r\n queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context)\r\n },\r\n apiSettings.channelId,\r\n [productId],\r\n null,\r\n input.catalogId ?? 0\r\n )\r\n );\r\n } catch {\r\n // Do nothing, if there's an error we fall back to values defined from config\r\n }\r\n if (ArrayExtensions.hasElements(simpleProductsData)) {\r\n const simpleProductData = simpleProductsData[0];\r\n let productUrl: string | undefined;\r\n try {\r\n productUrl = getProductUrlSync(simpleProductData, context);\r\n const canonicalDomain = context.requestContext.canonicalDomain;\r\n if (productUrl && canonicalDomain) {\r\n productUrl = `https://${canonicalDomain}/${context.requestContext.locale}${productUrl}`.toLocaleLowerCase();\r\n productUrl = removeDomainQspFromUrl(productUrl, context.requestContext);\r\n } else {\r\n productUrl = undefined;\r\n }\r\n } catch {\r\n productUrl = undefined;\r\n }\r\n\r\n let productBrand: string | undefined;\r\n let category: string | undefined;\r\n try {\r\n const attributes = await getProductAttributes(context, productId, apiSettings.channelId, input.catalogId ?? 0);\r\n productBrand = attributes.brand;\r\n //Gets the first category, which is the Bestseller category\r\n category = attributes.category?.split(';')[0];\r\n } catch (e) {\r\n productBrand = undefined;\r\n category = undefined;\r\n }\r\n\r\n let productPrice: number | undefined;\r\n try {\r\n const projectDomain: ProjectionDomain = {\r\n ChannelId: +context.requestContext.apiSettings.channelId,\r\n CatalogId: input.catalogId ?? 0\r\n };\r\n\r\n productPrice = await getActivePricesAsync(\r\n { callerContext: context, queryResultSettings: QueryResultSettingsProxy.getPagingFromInputDataOrDefaultValue(context) },\r\n projectDomain,\r\n [productId],\r\n new Date(),\r\n context.requestContext.user.customerAccountNumber,\r\n undefined,\r\n true\r\n ).then((productPrices: ProductPrice[]) => {\r\n if (!ArrayExtensions.hasElements(productPrices)) {\r\n throw new Error('[ExtProductPageSummaryAction]Invalid response received from getActivePricesAsync');\r\n }\r\n return productPrices[0].CustomerContextualPrice;\r\n });\r\n } catch {\r\n productPrice = undefined;\r\n }\r\n\r\n return {\r\n title: simpleProductData.Name,\r\n description: simpleProductData.Description,\r\n sharingImageUrl: generateImageUrl(simpleProductData.PrimaryImageUrl, apiSettings),\r\n canonicalUrl: productUrl,\r\n faviconUrl: config && config.faviconUrl,\r\n productId: parseInt(simpleProductData.ItemId ?? '', 10),\r\n price: productPrice ?? simpleProductData.AdjustedPrice,\r\n productBrand,\r\n category\r\n };\r\n\r\n // If the action fails fallback to values defined from config\r\n } else if (config) {\r\n return {\r\n title: config.title,\r\n description: config.description,\r\n sharingImageUrl: config.sharingImage && config.sharingImage.src,\r\n faviconUrl: config && config.faviconUrl\r\n };\r\n }\r\n return {};\r\n};\r\n\r\nexport default createObservableDataAction({\r\n id: '@msdyn365-commerce-modules/page-summary/product-page-summary',\r\n action: >action,\r\n input: createInput\r\n});\r\n","/*!\r\n * Copyright (c) Microsoft Corporation.\r\n * All rights reserved. See LICENSE in the project root for license information.\r\n */\r\n\r\n/* eslint-disable no-duplicate-imports */\r\nimport { HtmlHeadInclude, IAny, IGeneric } from '@msdyn365-commerce/core';\r\nimport * as React from 'react';\r\n\r\nimport { IExtProductPageSummaryData } from './ext-product-page-summary.data';\r\nimport { IExtProductPageSummaryProps } from './ext-product-page-summary.props.autogenerated';\r\n\r\ninterface ICategoryBinding {\r\n bindings: ICategoryBindingItem[];\r\n default: string;\r\n}\r\n\r\ninterface ICategoryBindingItem {\r\n google_id: string;\r\n categories: string[];\r\n}\r\n/**\r\n *\r\n * ProductPageSummary component.\r\n * @extends {React.PureComponent}\r\n */\r\nclass ProductPageSummary extends React.PureComponent> {\r\n public render(): JSX.Element {\r\n if (this.props.data.productPageSummary.result === undefined) {\r\n throw new Error('PageSummaryData input to page-summary is undefined. Unable to generate page-summary');\r\n }\r\n let {\r\n data: {\r\n productPageSummary: {\r\n result: { title, description, keywords, sharingImageUrl, faviconUrl }\r\n }\r\n }\r\n } = this.props;\r\n\r\n const {\r\n config,\r\n context,\r\n data: {\r\n productPageSummary: {\r\n result: { canonicalUrl, productId, productBrand, price, category }\r\n }\r\n }\r\n } = this.props;\r\n\r\n // Product SEO metadata specific information - non-overridable\r\n const productName = title;\r\n const productDescription = description;\r\n const productImageUrl = sharingImageUrl;\r\n\r\n // Override values coming from data action if config values are provided\r\n title = config.title || title;\r\n description = config.description || description;\r\n keywords = config.keywords || keywords;\r\n sharingImageUrl = (config.sharingImage && config.sharingImage.src) || sharingImageUrl;\r\n faviconUrl = config.faviconUrl || faviconUrl;\r\n\r\n // Construct page title with suffix and prefix if provided from app settings\r\n const pageTitle = this._constructPageTitle(title, context && context.request && context.request.app);\r\n return (\r\n <>\r\n \r\n {pageTitle && {pageTitle}}\r\n {description && }\r\n {keywords && }\r\n {canonicalUrl && }\r\n {faviconUrl && }\r\n \r\n {this._renderProductMetadata(\r\n productName,\r\n productDescription,\r\n productImageUrl,\r\n canonicalUrl,\r\n productId,\r\n price,\r\n context.request.channel?.Currency,\r\n productBrand,\r\n category\r\n )}\r\n {!config.disableOgTags && this._renderOgTags(pageTitle, description, sharingImageUrl)}\r\n {!config.disableTwitterTags && this._renderTwitterTags(pageTitle, description, sharingImageUrl)}\r\n \r\n );\r\n }\r\n\r\n /**\r\n * Renders the facebook and other social media specific metadata tags.\r\n *\r\n * @param title Page title.\r\n * @param description Product description.\r\n * @param sharingImageUrl Primary product image url.\r\n */\r\n private _renderOgTags(title: string | undefined, description: string | undefined, sharingImageUrl: string | undefined): JSX.Element {\r\n return (\r\n \r\n {title && }\r\n {description && }\r\n {sharingImageUrl && }\r\n \r\n \r\n );\r\n }\r\n\r\n /**\r\n * Constructs and renders the JSON-LD tag used to output product specific metadata used by search engine crawlers.\r\n *\r\n * @param productName Product name.\r\n * @param description Product description.\r\n * @param sharingImageUrl Primary product image url.\r\n * @param canonicalUrl Product canonical url.\r\n * @param productId Master product id.\r\n * @param masterProductId Master product id.\r\n * @param price Proudct price.\r\n * @param currencyCode Current channel currency code.\r\n * @param productBrand Product brand.\r\n * @param category Category.\r\n */\r\n private _renderProductMetadata(\r\n productName: string | undefined,\r\n description: string | undefined,\r\n sharingImageUrl: string | undefined,\r\n canonicalUrl: string | undefined,\r\n productId: number | undefined,\r\n price: number | undefined,\r\n currencyCode: string | undefined,\r\n productBrand: string | undefined,\r\n category?: string | undefined\r\n ): JSX.Element {\r\n var color = '';\r\n //Put the color in the query onto urls\r\n for (const key in this.props.context.request.query) {\r\n if (key === 'color') {\r\n /* eslint-disable-next-line security/detect-object-injection*/\r\n color = this.props.context.request.query[key];\r\n const strings = sharingImageUrl?.split('fileName=/');\r\n sharingImageUrl = strings ? strings[0] : '';\r\n /* eslint-disable-next-line security/detect-object-injection*/\r\n sharingImageUrl = `${sharingImageUrl}filename=/${productId}_${this.props.context.request.query[key]}_000_001.jpg`;\r\n /* eslint-disable-next-line security/detect-object-injection*/\r\n canonicalUrl = `${canonicalUrl}?color=${encodeURIComponent(this.props.context.request.query[key])}`;\r\n }\r\n }\r\n // Construct the JSON-LD data that contains the product metadata information used by search engine crawlers\r\n const productMetaData = JSON.stringify({\r\n '@context': 'http://schema.org',\r\n '@type': 'Product',\r\n name: productName,\r\n description,\r\n image: sharingImageUrl,\r\n productID: `${productId}${color}`,\r\n google_product_category: this._getCategoryId(category),\r\n brand: {\r\n '@type': 'Brand',\r\n name: productBrand\r\n },\r\n offers: {\r\n '@type': 'Offer',\r\n url: canonicalUrl,\r\n priceCurrency: currencyCode,\r\n price,\r\n itemCondition: 'https://schema.org/NewCondition',\r\n availability: 'https://schema.org/InStock'\r\n },\r\n additionalProperty: [\r\n {\r\n '@type': 'PropertyValue',\r\n propertyId: 'item_group_id',\r\n value: productId\r\n }\r\n ]\r\n });\r\n return (\r\n \r\n {/* eslint-disable-next-line react/no-danger -- Implementation is a copy.*/}\r\n