crmbonus-component-wake 2.1.31-ngrok → 2.1.32-ngrok
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/crm-bonus-2.cjs.entry.js +6 -257
- package/dist/cjs/crm-bonus-2.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-bonus.cjs.entry.js +257 -6
- package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -1
- package/dist/cjs/crmbonus-component-wake.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/crm-bonus/crm-bonus.js +1 -1
- package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
- package/dist/collection/components/crm-bonus/crmbonus.js +2 -2
- package/dist/collection/components/crm-bonus/crmbonus.js.map +1 -1
- package/dist/components/crm-bonus-2.js +10 -332
- package/dist/components/crm-bonus-2.js.map +1 -1
- package/dist/components/crm-bonus-note.js +1 -1
- package/dist/components/crm-bonus.js +332 -10
- package/dist/components/crm-bonus.js.map +1 -1
- package/dist/components/crm-giftback-form.js +1 -1
- package/dist/components/giftback-info.js +1 -1
- package/dist/components/{p-fedabc25.js → p-028f43a1.js} +2 -2
- package/dist/components/{p-fedabc25.js.map → p-028f43a1.js.map} +1 -1
- package/dist/components/{p-78fbe33d.js → p-0bb6b0e5.js} +3 -3
- package/dist/components/{p-78fbe33d.js.map → p-0bb6b0e5.js.map} +1 -1
- package/dist/components/{p-0a5e4aca.js → p-c90ea2e9.js} +57 -57
- package/dist/components/p-c90ea2e9.js.map +1 -0
- package/dist/components/pedido-finalizado.js +1 -1
- package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
- package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js.map +1 -1
- package/dist/crmbonus-component-wake/{p-b928333a.entry.js → p-4ed412c2.entry.js} +2 -2
- package/dist/crmbonus-component-wake/p-4ed412c2.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/{p-c54d706c.entry.js → p-a0d73d77.entry.js} +2 -2
- package/dist/crmbonus-component-wake/p-a0d73d77.entry.js.map +1 -0
- package/dist/esm/crm-bonus-2.entry.js +7 -258
- package/dist/esm/crm-bonus-2.entry.js.map +1 -1
- package/dist/esm/crm-bonus.entry.js +258 -7
- package/dist/esm/crm-bonus.entry.js.map +1 -1
- package/dist/esm/crmbonus-component-wake.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components.d.ts +4 -4
- package/package.json +1 -1
- package/dist/components/p-0a5e4aca.js.map +0 -1
- package/dist/crmbonus-component-wake/p-b928333a.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-c54d706c.entry.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["patchBrowser","importMeta","url","opts","resourcesUrl","URL","href","promiseResolve","then","async","options","globalScripts","bootstrapLazy","cart","canhidden","showModal","cartWake","customer","loading","message","phone","canCancel","amountCancel","sent","session","loading_reprocess","styles","reservedInfo","resetBonus","setloading","reprocess","config","bonus","showEdit","infoBonus","info","isOpen","modalTitle","downtime","reload","dates","seconds","minutes","size","color","txtBtn","handleClick","dataCriacao","minutos","segundos","tempoRestante","value","handlerSubmit","validate","cancel","resend","pin","isVerified","canResend","cartId","reserve","storeName","usedValue","selectedOption","sliderPosition","sliderValuePosition","loadingTime","text","identity","initialValue","disabled","getPhone","products","loadProducts","loadAll","customStyles","pinInfo","step","sucess","error","hasApplyBonus","loadingAllComponent","setStep","processBonus"],"sources":["node_modules/@stencil/core/internal/client/patch-browser.js","@lazy-browser-entrypoint?app-data=conditional"],"sourcesContent":["/*\n Stencil Client Patch Browser v4.22.2 | MIT Licensed | https://stenciljs.com\n */\n\n// src/client/client-patch-browser.ts\nimport { BUILD, NAMESPACE } from \"@stencil/core/internal/app-data\";\nimport { consoleDevInfo, doc, H, promiseResolve } from \"@stencil/core\";\nvar patchBrowser = () => {\n if (BUILD.isDev && !BUILD.isTesting) {\n consoleDevInfo(\"Running in development mode.\");\n }\n if (BUILD.cloneNodeFix) {\n patchCloneNodeFix(H.prototype);\n }\n const scriptElm = BUILD.scriptDataOpts ? Array.from(doc.querySelectorAll(\"script\")).find(\n (s) => new RegExp(`/${NAMESPACE}(\\\\.esm)?\\\\.js($|\\\\?|#)`).test(s.src) || s.getAttribute(\"data-stencil-namespace\") === NAMESPACE\n ) : null;\n const importMeta = import.meta.url;\n const opts = BUILD.scriptDataOpts ? (scriptElm || {})[\"data-opts\"] || {} : {};\n if (importMeta !== \"\") {\n opts.resourcesUrl = new URL(\".\", importMeta).href;\n }\n return promiseResolve(opts);\n};\nvar patchCloneNodeFix = (HTMLElementPrototype) => {\n const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;\n HTMLElementPrototype.cloneNode = function(deep) {\n if (this.nodeName === \"TEMPLATE\") {\n return nativeCloneNodeFn.call(this, deep);\n }\n const clonedNode = nativeCloneNodeFn.call(this, false);\n const srcChildNodes = this.childNodes;\n if (deep) {\n for (let i = 0; i < srcChildNodes.length; i++) {\n if (srcChildNodes[i].nodeType !== 2) {\n clonedNode.appendChild(srcChildNodes[i].cloneNode(true));\n }\n }\n }\n return clonedNode;\n };\n};\nexport {\n patchBrowser\n};\n","export { setNonce } from '@stencil/core';\nimport { bootstrapLazy } from '@stencil/core';\nimport { patchBrowser } from '@stencil/core/internal/client/patch-browser';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\npatchBrowser().then(async (options) => {\n await globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n});\n"],"mappings":"0HAOA,IAAIA,EAAe,KAUjB,MAAMC,cAAyBC,IAC/B,MAAMC,EAAqE,GAC3E,GAAIF,IAAe,GAAI,CACrBE,EAAKC,aAAe,IAAIC,IAAI,IAAKJ,GAAYK,IACjD,CACE,OAAOC,EAAeJ,EAAK,EClB7BH,IAAeQ,MAAKC,MAAOC,UACnBC,IACN,OAAOC,EAAc,
|
1
|
+
{"version":3,"names":["patchBrowser","importMeta","url","opts","resourcesUrl","URL","href","promiseResolve","then","async","options","globalScripts","bootstrapLazy","cart","canhidden","showModal","cartWake","customer","loading","message","phone","canCancel","amountCancel","sent","session","loading_reprocess","styles","reservedInfo","resetBonus","setloading","reprocess","config","bonus","showEdit","infoBonus","info","isOpen","modalTitle","downtime","reload","dates","seconds","minutes","size","color","txtBtn","handleClick","dataCriacao","minutos","segundos","tempoRestante","value","handlerSubmit","validate","cancel","resend","pin","isVerified","canResend","cartId","reserve","storeName","usedValue","selectedOption","sliderPosition","sliderValuePosition","loadingTime","text","identity","initialValue","disabled","getPhone","products","loadProducts","loadAll","customStyles","pinInfo","step","sucess","error","hasApplyBonus","loadingAllComponent","setStep","processBonus"],"sources":["node_modules/@stencil/core/internal/client/patch-browser.js","@lazy-browser-entrypoint?app-data=conditional"],"sourcesContent":["/*\n Stencil Client Patch Browser v4.22.2 | MIT Licensed | https://stenciljs.com\n */\n\n// src/client/client-patch-browser.ts\nimport { BUILD, NAMESPACE } from \"@stencil/core/internal/app-data\";\nimport { consoleDevInfo, doc, H, promiseResolve } from \"@stencil/core\";\nvar patchBrowser = () => {\n if (BUILD.isDev && !BUILD.isTesting) {\n consoleDevInfo(\"Running in development mode.\");\n }\n if (BUILD.cloneNodeFix) {\n patchCloneNodeFix(H.prototype);\n }\n const scriptElm = BUILD.scriptDataOpts ? Array.from(doc.querySelectorAll(\"script\")).find(\n (s) => new RegExp(`/${NAMESPACE}(\\\\.esm)?\\\\.js($|\\\\?|#)`).test(s.src) || s.getAttribute(\"data-stencil-namespace\") === NAMESPACE\n ) : null;\n const importMeta = import.meta.url;\n const opts = BUILD.scriptDataOpts ? (scriptElm || {})[\"data-opts\"] || {} : {};\n if (importMeta !== \"\") {\n opts.resourcesUrl = new URL(\".\", importMeta).href;\n }\n return promiseResolve(opts);\n};\nvar patchCloneNodeFix = (HTMLElementPrototype) => {\n const nativeCloneNodeFn = HTMLElementPrototype.cloneNode;\n HTMLElementPrototype.cloneNode = function(deep) {\n if (this.nodeName === \"TEMPLATE\") {\n return nativeCloneNodeFn.call(this, deep);\n }\n const clonedNode = nativeCloneNodeFn.call(this, false);\n const srcChildNodes = this.childNodes;\n if (deep) {\n for (let i = 0; i < srcChildNodes.length; i++) {\n if (srcChildNodes[i].nodeType !== 2) {\n clonedNode.appendChild(srcChildNodes[i].cloneNode(true));\n }\n }\n }\n return clonedNode;\n };\n};\nexport {\n patchBrowser\n};\n","export { setNonce } from '@stencil/core';\nimport { bootstrapLazy } from '@stencil/core';\nimport { patchBrowser } from '@stencil/core/internal/client/patch-browser';\nimport { globalScripts } from '@stencil/core/internal/app-globals';\npatchBrowser().then(async (options) => {\n await globalScripts();\n return bootstrapLazy([/*!__STENCIL_LAZY_DATA__*/], options);\n});\n"],"mappings":"0HAOA,IAAIA,EAAe,KAUjB,MAAMC,cAAyBC,IAC/B,MAAMC,EAAqE,GAC3E,GAAIF,IAAe,GAAI,CACrBE,EAAKC,aAAe,IAAIC,IAAI,IAAKJ,GAAYK,IACjD,CACE,OAAOC,EAAeJ,EAAK,EClB7BH,IAAeQ,MAAKC,MAAOC,UACnBC,IACN,OAAOC,EAAc,+BAA8B,CAAAC,KAAS,IAAAC,UAAA,IAAAC,UAAA,KAAAC,SAAA,KAAAC,SAAA,KAAAC,QAAA,KAAAC,QAAA,KAAAC,MAAA,KAAAC,UAAA,KAAAC,aAAA,KAAAC,KAAA,KAAAC,QAAA,KAAAC,kBAAA,KAAAC,OAAA,KAAAC,aAAA,KAAAC,WAAA,KAAAC,WAAA,KAAAC,UAAA,0CAAAZ,QAAA,KAAAF,SAAA,6CAAAH,KAAA,IAAAG,SAAA,KAAAd,IAAA,KAAA6B,OAAA,KAAAC,MAAA,KAAAC,SAAA,KAAAP,OAAA,KAAAQ,UAAA,KAAAhB,QAAA,KAAAiB,KAAA,wCAAAC,OAAA,gBAAAC,WAAA,8DAAAC,SAAA,KAAAC,OAAA,IAAAC,MAAA,KAAAC,QAAA,KAAAC,QAAA,sFAAA7B,KAAA,+CAAAK,QAAA,6CAAAyB,KAAA,IAAAC,MAAA,wCAAAC,OAAA,cAAA3B,QAAA,IAAA4B,YAAA,6BAAAR,SAAA,KAAAS,YAAA,mBAAAC,QAAA,IAAAC,SAAA,IAAAC,cAAA,yCAAAC,MAAA,IAAAjC,QAAA,IAAAkC,cAAA,KAAArB,OAAA,sBAAAsB,SAAA,KAAAC,OAAA,KAAAC,OAAA,KAAAhC,KAAA,KAAAL,QAAA,IAAAE,MAAA,IAAAW,OAAA,KAAAyB,IAAA,KAAAC,WAAA,KAAAC,UAAA,2BAAAC,OAAA,cAAAzC,QAAA,IAAAc,MAAA,KAAA4B,QAAA,KAAAN,OAAA,KAAAvB,OAAA,KAAAG,UAAA,KAAA2B,UAAA,iBAAAC,UAAA,KAAAC,eAAA,KAAAC,eAAA,KAAAC,oBAAA,KAAAC,YAAA,YAAAlC,MAAA,qCAAAmC,KAAA,IAAAC,SAAA,6BAAAC,aAAA,oBAAAC,SAAA,IAAAlD,MAAA,KAAAD,QAAA,KAAAoD,SAAA,gDAAAV,UAAA,gBAAAF,OAAA,cAAAa,SAAA,KAAAvD,SAAA,KAAAwD,aAAA,KAAAC,QAAA,KAAAC,aAAA,oBAAAhD,aAAA,KAAAwB,MAAA,KAAAjC,QAAA,KAAAC,QAAA,KAAAC,MAAA,KAAAwD,QAAA,KAAAC,KAAA,KAAA7C,MAAA,KAAA8C,OAAA,KAAAC,MAAA,KAAAhD,OAAA,KAAAiD,cAAA,KAAAC,oBAAA,KAAAC,QAAA,KAAAC,aAAA,UAAAzE,EAAA","ignoreList":[]}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{r as e,h as t}from"./p-8c362346.js";import{g as n}from"./p-c74567c6.js";const o=".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";const i=o;const r=class{constructor(t){e(this,t);this.loading=false;this.cartWake=undefined}async componentDidLoad(){await this.loadCheckout()}async loadCheckout(){this.cartWake=await n()}render(){console.log("this.cartWake",this.cartWake);return t("div",{key:"
|
2
|
-
//# sourceMappingURL=p-
|
1
|
+
import{r as e,h as t}from"./p-8c362346.js";import{g as n}from"./p-c74567c6.js";const o=".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";const i=o;const r=class{constructor(t){e(this,t);this.loading=false;this.cartWake=undefined}async componentDidLoad(){await this.loadCheckout()}async loadCheckout(){this.cartWake=await n()}render(){console.log("this.cartWake",this.cartWake);return t("div",{key:"cc9dc7fa4262bf6cb5df716164ee9413f9a3bc6f"},t("loading-container",{key:"4d5ff4d93a3769e609b630cc0760043458990e64",loading:this.loading},t("h3",{key:"f7f60857813f42b2735cc3ee6e73523fb4018f2b"},"CARREGANDO...")),this.cartWake&&t("div",{key:"bb86c641b03cbf94e50560a3d0d62d022cb80499"},this.cartWake.id))}static get assetsDirs(){return["assets"]}};r.style=i;export{r as crm_bonus_2};
|
2
|
+
//# sourceMappingURL=p-4ed412c2.entry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["crmBonusCss","CrmBonus2Style0","CrmBonus","componentDidLoad","this","loadCheckout","cartWake","getCart","render","console","log","h","key","loading","id"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus-2&encapsulation=shadow","src/components/crm-bonus/crmbonus.tsx"],"sourcesContent":["\r\n.container-button {\r\n /* max-width: 100%; */\r\n cursor: pointer;\r\n padding: 5px 5px 5px 14px;\r\n /* display: flex; */\r\n}\r\n\r\n/* padding: 0 15px 15px;\r\nborder: 1px solid #ddd;\r\nmargin-bottom: 20px; */\r\n\r\n.section-crm {\r\n border: 1px solid #dbd4d4;\r\n /* min-height: 50px; */\r\n text-align: -webkit-center;\r\n margin-bottom: 20px;\r\n}\r\n\r\n.section-cart-crm {\r\n margin-top: 10px;\r\n}\r\n\r\n.section-cart-crm p {\r\n padding: 0;\r\n margin: 0px 0px 0px 15px;\r\n}\r\n\r\n.button {\r\n top: 50%;\r\n background-color: #6c6c7e;\r\n color: #fff;\r\n border: none;\r\n /* border-radius: 10px; */\r\n padding: 15px;\r\n min-height: 30px;\r\n min-width: 120px;\r\n /* font-size: 20px; */\r\n cursor: pointer;\r\n margin-left: 10px;\r\n height: 70px;\r\n}\r\n\r\n.form-container {\r\n width: 97%;\r\n display: flex;\r\n justify-content: space-around;\r\n}\r\n\r\n\r\n.btn {\r\n display: inline-block;\r\n padding: 6px 12px;\r\n margin-bottom: 0;\r\n /* font-size: 14px; */\r\n font-weight: 400;\r\n line-height: 1.42857143;\r\n text-align: center;\r\n white-space: nowrap;\r\n vertical-align: middle;\r\n -ms-touch-action: manipulation;\r\n touch-action: manipulation;\r\n cursor: pointer;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n background-image: none;\r\n border: 1px solid transparent;\r\n border-radius: 0px;\r\n}\r\n\r\n.form-container .btnCrm {\r\n background: #00162e;\r\n border-color: #00162e;\r\n width: 30%;\r\n color: #fff;\r\n}\r\n\r\n.message-alert {\r\n color: #df4d4d;\r\n margin-top: 5px;\r\n}","import { Component, h, State } from \"@stencil/core\";\r\nimport { CartWake } from \"../../objectvalues/cart.wake\";\r\nimport { getCart } from \"../../helpers/cart.helper\";\r\n\r\n@Component({\r\n tag: 'crm-bonus-2',\r\n styleUrl: 'crm-bonus.css',\r\n assetsDirs: ['assets'],\r\n // scoped: true\r\n shadow: true\r\n})\r\nexport class CrmBonus {\r\n\r\n @State() loading = false;\r\n\r\n @State() cartWake: CartWake;\r\n\r\n async componentDidLoad() {\r\n await this.loadCheckout()\r\n }\r\n\r\n async loadCheckout() {\r\n this.cartWake = await getCart();\r\n }\r\n\r\n render() {\r\n\r\n console.log('this.cartWake', this.cartWake)\r\n\r\n return (\r\n <div>\r\n <loading-container loading={this.loading}>\r\n <h3>CARREGANDO...</h3>\r\n </loading-container>\r\n {\r\n this.cartWake && (\r\n <div>\r\n {this.cartWake.id}\r\n </div>\r\n )\r\n }\r\n </div>\r\n\r\n )\r\n }\r\n}"],"mappings":"+EAAA,MAAMA,EAAc,q8BACpB,MAAAC,EAAeD,E,MCUFE,EAAQ,M,sCAEE,M,wBAInB,sBAAMC,SACIC,KAAKC,c,CAGf,kBAAMA,GACFD,KAAKE,eAAiBC,G,CAG1B,MAAAC,GAEIC,QAAQC,IAAI,gBAAiBN,KAAKE,UAElC,OACIK,EAAA,OAAAC,IAAA,4CACID,EAAA,qBAAAC,IAAA,2CAAmBC,QAAST,KAAKS,SAC7BF,EAAA,MAAAC,IAAA,8DAGAR,KAAKE,UACDK,EAAA,OAAAC,IAAA,4CACKR,KAAKE,SAASQ,I","ignoreList":[]}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{r as t,h as s}from"./p-8c362346.js";import{a as i,U as o,g as e,b as n,C as a}from"./p-c74567c6.js";import{d as r,S as c,i as h}from"./p-702d5a6f.js";import{b as l}from"./p-4c7e066c.js";const d=".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";const u=d;const f=class{constructor(s){t(this,s);this.crmBonusService=i.getInstance();this.cart=undefined;this.canhidden=false;this.showModal=false;this.cartWake=undefined;this.customer={birthDate:"",document:"",name:"",phone:""};this.loading=false;this.message=undefined;this.phone=undefined;this.canCancel=false;this.amountCancel=undefined;this.sent=undefined;this.session=undefined;this.loading_reprocess=false;this.styles=r;this.reservedInfo=undefined}async resetBonus(){console.log("[START RESET BONUS]!!!!!");try{await this.crmBonusRef.processBonus(this.buildProducts(),true);console.log("[BONUS RESETADO]!!!!!")}catch(t){this.loading=false;console.log("[error ao reprocessar bonous]");await this.crmBonusRef.setStep(c.STEP_PHONE)}finally{this.loading=false}}async setloading(){this.loading_reprocess=!this.loading_reprocess}async reprocess(){console.log("[CRMBONUS] - reprocess");this.loading_reprocess=true;try{const t=localStorage.getItem(o);if(!t)return;this.cartWake=await e();await this.resetBonus()}catch(t){console.debug("[watchProducts]",t.message)}finally{this.loading_reprocess=false}}async componentWillLoad(){window.addEventListener("productRemovedFromCart",(async()=>{console.log("[CRMBONUS] - productRemovedFromCart");await this.reprocess()}));window.addEventListener("productAddedToCart",(async()=>{console.log("[CRMBONUS] - productAddedToCart");await this.reprocess()}));document.querySelectorAll("form").forEach((t=>{t.addEventListener("submit",(()=>{console.log("[CRMBONUS] - Formulário está sendo submetido!");setTimeout((async()=>{await this.reprocess()}))}))}));await this.observerHandle();h.changeLanguage(h.language);await this.loadSession();this.handleLoad();await this.loadConfigStore()}async componentDidLoad(){console.log("[did load]")}async observerHandle(){const t=document.getElementsByTagName("a");for(let s of t){console.log("[el.href]",s.href);if(s.href.includes("Produto/Delete")){s.addEventListener("click",(async()=>{console.log("[CRMBONUS] - Produto removido do carrinho");setTimeout((async()=>{await this.reprocess();this.observerHandle()}),2e3)}))}if(s.href.includes("Produto/Add")){s.addEventListener("click",(async()=>{console.log("[CRMBONUS] - Produto adicionado ao carrinho");setTimeout((async()=>{await this.reprocess();this.observerHandle()}),2e3)}))}}}async loadConfigStore(){const[t,s]=await Promise.all([this.crmBonusService.getCustomization(this.cartWake.store.name),n(this.cartWake.id,this.cartWake.store.name)]);console.log("[infoBonus]",s);this.reservedInfo=s;if(t.keepStoreFrontStyle){console.log("[bc:usar estilo da loja]");this.styles=null}}async fetchCustomer(t,s){try{return await this.crmBonusService.getCustomer(t,s)}catch(t){console.error("[fetchCustomer] Error fetching customer:",t);return null}}async handleLoad(){try{if(this.cartWake.user.id){this.fetchCustomer(this.cartWake.user.id,this.cartWake.store.name).then((t=>{console.log("[bc:loading customer]");if(t){this.customer=t;console.log("customer",this.customer)}}))}const t=localStorage.getItem(this.cartWake.id);if(t){this.canCancel=true;this.amountCancel=t}await this.buildAndGetProducts(this.cartWake.products)}catch(t){console.log("info customer")}}async loadSession(){this.cartWake=this.cart?new a(JSON.parse(this.cart)):await e();console.log("[bc:carregou carrinho]");this.session=await this.crmBonusService.getToken(this.cartWake.store.name);console.log("[bc:carregou session]");setTimeout((()=>{this.loadSession()}),15e5)}async buildAndGetProducts(t){console.log();const s=`bc-products:${this.cartWake.id}`;const i=JSON.stringify(t);localStorage.setItem(s,i);const o=JSON.parse(localStorage.getItem(s));const e=[];for(const s of t){const[t]=o.filter((t=>t.ProdutoVarianteId==s.ProdutoVarianteId));if(t){e.push(Object.assign(Object.assign({},s),{PrecoPor:t.PrecoPor,PrecoDe:t.PrecoDe,Quantidade:t.Quantidade,Ajustes:t.Ajustes}))}else{e.push(s)}}this.cartWake.products=e}async sendPin(t){var s,i;this.loading=true;this.message="";try{const s=t.replace(/\D/g,"");this.phone=Number(s);this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.cartWake.store.name);await this.crmBonusRef.setStep(c.STEP_PIN);this.showModal=true}catch(t){this.message=(i=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||i===void 0?void 0:i.message}finally{this.loading=false}}async sendPinName(t){var s,i;this.loading=true;this.message="";try{this.customer.name=t;this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.cartWake.store.name);await this.crmBonusRef.setStep(c.STEP_PIN);this.showModal=true}catch(t){this.message=(i=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||i===void 0?void 0:i.message}finally{this.loading=false}}buildProducts(){return l(this.cartWake.products)}handleCloseModal(){this.showModal=false}save(t){localStorage.setItem(this.cartWake.id,t.toString());this.canCancel=true;this.amountCancel=t.toString()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartWake.id);this.canCancel=false;localStorage.removeItem(this.cartWake.id)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async handleSendPin(t){this.message="";if(!t){this.message="Informe seu telefone";return}this.customer.phone=t;const s=t.replace(/\D/g,"");this.phone=Number(s);if(this.customer.name){return this.sendPin(t)}await this.crmBonusRef.setStep(c.STEP_NAME);this.showModal=true}render(){if(this.canhidden){return null}return s("loading-container",{loading:this.loading_reprocess},s("crm-giftback-form",{customStyles:this.styles,style:{position:"relative"},ref:t=>this.crmBonusRef=t,storeName:this.cartWake.store.name,products:this.buildProducts(),cartId:this.cartWake.id,customer:this.customer,loadProducts:()=>this.buildProducts(),loadAll:()=>this.handleLoad(),reservedInfo:this.reservedInfo}))}static get assetsDirs(){return["assets"]}};f.style=u;export{f as
|
2
|
-
//# sourceMappingURL=p-
|
1
|
+
import{r as t,h as s}from"./p-8c362346.js";import{a as i,U as o,g as e,b as n,C as a}from"./p-c74567c6.js";import{d as r,S as c,i as h}from"./p-702d5a6f.js";import{b as l}from"./p-4c7e066c.js";const d=".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";const u=d;const f=class{constructor(s){t(this,s);this.crmBonusService=i.getInstance();this.cart=undefined;this.canhidden=false;this.showModal=false;this.cartWake=undefined;this.customer={birthDate:"",document:"",name:"",phone:""};this.loading=false;this.message=undefined;this.phone=undefined;this.canCancel=false;this.amountCancel=undefined;this.sent=undefined;this.session=undefined;this.loading_reprocess=false;this.styles=r;this.reservedInfo=undefined}async resetBonus(){console.log("[START RESET BONUS]!!!!!");try{await this.crmBonusRef.processBonus(this.buildProducts(),true);console.log("[BONUS RESETADO]!!!!!")}catch(t){this.loading=false;console.log("[error ao reprocessar bonous]");await this.crmBonusRef.setStep(c.STEP_PHONE)}finally{this.loading=false}}async setloading(){this.loading_reprocess=!this.loading_reprocess}async reprocess(){console.log("[CRMBONUS] - reprocess");this.loading_reprocess=true;try{const t=localStorage.getItem(o);if(!t)return;this.cartWake=await e();await this.resetBonus()}catch(t){console.debug("[watchProducts]",t.message)}finally{this.loading_reprocess=false}}async componentWillLoad(){window.addEventListener("productRemovedFromCart",(async()=>{console.log("[CRMBONUS] - productRemovedFromCart");await this.reprocess()}));window.addEventListener("productAddedToCart",(async()=>{console.log("[CRMBONUS] - productAddedToCart");await this.reprocess()}));document.querySelectorAll("form").forEach((t=>{t.addEventListener("submit",(()=>{console.log("[CRMBONUS] - Formulário está sendo submetido!");setTimeout((async()=>{await this.reprocess()}))}))}));await this.observerHandle();h.changeLanguage(h.language);await this.loadSession();this.handleLoad();await this.loadConfigStore()}async componentDidLoad(){console.log("[did load]")}async observerHandle(){const t=document.getElementsByTagName("a");for(let s of t){console.log("[el.href]",s.href);if(s.href.includes("Produto/Delete")){s.addEventListener("click",(async()=>{console.log("[CRMBONUS] - Produto removido do carrinho");setTimeout((async()=>{await this.reprocess();this.observerHandle()}),2e3)}))}if(s.href.includes("Produto/Add")){s.addEventListener("click",(async()=>{console.log("[CRMBONUS] - Produto adicionado ao carrinho");setTimeout((async()=>{await this.reprocess();this.observerHandle()}),2e3)}))}}}async loadConfigStore(){const[t,s]=await Promise.all([this.crmBonusService.getCustomization(this.cartWake.store.name),n(this.cartWake.id,this.cartWake.store.name)]);console.log("[infoBonus]",s);this.reservedInfo=s;if(t.keepStoreFrontStyle){console.log("[bc:usar estilo da loja]");this.styles=null}}async fetchCustomer(t,s){try{return await this.crmBonusService.getCustomer(t,s)}catch(t){console.error("[fetchCustomer] Error fetching customer:",t);return null}}async handleLoad(){try{if(this.cartWake.user.id){this.fetchCustomer(this.cartWake.user.id,this.cartWake.store.name).then((t=>{console.log("[bc:loading customer]");if(t){this.customer=t;console.log("customer",this.customer)}}))}const t=localStorage.getItem(this.cartWake.id);if(t){this.canCancel=true;this.amountCancel=t}await this.buildAndGetProducts(this.cartWake.products)}catch(t){console.log("info customer")}}async loadSession(){this.cartWake=this.cart?new a(JSON.parse(this.cart)):await e();console.log("[bc:carregou carrinho]");this.session=await this.crmBonusService.getToken(this.cartWake.store.name);console.log("[bc:carregou session]");setTimeout((()=>{this.loadSession()}),15e5)}async buildAndGetProducts(t){console.log();const s=`bc-products:${this.cartWake.id}`;const i=JSON.stringify(t);localStorage.setItem(s,i);const o=JSON.parse(localStorage.getItem(s));const e=[];for(const s of t){const[t]=o.filter((t=>t.ProdutoVarianteId==s.ProdutoVarianteId));if(t){e.push(Object.assign(Object.assign({},s),{PrecoPor:t.PrecoPor,PrecoDe:t.PrecoDe,Quantidade:t.Quantidade,Ajustes:t.Ajustes}))}else{e.push(s)}}this.cartWake.products=e}async sendPin(t){var s,i;this.loading=true;this.message="";try{const s=t.replace(/\D/g,"");this.phone=Number(s);this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.cartWake.store.name);await this.crmBonusRef.setStep(c.STEP_PIN);this.showModal=true}catch(t){this.message=(i=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||i===void 0?void 0:i.message}finally{this.loading=false}}async sendPinName(t){var s,i;this.loading=true;this.message="";try{this.customer.name=t;this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.cartWake.store.name);await this.crmBonusRef.setStep(c.STEP_PIN);this.showModal=true}catch(t){this.message=(i=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||i===void 0?void 0:i.message}finally{this.loading=false}}buildProducts(){return l(this.cartWake.products)}handleCloseModal(){this.showModal=false}save(t){localStorage.setItem(this.cartWake.id,t.toString());this.canCancel=true;this.amountCancel=t.toString()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartWake.id);this.canCancel=false;localStorage.removeItem(this.cartWake.id)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async handleSendPin(t){this.message="";if(!t){this.message="Informe seu telefone";return}this.customer.phone=t;const s=t.replace(/\D/g,"");this.phone=Number(s);if(this.customer.name){return this.sendPin(t)}await this.crmBonusRef.setStep(c.STEP_NAME);this.showModal=true}render(){if(this.canhidden){return null}return s("loading-container",{loading:this.loading_reprocess},s("crm-giftback-form",{customStyles:this.styles,style:{position:"relative"},ref:t=>this.crmBonusRef=t,storeName:this.cartWake.store.name,products:this.buildProducts(),cartId:this.cartWake.id,customer:this.customer,loadProducts:()=>this.buildProducts(),loadAll:()=>this.handleLoad(),reservedInfo:this.reservedInfo}))}static get assetsDirs(){return["assets"]}};f.style=u;export{f as crm_bonus};
|
2
|
+
//# sourceMappingURL=p-a0d73d77.entry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["crmBonusCss","CrmBonusStyle0","CrmBonus","this","crmBonusService","CrmBonusService","getInstance","birthDate","document","name","phone","defaultStyles","resetBonus","console","log","crmBonusRef","processBonus","buildProducts","err","loading","setStep","StepFormEnum","STEP_PHONE","setloading","loading_reprocess","reprocess","isUse","localStorage","getItem","USED_KEY","cartWake","getCart","debug","message","componentWillLoad","window","addEventListener","async","querySelectorAll","forEach","el","setTimeout","observerHandle","i18next","changeLanguage","language","loadSession","handleLoad","loadConfigStore","componentDidLoad","elements","getElementsByTagName","href","includes","customization","infoBonus","Promise","all","getCustomization","store","getInfoBonusByCartIdAndStoreName","id","reservedInfo","keepStoreFrontStyle","styles","fetchCustomer","userId","storeName","getCustomer","error","user","then","customer","amount","canCancel","amountCancel","buildAndGetProducts","products","cart","CartWake","JSON","parse","session","getToken","productsWake","key","productsString","stringify","setItem","products_in_cache","product_cart","pro","filter","p","ProdutoVarianteId","push","Object","assign","PrecoPor","PrecoDe","Quantidade","Ajustes","sendPin","_phone","replace","Number","sent","STEP_PIN","showModal","_b","_a","response","data","sendPinName","customerName","buildProductsByWake","handleCloseModal","save","toString","cancel","removeItem","handleSendPin","STEP_NAME","render","canhidden","h","customStyles","style","position","ref","cartId","loadProducts","loadAll"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=shadow","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\r\n.container-button {\r\n /* max-width: 100%; */\r\n cursor: pointer;\r\n padding: 5px 5px 5px 14px;\r\n /* display: flex; */\r\n}\r\n\r\n/* padding: 0 15px 15px;\r\nborder: 1px solid #ddd;\r\nmargin-bottom: 20px; */\r\n\r\n.section-crm {\r\n border: 1px solid #dbd4d4;\r\n /* min-height: 50px; */\r\n text-align: -webkit-center;\r\n margin-bottom: 20px;\r\n}\r\n\r\n.section-cart-crm {\r\n margin-top: 10px;\r\n}\r\n\r\n.section-cart-crm p {\r\n padding: 0;\r\n margin: 0px 0px 0px 15px;\r\n}\r\n\r\n.button {\r\n top: 50%;\r\n background-color: #6c6c7e;\r\n color: #fff;\r\n border: none;\r\n /* border-radius: 10px; */\r\n padding: 15px;\r\n min-height: 30px;\r\n min-width: 120px;\r\n /* font-size: 20px; */\r\n cursor: pointer;\r\n margin-left: 10px;\r\n height: 70px;\r\n}\r\n\r\n.form-container {\r\n width: 97%;\r\n display: flex;\r\n justify-content: space-around;\r\n}\r\n\r\n\r\n.btn {\r\n display: inline-block;\r\n padding: 6px 12px;\r\n margin-bottom: 0;\r\n /* font-size: 14px; */\r\n font-weight: 400;\r\n line-height: 1.42857143;\r\n text-align: center;\r\n white-space: nowrap;\r\n vertical-align: middle;\r\n -ms-touch-action: manipulation;\r\n touch-action: manipulation;\r\n cursor: pointer;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n background-image: none;\r\n border: 1px solid transparent;\r\n border-radius: 0px;\r\n}\r\n\r\n.form-container .btnCrm {\r\n background: #00162e;\r\n border-color: #00162e;\r\n width: 30%;\r\n color: #fff;\r\n}\r\n\r\n.message-alert {\r\n color: #df4d4d;\r\n margin-top: 5px;\r\n}","import { Component, Method, Prop, State, h } from '@stencil/core';\r\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\r\nimport { CrmBonusService } from '../../services/crmbonus.service';\r\nimport { IPinSent } from '../../components';\r\nimport { defaultStyles, StepFormEnum } from '../../contants';\r\n\r\nimport i18next from '../../i18n/i18n'\r\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\r\nimport { getCart, getInfoBonusByCartIdAndStoreName } from '../../helpers/cart.helper';\r\nimport { CartWake } from '../../objectvalues/cart.wake';\r\nimport { USED_KEY } from '../../utils/keys.storage';\r\nimport { ReservedInfoDTO } from '../../dto/reserved-info.dto';\r\n\r\n@Component({\r\n tag: 'crm-bonus',\r\n styleUrl: 'crm-bonus.css',\r\n assetsDirs: ['assets'],\r\n // scoped: true\r\n shadow: true\r\n})\r\nexport class CrmBonus {\r\n\r\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\r\n\r\n private crmBonusRef: HTMLCrmGiftbackFormElement;\r\n\r\n @Prop() cart;\r\n @Prop() canhidden: boolean = false;\r\n\r\n @State() showModal: boolean = false;\r\n\r\n @State() cartWake: CartWake;\r\n\r\n @State() customer: ICustomer = {\r\n birthDate: \"\",\r\n document: \"\",\r\n name: \"\",\r\n phone: \"\"\r\n };\r\n\r\n @State() loading: boolean = false;\r\n @State() message: string;\r\n @State() phone: number;\r\n @State() canCancel: boolean = false;\r\n @State() amountCancel: string;\r\n @State() sent: IPinSent;\r\n\r\n @State() session: string;\r\n @State() loading_reprocess = false;\r\n @State() styles = defaultStyles;\r\n @State() reservedInfo: ReservedInfoDTO;\r\n\r\n @Method()\r\n async resetBonus() {\r\n console.log('[START RESET BONUS]!!!!!');\r\n\r\n try {\r\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\r\n console.log('[BONUS RESETADO]!!!!!');\r\n } catch (err) {\r\n\r\n this.loading = false;\r\n console.log('[error ao reprocessar bonous]');\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n @Method()\r\n async setloading() {\r\n this.loading_reprocess = !this.loading_reprocess;\r\n }\r\n\r\n @Method()\r\n async reprocess() {\r\n console.log(\"[CRMBONUS] - reprocess\")\r\n this.loading_reprocess = true\r\n\r\n try {\r\n\r\n const isUse = localStorage.getItem(USED_KEY);\r\n\r\n if (!isUse) return;\r\n\r\n this.cartWake = await getCart();\r\n await this.resetBonus();\r\n } catch (err) {\r\n console.debug('[watchProducts]', err.message);\r\n } finally {\r\n this.loading_reprocess = false\r\n }\r\n }\r\n\r\n async componentWillLoad() {\r\n\r\n window.addEventListener('productRemovedFromCart', async () => {\r\n console.log('[CRMBONUS] - productRemovedFromCart');\r\n await this.reprocess()\r\n });\r\n\r\n window.addEventListener('productAddedToCart', async () => {\r\n console.log('[CRMBONUS] - productAddedToCart');\r\n await this.reprocess();\r\n });\r\n\r\n document.querySelectorAll('form').forEach((el) => {\r\n el.addEventListener(\"submit\", () => {\r\n console.log(\"[CRMBONUS] - Formulário está sendo submetido!\");\r\n // você pode marcar como \"em submissão\" aqui\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n })\r\n });\r\n });\r\n\r\n await this.observerHandle();\r\n\r\n i18next.changeLanguage(i18next.language);\r\n\r\n await this.loadSession();\r\n\r\n this.handleLoad();\r\n await this.loadConfigStore()\r\n }\r\n\r\n async componentDidLoad() {\r\n console.log('[did load]');\r\n \r\n }\r\n\r\n private async observerHandle() {\r\n const elements = document.getElementsByTagName('a');\r\n\r\n //@ts-ignore\r\n for (let el of elements) {\r\n console.log('[el.href]', el.href);\r\n if (el.href.includes('Produto/Delete')) {\r\n el.addEventListener('click', async () => {\r\n console.log('[CRMBONUS] - Produto removido do carrinho');\r\n\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n this.observerHandle();\r\n }, 2000);\r\n\r\n });\r\n }\r\n\r\n if (el.href.includes('Produto/Add')) {\r\n el.addEventListener('click', async () => {\r\n console.log('[CRMBONUS] - Produto adicionado ao carrinho');\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n this.observerHandle();\r\n }, 2000);\r\n });\r\n }\r\n }\r\n }\r\n\r\n async loadConfigStore() {\r\n\r\n const [customization, infoBonus] = await Promise.all([\r\n this.crmBonusService.getCustomization(this.cartWake.store.name),\r\n getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name)\r\n ]);\r\n\r\n console.log('[infoBonus]', infoBonus);\r\n\r\n this.reservedInfo = infoBonus;\r\n\r\n if (customization.keepStoreFrontStyle) {\r\n console.log('[bc:usar estilo da loja]');\r\n this.styles = null;\r\n }\r\n }\r\n\r\n async fetchCustomer(userId: number, storeName: string) {\r\n try {\r\n return await this.crmBonusService.getCustomer(userId, storeName);\r\n } catch (error) {\r\n console.error('[fetchCustomer] Error fetching customer:', error);\r\n return null;\r\n }\r\n }\r\n\r\n async handleLoad() {\r\n try {\r\n if (this.cartWake.user.id) {\r\n this.fetchCustomer(this.cartWake.user.id, this.cartWake.store.name).then((customer) => {\r\n console.log('[bc:loading customer]');\r\n if (customer) {\r\n this.customer = customer;\r\n console.log('customer', this.customer);\r\n }\r\n });\r\n }\r\n\r\n const amount = localStorage.getItem(this.cartWake.id);\r\n\r\n if (amount) {\r\n this.canCancel = true;\r\n this.amountCancel = amount;\r\n }\r\n\r\n await this.buildAndGetProducts(this.cartWake.products);\r\n } catch (error) {\r\n console.log('info customer')\r\n }\r\n }\r\n\r\n async loadSession() {\r\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\r\n console.log('[bc:carregou carrinho]');\r\n\r\n this.session = await this.crmBonusService.getToken(this.cartWake.store.name);\r\n console.log('[bc:carregou session]');\r\n setTimeout(() => {\r\n this.loadSession()\r\n }, 1500000)\r\n }\r\n\r\n async buildAndGetProducts(productsWake: IProductWake[]) {\r\n console.log()\r\n\r\n const key = `bc-products:${this.cartWake.id}`;\r\n\r\n const productsString = JSON.stringify(productsWake)\r\n\r\n localStorage.setItem(key, productsString);\r\n\r\n const products_in_cache = JSON.parse(localStorage.getItem(key));\r\n\r\n const products: Array<IProductWake> = []\r\n\r\n for (const product_cart of productsWake) {\r\n\r\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\r\n\r\n //const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === \"Formula\")\r\n\r\n if (pro) {\r\n products.push({\r\n ...product_cart,\r\n PrecoPor: pro.PrecoPor,\r\n PrecoDe: pro.PrecoDe,\r\n Quantidade: pro.Quantidade,\r\n Ajustes: pro.Ajustes\r\n })\r\n } else {\r\n products.push(product_cart)\r\n }\r\n\r\n }\r\n\r\n this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\r\n\r\n }\r\n\r\n public async sendPin(phone: string) {\r\n this.loading = true;\r\n this.message = \"\";\r\n\r\n try {\r\n\r\n const _phone = phone.replace(/\\D/g, '');\r\n this.phone = Number(_phone);\r\n\r\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);;\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\r\n\r\n this.showModal = true;\r\n } catch (error) {\r\n this.message = error?.response?.data?.message\r\n } finally {\r\n this.loading = false\r\n }\r\n }\r\n\r\n public async sendPinName(customerName: string) {\r\n this.loading = true;\r\n this.message = \"\";\r\n\r\n try {\r\n this.customer.name = customerName;\r\n\r\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\r\n\r\n this.showModal = true;\r\n } catch (error) {\r\n this.message = error?.response?.data?.message\r\n } finally {\r\n this.loading = false\r\n }\r\n }\r\n\r\n buildProducts(): IProduct[] {\r\n return buildProductsByWake(this.cartWake.products);\r\n }\r\n\r\n handleCloseModal() {\r\n this.showModal = false;\r\n }\r\n\r\n save(amount: number) {\r\n localStorage.setItem(this.cartWake.id, amount.toString());\r\n this.canCancel = true;\r\n this.amountCancel = amount.toString()\r\n }\r\n\r\n async cancel() {\r\n this.message = \"\";\r\n this.loading = true;\r\n try {\r\n await this.crmBonusService.cancel(this.cartWake.id);\r\n this.canCancel = false;\r\n\r\n localStorage.removeItem(this.cartWake.id);\r\n } catch (error) {\r\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n async handleSendPin(phone: string) {\r\n this.message = \"\"\r\n if (!phone) {\r\n this.message = \"Informe seu telefone\";\r\n return;\r\n }\r\n\r\n this.customer.phone = phone;\r\n const _phone = phone.replace(/\\D/g, '');\r\n this.phone = Number(_phone);\r\n\r\n if (this.customer.name) {\r\n return this.sendPin(phone)\r\n }\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\r\n this.showModal = true;\r\n }\r\n\r\n render() {\r\n\r\n if (this.canhidden) {\r\n return null;\r\n }\r\n\r\n return (\r\n <loading-container loading={this.loading_reprocess} >\r\n <crm-giftback-form\r\n customStyles={this.styles}\r\n style={{ position: \"relative\" }}\r\n ref={ref => this.crmBonusRef = ref}\r\n storeName={this.cartWake.store.name}\r\n products={this.buildProducts()}\r\n cartId={this.cartWake.id}\r\n customer={this.customer}\r\n loadProducts={() => this.buildProducts()}\r\n loadAll={() => this.handleLoad()}\r\n reservedInfo={this.reservedInfo}\r\n />\r\n </loading-container>\r\n )\r\n }\r\n}\r\n"],"mappings":"iMAAA,MAAMA,EAAc,q8BACpB,MAAAC,EAAeD,E,MCmBFE,EAAQ,M,yBAEXC,KAAAC,gBAAmCC,EAAgBC,c,mCAK9B,M,eAEC,M,sCAIC,CAC7BC,UAAW,GACXC,SAAU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AAQ,MAAO,IACpCrG,KAAKO,MAAQ+F,OAAOF,GAEpB,GAAIpG,KAAKqE,SAAS/D,KAAM,CACtB,OAAON,KAAKmG,QAAQ5F,E,OAGhBP,KAAKY,YAAYK,QAAQC,EAAaqG,WAC5CvH,KAAKyG,UAAY,I,CAGnB,MAAAe,GAEE,GAAIxH,KAAKyH,UAAW,CAClB,OAAO,I,CAGT,OACEC,EAAA,qBAAmB1G,QAAShB,KAAKqB,mBAC/BqG,EAAA,qBACEC,aAAc3H,KAAK6D,OACnB+D,MAAO,CAAEC,SAAU,YACnBC,IAAKA,GAAO9H,KAAKY,YAAckH,EAC/B9D,UAAWhE,KAAK2B,SAAS6B,MAAMlD,KAC/BoE,SAAU1E,KAAKc,gBACfiH,OAAQ/H,KAAK2B,SAAS+B,GACtBW,SAAUrE,KAAKqE,SACf2D,aAAc,IAAMhI,KAAKc,gBACzBmH,QAAS,IAAMjI,KAAK4C,aACpBe,aAAc3D,KAAK2D,e","ignoreList":[]}
|
@@ -1,7 +1,5 @@
|
|
1
1
|
import { r as registerInstance, h } from './index-bdb70d5a.js';
|
2
|
-
import {
|
3
|
-
import { d as defaultStyles, S as StepFormEnum, i as instance } from './i18n-7938fb86.js';
|
4
|
-
import { b as buildProductsByWake } from './build.payload.helper-caf0a82b.js';
|
2
|
+
import { g as getCart } from './cart.helper-7101c047.js';
|
5
3
|
|
6
4
|
const crmBonusCss = ".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";
|
7
5
|
const CrmBonus2Style0 = crmBonusCss;
|
@@ -9,267 +7,18 @@ const CrmBonus2Style0 = crmBonusCss;
|
|
9
7
|
const CrmBonus = class {
|
10
8
|
constructor(hostRef) {
|
11
9
|
registerInstance(this, hostRef);
|
12
|
-
this.crmBonusService = CrmBonusService.getInstance();
|
13
|
-
this.cart = undefined;
|
14
|
-
this.canhidden = false;
|
15
|
-
this.showModal = false;
|
16
|
-
this.cartWake = undefined;
|
17
|
-
this.customer = {
|
18
|
-
birthDate: "",
|
19
|
-
document: "",
|
20
|
-
name: "",
|
21
|
-
phone: ""
|
22
|
-
};
|
23
10
|
this.loading = false;
|
24
|
-
this.
|
25
|
-
this.phone = undefined;
|
26
|
-
this.canCancel = false;
|
27
|
-
this.amountCancel = undefined;
|
28
|
-
this.sent = undefined;
|
29
|
-
this.session = undefined;
|
30
|
-
this.loading_reprocess = false;
|
31
|
-
this.styles = defaultStyles;
|
32
|
-
this.reservedInfo = undefined;
|
33
|
-
}
|
34
|
-
async resetBonus() {
|
35
|
-
console.log('[START RESET BONUS]!!!!!');
|
36
|
-
try {
|
37
|
-
await this.crmBonusRef.processBonus(this.buildProducts(), true);
|
38
|
-
console.log('[BONUS RESETADO]!!!!!');
|
39
|
-
}
|
40
|
-
catch (err) {
|
41
|
-
this.loading = false;
|
42
|
-
console.log('[error ao reprocessar bonous]');
|
43
|
-
await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);
|
44
|
-
}
|
45
|
-
finally {
|
46
|
-
this.loading = false;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
async setloading() {
|
50
|
-
this.loading_reprocess = !this.loading_reprocess;
|
51
|
-
}
|
52
|
-
async reprocess() {
|
53
|
-
console.log("[CRMBONUS] - reprocess");
|
54
|
-
this.loading_reprocess = true;
|
55
|
-
try {
|
56
|
-
const isUse = localStorage.getItem(USED_KEY);
|
57
|
-
if (!isUse)
|
58
|
-
return;
|
59
|
-
this.cartWake = await getCart();
|
60
|
-
await this.resetBonus();
|
61
|
-
}
|
62
|
-
catch (err) {
|
63
|
-
console.debug('[watchProducts]', err.message);
|
64
|
-
}
|
65
|
-
finally {
|
66
|
-
this.loading_reprocess = false;
|
67
|
-
}
|
68
|
-
}
|
69
|
-
async componentWillLoad() {
|
70
|
-
window.addEventListener('productRemovedFromCart', async () => {
|
71
|
-
console.log('[CRMBONUS] - productRemovedFromCart');
|
72
|
-
await this.reprocess();
|
73
|
-
});
|
74
|
-
window.addEventListener('productAddedToCart', async () => {
|
75
|
-
console.log('[CRMBONUS] - productAddedToCart');
|
76
|
-
await this.reprocess();
|
77
|
-
});
|
78
|
-
document.querySelectorAll('form').forEach((el) => {
|
79
|
-
el.addEventListener("submit", () => {
|
80
|
-
console.log("[CRMBONUS] - Formulário está sendo submetido!");
|
81
|
-
// você pode marcar como "em submissão" aqui
|
82
|
-
setTimeout(async () => {
|
83
|
-
await this.reprocess();
|
84
|
-
});
|
85
|
-
});
|
86
|
-
});
|
87
|
-
await this.observerHandle();
|
88
|
-
instance.changeLanguage(instance.language);
|
89
|
-
await this.loadSession();
|
90
|
-
this.handleLoad();
|
91
|
-
await this.loadConfigStore();
|
11
|
+
this.cartWake = undefined;
|
92
12
|
}
|
93
13
|
async componentDidLoad() {
|
94
|
-
|
95
|
-
}
|
96
|
-
async observerHandle() {
|
97
|
-
const elements = document.getElementsByTagName('a');
|
98
|
-
//@ts-ignore
|
99
|
-
for (let el of elements) {
|
100
|
-
console.log('[el.href]', el.href);
|
101
|
-
if (el.href.includes('Produto/Delete')) {
|
102
|
-
el.addEventListener('click', async () => {
|
103
|
-
console.log('[CRMBONUS] - Produto removido do carrinho');
|
104
|
-
setTimeout(async () => {
|
105
|
-
await this.reprocess();
|
106
|
-
this.observerHandle();
|
107
|
-
}, 2000);
|
108
|
-
});
|
109
|
-
}
|
110
|
-
if (el.href.includes('Produto/Add')) {
|
111
|
-
el.addEventListener('click', async () => {
|
112
|
-
console.log('[CRMBONUS] - Produto adicionado ao carrinho');
|
113
|
-
setTimeout(async () => {
|
114
|
-
await this.reprocess();
|
115
|
-
this.observerHandle();
|
116
|
-
}, 2000);
|
117
|
-
});
|
118
|
-
}
|
119
|
-
}
|
120
|
-
}
|
121
|
-
async loadConfigStore() {
|
122
|
-
const [customization, infoBonus] = await Promise.all([
|
123
|
-
this.crmBonusService.getCustomization(this.cartWake.store.name),
|
124
|
-
getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name)
|
125
|
-
]);
|
126
|
-
console.log('[infoBonus]', infoBonus);
|
127
|
-
this.reservedInfo = infoBonus;
|
128
|
-
if (customization.keepStoreFrontStyle) {
|
129
|
-
console.log('[bc:usar estilo da loja]');
|
130
|
-
this.styles = null;
|
131
|
-
}
|
132
|
-
}
|
133
|
-
async fetchCustomer(userId, storeName) {
|
134
|
-
try {
|
135
|
-
return await this.crmBonusService.getCustomer(userId, storeName);
|
136
|
-
}
|
137
|
-
catch (error) {
|
138
|
-
console.error('[fetchCustomer] Error fetching customer:', error);
|
139
|
-
return null;
|
140
|
-
}
|
141
|
-
}
|
142
|
-
async handleLoad() {
|
143
|
-
try {
|
144
|
-
if (this.cartWake.user.id) {
|
145
|
-
this.fetchCustomer(this.cartWake.user.id, this.cartWake.store.name).then((customer) => {
|
146
|
-
console.log('[bc:loading customer]');
|
147
|
-
if (customer) {
|
148
|
-
this.customer = customer;
|
149
|
-
console.log('customer', this.customer);
|
150
|
-
}
|
151
|
-
});
|
152
|
-
}
|
153
|
-
const amount = localStorage.getItem(this.cartWake.id);
|
154
|
-
if (amount) {
|
155
|
-
this.canCancel = true;
|
156
|
-
this.amountCancel = amount;
|
157
|
-
}
|
158
|
-
await this.buildAndGetProducts(this.cartWake.products);
|
159
|
-
}
|
160
|
-
catch (error) {
|
161
|
-
console.log('info customer');
|
162
|
-
}
|
163
|
-
}
|
164
|
-
async loadSession() {
|
165
|
-
this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();
|
166
|
-
console.log('[bc:carregou carrinho]');
|
167
|
-
this.session = await this.crmBonusService.getToken(this.cartWake.store.name);
|
168
|
-
console.log('[bc:carregou session]');
|
169
|
-
setTimeout(() => {
|
170
|
-
this.loadSession();
|
171
|
-
}, 1500000);
|
172
|
-
}
|
173
|
-
async buildAndGetProducts(productsWake) {
|
174
|
-
console.log();
|
175
|
-
const key = `bc-products:${this.cartWake.id}`;
|
176
|
-
const productsString = JSON.stringify(productsWake);
|
177
|
-
localStorage.setItem(key, productsString);
|
178
|
-
const products_in_cache = JSON.parse(localStorage.getItem(key));
|
179
|
-
const products = [];
|
180
|
-
for (const product_cart of productsWake) {
|
181
|
-
const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId);
|
182
|
-
//const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === "Formula")
|
183
|
-
if (pro) {
|
184
|
-
products.push(Object.assign(Object.assign({}, product_cart), { PrecoPor: pro.PrecoPor, PrecoDe: pro.PrecoDe, Quantidade: pro.Quantidade, Ajustes: pro.Ajustes }));
|
185
|
-
}
|
186
|
-
else {
|
187
|
-
products.push(product_cart);
|
188
|
-
}
|
189
|
-
}
|
190
|
-
this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);
|
191
|
-
}
|
192
|
-
async sendPin(phone) {
|
193
|
-
var _a, _b;
|
194
|
-
this.loading = true;
|
195
|
-
this.message = "";
|
196
|
-
try {
|
197
|
-
const _phone = phone.replace(/\D/g, '');
|
198
|
-
this.phone = Number(_phone);
|
199
|
-
this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
|
200
|
-
await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);
|
201
|
-
this.showModal = true;
|
202
|
-
}
|
203
|
-
catch (error) {
|
204
|
-
this.message = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message;
|
205
|
-
}
|
206
|
-
finally {
|
207
|
-
this.loading = false;
|
208
|
-
}
|
209
|
-
}
|
210
|
-
async sendPinName(customerName) {
|
211
|
-
var _a, _b;
|
212
|
-
this.loading = true;
|
213
|
-
this.message = "";
|
214
|
-
try {
|
215
|
-
this.customer.name = customerName;
|
216
|
-
this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
|
217
|
-
await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);
|
218
|
-
this.showModal = true;
|
219
|
-
}
|
220
|
-
catch (error) {
|
221
|
-
this.message = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message;
|
222
|
-
}
|
223
|
-
finally {
|
224
|
-
this.loading = false;
|
225
|
-
}
|
226
|
-
}
|
227
|
-
buildProducts() {
|
228
|
-
return buildProductsByWake(this.cartWake.products);
|
229
|
-
}
|
230
|
-
handleCloseModal() {
|
231
|
-
this.showModal = false;
|
232
|
-
}
|
233
|
-
save(amount) {
|
234
|
-
localStorage.setItem(this.cartWake.id, amount.toString());
|
235
|
-
this.canCancel = true;
|
236
|
-
this.amountCancel = amount.toString();
|
237
|
-
}
|
238
|
-
async cancel() {
|
239
|
-
this.message = "";
|
240
|
-
this.loading = true;
|
241
|
-
try {
|
242
|
-
await this.crmBonusService.cancel(this.cartWake.id);
|
243
|
-
this.canCancel = false;
|
244
|
-
localStorage.removeItem(this.cartWake.id);
|
245
|
-
}
|
246
|
-
catch (error) {
|
247
|
-
this.message = "Não consegui cancelar o bônus, tente novamente!";
|
248
|
-
}
|
249
|
-
finally {
|
250
|
-
this.loading = false;
|
251
|
-
}
|
14
|
+
await this.loadCheckout();
|
252
15
|
}
|
253
|
-
async
|
254
|
-
this.
|
255
|
-
if (!phone) {
|
256
|
-
this.message = "Informe seu telefone";
|
257
|
-
return;
|
258
|
-
}
|
259
|
-
this.customer.phone = phone;
|
260
|
-
const _phone = phone.replace(/\D/g, '');
|
261
|
-
this.phone = Number(_phone);
|
262
|
-
if (this.customer.name) {
|
263
|
-
return this.sendPin(phone);
|
264
|
-
}
|
265
|
-
await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);
|
266
|
-
this.showModal = true;
|
16
|
+
async loadCheckout() {
|
17
|
+
this.cartWake = await getCart();
|
267
18
|
}
|
268
19
|
render() {
|
269
|
-
|
270
|
-
|
271
|
-
}
|
272
|
-
return (h("loading-container", { loading: this.loading_reprocess }, h("crm-giftback-form", { customStyles: this.styles, style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.cartWake.store.name, products: this.buildProducts(), cartId: this.cartWake.id, customer: this.customer, loadProducts: () => this.buildProducts(), loadAll: () => this.handleLoad(), reservedInfo: this.reservedInfo })));
|
20
|
+
console.log('this.cartWake', this.cartWake);
|
21
|
+
return (h("div", { key: 'cc9dc7fa4262bf6cb5df716164ee9413f9a3bc6f' }, h("loading-container", { key: '4d5ff4d93a3769e609b630cc0760043458990e64', loading: this.loading }, h("h3", { key: 'f7f60857813f42b2735cc3ee6e73523fb4018f2b' }, "CARREGANDO...")), this.cartWake && (h("div", { key: 'bb86c641b03cbf94e50560a3d0d62d022cb80499' }, this.cartWake.id))));
|
273
22
|
}
|
274
23
|
static get assetsDirs() { return ["assets"]; }
|
275
24
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"crm-bonus-2.entry.js","mappings":";;;;;AAAA,MAAM,WAAW,GAAG,o8BAAo8B,CAAC;AACz9B,wBAAe,WAAW;;MCmBb,QAAQ;;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;;yBAK5C,KAAK;yBAEJ,KAAK;;wBAIJ;YAC7B,SAAS,EAAE,EAAE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,OAAO,GAAG,sBAAsB,CAAC;YACtC,OAAO;SACR;QAED,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;SAC3B;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;KACvB;IAED,MAAM;QAEJ,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,OAAO,IAAI,CAAC;SACb;QAED,QACE,yBAAmB,OAAO,EAAE,IAAI,CAAC,iBAAiB,IAChD,yBACE,YAAY,EAAE,IAAI,CAAC,MAAM,EACzB,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAC/B,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EACnC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,EACxC,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE,EAChC,YAAY,EAAE,IAAI,CAAC,YAAY,GAC/B,CACgB,EACrB;KACF;;;;;;;","names":["i18next"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus-2&encapsulation=shadow","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\r\n.container-button {\r\n /* max-width: 100%; */\r\n cursor: pointer;\r\n padding: 5px 5px 5px 14px;\r\n /* display: flex; */\r\n}\r\n\r\n/* padding: 0 15px 15px;\r\nborder: 1px solid #ddd;\r\nmargin-bottom: 20px; */\r\n\r\n.section-crm {\r\n border: 1px solid #dbd4d4;\r\n /* min-height: 50px; */\r\n text-align: -webkit-center;\r\n margin-bottom: 20px;\r\n}\r\n\r\n.section-cart-crm {\r\n margin-top: 10px;\r\n}\r\n\r\n.section-cart-crm p {\r\n padding: 0;\r\n margin: 0px 0px 0px 15px;\r\n}\r\n\r\n.button {\r\n top: 50%;\r\n background-color: #6c6c7e;\r\n color: #fff;\r\n border: none;\r\n /* border-radius: 10px; */\r\n padding: 15px;\r\n min-height: 30px;\r\n min-width: 120px;\r\n /* font-size: 20px; */\r\n cursor: pointer;\r\n margin-left: 10px;\r\n height: 70px;\r\n}\r\n\r\n.form-container {\r\n width: 97%;\r\n display: flex;\r\n justify-content: space-around;\r\n}\r\n\r\n\r\n.btn {\r\n display: inline-block;\r\n padding: 6px 12px;\r\n margin-bottom: 0;\r\n /* font-size: 14px; */\r\n font-weight: 400;\r\n line-height: 1.42857143;\r\n text-align: center;\r\n white-space: nowrap;\r\n vertical-align: middle;\r\n -ms-touch-action: manipulation;\r\n touch-action: manipulation;\r\n cursor: pointer;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n background-image: none;\r\n border: 1px solid transparent;\r\n border-radius: 0px;\r\n}\r\n\r\n.form-container .btnCrm {\r\n background: #00162e;\r\n border-color: #00162e;\r\n width: 30%;\r\n color: #fff;\r\n}\r\n\r\n.message-alert {\r\n color: #df4d4d;\r\n margin-top: 5px;\r\n}","import { Component, Method, Prop, State, h } from '@stencil/core';\r\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\r\nimport { CrmBonusService } from '../../services/crmbonus.service';\r\nimport { IPinSent } from '../../components';\r\nimport { defaultStyles, StepFormEnum } from '../../contants';\r\n\r\nimport i18next from '../../i18n/i18n'\r\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\r\nimport { getCart, getInfoBonusByCartIdAndStoreName } from '../../helpers/cart.helper';\r\nimport { CartWake } from '../../objectvalues/cart.wake';\r\nimport { USED_KEY } from '../../utils/keys.storage';\r\nimport { ReservedInfoDTO } from '../../dto/reserved-info.dto';\r\n\r\n@Component({\r\n tag: 'crm-bonus-2',\r\n styleUrl: 'crm-bonus.css',\r\n assetsDirs: ['assets'],\r\n // scoped: true\r\n shadow: true\r\n})\r\nexport class CrmBonus {\r\n\r\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\r\n\r\n private crmBonusRef: HTMLCrmGiftbackFormElement;\r\n\r\n @Prop() cart;\r\n @Prop() canhidden: boolean = false;\r\n\r\n @State() showModal: boolean = false;\r\n\r\n @State() cartWake: CartWake;\r\n\r\n @State() customer: ICustomer = {\r\n birthDate: \"\",\r\n document: \"\",\r\n name: \"\",\r\n phone: \"\"\r\n };\r\n\r\n @State() loading: boolean = false;\r\n @State() message: string;\r\n @State() phone: number;\r\n @State() canCancel: boolean = false;\r\n @State() amountCancel: string;\r\n @State() sent: IPinSent;\r\n\r\n @State() session: string;\r\n @State() loading_reprocess = false;\r\n @State() styles = defaultStyles;\r\n @State() reservedInfo: ReservedInfoDTO;\r\n\r\n @Method()\r\n async resetBonus() {\r\n console.log('[START RESET BONUS]!!!!!');\r\n\r\n try {\r\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\r\n console.log('[BONUS RESETADO]!!!!!');\r\n } catch (err) {\r\n\r\n this.loading = false;\r\n console.log('[error ao reprocessar bonous]');\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n @Method()\r\n async setloading() {\r\n this.loading_reprocess = !this.loading_reprocess;\r\n }\r\n\r\n @Method()\r\n async reprocess() {\r\n console.log(\"[CRMBONUS] - reprocess\")\r\n this.loading_reprocess = true\r\n\r\n try {\r\n\r\n const isUse = localStorage.getItem(USED_KEY);\r\n\r\n if (!isUse) return;\r\n\r\n this.cartWake = await getCart();\r\n await this.resetBonus();\r\n } catch (err) {\r\n console.debug('[watchProducts]', err.message);\r\n } finally {\r\n this.loading_reprocess = false\r\n }\r\n }\r\n\r\n async componentWillLoad() {\r\n\r\n window.addEventListener('productRemovedFromCart', async () => {\r\n console.log('[CRMBONUS] - productRemovedFromCart');\r\n await this.reprocess()\r\n });\r\n\r\n window.addEventListener('productAddedToCart', async () => {\r\n console.log('[CRMBONUS] - productAddedToCart');\r\n await this.reprocess();\r\n });\r\n\r\n document.querySelectorAll('form').forEach((el) => {\r\n el.addEventListener(\"submit\", () => {\r\n console.log(\"[CRMBONUS] - Formulário está sendo submetido!\");\r\n // você pode marcar como \"em submissão\" aqui\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n })\r\n });\r\n });\r\n\r\n await this.observerHandle();\r\n\r\n i18next.changeLanguage(i18next.language);\r\n\r\n await this.loadSession();\r\n\r\n this.handleLoad();\r\n await this.loadConfigStore()\r\n }\r\n\r\n async componentDidLoad() {\r\n console.log('[did load]');\r\n \r\n }\r\n\r\n private async observerHandle() {\r\n const elements = document.getElementsByTagName('a');\r\n\r\n //@ts-ignore\r\n for (let el of elements) {\r\n console.log('[el.href]', el.href);\r\n if (el.href.includes('Produto/Delete')) {\r\n el.addEventListener('click', async () => {\r\n console.log('[CRMBONUS] - Produto removido do carrinho');\r\n\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n this.observerHandle();\r\n }, 2000);\r\n\r\n });\r\n }\r\n\r\n if (el.href.includes('Produto/Add')) {\r\n el.addEventListener('click', async () => {\r\n console.log('[CRMBONUS] - Produto adicionado ao carrinho');\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n this.observerHandle();\r\n }, 2000);\r\n });\r\n }\r\n }\r\n }\r\n\r\n async loadConfigStore() {\r\n\r\n const [customization, infoBonus] = await Promise.all([\r\n this.crmBonusService.getCustomization(this.cartWake.store.name),\r\n getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name)\r\n ]);\r\n\r\n console.log('[infoBonus]', infoBonus);\r\n\r\n this.reservedInfo = infoBonus;\r\n\r\n if (customization.keepStoreFrontStyle) {\r\n console.log('[bc:usar estilo da loja]');\r\n this.styles = null;\r\n }\r\n }\r\n\r\n async fetchCustomer(userId: number, storeName: string) {\r\n try {\r\n return await this.crmBonusService.getCustomer(userId, storeName);\r\n } catch (error) {\r\n console.error('[fetchCustomer] Error fetching customer:', error);\r\n return null;\r\n }\r\n }\r\n\r\n async handleLoad() {\r\n try {\r\n if (this.cartWake.user.id) {\r\n this.fetchCustomer(this.cartWake.user.id, this.cartWake.store.name).then((customer) => {\r\n console.log('[bc:loading customer]');\r\n if (customer) {\r\n this.customer = customer;\r\n console.log('customer', this.customer);\r\n }\r\n });\r\n }\r\n\r\n const amount = localStorage.getItem(this.cartWake.id);\r\n\r\n if (amount) {\r\n this.canCancel = true;\r\n this.amountCancel = amount;\r\n }\r\n\r\n await this.buildAndGetProducts(this.cartWake.products);\r\n } catch (error) {\r\n console.log('info customer')\r\n }\r\n }\r\n\r\n async loadSession() {\r\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\r\n console.log('[bc:carregou carrinho]');\r\n\r\n this.session = await this.crmBonusService.getToken(this.cartWake.store.name);\r\n console.log('[bc:carregou session]');\r\n setTimeout(() => {\r\n this.loadSession()\r\n }, 1500000)\r\n }\r\n\r\n async buildAndGetProducts(productsWake: IProductWake[]) {\r\n console.log()\r\n\r\n const key = `bc-products:${this.cartWake.id}`;\r\n\r\n const productsString = JSON.stringify(productsWake)\r\n\r\n localStorage.setItem(key, productsString);\r\n\r\n const products_in_cache = JSON.parse(localStorage.getItem(key));\r\n\r\n const products: Array<IProductWake> = []\r\n\r\n for (const product_cart of productsWake) {\r\n\r\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\r\n\r\n //const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === \"Formula\")\r\n\r\n if (pro) {\r\n products.push({\r\n ...product_cart,\r\n PrecoPor: pro.PrecoPor,\r\n PrecoDe: pro.PrecoDe,\r\n Quantidade: pro.Quantidade,\r\n Ajustes: pro.Ajustes\r\n })\r\n } else {\r\n products.push(product_cart)\r\n }\r\n\r\n }\r\n\r\n this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\r\n\r\n }\r\n\r\n public async sendPin(phone: string) {\r\n this.loading = true;\r\n this.message = \"\";\r\n\r\n try {\r\n\r\n const _phone = phone.replace(/\\D/g, '');\r\n this.phone = Number(_phone);\r\n\r\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);;\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\r\n\r\n this.showModal = true;\r\n } catch (error) {\r\n this.message = error?.response?.data?.message\r\n } finally {\r\n this.loading = false\r\n }\r\n }\r\n\r\n public async sendPinName(customerName: string) {\r\n this.loading = true;\r\n this.message = \"\";\r\n\r\n try {\r\n this.customer.name = customerName;\r\n\r\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\r\n\r\n this.showModal = true;\r\n } catch (error) {\r\n this.message = error?.response?.data?.message\r\n } finally {\r\n this.loading = false\r\n }\r\n }\r\n\r\n buildProducts(): IProduct[] {\r\n return buildProductsByWake(this.cartWake.products);\r\n }\r\n\r\n handleCloseModal() {\r\n this.showModal = false;\r\n }\r\n\r\n save(amount: number) {\r\n localStorage.setItem(this.cartWake.id, amount.toString());\r\n this.canCancel = true;\r\n this.amountCancel = amount.toString()\r\n }\r\n\r\n async cancel() {\r\n this.message = \"\";\r\n this.loading = true;\r\n try {\r\n await this.crmBonusService.cancel(this.cartWake.id);\r\n this.canCancel = false;\r\n\r\n localStorage.removeItem(this.cartWake.id);\r\n } catch (error) {\r\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n async handleSendPin(phone: string) {\r\n this.message = \"\"\r\n if (!phone) {\r\n this.message = \"Informe seu telefone\";\r\n return;\r\n }\r\n\r\n this.customer.phone = phone;\r\n const _phone = phone.replace(/\\D/g, '');\r\n this.phone = Number(_phone);\r\n\r\n if (this.customer.name) {\r\n return this.sendPin(phone)\r\n }\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\r\n this.showModal = true;\r\n }\r\n\r\n render() {\r\n\r\n if (this.canhidden) {\r\n return null;\r\n }\r\n\r\n return (\r\n <loading-container loading={this.loading_reprocess} >\r\n <crm-giftback-form\r\n customStyles={this.styles}\r\n style={{ position: \"relative\" }}\r\n ref={ref => this.crmBonusRef = ref}\r\n storeName={this.cartWake.store.name}\r\n products={this.buildProducts()}\r\n cartId={this.cartWake.id}\r\n customer={this.customer}\r\n loadProducts={() => this.buildProducts()}\r\n loadAll={() => this.handleLoad()}\r\n reservedInfo={this.reservedInfo}\r\n />\r\n </loading-container>\r\n )\r\n }\r\n}\r\n"],"version":3}
|
1
|
+
{"file":"crm-bonus-2.entry.js","mappings":";;;AAAA,MAAM,WAAW,GAAG,o8BAAo8B,CAAC;AACz9B,wBAAe,WAAW;;MCUb,QAAQ;;;uBAEE,KAAK;;;IAIxB,MAAM,gBAAgB;QAClB,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;KAC5B;IAED,MAAM,YAAY;QACd,IAAI,CAAC,QAAQ,GAAG,MAAM,OAAO,EAAE,CAAC;KACnC;IAED,MAAM;QAEF,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QAE3C,QACI,8DACI,0EAAmB,OAAO,EAAE,IAAI,CAAC,OAAO,IACpC,6EAAsB,CACN,EAEhB,IAAI,CAAC,QAAQ,KACT,8DACK,IAAI,CAAC,QAAQ,CAAC,EAAE,CACf,CACT,CAEH,EAET;KACJ;;;;;;;","names":[],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus-2&encapsulation=shadow","src/components/crm-bonus/crmbonus.tsx"],"sourcesContent":["\r\n.container-button {\r\n /* max-width: 100%; */\r\n cursor: pointer;\r\n padding: 5px 5px 5px 14px;\r\n /* display: flex; */\r\n}\r\n\r\n/* padding: 0 15px 15px;\r\nborder: 1px solid #ddd;\r\nmargin-bottom: 20px; */\r\n\r\n.section-crm {\r\n border: 1px solid #dbd4d4;\r\n /* min-height: 50px; */\r\n text-align: -webkit-center;\r\n margin-bottom: 20px;\r\n}\r\n\r\n.section-cart-crm {\r\n margin-top: 10px;\r\n}\r\n\r\n.section-cart-crm p {\r\n padding: 0;\r\n margin: 0px 0px 0px 15px;\r\n}\r\n\r\n.button {\r\n top: 50%;\r\n background-color: #6c6c7e;\r\n color: #fff;\r\n border: none;\r\n /* border-radius: 10px; */\r\n padding: 15px;\r\n min-height: 30px;\r\n min-width: 120px;\r\n /* font-size: 20px; */\r\n cursor: pointer;\r\n margin-left: 10px;\r\n height: 70px;\r\n}\r\n\r\n.form-container {\r\n width: 97%;\r\n display: flex;\r\n justify-content: space-around;\r\n}\r\n\r\n\r\n.btn {\r\n display: inline-block;\r\n padding: 6px 12px;\r\n margin-bottom: 0;\r\n /* font-size: 14px; */\r\n font-weight: 400;\r\n line-height: 1.42857143;\r\n text-align: center;\r\n white-space: nowrap;\r\n vertical-align: middle;\r\n -ms-touch-action: manipulation;\r\n touch-action: manipulation;\r\n cursor: pointer;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n background-image: none;\r\n border: 1px solid transparent;\r\n border-radius: 0px;\r\n}\r\n\r\n.form-container .btnCrm {\r\n background: #00162e;\r\n border-color: #00162e;\r\n width: 30%;\r\n color: #fff;\r\n}\r\n\r\n.message-alert {\r\n color: #df4d4d;\r\n margin-top: 5px;\r\n}","import { Component, h, State } from \"@stencil/core\";\r\nimport { CartWake } from \"../../objectvalues/cart.wake\";\r\nimport { getCart } from \"../../helpers/cart.helper\";\r\n\r\n@Component({\r\n tag: 'crm-bonus-2',\r\n styleUrl: 'crm-bonus.css',\r\n assetsDirs: ['assets'],\r\n // scoped: true\r\n shadow: true\r\n})\r\nexport class CrmBonus {\r\n\r\n @State() loading = false;\r\n\r\n @State() cartWake: CartWake;\r\n\r\n async componentDidLoad() {\r\n await this.loadCheckout()\r\n }\r\n\r\n async loadCheckout() {\r\n this.cartWake = await getCart();\r\n }\r\n\r\n render() {\r\n\r\n console.log('this.cartWake', this.cartWake)\r\n\r\n return (\r\n <div>\r\n <loading-container loading={this.loading}>\r\n <h3>CARREGANDO...</h3>\r\n </loading-container>\r\n {\r\n this.cartWake && (\r\n <div>\r\n {this.cartWake.id}\r\n </div>\r\n )\r\n }\r\n </div>\r\n\r\n )\r\n }\r\n}"],"version":3}
|