{"version":3,"sources":["webpack:///./src/modules/farmlands-header/farmlands-header.view.tsx?0cdd","webpack:///./src/modules/farmlands-header/components/logo.tsx?c729","webpack:///./src/modules/farmlands-header/components/nav-icon.tsx?0d63","webpack:///./src/common/components/multi-account.tsx?8d25","webpack:///./src/modules/farmlands-header/utilities/multi-account.ts?c57c","webpack:///./src/common/components/account-switch-modal.tsx?a58b","webpack:///./src/modules/farmlands-header/farmlands-header.tsx?a9a6","webpack:///./src/common/method/functions.ts?e410"],"names":["headerView","props","_props$menuBar$","AccountSwitchModal","RefreshPageModal","secondaryNavData","menuBar","config","cmsNavItems","isMobile","context","request","device","Type","searchUrl","MsDyn365","isBrowser","window","location","hostname","includes","protocol","port","account","wishlist","orderDetails","app","routes","signinLinks","label","path","destinationUrl","target","React","CommonHeader","Object","assign","headerData","items","slice","AEM_URL","wishListIconDesktop","wishListIconMobile","cartIcon","secondaryNavSize","secondaryNavSource","SearchForm","_renderReactFragment","search","length","map","slot","index","key","SigninButton","AccountName","AccountInfoDropdownParentContainer","AccountInfoDropdownPopoverContentContainer","accountInfoDropdownButton","signOutLink","signInLink","accountLinksContainer","accountLinks","toggleAccountModal","togglePopover","totalAccountLength","accountList","isSingleAccount","isOpen","className","Node","Button","onClick","list","link","telemetry","error","_renderDesktopAccountBlock","isAuthenticated","user","isAuthenticatedMenu","Logo","NavIcon","render","this","toggleNavBar","title","resources","mobileHamburgerAriaLabel","isExpanded","targetId","role","__decorate","observer","renderActiveAccount","isOnly","_account$CustomerName","_account$CustomerName2","_account$CustomerName3","displayName","CustomerName","substr","charLimit","trim","createElement","AccountNumber","renderAccount","switchProps","toggleRefreshModal","_account$CustomerName4","_account$CustomerName5","_account$CustomerName6","async","updateAccount","accountNumber","setActiveEcomCustomerByExternalIdAsync","customerAccountNumber","then","data","Code","accountDropdown","document","getElementById","style","display","accountSwitchModal","sessionStorage","setItem","setActiveAccountNumber","setTimeout","reload","getAccountList","customer","customerAccounts","_customerAccounts$sli","IsActive","undefined","Modal","isModalOpen","ModalBody","Header","constructor","super","bodyTag","getElementsByTagName","_toggleAccountModal","updatedModalOpen","state","isAccountModalOpen","setState","_toggleRefreshPageModal","isRefreshModalOpen","popOverRef","_toggleNavbar","bind","_togglePopover","_keydown","mobileMenuCollapsed","signinPopoverOpen","hasEcomPermission","_this$props$data$acco","accountInformation","result","FirstName","Name","_this$props$data$cart","shareholderData","cart","ExtensionProperties","token","isShareholderAccountDisabled","isShareholderAccountNotOnHold","addEventListener","_userContactDetails$C","accountData","getUserAccountDetailsAsync","callerContext","actionContext","queryResultSettings","JSON","parse","atob","split","oid","userContactDetails","getContactDetailsAsync","CustomerAccounts","sortedAccounts","sort","a","b","hasEcommerceAccess","CustomerAccountNumber","customerAccount","find","obj","Permissions","AuthorityLevel","Window","digitalData","customerType","getItem","page","attributes","findingMethod","headerAction","header","dispatchEvent","CustomEvent","removeItem","_logoutInactiveUser","componentWillUnmount","removeEventListener","_this$state$accountDa","_this$state$customerA","id","slots","typeName","cartLabel","cartQtyLabel","headerClassName","classnames","homeLink","switchAccountProps","viewProps","_objectSpread","homeLinkAnchor","href","linkUrl","canAccessCheckout","WishListIconComponent","showButtonTooltip","wishlistTooltipText","CartIconComponent","navIcon","HeaderTag","moduleProps","tag","HeaderContainer","HeaderTopBarContainer","HeaderSecondaryNavContainer","MobileMenuContainer","wrapClassName","MobileMenuBodyContainer","MobileMenuLinksContainer","toggle","_props$customerAccoun","input","substring","Popover","placement","_getSigninButton","_getSignOutButton","_getAccountInfoDropdownButton","_getAccountLinks","topBarNavLinks","_getTopBarNavLinks","topBarNavMobileLinks","contactUsIcon","_getContactUsIcon","renderView","signInLinkText","signInUrl","signInLinkAriaText","_handleSignOut","signOutLinkText","signOutUrl","signOutLinkAriaText","myAccountLinks","cta","color","ariaLabel","openInNewTab","linkText","innerRef","charAt","arguments","mobileNavIconList","linkGroupList","linkgroup","linkList","linkGroupLabel","toLowerCase","contactUsLink","src","alt","toggled","classList","add","remove","e","keyCode","KeyCodes","Escape","_userContactDetails$C2","replace","_userContactDetails$C3","AccountStatus","OnHoldStatus","computed","ePropsValue","isShareholder","console","log","CustomerId","isBusinessAccountProperty","prop","Key","_isBusinessAccountPro","Value","BooleanValue","isCasual","_isBusinessAccountPro2","isGuest","findExtensionProperty","custHoldStatusProp","onHoldStatus","StringValue","isShareholderAccountNotInactive","custAccountStatusProp","accountStatus","isShareholderAccountInactive","Authorities","Authority","getExtensionProperty","extensionProperties","keyValue","typeValue","extensionProperty","String","Boolean","Integer","IntegerValue","Decimal","DecimalValue","isValidColour","str","match"],"mappings":"6MAiLeA,UA9JiCC,IAAS,IAAAC,EACrD,MAAM,mBACFC,EAAkB,iBAClBC,GACAH,EAKEI,EAAmBJ,SAAiB,QAAZC,EAALD,EAAOK,QAAQ,UAAE,IAAAJ,OAAZ,EAALA,EAAmBD,MAAMM,OAAOC,YACnDC,EACFR,EAAMS,QAAQC,SACdV,EAAMS,QAAQC,QAAQC,QACgC,WAArDX,EAAMS,QAAQC,QAAQC,OAAOC,KAElC,IAAIC,EAAY,GACXC,IAASC,YAKNF,EADAG,OAAOC,SAASC,SAASC,SAAS,aACtB,GAAGH,OAAOC,SAASG,aAAaJ,OAAOC,SAASC,YAAYF,OAAOC,SAASI,iBAG5E,GAAGL,OAAOC,SAASG,aAAaJ,OAAOC,SAASC,sBAIpE,MAAM,QACFI,EAAO,SACPC,EAAQ,aACRC,GACAxB,EAAMS,QAAQC,QAAQe,IAAIC,OAExBC,EAAc,CAChB,CACIC,MAAO,aACPC,KAAMP,EAAQQ,eACdC,OAAQ,SAEZ,CACIH,MAAO,gBACPC,KAAML,EAAaM,eACnBC,OAAQ,SAEZ,CACIH,MAAO,WACPC,KAAMN,EAASO,eACfC,OAAQ,UAIhB,OACIC,gBAACC,eAAYC,OAAAC,OAAA,GACLnC,aAAK,EAALA,EAAOoC,WAAU,CACrBC,MAAOjC,EAAiBkC,QACxBC,QAASA,IACTC,oBAAqBxC,aAAK,EAALA,EAAOwC,oBAC5BC,m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,IAAAX,EAC5D,OAAOW,SAAqG,QAAnFX,EAAlBW,EAAoBE,iBAAiBQ,KAAM3K,IAAsC,IAArBA,EAAQgH,UAAmB6D,YAAY,UAAE,IAAAvB,OAAnF,EAAlBA,EAAuGqJ,YAAYhI,KACrHgH,GAAiC,oBAAnBA,EAAKiB,YAWtBC,EAAuB,SAACC,EAAyCC,GAAgE,IAA9CC,EAAAnD,UAAAnO,OAAA,QAAAuF,IAAA4I,UAAA,GAAAA,UAAA,GAAiC,KACtH,MAAMoD,EAAoBH,EAAoBnI,KAAMgH,GAA2BA,EAAKC,MAAQmB,GAE5F,GAAkB,OAAdC,IAAuBC,EACvB,OAAOA,EAGX,OAAQD,GACJ,KAAK3B,EAAY6B,OACb,OAAOD,EAAkBnB,MAAOQ,YACpC,KAAKjB,EAAY8B,QACb,OAAOF,EAAkBnB,MAAOC,aACpC,KAAKV,EAAY+B,QACb,OAAOH,EAAkBnB,MAAOuB,aACpC,KAAKhC,EAAYiC,QACb,OAAOL,EAAkBnB,MAAOyB,aACpC,QACI,OAAO,OAIbC,EAAiBC,IACnB,QAAYxM,IAARwM,GAAsD,OAAjCA,EAAIC,MAAM,mBAGnC,OAAOD","file":"static/js/20.1792d8f515aa5748af5a.chunk.js","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License. See License.txt in the project root for license information.\r\n *--------------------------------------------------------------------------------------------*/\r\n\r\nimport {\r\n Button,\r\n Node\r\n} from '@msdyn365-commerce-modules/utilities';\r\nimport * as React from 'react';\r\nimport { IHeaderViewProps } from './farmlands-header';\r\n// @ts-ignore\r\nimport { CommonHeader } from '@farmlands/common-components';\r\nimport MsDyn365 from '@msdyn365-commerce/core';\r\n\r\nimport { AEM_URL } from '../../config';\r\n\r\ntype DeviceType = 'Mobile';\r\n\r\nconst headerView: React.FC = (props) => {\r\n const {\r\n AccountSwitchModal,\r\n RefreshPageModal\r\n } = props;\r\n\r\n const AccountSwitch = () => AccountSwitchModal;\r\n const RefreshPage = () => RefreshPageModal;\r\n // @ts-ignore\r\n const secondaryNavData = props?.menuBar[0]?.props.config.cmsNavItems;\r\n const isMobile =\r\n props.context.request &&\r\n props.context.request.device &&\r\n (props.context.request.device.Type as DeviceType) === 'Mobile';\r\n\r\n let searchUrl = '';\r\n if (!MsDyn365.isBrowser) {\r\n // return null;\r\n }\r\n else {\r\n if (window.location.hostname.includes('localhost')) {\r\n searchUrl = `${window.location.protocol}//${window.location.hostname}:${window.location.port}/search?q=`;\r\n }\r\n else {\r\n searchUrl = `${window.location.protocol}//${window.location.hostname}/search?q=`;\r\n }\r\n }\r\n\r\n const {\r\n account,\r\n wishlist,\r\n orderDetails\r\n } = props.context.request.app.routes;\r\n\r\n const signinLinks = [\r\n {\r\n label: 'My account',\r\n path: account.destinationUrl,\r\n target: '_self'\r\n },\r\n {\r\n label: 'Order history',\r\n path: orderDetails.destinationUrl,\r\n target: '_self'\r\n },\r\n {\r\n label: 'Wishlist',\r\n path: wishlist.destinationUrl,\r\n target: '_self'\r\n }\r\n ];\r\n\r\n return (\r\n _renderReactFragment(props.search)}\r\n searchUrl={searchUrl}\r\n SigninButton={() => _renderDesktopAccountBlock(props)}\r\n AccountSwitchModal={() => AccountSwitch()}\r\n RefreshPageModal={() => RefreshPage()}\r\n isMobile={isMobile}\r\n isAuthenticated={props.context.request.user.isAuthenticated}\r\n isAuthenticatedMenu={signinLinks}\r\n />\r\n );\r\n};\r\n\r\nfunction _renderDesktopAccountBlock(props: IHeaderViewProps): JSX.Element | null {\r\n const {\r\n AccountName,\r\n AccountInfoDropdownParentContainer,\r\n AccountInfoDropdownPopoverContentContainer,\r\n accountInfoDropdownButton,\r\n signOutLink,\r\n signInLink,\r\n accountLinksContainer,\r\n accountLinks,\r\n toggleAccountModal,\r\n togglePopover,\r\n totalAccountLength,\r\n accountList\r\n } = props;\r\n\r\n const isSingleAccount = totalAccountLength <= 1;\r\n\r\n if (AccountInfoDropdownParentContainer) {\r\n if (AccountInfoDropdownPopoverContentContainer) {\r\n return (\r\n <>\r\n {AccountInfoDropdownPopoverContentContainer.isOpen ?
: null}\r\n \r\n {AccountName}\r\n {accountInfoDropdownButton}\r\n \r\n {/*tslint:disable-next-line: react-this-binding-issue jsx-no-lambda*/}\r\n
\r\n \r\n close\r\n \r\n {!isSingleAccount && (\r\n <>\r\n person\r\n

Select your Account

\r\n {accountList ? accountList.map((list) => list) : false}\r\n {accountList && totalAccountLength > 5 ? (\r\n {\r\n togglePopover();\r\n toggleAccountModal();\r\n }}\r\n >\r\n See more Accounts\r\n
\r\n ) : null}\r\n \r\n )}\r\n \r\n \r\n
{accountLinks ? accountLinks.map((link) => link) : false}
\r\n {signOutLink}\r\n
\r\n
\r\n
\r\n \r\n );\r\n } else if (signInLink) {\r\n return {signInLink};\r\n }\r\n }\r\n props.context.telemetry.error('Header content is empty, module wont render.');\r\n return null;\r\n}\r\n\r\nfunction _renderReactFragment(items: React.ReactNode[]): JSX.Element | null {\r\n return (\r\n \r\n {items && items.length\r\n ? items.map((slot: React.ReactNode, index: number) => {\r\n return {slot};\r\n })\r\n : null}\r\n \r\n );\r\n}\r\n\r\nexport default headerView;\r\n","/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License. See License.txt in the project root for license information.\r\n *--------------------------------------------------------------------------------------------*/\r\nimport * as Msdyn365 from '@msdyn365-commerce/core';\r\nimport * as React from 'react';\r\n\r\nexport interface ILogoProps {\r\n image: Msdyn365.IImageData;\r\n gridSettings?: Msdyn365.IGridSettings;\r\n link?: ILinkData;\r\n className?: string;\r\n}\r\n\r\nexport interface ILinkData {\r\n linkUrl: Msdyn365.ILinkData;\r\n ariaLabel?: string;\r\n openInNewTab?: boolean;\r\n linkText?: string;\r\n}\r\n\r\n/**\r\n *\r\n * Logo component\r\n * @extends {React.PureComponent}\r\n */\r\nexport class Logo extends React.PureComponent {\r\n public render():JSX.Element {\r\n return(\r\n
\r\n {this._renderLogo(this.props)}\r\n
\r\n );\r\n }\r\n\r\n private _renderLogo(config: ILogoProps):JSX.Element {\r\n if(config.link && config.link.linkUrl.destinationUrl) {\r\n return(\r\n \r\n {this._renderImage(config)}\r\n \r\n );\r\n }\r\n return(\r\n this._renderImage(config)\r\n );\r\n }\r\n\r\n private _renderImage(config: ILogoProps): JSX.Element {\r\n const defaultImageSettings: Msdyn365.IImageSettings = {\r\n viewports: {\r\n xs: { q: `w=132&h=28&m=6`, w: 0, h: 0 },\r\n lg: { q: `w=160&h=48&m=6`, w: 0, h: 0 }\r\n },\r\n lazyload: true\r\n };\r\n\r\n return (\r\n \r\n );\r\n }\r\n}\r\n\r\nexport default Logo;","/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License. See License.txt in the project root for license information.\r\n *--------------------------------------------------------------------------------------------*/\r\nimport * as React from 'react';\r\n\r\nimport { observer } from 'mobx-react';\r\nimport { IFarmlandsHeaderResources } from '../farmlands-header.props.autogenerated';\r\n\r\nexport interface INavIconProps {\r\n resources: IFarmlandsHeaderResources;\r\n isExpanded: boolean;\r\n targetId: string;\r\n toggleNavBar(): void;\r\n}\r\n\r\n/**\r\n *\r\n * NavIcon component\r\n * @extends {React.PureComponent}\r\n */\r\n\r\n@observer\r\nexport class NavIcon extends React.Component {\r\n public render(): JSX.Element {\r\n return (\r\n \r\n {this.props.isExpanded ? 'close' : 'menu'}\r\n \r\n );\r\n }\r\n}\r\n","import { Customer } from '@msdyn365-commerce/retail-proxy';\r\nimport React from 'react';\r\nimport { setActiveEcomCustomerByExternalIdAsync } from '../../actions/farmlands-set-active-ecom-customer-by-external-id-calls.action';\r\nimport { ICustomerAccountData } from '../../modules/farmlands-header/farmlands-header.data';\r\nimport { setActiveAccountNumber } from '../../modules/farmlands-header/utilities/multi-account';\r\n\r\nconst charLimit = 30;\r\n\r\nexport const renderActiveAccount = (account: ICustomerAccountData, isOnly: boolean) => {\r\n const overLimit = account?.CustomerName?.length > charLimit;\r\n const displayName = overLimit ? `${account?.CustomerName?.substr(0, charLimit - 3)?.trim()}...` : account?.CustomerName;\r\n\r\n return (\r\n
\r\n
\r\n
\r\n {displayName}\r\n \r\n Account number: {account?.AccountNumber}\r\n \r\n
\r\n
\r\n \r\n ACTIVE\r\n \r\n
\r\n );\r\n};\r\n\r\nexport const renderAccount = (\r\n account: ICustomerAccountData,\r\n switchProps: { context: any; externalId: any; accountNo: any },\r\n toggleRefreshModal: () => void\r\n) => {\r\n const overLimit = account?.CustomerName?.length > charLimit;\r\n const displayName = overLimit ? `${account?.CustomerName?.substr(0, charLimit - 3)?.trim()}...` : account?.CustomerName;\r\n\r\n async function updateAccount(accountNumber: string) {\r\n await setActiveEcomCustomerByExternalIdAsync({\r\n context: switchProps.context,\r\n customerAccountNumber: accountNumber\r\n }).then((data) => {\r\n if (data.Code === '200') {\r\n const accountDropdown = document.getElementById('myprofilePopover');\r\n if (accountDropdown) {\r\n accountDropdown.style.display = 'none';\r\n }\r\n const accountSwitchModal = document.getElementById('AccountSwitchModal');\r\n if (accountSwitchModal) {\r\n accountSwitchModal.style.display = 'none';\r\n }\r\n setActiveAccountNumber(accountNumber);\r\n toggleRefreshModal();\r\n if (window) {\r\n setTimeout(() => {\r\n window.location.reload();\r\n }, 5000);\r\n }\r\n }\r\n });\r\n }\r\n\r\n return (\r\n
\r\n
\r\n
\r\n {displayName}\r\n \r\n Account number: {account?.AccountNumber}\r\n \r\n
\r\n
\r\n {\r\n updateAccount(account?.AccountNumber);\r\n }}\r\n >\r\n Select\r\n
\r\n \r\n );\r\n};\r\n\r\nexport const getAccountList = (\r\n customer: Customer | undefined,\r\n switchProps: any,\r\n toggleRefreshModal: () => void,\r\n customerAccounts?: ICustomerAccountData[],\r\n displayName?: string\r\n): React.ReactNode[] | undefined => {\r\n return customer && displayName && customerAccounts && customerAccounts.length > 0\r\n ? customerAccounts\r\n ?.slice(0, 5)\r\n ?.map((account) =>\r\n account?.IsActive\r\n ? renderActiveAccount(account, customerAccounts.length === 1)\r\n : renderAccount(account, switchProps, toggleRefreshModal)\r\n )\r\n : undefined;\r\n};\r\n","export function setActiveAccountNumber(accountNumber: string): void {\r\n sessionStorage.setItem('ActiveAccountNumber', accountNumber);\r\n}\r\n\r\nexport function getActiveAccountNumber(): string | null {\r\n return sessionStorage.getItem('ActiveAccountNumber');\r\n}\r\n","import { Button, Modal, ModalBody } from '@msdyn365-commerce-modules/utilities';\r\nimport React from 'react';\r\nimport { ICustomerAccountData } from '../../modules/farmlands-header/farmlands-header.data';\r\nimport { renderAccount, renderActiveAccount } from './multi-account';\r\n\r\ninterface IAccountSwitchModal {\r\n toggleAccountModal: (e: boolean) => void;\r\n toggleRefreshModal: () => void;\r\n customerAccounts?: ICustomerAccountData[];\r\n isAccountModalOpen: boolean;\r\n switchAccountProps: any;\r\n}\r\n\r\nexport interface IRefreshPageModal {\r\n toggleRefreshModal: () => void;\r\n isModalOpen: boolean;\r\n}\r\n\r\nexport const AccountSwitchModal = (props: IAccountSwitchModal) => {\r\n const _renderAccountModalContent = () => {\r\n return (\r\n
\r\n props.toggleAccountModal(false)}\r\n >\r\n person\r\n

Select your Account

\r\n {props.customerAccounts?.map((account: any) =>\r\n account?.IsActive\r\n ? renderActiveAccount(account, false)\r\n : renderAccount(account, props.switchAccountProps, props.toggleRefreshModal)\r\n )}\r\n
\r\n );\r\n };\r\n\r\n return (\r\n props.toggleAccountModal(false)}>\r\n {_renderAccountModalContent()}\r\n \r\n );\r\n};\r\n\r\nexport const RefreshPageModal = (props: IRefreshPageModal) => {\r\n const _renderModalContent = () => {\r\n return (\r\n
\r\n

Switching your Shareholder Account.

\r\n

Please refresh any open Farmlands pages to view your Shareholder Account.

\r\n
\r\n );\r\n };\r\n\r\n return (\r\n \r\n {_renderModalContent()}\r\n \r\n );\r\n};\r\n","/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License. See License.txt in the project root for license information.\r\n *--------------------------------------------------------------------------------------------*/\r\nimport classnames from 'classnames';\r\nimport { computed } from 'mobx';\r\nimport * as React from 'react';\r\n\r\nimport { Button, IModuleProps, INodeProps, KeyCodes, Modal, ModalBody, Popover } from '@msdyn365-commerce-modules/utilities';\r\nimport { CartIconComponent, WishListIconComponent } from '@msdyn365-commerce/components';\r\nimport { IRequestContextUser } from '@msdyn365-commerce/core';\r\nimport { Customer } from '@msdyn365-commerce/retail-proxy';\r\n\r\nimport { ILinkGroup } from '../../types/links';\r\nimport { NavIcon } from './components';\r\nimport { ICustomerAccountData, IFarmlandsHeaderData, IHeaderData } from './farmlands-header.data';\r\nimport { IFarmlandsHeaderProps, IFarmlandsHeaderResources, IMyAccountLinksData } from './farmlands-header.props.autogenerated';\r\nimport { getUserAccountDetailsAsync } from '../../actions/farmlands-account-details-calls.action';\r\nimport { getContactDetailsAsync } from '../../actions/farmlands-get-contact-details-calls.action';\r\nimport { isShareholderAccountDisabled, isShareholderAccountNotOnHold, hasEcommerceAccess } from '../../common/method/functions';\r\nimport { AccountSwitchModal, RefreshPageModal } from '../../common/components/account-switch-modal';\r\nimport { getAccountList } from '../../common/components/multi-account';\r\n\r\nexport interface IHeaderState {\r\n mobileMenuCollapsed: boolean;\r\n signinPopoverOpen: boolean;\r\n isAccountModalOpen: boolean;\r\n isRefreshModalOpen: boolean;\r\n headerData?: any;\r\n accountData?: any;\r\n customerAccounts?: ICustomerAccountData[];\r\n hasEcomPermission: boolean;\r\n}\r\n\r\nexport interface IHeaderViewProps extends IFarmlandsHeaderProps, IHeaderState {\r\n wishListIconDesktop: React.ReactNode;\r\n wishListIconMobile: React.ReactNode;\r\n cartIcon: React.ReactNode;\r\n isOpen: boolean;\r\n navIcon: React.ReactNode;\r\n className: string;\r\n menuBar: React.ReactNode[];\r\n search: React.ReactNode[];\r\n HeaderTag: IModuleProps;\r\n HeaderContainer: INodeProps;\r\n MobileMenuContainer: INodeProps;\r\n MobileMenuBodyContainer: INodeProps;\r\n MobileMenuLinksContainer: INodeProps;\r\n AccountSwitchModal: JSX.Element;\r\n RefreshPageModal: JSX.Element;\r\n toggleAccountModal: () => void;\r\n togglePopover: () => void;\r\n HeaderTopBarContainer: INodeProps;\r\n HeaderSecondaryNavContainer: INodeProps;\r\n\r\n AccountName?: React.ReactNode;\r\n AccountInfoDropdownParentContainer?: INodeProps;\r\n AccountInfoDropdownPopoverContentContainer?: INodeProps;\r\n accountInfoDropdownButton?: React.ReactNode;\r\n\r\n signOutLink?: React.ReactNode;\r\n signInLink?: React.ReactNode;\r\n accountLinksContainer: INodeProps;\r\n accountLinks?: React.ReactNode[];\r\n totalAccountLength: number;\r\n accountList?: React.ReactNode[];\r\n topBarNavLinks?: React.ReactNode[];\r\n topBarNavMobileLinks?: React.ReactNode[];\r\n contactUsIcon?: React.ReactNode;\r\n homeLinkAnchor?: React.ReactNode;\r\n}\r\n\r\ninterface ICustomerAccount {\r\n AccountNumber?: string;\r\n AccountStatus?: string;\r\n}\r\n/**\r\n *\r\n * Header component\r\n * @extends {React.PureComponent>}\r\n */\r\nclass Header extends React.PureComponent, IHeaderState> {\r\n private popOverRef: React.RefObject;\r\n\r\n @computed public get displayName(): Readonly {\r\n const customer = this.props.data.accountInformation?.result;\r\n return customer ? customer.FirstName || customer.Name : undefined;\r\n }\r\n\r\n @computed get canAccessCheckout(): boolean {\r\n const shareholderData = this.props.data.cart.result?.cart.ExtensionProperties!;\r\n if (this.props.context.request.user.token) {\r\n if (shareholderData) {\r\n return !isShareholderAccountDisabled(shareholderData) && isShareholderAccountNotOnHold(shareholderData);\r\n }\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n constructor(props: IFarmlandsHeaderProps) {\r\n super(props);\r\n this.popOverRef = React.createRef();\r\n this._toggleNavbar = this._toggleNavbar.bind(this);\r\n this._togglePopover = this._togglePopover.bind(this);\r\n this._keydown = this._keydown.bind(this);\r\n this.state = {\r\n mobileMenuCollapsed: true,\r\n signinPopoverOpen: false,\r\n hasEcomPermission: false,\r\n isAccountModalOpen: false,\r\n isRefreshModalOpen: false\r\n };\r\n }\r\n public async componentDidMount(): Promise {\r\n // this._silentSignOn();\r\n window && window.addEventListener('keydown', this._keydown);\r\n if (this.props.context.request.user.token) {\r\n const accountData = await getUserAccountDetailsAsync(\r\n { callerContext: this.props.context.actionContext, queryResultSettings: {} },\r\n JSON.parse(atob(this.props.context.request.user.token.split('.')[1])).oid\r\n );\r\n const userContactDetails = await getContactDetailsAsync(\r\n { callerContext: this.props.context.actionContext, queryResultSettings: {} },\r\n JSON.parse(atob(this.props.context.request.user.token.split('.')[1])).oid\r\n );\r\n\r\n const customerAccounts: ICustomerAccountData[] = userContactDetails.CustomerAccounts;\r\n\r\n const sortedAccounts =\r\n customerAccounts && customerAccounts?.length > 0\r\n ? customerAccounts.sort((a, b) => {\r\n if (a?.IsActive) {\r\n return -1;\r\n } else if (b?.IsActive) {\r\n return 1;\r\n } else if (a?.CustomerName < b?.CustomerName) {\r\n return -1;\r\n } else if (a?.CustomerName > b?.CustomerName) {\r\n return 1;\r\n } else {\r\n return 0;\r\n }\r\n })\r\n : [];\r\n\r\n this.setState({\r\n customerAccounts: sortedAccounts\r\n });\r\n\r\n this.setState({\r\n accountData\r\n });\r\n\r\n if (hasEcommerceAccess(userContactDetails)) {\r\n this.setState({\r\n hasEcomPermission: true\r\n });\r\n }\r\n\r\n //Get Customer Account and check customer type for analytics\r\n const accountNumber = this.state.accountData.CustomerAccountNumber;\r\n const customerAccount = userContactDetails.CustomerAccounts?.find(\r\n (obj: ICustomerAccount) => obj?.AccountNumber === accountNumber\r\n );\r\n if (customerAccount && customerAccount.Permissions && customerAccount.Permissions.length > 0) {\r\n if (customerAccount.Permissions[0].AuthorityLevel.includes('Casual')) {\r\n (Window as any).digitalData.user.customerType = 'casual';\r\n }\r\n else {\r\n (Window as any).digitalData.user.customerType = 'shareholder';\r\n }\r\n }\r\n } else {\r\n this.setState({ hasEcomPermission: true });\r\n (Window as any).digitalData.user.customerType = 'guest';\r\n }\r\n if (sessionStorage.getItem('findingMethod')) {\r\n (Window as any).digitalData.page.attributes.findingMethod = sessionStorage.getItem('findingMethod');\r\n }\r\n this.props.data.headerAction.then((data) => {\r\n this.setState({\r\n headerData: data.header\r\n });\r\n });\r\n\r\n //ToDo: Change to functional component if data does not get passed correctly consistently. Use react hook with dependency on document.readyState\r\n //https://stackoverflow.com/questions/24947837/javascript-page-is-fully-loaded-boolean-check\r\n window.dispatchEvent(new CustomEvent('PageLoad'));\r\n sessionStorage.removeItem('findingMethod');\r\n await this._logoutInactiveUser();\r\n }\r\n\r\n public componentWillUnmount(): void {\r\n window && window.removeEventListener('keydown', this._keydown, false);\r\n }\r\n\r\n public render(): JSX.Element | null {\r\n const {\r\n id,\r\n slots,\r\n typeName,\r\n data: {\r\n accountInformation,\r\n cart: { result: cart }\r\n },\r\n context: {\r\n request: { user }\r\n },\r\n context,\r\n resources: { cartLabel, cartQtyLabel }\r\n } = this.props;\r\n\r\n const { hasEcomPermission } = this.state;\r\n\r\n const headerClassName = classnames('ms-header', this.props.config.className);\r\n const navbarKey = 'header-nav-mobile';\r\n const homeLink = this.props.config.homeLink;\r\n const truncate = (input: string) => (input.length > 21 ? `${input.substring(0, 21)}​​​​​...` : input);\r\n const customer = accountInformation && accountInformation.result;\r\n const switchAccountProps = {\r\n context: { callerContext: context.actionContext, queryResultSettings: {} }\r\n };\r\n const viewProps: IHeaderViewProps = {\r\n ...(this.props as IFarmlandsHeaderProps),\r\n ...this.state,\r\n homeLinkAnchor: (\r\n \r\n Shop online\r\n \r\n ),\r\n wishListIconDesktop: this.canAccessCheckout && hasEcomPermission && (\r\n \r\n ),\r\n wishListIconMobile: this.canAccessCheckout && hasEcomPermission && (\r\n \r\n ),\r\n cartIcon:\r\n this.canAccessCheckout && hasEcomPermission && slots && slots.cartIcon && slots.cartIcon.length > 0\r\n ? slots.cartIcon[0]\r\n : this.canAccessCheckout &&\r\n hasEcomPermission &&\r\n cart && (\r\n \r\n ),\r\n isOpen: !this.state.mobileMenuCollapsed,\r\n navIcon: (\r\n \r\n ),\r\n menuBar: (slots && slots.menuBar && slots.menuBar.length && slots.menuBar) || [],\r\n search: (slots && slots.search && slots.search.length && slots.search) || [],\r\n className: headerClassName,\r\n HeaderTag: {\r\n moduleProps: this.props,\r\n className: classnames(headerClassName),\r\n tag: 'header'\r\n },\r\n HeaderContainer: {\r\n className: classnames('ms-header__container')\r\n },\r\n HeaderTopBarContainer: {\r\n className: classnames('ms-header__topbar')\r\n },\r\n HeaderSecondaryNavContainer: {\r\n className: classnames('ms-header__secondarynav')\r\n },\r\n MobileMenuContainer: {\r\n tag: Modal,\r\n id: navbarKey,\r\n className: 'ms-header__mobile-hamburger',\r\n isOpen: !this.state.mobileMenuCollapsed,\r\n wrapClassName: 'ms-header__modal'\r\n },\r\n MobileMenuBodyContainer: {\r\n tag: ModalBody,\r\n className: 'ms-header__mobile-hamburger-menu-body'\r\n },\r\n MobileMenuLinksContainer: {\r\n className: 'ms-header__mobile-hamburger-menu-links'\r\n },\r\n AccountSwitchModal: AccountSwitchModal({\r\n customerAccounts: this.state.customerAccounts,\r\n toggleAccountModal: this._toggleAccountModal,\r\n isAccountModalOpen: this.state.isAccountModalOpen,\r\n switchAccountProps,\r\n toggleRefreshModal: this._toggleRefreshPageModal\r\n }),\r\n RefreshPageModal: RefreshPageModal({\r\n isModalOpen: this.state.isRefreshModalOpen,\r\n toggleRefreshModal: this._toggleRefreshPageModal\r\n }),\r\n toggleAccountModal: this._toggleAccountModal,\r\n AccountInfoDropdownParentContainer: { className: 'ms-header__account-info' },\r\n AccountName: (\r\n \r\n {this.state.accountData?.CustomerName && truncate(this.state.accountData.CustomerName)}\r\n \r\n ),\r\n AccountInfoDropdownPopoverContentContainer:\r\n (customer &&\r\n this.displayName && {\r\n tag: Popover,\r\n id: 'myprofilePopover',\r\n className: 'ms-header__account-info-content',\r\n placement: 'bottom',\r\n isOpen: this.state.signinPopoverOpen,\r\n target: this.popOverRef,\r\n toggle: this._togglePopover\r\n }) ||\r\n undefined,\r\n signInLink: this._getSigninButton(customer, user, this.props.resources),\r\n signOutLink: this._getSignOutButton(customer, user, this.props.resources),\r\n accountInfoDropdownButton: this._getAccountInfoDropdownButton(customer),\r\n totalAccountLength: this.state.customerAccounts?.length || 0,\r\n accountLinksContainer: {\r\n className: 'ms-header__account-links-container'\r\n },\r\n accountLinks: this._getAccountLinks(customer),\r\n accountList: getAccountList(\r\n customer,\r\n switchAccountProps,\r\n this._toggleRefreshPageModal,\r\n this.state.customerAccounts,\r\n this.displayName\r\n ),\r\n topBarNavLinks: this._getTopBarNavLinks(this.state.headerData),\r\n topBarNavMobileLinks: this._getTopBarNavLinks(this.state.headerData, true),\r\n contactUsIcon: this._getContactUsIcon(this.state.headerData),\r\n togglePopover: this._togglePopover\r\n };\r\n return this.props.renderView(viewProps) as React.ReactElement;\r\n }\r\n\r\n private _getSigninButton(\r\n customer: Customer | undefined,\r\n user: IRequestContextUser | undefined,\r\n resources: IFarmlandsHeaderResources\r\n ): React.ReactNode | undefined {\r\n return (\r\n !customer && (\r\n \r\n \r\n {resources.signInLinkText}\r\n \r\n \r\n )\r\n );\r\n }\r\n\r\n private _getSignOutButton(\r\n customer: Customer | undefined,\r\n user: IRequestContextUser | undefined,\r\n resources: IFarmlandsHeaderResources\r\n ): React.ReactNode | undefined {\r\n return (\r\n customer &&\r\n this.displayName && (\r\n <>\r\n
\r\n this._handleSignOut()}\r\n className={'ms-header__signout-button'}\r\n title={resources.signOutLinkText}\r\n href={(user && user.signOutUrl) || ''}\r\n aria-label={resources.signOutLinkAriaText}\r\n >\r\n \r\n {resources.signOutLinkText}\r\n \r\n
\r\n login\r\n
\r\n \r\n \r\n )\r\n );\r\n }\r\n\r\n private _handleSignOut(): void {\r\n return window.sessionStorage.removeItem('phone');\r\n }\r\n\r\n private _getAccountLinks(customer: Customer | undefined): React.ReactNode[] | undefined {\r\n const { myAccountLinks } = this.props.config;\r\n\r\n return customer && this.displayName && myAccountLinks && myAccountLinks.length\r\n ? myAccountLinks.map((cta: IMyAccountLinksData, index: number) => (\r\n \r\n {cta.linkText || ''}\r\n \r\n ))\r\n : undefined;\r\n }\r\n\r\n private _getAccountInfoDropdownButton(customer: Customer | undefined): React.ReactNode | undefined {\r\n return (\r\n customer &&\r\n this.displayName && (\r\n \r\n {this.displayName.charAt(0)}\r\n \r\n )\r\n );\r\n }\r\n\r\n private _getTopBarNavLinks(headerData: IHeaderData | undefined, isMobile: boolean = false): React.ReactNode[] | undefined {\r\n const choicesRewardsLabel = 'choices rewards';\r\n // Icon names need to be changed accordingly to represent the nav items\r\n const mobileNavIconList = ['card_giftcard', 'location_on', 'emoji_events', 'grade'];\r\n return headerData?.linkGroupList && headerData?.linkGroupList.length\r\n ? headerData?.linkGroupList.map((linkgroup: ILinkGroup, index: number) =>\r\n isMobile ? (\r\n
\r\n {mobileNavIconList[index]}\r\n \r\n {linkgroup.linkList[0].label || ''}\r\n \r\n
\r\n ) : (\r\n \r\n {linkgroup.linkList[0].label || ''}\r\n \r\n )\r\n )\r\n : undefined;\r\n }\r\n\r\n private _getContactUsIcon(headerData: IHeaderData | undefined): React.ReactNode | undefined {\r\n return headerData?.contactUsLink ? (\r\n
\r\n \r\n \r\n \r\n Contact us\r\n
\r\n ) : undefined;\r\n }\r\n\r\n private _toggleNavbar(): void {\r\n this.setState({\r\n mobileMenuCollapsed: !this.state.mobileMenuCollapsed\r\n });\r\n }\r\n\r\n private bodyTag = typeof document !== 'undefined' && document.getElementsByTagName('BODY')[0];\r\n\r\n private _togglePopover(): void {\r\n if (this.bodyTag) {\r\n const toggled = !this.state.signinPopoverOpen;\r\n if (toggled) {\r\n this.bodyTag.classList.add('disable-scroll');\r\n } else {\r\n this.bodyTag.classList.remove('disable-scroll');\r\n }\r\n this.setState({\r\n signinPopoverOpen: toggled\r\n });\r\n }\r\n }\r\n\r\n private _toggleAccountModal = (): void => {\r\n const updatedModalOpen = !this.state.isAccountModalOpen;\r\n const accountDropdown = document.getElementById('myprofilePopover');\r\n if (updatedModalOpen) {\r\n if (accountDropdown) {\r\n accountDropdown.style.display = 'none';\r\n }\r\n } else {\r\n if (accountDropdown) {\r\n accountDropdown.style.display = 'unset';\r\n }\r\n }\r\n this.setState({\r\n isAccountModalOpen: updatedModalOpen\r\n });\r\n };\r\n\r\n private _toggleRefreshPageModal = (): void => {\r\n this.setState({\r\n isRefreshModalOpen: !this.state.isRefreshModalOpen\r\n });\r\n };\r\n\r\n private _keydown(e: KeyboardEvent): void {\r\n if (e.keyCode === KeyCodes.Escape) {\r\n this.setState({ mobileMenuCollapsed: true });\r\n }\r\n }\r\n private async _logoutInactiveUser(): Promise {\r\n if (this.props.context.request.user.token && this.props.context.request.user.signOutUrl) {\r\n const userContactDetails = await getContactDetailsAsync(\r\n { callerContext: this.props.context.actionContext, queryResultSettings: {} },\r\n JSON.parse(atob(this.props.context.request.user.token.split('.')[1])).oid\r\n );\r\n if (userContactDetails.CustomerAccounts?.length === 0) {\r\n window.location.replace(this.props.context.request.user.signOutUrl);\r\n } else {\r\n const accountNumber = this.state.accountData.CustomerAccountNumber;\r\n const customerAccount = userContactDetails.CustomerAccounts?.find(\r\n (obj: ICustomerAccount) => obj?.AccountNumber === accountNumber\r\n );\r\n if (customerAccount?.AccountStatus === 'Inactive' && customerAccount?.OnHoldStatus !== 'No') {\r\n window.location.replace(this.props.context.request.user.signOutUrl);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nexport default Header;\r\n","import { Cart, CommerceProperty } from '@msdyn365-commerce/retail-proxy/dist/Entities/CommerceTypes.g.d';\r\n\r\nenum ePropsValue {\r\n String = 'STRING',\r\n Integer = 'INTEGER',\r\n Boolean = 'BOOLEAN',\r\n Decimal = 'DECIMAL'\r\n}\r\n\r\ntype ExtensionPropsValue = ePropsValue.Boolean | ePropsValue.Integer | ePropsValue.String | ePropsValue.Decimal | null;\r\n\r\nconst IS_BUSINESS_ACCOUNT_KEY = 'IsBusinessAccount';\r\nconst CUST_HOLD_STATUS_KEY = 'CustHoldStatus';\r\nconst CUST_ACCOUNT_STATUS_KEY = 'CustAccountStatus';\r\n\r\n\r\nconst isShareholder = (cart: Cart): boolean => {\r\n console.log(cart)\r\n const { CustomerId, ExtensionProperties } = cart;\r\n const isBusinessAccountProperty = ExtensionProperties!.find((prop: CommerceProperty) => prop.Key === IS_BUSINESS_ACCOUNT_KEY);\r\n if (CustomerId !==undefined)\r\n {\r\n return CustomerId !== null && CustomerId!.length > 0 && ((isBusinessAccountProperty && isBusinessAccountProperty?.Value?.BooleanValue) || false);\r\n }\r\n else\r\n {\r\n return false;\r\n }\r\n};\r\n\r\nconst isCasual = (cart: Cart): boolean => {\r\n const { CustomerId, ExtensionProperties } = cart;\r\n const isBusinessAccountProperty = ExtensionProperties!.find((prop: CommerceProperty) => prop.Key === IS_BUSINESS_ACCOUNT_KEY);\r\n if (CustomerId !==undefined)\r\n {\r\n return CustomerId !== null && CustomerId!.length > 0 && ((isBusinessAccountProperty && !(isBusinessAccountProperty?.Value?.BooleanValue)) || false);\r\n }\r\n else{\r\n return false;\r\n }\r\n};\r\n\r\nconst isGuest = (cart: Cart): boolean => {\r\n const { CustomerId } = cart;\r\n if (CustomerId !==undefined)\r\n {\r\n return !(CustomerId!.length > 0);\r\n }\r\n else{\r\n return true;\r\n }\r\n\r\n};\r\n\r\nconst findExtensionProperty = (ExtensionProperties: CommerceProperty[], key: string): CommerceProperty | undefined => {\r\n return ExtensionProperties.find((prop: CommerceProperty) => prop.Key === key);\r\n};\r\n\r\n// CustHoldStatus for the customer is not set to \"Tax invoice\" or \"All\"\r\nconst isShareholderAccountNotOnHold = (ExtensionProperties: CommerceProperty[]): boolean => {\r\n const custHoldStatusProp = findExtensionProperty(ExtensionProperties, CUST_HOLD_STATUS_KEY);\r\n const onHoldStatus = custHoldStatusProp ? custHoldStatusProp.Value!.StringValue! : '';\r\n return !['Tax invoice', 'All'].includes(onHoldStatus);\r\n};\r\n\r\n// CustAccountStatus for the customer is set to \"Active\" or \"Monitored\"\r\nconst isShareholderAccountNotInactive = (ExtensionProperties: CommerceProperty[]): boolean => {\r\n const custAccountStatusProp = findExtensionProperty(ExtensionProperties, CUST_ACCOUNT_STATUS_KEY);\r\n const accountStatus = custAccountStatusProp ? custAccountStatusProp.Value!.StringValue! : '';\r\n return ['Active', 'Monitored'].includes(accountStatus);\r\n};\r\n\r\n// CustAccountStatus for the customer is set to \"Off-boarding\" or \"Suspended\"\r\nconst isShareholderAccountDisabled = (ExtensionProperties: CommerceProperty[]): boolean => {\r\n const custAccountStatusProp = findExtensionProperty(ExtensionProperties, CUST_ACCOUNT_STATUS_KEY);\r\n const accountStatus = custAccountStatusProp ? custAccountStatusProp.Value!.StringValue! : '';\r\n return ['Off-boarding', 'Suspended'].includes(accountStatus);\r\n};\r\n\r\n// CustAccountStatus for the customer is set to specifically to \"Inactive\"\r\nconst isShareholderAccountInactive = (ExtensionProperties: CommerceProperty[]): boolean => {\r\n const custAccountStatusProp = findExtensionProperty(ExtensionProperties, CUST_ACCOUNT_STATUS_KEY);\r\n const accountStatus = custAccountStatusProp ? custAccountStatusProp.Value!.StringValue! : '';\r\n return ['Inactive'].includes(accountStatus);\r\n};\r\n\r\nconst hasEcommerceAccess = (userContactDetails: any): boolean => {\r\n return userContactDetails?.CustomerAccounts.find((account: any) => account.IsActive === true).Permissions[0]?.Authorities.find(\r\n (prop: any) => prop.Authority === 'EcommerceAccess'\r\n );\r\n};\r\n\r\n/**\r\n * Get the value of an ExtensionProperty (EP)\r\n * @param extensionProperties The EP used to search for property\r\n * @param keyValue The key value to search\r\n * @param typeValue The type value to return\r\n * @returns The value from EP or EP Object if no typeValue is passed\r\n */\r\nconst getExtensionProperty = (extensionProperties: CommerceProperty[], keyValue: string, typeValue: ExtensionPropsValue = null): any => {\r\n const extensionProperty = extensionProperties.find((prop: CommerceProperty) => prop.Key === keyValue);\r\n\r\n if (typeValue === null || !extensionProperty) {\r\n return extensionProperty;\r\n }\r\n\r\n switch (typeValue) {\r\n case ePropsValue.String:\r\n return extensionProperty.Value!.StringValue;\r\n case ePropsValue.Boolean:\r\n return extensionProperty.Value!.BooleanValue;\r\n case ePropsValue.Integer:\r\n return extensionProperty.Value!.IntegerValue;\r\n case ePropsValue.Decimal:\r\n return extensionProperty.Value!.DecimalValue;\r\n default:\r\n return null;\r\n }\r\n};\r\n\r\nconst isValidColour = (str: string | undefined): string | void => {\r\n if (str === undefined || str.match(/^#[a-f0-9]{6}$/i) === null) {\r\n return;\r\n }\r\n return str;\r\n};\r\n\r\nexport {\r\n isShareholder,\r\n isCasual,\r\n isGuest,\r\n isShareholderAccountNotInactive,\r\n isShareholderAccountDisabled,\r\n isShareholderAccountInactive,\r\n isShareholderAccountNotOnHold,\r\n hasEcommerceAccess,\r\n ePropsValue,\r\n getExtensionProperty,\r\n isValidColour\r\n};\r\n"],"sourceRoot":""}