{"version":3,"file":"781.fce75467f9c0c1ba.js","mappings":"6JAKA,MA6BA,EA7B0BA,EAAEC,gBACxB,MAAOC,EAAUC,IAAeC,EAAAA,EAAAA,YAiBhC,OACIC,EAAAA,cAAAA,EAAAA,SAAA,KACIA,EAAAA,cAAA,KAAGC,QAASA,IAjBJC,YACZC,EAAAA,EAAAA,KACA,UACUC,EAAAA,EAAAA,IAAI,wBAA0BR,GAAWS,MAAMC,GAASA,EAAKC,SAAQF,MAAMG,IAC7EC,OAAOC,KAAKC,IAAIC,gBAAgBJ,GAAQ,KAE5CK,EAAAA,EAAAA,KACAf,EAAY,KAEhB,CAAE,MAAOgB,GACLA,EAAMC,SAASC,OAAOX,MAAKY,GAAKnB,EAAYmB,MAC5CJ,EAAAA,EAAAA,IACJ,GAKsBZ,GACfiB,UAAU,yDACRC,EAAAA,EAAAA,GAAU,mCAEdtB,GAAYG,EAAAA,cAAA,KAAGkB,UAAU,+CAA+CrB,EAAS,KACnF,C,0CC9BX,MAAMuB,EAAkB,qBACxB,IAAIC,EAAc,EAGX,MAAMlB,EAAkBA,KAC3BkB,IACA,IAAIC,EAAUC,SAASC,eAAeJ,GAElCE,GACAA,EAAQG,UAAUC,IAAI,SAC1B,EAGSb,EAAmBc,IAC5BN,IACA,IAAIC,EAAUC,SAASC,eAAeJ,IAElCC,EAAc,GAAKM,KACnBN,EAAc,GAGdC,GAA2B,IAAhBD,GACXO,YAAW,KACPN,EAAQG,UAAUI,OAAO,SAAS,GACnC,IACP,C","sources":["webpack:///./Scripts/Components/GeneratePdfButton.js","webpack:///./Scripts/loadSpinner.js"],"sourcesContent":["import React, {useState} from 'react';\r\nimport {translate} from '../Services/translation'\r\nimport {get} from '../Services/http'\r\nimport {showLoadSpinner, hideLoadSpinner} from '../loadSpinner';\r\n\r\nconst GeneratePdfButton = ({variantId}) => {\r\n const [errorMsg, setErrorMsg] = useState()\r\n\r\n const onClick = async () => {\r\n showLoadSpinner();\r\n try {\r\n await get(\"/api/pdfGenerator?id=\" + variantId).then((resp) => resp.blob()).then((myBlob) => {\r\n window.open(URL.createObjectURL(myBlob))\r\n })\r\n hideLoadSpinner();\r\n setErrorMsg(null)\r\n\r\n } catch (error) {\r\n error.response.text().then(x => setErrorMsg(x))\r\n hideLoadSpinner();\r\n }\r\n }\r\n\r\n return (\r\n <>\r\n onClick()}\r\n className=\"product-detail__article-files-area-item-header-title\">\r\n {translate('product.pdf.downloadbuttontext')}\r\n \r\n {errorMsg &&
{errorMsg}
}\r\n >\r\n\r\n )\r\n}\r\nexport default GeneratePdfButton;","const genericLoaderId = \"genericLoadSpinner\";\r\nlet loaderCount = 0;\r\n\r\n\r\nexport const showLoadSpinner = () => {\r\n loaderCount++;\r\n var element = document.getElementById(genericLoaderId);\r\n\r\n if (element) {\r\n element.classList.add(\"active\");\r\n }\r\n};\r\n\r\nexport const hideLoadSpinner = (resetCount) => {\r\n loaderCount--;\r\n var element = document.getElementById(genericLoaderId);\r\n\r\n if (loaderCount < 0 || resetCount) {\r\n loaderCount = 0;\r\n }\r\n \r\n if (element && loaderCount === 0) {\r\n setTimeout(() => {\r\n element.classList.remove(\"active\");\r\n }, 100);\r\n }\r\n};\r\n"],"names":["GeneratePdfButton","variantId","errorMsg","setErrorMsg","useState","React","onClick","async","showLoadSpinner","get","then","resp","blob","myBlob","window","open","URL","createObjectURL","hideLoadSpinner","error","response","text","x","className","translate","genericLoaderId","loaderCount","element","document","getElementById","classList","add","resetCount","setTimeout","remove"],"sourceRoot":""}