{"version":3,"sources":["webpack:///./Scripts/Components/ProductPdfButton.js"],"names":["ProductPdfButton","variantID","loading","setLoading","useState","errorMsg","setErrorMsg","React","className","onClick","async","get","then","resp","blob","myBlob","window","open","URL","createObjectURL","error","response","text","x","translate"],"mappings":"mJAIA,MAqCA,EArCyBA,EAAGC,gBACxB,MAAOC,EAASC,IAAcC,eAAS,IAChCC,EAAUC,IAAeF,gBAmBhC,OACAG,2BAAA,KACIA,gBAAA,KAAGC,UAAU,yCAAyCC,QAASA,IAnBnDC,WAEZP,GAAW,GACX,UACUQ,QAAI,wBAA0BV,GAAWW,MAAMC,GAASA,EAAKC,SAAQF,MAAMG,IAC7EC,OAAOC,KAAKC,IAAIC,gBAAgBJ,GAAQ,IAE5CZ,GAAW,GACXG,EAAY,KAEhB,CACA,MAAOc,GACHA,EAAMC,SAASC,OAAOV,MAAKW,GAAKjB,EAAYiB,KAC5CpB,GAAW,EACf,GAKqEM,IACpEP,EAAUK,gBAAA,OAAKC,UAAU,YAAWD,gBAAA,YAAWA,gBAAA,YAAWA,gBAAA,YAAWA,gBAAA,aAEjEA,2BAAA,KACGA,gBAAA,KAAGC,UAAU,iDACbD,gBAAA,QAAMC,UAAU,gDAA+C,KAAEgB,OAAU,8BAA8B,OAI5GnB,GAAYE,gBAAA,KAAGC,UAAU,4BAA4BH,EAAS,KACpE,C","file":"899.2d298c97a6eecd8fbe56.js","sourcesContent":["import React, { useState } from 'react';\nimport { translate } from '../Services/translation'\nimport { get } from '../Services/http'\n\nconst ProductPdfButton = ({ variantID }) => {\n const [loading, setLoading] = useState(false)\n const [errorMsg, setErrorMsg] = useState()\n\n const onClick = async () => {\n \n setLoading(true)\n try {\n await get(\"/api/pdfGenerator?id=\" + variantID).then((resp) => resp.blob()).then((myBlob) => {\n window.open(URL.createObjectURL(myBlob))\n })\n setLoading(false)\n setErrorMsg(null)\n \n }\n catch (error) {\n error.response.text().then(x => setErrorMsg(x))\n setLoading(false)\n }\n }\n\n return (\n <>\n onClick()} >\n {loading ?
{errorMsg}
}\n >\n )\n\n}\nexport default ProductPdfButton;"],"sourceRoot":""}