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vB,EAAkBC,MAAMF,E,gDC7E5B,Q,SAAgC,O","sources":["webpack:///./modules/ShopOrderOverview/ShopOrderOverview.ts","webpack:///./modules/ShopOrderOverview/index.ts"],"sourcesContent":["import { getOptions } from '../../helpers/helperFunctions';\r\n\r\nconst moduleSelector = '[data-module=\"ShopOrderOverview\"]';\r\n\r\nexport default class ShopOrderOverview {\r\n private backButton: HTMLElement;\r\n private confirmButton: HTMLElement;\r\n\r\n static setup(selector: string = moduleSelector): void {\r\n Array.from(document.querySelectorAll(selector)).filter((node: HTMLElement) => !node.dataset.moduleInitialized).forEach((element: HTMLElement) => {\r\n new ShopOrderOverview(element);\r\n element.dataset.moduleInitialized = 'true';\r\n });\r\n }\r\n\r\n constructor(public element: HTMLElement, private options: ShopOrderOverviewOptions = {}) {\r\n this.options = getOptions(this.element, Object.assign(this.getDefaultOptions(), this.options));\r\n this.backButton = this.element.querySelector(`.${this.options.backToPreviousStep}`);\r\n this.confirmButton = this.element.querySelector(`.${this.options.confirmOrder}`);\r\n\r\n this.init();\r\n }\r\n\r\n protected init(): ShopOrderOverview {\r\n this.backButton.addEventListener('click', () => this.handleBackToPreviousStep(this.backButton.dataset.ajaxUrl));\r\n this.confirmButton.addEventListener('click', () => this.fetchOrderResponse(this.confirmButton.dataset.ajaxUrl));\r\n\r\n return this;\r\n }\r\n\r\n protected fetchOrderResponse(url: string): void {\r\n fetch(url, {\r\n method: 'POST',\r\n credentials: 'include',\r\n })\r\n .then((response) => {\r\n if (response.ok) {\r\n return response.text();\r\n } else {\r\n throw new Error('Something went wrong with the response');\r\n }\r\n })\r\n .then((text: any) => this.handleOrderResponse(text))\r\n .catch((error) => {\r\n console.error(error);\r\n });\r\n };\r\n\r\n protected handleBackToPreviousStep(url: string) {\r\n window.NiveaX.layer.openAsync(url);\r\n }\r\n\r\n protected handleOrderResponse(response: any) {\r\n window.NiveaX.layer.openAsync(response);\r\n }\r\n\r\n protected getDefaultOptions(): ShopOrderOverviewOptions {\r\n return {\r\n backToPreviousStep: 'nx-back-to-checkout',\r\n confirmOrder: 'nx-confirm-order',\r\n };\r\n }\r\n\r\n}\r\n\r\n// Hot Module Replacement\r\nif (module.hot) {\r\n let nodesCache: HMRNodes[] = Array.from(document.querySelectorAll(moduleSelector)).map((element: Node) => ({ nodeToReplace: element, nodeOrigin: element.cloneNode(true) }));\r\n\r\n ShopOrderOverview.setup(moduleSelector);\r\n\r\n module.hot.accept(() => {\r\n ShopOrderOverview.setup(moduleSelector);\r\n });\r\n module.hot.dispose(() => {\r\n nodesCache.forEach(({ nodeToReplace, nodeOrigin }) => { nodeToReplace = nodeToReplace.parentElement.replaceChild(nodeOrigin.cloneNode(true), nodeToReplace) });\r\n });\r\n} else {\r\n ShopOrderOverview.setup(moduleSelector);\r\n}","import ShopOrderOverview from './ShopOrderOverview';\r\nexport default ShopOrderOverview;"],"names":["moduleSelector","ShopOrderOverview","setup","selector","Array","from","document","querySelectorAll","filter","node","dataset","moduleInitialized","forEach","element","constructor","options","this","Object","assign","getDefaultOptions","backButton","querySelector","backToPreviousStep","confirmButton","confirmOrder","init","addEventListener","handleBackToPreviousStep","ajaxUrl","fetchOrderResponse","url","fetch","method","credentials","then","response","ok","text","Error","handleOrderResponse","catch","error","console","window","NiveaX","layer","openAsync"],"sourceRoot":""}