{"version":3,"sources":["webpack:///./Scripts/Actions/Conversion.action.js","webpack:///./Scripts/Services/ByRydens/Cart.service.js","webpack:///./Scripts/Actions/Magasin/Gtm.action.js","webpack:///./Scripts/Components/Magasin/BuyButton.js","webpack:///./Scripts/Components/withReactiveStyleBuyButton.js"],"names":["postConversionEvent","async","event","eventName","cDetails","post","event_id","ecommerce","transaction_id","fb_event_id","event_name","event_source_url","window","location","href","custom_data","value","currency","content_name","document","title","content_ids","items","map","x","item_id","content_type","user_data","email","em","firstName","fn","lastName","ln","phoneNumber","ph","then","response","json","d","console","log","catch","error","message","cookieAccepted","val","cname","name","ca","decodeURIComponent","cookie","split","i","length","c","charAt","substring","indexOf","getCookieValue","valObj","JSON","parse","targeting","add","articleNumber","quantity","bundleProductId","isBundle","bundleStringId","variantId","deliveryDays","deliveryText","lightsourceId","lampplugId","lightplugquantity","lightsourcequantity","isNaN","parseFloat","addToDataLayer","data","dataLayer","push","BuyButton","label","quantityFieldId","articleName","articleBrand","articleImageUrl","minimumQuantity","isMinimumQuantity","maximumQuantity","isMaximumQuantity","quantityStepping","isQuantityStepping","articleStatus","isPreorder","cssClass","onClick","bundles","priceTag","Fragment","className","e","preventDefault","rel","errorQuantity","id","errorName","getElementById","innerText","props","dispatch","useDispatch","Button","withReactiveStyleBuyButton","buybtn","getElementsByTagName","getAttribute","cart","toLowerCase","trim","parseInt","translate","addQty","undefined","bundleId","item","variant","addToCartService","addToCartEvent","receive","ex","catchError","loadError","StateStyles","WrappedComponent","stylePrefix","stateClass","setStateClass","useState","startTime","useRef","useEffect","changeState","complete","autoReset","setTimeout","current","resetTimeout","onButtonClick","params","Date","now","loadingDuration","minimumLoadingTime","onComplete"],"mappings":"2HAEO,MAAMA,EAAsBC,MAC/BC,EACAC,EACAC,EAAW,cAELC,QAAM,kBAAkB,CAC1BC,SAAUJ,EAAMK,UAAUC,eACpBN,EAAMK,UAAUC,eAChBN,EAAMO,YACZC,WAAYP,EACZQ,iBAAkBC,OAAOC,SAASC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Oa,GAEL,OADApB,GAASqB,OAAWD,GAAKzF,IAAU2F,QAAU3F,OACtC,KAG+C,cAE9D,OAAO,gBAACuE,EAAWH,K,0QClNvB,MAAMwB,EACO,YADPA,EAEO,YAFPA,EAGK,UAgBI,SAASpB,EACpBqB,EACAtC,EACAuC,GAEA,OAAQ1B,IACJ,MAAO2B,EAAYC,IAAiBC,cAAS,IACvCC,GAAYC,YAAO,IAEzBC,gBAAU,IACC,KACHJ,EAAc,MAEnB,IAYH,MAAMK,EAAeC,IACjBN,EACK,GAAEF,IACCQ,EAAWV,EAAsBA,MAMrB,IAApBxB,EAAMmC,WACFC,YAAW,KAnBfR,EAAc,IACdE,EAAUO,QAAU,IAoBbrC,EAAMsC,cAAgB,MAiBjCpJ,eAAeqJ,EAAcC,GAjCzBZ,EAAe,GAAEF,IAAcF,KAC/BM,EAAUO,QAAUI,KAAKC,OAkB7B,SAAoBR,GAChB,MAAMS,EAAkBF,KAAKC,MAAQZ,EAAUO,QACzCO,EAAqB5C,EAAM4C,oBAAsB,IAGnDD,GAAmBC,EACnBX,EAAYC,GAEZE,YAAW,KACPH,EAAYC,KACbU,EAAqBD,GAO5BE,OADmB1D,EAAQqD,IAI/B,OACI,wBAAMjD,UAAWoC,GACb,gBAACF,EAAD,GACItC,QAAUqD,GAAWD,EAAcC,IAC/BxC","file":"2360.08afcb993cf8ecc96490.js","sourcesContent":["import { post } from '../Services/http';\r\n\r\nexport const postConversionEvent = async (\r\n event,\r\n eventName,\r\n cDetails = null\r\n) => {\r\n await post(`/api/conversion`, {\r\n event_id: event.ecommerce.transaction_id\r\n ? event.ecommerce.transaction_id\r\n : event.fb_event_id,\r\n event_name: eventName,\r\n event_source_url: window.location.href,\r\n custom_data: {\r\n ...(event.ecommerce.value && { value: event.ecommerce.value }),\r\n currency: event.ecommerce.currency,\r\n content_name: document.title,\r\n content_ids: event.ecommerce.items.map((x) => x.item_id),\r\n content_type: 'product_group',\r\n },\r\n\r\n user_data: {\r\n ...(cDetails && cDetails.email && { em: cDetails.email }),\r\n ...(cDetails && cDetails.firstName && { fn: cDetails.firstName }),\r\n ...(cDetails && cDetails.lastName && { ln: cDetails.lastName }),\r\n ...(cDetails &&\r\n cDetails.phoneNumber && { ph: cDetails.phoneNumber }),\r\n },\r\n })\r\n .then((response) => response.json())\r\n .then((d) => {\r\n console.log(d);\r\n })\r\n .catch((error) => {\r\n if (error.message) {\r\n console.log(error.message);\r\n }\r\n });\r\n};\r\n\r\nconst getCookieValue = (cname) => {\r\n let name = cname + '=';\r\n let decodedCookie = decodeURIComponent(document.cookie);\r\n let ca = decodedCookie.split(';');\r\n for (let i = 0; i < ca.length; i++) {\r\n let c = ca[i];\r\n while (c.charAt(0) == ' ') {\r\n c = c.substring(1);\r\n }\r\n if (c.indexOf(name) == 0) {\r\n return c.substring(name.length, c.length);\r\n }\r\n }\r\n return '';\r\n};\r\n\r\nexport const cookieAccepted = () => {\r\n const val = getCookieValue('cookie_consent_level');\r\n if (val) {\r\n const valObj = JSON.parse(val);\r\n if (typeof valObj.targeting != 'undefined') {\r\n return valObj.targeting;\r\n }\r\n }\r\n return false;\r\n};\r\n","import { post } from '../http';\r\n\r\n export const add = async ({ articleNumber, quantity = 1, bundleProductId = '', isBundle = false, bundleStringId = '', variantId = '', deliveryDays='',deliveryText='', lightsourceId='',lampplugId='',lightplugquantity='', lightsourcequantity='' }) => {\r\n\r\n if (!quantity || isNaN(quantity) || parseFloat(quantity) <= 0) {\r\n throw 'Invalid quantity';\r\n }\r\n\r\n const response = await post('/api/cart/add', {\r\n articleNumber,\r\n quantity: parseFloat(quantity),\r\n bundleProductId,\r\n bundleStringId,\r\n isBundle,\r\n deliveryDays,\r\n deliveryText,\r\n variantId,\r\n lightsourceId,\r\n lampplugId,\r\n lightplugquantity,\r\n lightsourcequantity\r\n });\r\n return response.json();\r\n};\r\n\r\nexport const reorder = async (orderId) => {\r\n const response = await post('/api/cart/reorder', { orderId });\r\n return response.json();\r\n};\r\n","import { post } from '../../Services/http';\r\nconst rootRoute = '/api/gtm';\r\nimport { postConversionEvent, cookieAccepted } from '../Conversion.action';\r\n\r\nexport const addToCartEvent = async (articleNumber, quantity = 1) => {\r\n try {\r\n const response = await post(`${rootRoute}/add-to-cart`, {\r\n articleNumber,\r\n quantity,\r\n });\r\n const event = await response.json();\r\n addToDataLayer(event);\r\n if (cookieAccepted()) await postConversionEvent(event, 'AddToCart');\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n};\r\n\r\nexport const removeFromCartEvent = async (articleNumber) => {\r\n try {\r\n const response = await post(`${rootRoute}/remove-from-cart`, {\r\n articleNumber,\r\n });\r\n const event = await response.json();\r\n addToDataLayer(event);\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n};\r\n\r\nexport const beginCheckoutEvent = async () => {\r\n try {\r\n const response = await post(`${rootRoute}/begin-checkout`);\r\n const event = await response.json();\r\n addToDataLayer(event);\r\n if (cookieAccepted())\r\n await postConversionEvent(event, 'InitiateCheckout');\r\n } catch (error) {\r\n console.error(error);\r\n }\r\n};\r\n\r\nconst addToDataLayer = (data) => {\r\n dataLayer = window.dataLayer || [];\r\n dataLayer.push({ ecommerce: null });\r\n dataLayer.push(data);\r\n};\r\n","import React, { Fragment } from 'react';\r\nimport { add as addToCartService } from '../../Services/ByRydens/Cart.service';\r\nimport withReactiveStyleBuyButton from '../withReactiveStyleBuyButton';\r\nimport { receive, loadError } from '../../Actions/Cart.action';\r\nimport { catchError } from '../../Actions/Error.action';\r\nimport { useDispatch } from 'react-redux';\r\nimport { translate } from '../../Services/translation';\r\nimport { addToCartEvent } from '../../Actions/Magasin/Gtm.action';\r\nconst BuyButton = ({\r\n label,\r\n articleNumber,\r\n quantityFieldId,\r\n articleName,\r\n articleBrand,\r\n articleImageUrl,\r\n minimumQuantity,\r\n isMinimumQuantity,\r\n maximumQuantity,\r\n isMaximumQuantity,\r\n quantityStepping,\r\n isQuantityStepping,\r\n articleStatus,\r\n isPreorder,\r\n href,\r\n cssClass,\r\n onClick,\r\n bundles,\r\n priceTag,\r\n deliveryDays,\r\n deliveryText,\r\n variantId,\r\n}) => {\r\n return (\r\n \r\n {articleNumber ? (\r\n {\r\n e.preventDefault();\r\n onClick({\r\n articleNumber,\r\n quantityFieldId,\r\n articleName,\r\n articleBrand,\r\n articleImageUrl,\r\n minimumQuantity,\r\n isMinimumQuantity,\r\n maximumQuantity,\r\n isMaximumQuantity,\r\n quantityStepping,\r\n isQuantityStepping,\r\n articleStatus,\r\n isPreorder,\r\n bundles,\r\n priceTag,\r\n deliveryDays,\r\n deliveryText,\r\n variantId,\r\n });\r\n }}\r\n href={href || '#'}\r\n rel=\"nofollow\"\r\n >\r\n {label}\r\n \r\n ) : (\r\n \r\n {label}\r\n \r\n )}\r\n \r\n );\r\n};\r\nconst errorQuantity = (id, errorName) => {\r\n document.getElementById(id).innerText = errorName;\r\n\r\n return;\r\n};\r\nconst StyledButton = (props) => {\r\n const dispatch = useDispatch();\r\n const onClick = async ({\r\n articleNumber,\r\n quantityFieldId,\r\n minimumQuantity,\r\n isMinimumQuantity,\r\n maximumQuantity,\r\n isMaximumQuantity,\r\n quantityStepping,\r\n isQuantityStepping,\r\n bundles,\r\n deliveryDays,\r\n deliveryText,\r\n variantId,\r\n }) => {\r\n try {\r\n var buybtn = document.getElementsByTagName('buy-button')[0];\r\n\r\n if (buybtn) {\r\n var lightsourceId = buybtn.getAttribute('data-lightsourceid');\r\n var lampplugId = buybtn.getAttribute('data-lightplugid');\r\n var lightplugquantity = buybtn.getAttribute(\r\n 'data-lightplugquantity'\r\n );\r\n var lightsourcequantity = buybtn.getAttribute(\r\n 'data-lightsourcequantity'\r\n );\r\n }\r\n let quantity;\r\n\r\n if (quantityFieldId) {\r\n quantity = quantityFieldId\r\n ? document.getElementById(quantityFieldId).value\r\n : 1;\r\n var id = 'span-' + quantityFieldId;\r\n\r\n if (\r\n isMinimumQuantity &&\r\n isMinimumQuantity.toLowerCase().trim() === 'true' &&\r\n minimumQuantity &&\r\n parseInt(quantity) < parseInt(minimumQuantity)\r\n ) {\r\n errorQuantity(\r\n id,\r\n translate('product.minimumquantity') +\r\n ' ' +\r\n minimumQuantity\r\n );\r\n return false;\r\n }\r\n\r\n if (\r\n isMaximumQuantity &&\r\n isMaximumQuantity.toLowerCase().trim() == 'true' &&\r\n maximumQuantity &&\r\n parseInt(quantity) > parseInt(maximumQuantity)\r\n ) {\r\n errorQuantity(\r\n id,\r\n translate('product.maximumquantity') +\r\n ' ' +\r\n maximumQuantity\r\n );\r\n return false;\r\n }\r\n\r\n if (\r\n isQuantityStepping &&\r\n isQuantityStepping.toLowerCase().trim() === 'true' &&\r\n quantityStepping &&\r\n parseInt(quantity) % parseInt(quantityStepping) !== 0\r\n ) {\r\n var addQty =\r\n parseInt(quantity) % parseInt(quantityStepping);\r\n errorQuantity(\r\n id,\r\n translate('product.multiplequantity') +\r\n ' ' +\r\n quantityStepping +\r\n ' add ' +\r\n addQty\r\n );\r\n return false;\r\n }\r\n } else {\r\n quantity = 1;\r\n }\r\n\r\n let cart;\r\n if (\r\n bundles != null &&\r\n bundles !== undefined &&\r\n bundles.length > 0\r\n ) {\r\n var bundleStringId = bundles[0].bundleId;\r\n for (const item of bundles) {\r\n bundleStringId += ';' + item.variant;\r\n }\r\n\r\n cart = await addToCartService({\r\n isBundle: true,\r\n bundleStringId: bundleStringId,\r\n deliveryDays,\r\n deliveryText,\r\n lightsourceId,\r\n lampplugId,\r\n lightplugquantity,\r\n lightsourcequantity,\r\n });\r\n } else {\r\n cart = await addToCartService({\r\n articleNumber,\r\n quantity,\r\n variantId,\r\n deliveryDays,\r\n deliveryText,\r\n lightsourceId,\r\n lampplugId,\r\n lightplugquantity,\r\n lightsourcequantity,\r\n });\r\n }\r\n await addToCartEvent(articleNumber, quantity);\r\n dispatch(receive(cart));\r\n\r\n return true;\r\n } catch (ex) {\r\n dispatch(catchError(ex, (error) => loadError(error)));\r\n return false;\r\n }\r\n };\r\n const Button = withReactiveStyleBuyButton(BuyButton, onClick, 'buy-button');\r\n\r\n return