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,qEAAuE,CAC9Fd,EAAGA,IAAMC,EAAQ,MACjBc,GAAI,0CAEpBvF,OAAOqF,aAAerF,OAAOqF,cAAgB,GAC7CrF,OAAOqF,aAAaC,eAActC,EAAAA,EAAA,GACPhD,OAAOqF,aAAaC,gBAAkB,IACtCA,UC1F3BE,EAAOC,QAAU1I,cCAjByI,EAAOC,QAAUC","sources":["webpack://Msdyn365.Commerce.Online/./src/modules/eve-catalog-picker/eve-catalog-picker.tsx?8101","webpack://Msdyn365.Commerce.Online/./src/modules/eve-catalog-picker/eve-catalog-picker.view.tsx?aa86","webpack://Msdyn365.Commerce.Online/./lib/eve-catalog-picker/module-registration.js?9ee0","webpack://Msdyn365.Commerce.Online/external var \"React\"?0d3b","webpack://Msdyn365.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 Msdyn365, {\r\n ContentEditableEvent,\r\n generateImageUrl,\r\n getCatalogId,\r\n getUrlSync,\r\n Image,\r\n RichTextComponent,\r\n Text\r\n} from '@msdyn365-commerce/core';\r\nimport { Cart, MediaLocation, ProductCatalog } from '@msdyn365-commerce/retail-proxy';\r\nimport { ArrayExtensions } from '@msdyn365-commerce-modules/retail-actions';\r\nimport { Button, IModuleProps } from '@msdyn365-commerce-modules/utilities';\r\nimport React, { ReactNode } from 'react';\r\nimport { reaction } from 'mobx';\r\nimport { observer } from 'mobx-react';\r\nimport { getCartState } from '@msdyn365-commerce/global-state';\r\n\r\nimport { IEveCatalogPickerData } from './eve-catalog-picker.data';\r\nimport { IEveCatalogPickerProps } from './eve-catalog-picker.props.autogenerated';\r\n\r\n/**\r\n * ICatalogPickerViewProps.\r\n */\r\nexport interface ICatalogPickerViewProps extends IEveCatalogPickerProps {\r\n catalogPicker: IModuleProps;\r\n heading: React.ReactNode;\r\n paragraph: React.ReactNode;\r\n catalogs: ReactNode;\r\n}\r\n\r\ninterface IEveCatalogPickerState {\r\n containsCartline: boolean;\r\n}\r\n\r\n/**\r\n * CatalogPicker component.\r\n * @extends {React.PureComponent>}\r\n */\r\n@observer\r\nexport class CatalogPicker extends React.PureComponent, IEveCatalogPickerState> {\r\n private static readonly _moduleClassName = 'eve-catalog-picker';\r\n\r\n public constructor(props: ICatalogPickerViewProps) {\r\n super(props);\r\n this.state = {\r\n containsCartline: false\r\n };\r\n }\r\n\r\n public async componentDidMount() {\r\n const {\r\n data: {\r\n cart: { result: cart }\r\n },\r\n context: { actionContext }\r\n } = this.props;\r\n\r\n reaction(\r\n () => this.props.data.cart.result?.cart.CartLines,\r\n async () => {\r\n const newCart = await getCartState(actionContext);\r\n this._updateState(newCart?.cart);\r\n }\r\n );\r\n\r\n this._updateState(cart?.cart);\r\n }\r\n\r\n /**\r\n * Updates containsCartline state value depending on whether or not the cart has any cartlines\r\n * @param cart Cart object\r\n */\r\n private _updateState = (cart: Readonly | undefined): void => {\r\n if (cart) {\r\n this.setState({\r\n containsCartline: ArrayExtensions.hasElements(cart.CartLines)\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * Handle text change.\r\n * @param event - The dialog that is allowed to remain open.\r\n */\r\n public handleTextChange = (event: ContentEditableEvent): void => {\r\n this.props.config.heading!.text = event.target.value;\r\n };\r\n\r\n /**\r\n * Handle paragraph change.\r\n * @param event - The dialog that is allowed to remain open.\r\n */\r\n public handleParagraphChange = (event: ContentEditableEvent): void => {\r\n this.props.config.paragraph = event.target.value;\r\n };\r\n\r\n /**\r\n * Renders either the current catalog flag, change catalog button or a message saying that catalogs cannot be switched.\r\n * @param item Individual product catalog object\r\n * @returns ReactNode containing the picker buttons section\r\n */\r\n private _renderCatalogPickerButton(item: ProductCatalog): React.ReactNode {\r\n const catalogId = item.RecordId;\r\n const currentCatalogId = getCatalogId(this.props.context.request);\r\n if (currentCatalogId === catalogId) {\r\n return
{this.props.resources.currentCatalogText}
;\r\n }\r\n let linkToCatalog = '';\r\n if (Msdyn365.isBrowser) {\r\n const catalogUrl = getUrlSync('home', this.props.context.actionContext) ?? '';\r\n const fullUrl = new URL(catalogUrl, window.location.href);\r\n fullUrl.searchParams.set('catalogid', `${catalogId}`);\r\n linkToCatalog = fullUrl.href;\r\n }\r\n if (!this.state.containsCartline) {\r\n return (\r\n \r\n {this.props.resources.changeCatalogButtonText}\r\n \r\n );\r\n }\r\n return
{this.props.resources.catalogSwitchMessageText}
;\r\n }\r\n\r\n /**\r\n * Renders the catalog picker if there are any catalogs available\r\n * @returns ReactNode containing the catalog picker\r\n */\r\n private _renderCatalogPicker(): React.ReactNode {\r\n const catalogs = this.props.data.catalogs?.result;\r\n\r\n const isBrowser = Msdyn365.isBrowser;\r\n\r\n return (\r\n
\r\n {catalogs?.map(item => {\r\n const reactKey = `${JSON.stringify(item)}-${String(isBrowser)}`;\r\n const image: MediaLocation | undefined = ArrayExtensions.firstOrDefault(item.Images);\r\n return (\r\n \r\n

{item.Name}

\r\n
\r\n \r\n
\r\n {this._renderCatalogPickerButton(item)}\r\n
\r\n
\r\n
\r\n );\r\n })}\r\n \r\n );\r\n }\r\n\r\n public render(): JSX.Element | null {\r\n const { heading, paragraph } = this.props.config;\r\n\r\n const catalogPickerHeading = heading && (\r\n <>\r\n \r\n \r\n );\r\n\r\n const isCatalogsAvailable: boolean = ArrayExtensions.hasElements(this.props.data.catalogs?.result);\r\n const catalogPickerParagraph = paragraph && (\r\n \r\n );\r\n const viewProps = {\r\n ...this.props,\r\n handleText: this.handleTextChange,\r\n catalogPicker: {\r\n moduleProps: this.props,\r\n className: CatalogPicker._moduleClassName\r\n },\r\n heading: catalogPickerHeading,\r\n paragraph: catalogPickerParagraph,\r\n catalogs: isCatalogsAvailable ? this._renderCatalogPicker() : ''\r\n };\r\n\r\n return this.props.renderView(viewProps);\r\n }\r\n}\r\n\r\nexport default CatalogPicker;\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 { Module } from '@msdyn365-commerce-modules/utilities';\r\nimport * as React from 'react';\r\n\r\nimport { ICatalogPickerViewProps } from './eve-catalog-picker';\r\n\r\n/**\r\n * ICatalogPickerViewProps.\r\n * @param props - ICatalogPickerViewProps.\r\n * @returns - Render Catalog Picker.\r\n */\r\nexport const CatalogPickerViewFunctionComponent: React.FC = props => {\r\n const { catalogPicker } = props;\r\n return (\r\n \r\n {props.heading}\r\n {props.paragraph}\r\n {props.catalogs}\r\n
{props.slots.help}
\r\n
\r\n );\r\n};\r\n\r\nexport default CatalogPickerViewFunctionComponent;\r\n","const binding = { modules: {}, dataActions: {} };\n\n const registerActionId = (actionPath) => {\n if (binding.dataActions[actionPath] &&\n binding.dataActions[actionPath].default &&\n binding.dataActions[actionPath].default.prototype &&\n binding.dataActions[actionPath].default.prototype.id) {\n binding.dataActions[binding.dataActions[actionPath].default.prototype.id] = binding.dataActions[actionPath];\n } else {\n Object.keys(binding.dataActions[actionPath] || {}).forEach(exportName => {\n if (binding.dataActions[actionPath][exportName] &&\n binding.dataActions[actionPath][exportName].prototype &&\n binding.dataActions[actionPath][exportName].prototype.Action) {\n binding.dataActions[binding.dataActions[actionPath][exportName].prototype.id] = binding.dataActions[actionPath][exportName];\n }\n })\n }\n };\n\n const registerSanitizedActionPath = (sanitizedActionPath, dataAction) => {\n if (process.env.NODE_ENV === 'development') {\n if (!dataAction.default) {\n throw new Error('Data action path does not have a default export');\n }\n if (!(dataAction.default.prototype.id && binding.dataActions[dataAction.default.prototype.id]) || !binding.dataActions[sanitizedActionPath]) {\n binding.dataActions[sanitizedActionPath] = dataAction;\n }\n } else {\n binding.dataActions[sanitizedActionPath] = dataAction;\n if (!binding.dataActions[sanitizedActionPath].default) {\n throw new Error('Data action path ' + sanitizedActionPath + ' does not have a default export');\n }\n binding.dataActions[sanitizedActionPath].default.prototype.RegistrationId = sanitizedActionPath;\n if (binding.dataActions[sanitizedActionPath].default.prototype.id) {\n binding.dataActions[binding.dataActions[sanitizedActionPath].default.prototype.id] = sanitizedActionPath;\n }\n }\n };\n \n\n (binding.modules['eve-catalog-picker'] = {\n c: () => require('partner/modules/eve-catalog-picker/eve-catalog-picker.tsx'),\n $type: 'containerModule',\n da: [{name:'cart', path:'@msdyn365-commerce/global-state/dist/lib/data-actions/cart-state-data-action', runOn: 0},{name:'catalogs', path:'@msdyn365-commerce-modules/retail-actions/dist/lib/get-catalogs', runOn: 0}],\n \n iNM: false,\n ns: '__local__',\n n: 'eve-catalog-picker',\n p: '__local__',\n \n pdp: '',\n \n \n md: 'src/modules/eve-catalog-picker'\n });\n \n\n {\n const sanitizedActionPath = '@msdyn365-commerce-modules/retail-actions/dist/lib/get-catalogs';\n let dataAction = require('@msdyn365-commerce-modules/retail-actions/dist/lib/get-catalogs');\n registerSanitizedActionPath(sanitizedActionPath, dataAction);\n }\n \n\n {\n const sanitizedActionPath = '@msdyn365-commerce/global-state/dist/lib/data-actions/cart-state-data-action';\n let dataAction = require('@msdyn365-commerce/global-state/dist/lib/data-actions/cart-state-data-action');\n registerSanitizedActionPath(sanitizedActionPath, dataAction);\n }\n \n\n \n window.__bindings__ = window.__bindings__ || {};\n window.__bindings__.modules = {\n ...window.__bindings__.modules || {},\n ...binding.modules\n };\n \n window.__bindings__.dataActions = {\n ...window.__bindings__.dataActions || {},\n ...binding.dataActions\n };\n export const viewDictionary = {};\n viewDictionary['__local__|__local__|modules|eve-catalog-picker|eve-catalog-picker'] = {\n c: () => require('partner/modules/eve-catalog-picker/eve-catalog-picker.view.tsx'),\n cn: '__local__-__local__-eve-catalog-picker'\n };\nwindow.__bindings__ = window.__bindings__ || {};\nwindow.__bindings__.viewDictionary = {\n ...window.__bindings__.viewDictionary || {},\n ...viewDictionary\n };","module.exports = React;","module.exports = ReactDOM;"],"names":["CatalogPicker","CatalogPicker_1","React","constructor","props","super","_updateState","cart","this","setState","containsCartline","ArrayExtensions","hasElements","CartLines","handleTextChange","event","config","heading","text","target","value","handleParagraphChange","paragraph","state","data","result","context","actionContext","reaction","_this$props$data$cart","async","newCart","getCartState","_renderCatalogPickerButton","item","catalogId","RecordId","getCatalogId","request","className","_moduleClassName","resources","currentCatalogText","linkToCatalog","Msdyn365","isBrowser","_getUrlSync","catalogUrl","getUrlSync","fullUrl","URL","window","location","href","searchParams","set","catalogSwitchMessageText","Button","changeCatalogButtonText","_renderCatalogPicker","_this$props$data$cata","catalogs","role","map","reactKey","JSON","stringify","String","image","firstOrDefault","Images","key","tabIndex","Name","Image","requestContext","src","generateImageUrl","apiSettings","Uri","gridSettings","imageSettings","galleryImageSettings","altText","AltText","loadFailureBehavior","render","_heading$tag","_this$props$data$cata2","catalogPickerHeading","Text","tag","editProps","onEdit","isCatalogsAvailable","catalogPickerParagraph","RichTextComponent","catalogValidationText","viewProps","_objectSpread","handleText","catalogPicker","moduleProps","renderView","__decorate","observer","CatalogPickerViewFunctionComponent","Module","Object","assign","slots","help","binding","modules","dataActions","registerSanitizedActionPath","sanitizedActionPath","dataAction","default","Error","prototype","RegistrationId","id","c","require","$type","da","name","path","runOn","iNM","ns","n","p","pdp","md","__bindings__","viewDictionary","cn","module","exports","ReactDOM"],"sourceRoot":""}