crmbonus-component-wake 2.1.16-homolog → 2.1.17-homolog
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/{cart.helper-06f44f70.js → cart.helper-d216033e.js} +43 -2
- package/dist/cjs/cart.helper-d216033e.js.map +1 -0
- package/dist/cjs/countdown-timer.cjs.entry.js +41 -11
- package/dist/cjs/countdown-timer.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-bonus-form.cjs.entry.js +1 -2
- package/dist/cjs/crm-bonus-form.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-bonus-note.cjs.entry.js +28 -11
- package/dist/cjs/crm-bonus-note.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-bonus.cjs.entry.js +11 -6
- package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-giftback-form_2.cjs.entry.js +33 -15
- package/dist/cjs/crm-giftback-form_2.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-tooltip_4.cjs.entry.js +28 -15
- package/dist/cjs/crm-tooltip_4.cjs.entry.js.map +1 -1
- package/dist/cjs/crmbonus-component-wake.cjs.js +1 -1
- package/dist/{components/p-292a2414.js → cjs/crmbonus.service-5537cef5.js} +35 -13
- package/dist/cjs/crmbonus.service-5537cef5.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pedido-finalizado.cjs.entry.js +3 -5
- package/dist/cjs/pedido-finalizado.cjs.entry.js.map +1 -1
- package/dist/cjs/phone-cancel-input.cjs.entry.js.map +1 -1
- package/dist/cjs/{utils-e9413ee3.js → utils-5d59acb1.js} +1 -2
- package/dist/cjs/utils-5d59acb1.js.map +1 -0
- package/dist/collection/components/_crm-bonus-form/subcomponents/phone-cancel/phone.cancel.input.js.map +1 -1
- package/dist/collection/components/countdown-timer/countdown-timer.js +64 -12
- package/dist/collection/components/countdown-timer/countdown-timer.js.map +1 -1
- package/dist/collection/components/crm-bonus/crm-bonus.js +11 -4
- package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
- package/dist/collection/components/giftback-form/giftback-form.js +46 -6
- package/dist/collection/components/giftback-form/giftback-form.js.map +1 -1
- package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.js +62 -11
- package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.js.map +1 -1
- package/dist/collection/components/note/crm-bonus-note.js +26 -8
- package/dist/collection/components/note/crm-bonus-note.js.map +1 -1
- package/dist/collection/components/pedido/pedido.js +1 -2
- package/dist/collection/components/pedido/pedido.js.map +1 -1
- package/dist/collection/dto/reserved-info.dto.js +28 -0
- package/dist/collection/dto/reserved-info.dto.js.map +1 -0
- package/dist/collection/helpers/cart.helper.js +12 -0
- package/dist/collection/helpers/cart.helper.js.map +1 -1
- package/dist/collection/helpers/payload.interface.js +2 -0
- package/dist/collection/helpers/payload.interface.js.map +1 -0
- package/dist/collection/services/crmbonus.service.js +19 -9
- package/dist/collection/services/crmbonus.service.js.map +1 -1
- package/dist/collection/utils/utils.js +0 -2
- package/dist/collection/utils/utils.js.map +1 -1
- package/dist/components/countdown-timer.js +1 -1
- package/dist/components/crm-bonus-form.js +1 -1
- package/dist/components/crm-bonus-note.js +28 -10
- package/dist/components/crm-bonus-note.js.map +1 -1
- package/dist/components/crm-bonus.js +15 -9
- 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/index.js +1 -1
- package/dist/components/p-30d12b1b.js +94 -0
- package/dist/components/p-30d12b1b.js.map +1 -0
- package/dist/components/{p-57e02602.js → p-3af6c647.js} +30 -15
- package/dist/components/p-3af6c647.js.map +1 -0
- package/dist/{esm/crmbonus.service-930edf47.js → components/p-3eba0eba.js} +31 -14
- package/dist/components/p-3eba0eba.js.map +1 -0
- package/dist/components/{p-77ecbcc9.js → p-4b131051.js} +31 -12
- package/dist/components/p-4b131051.js.map +1 -0
- package/dist/components/{p-3f7ddc97.js → p-70b3b7b3.js} +2 -2
- package/dist/components/{p-3f7ddc97.js.map → p-70b3b7b3.js.map} +1 -1
- package/dist/components/{p-ba369e65.js → p-af3ba015.js} +1 -2
- package/dist/components/p-af3ba015.js.map +1 -0
- package/dist/components/{p-20621444.js → p-b57fbd6d.js} +42 -3
- package/dist/components/p-b57fbd6d.js.map +1 -0
- package/dist/components/pedido-finalizado.js +3 -4
- package/dist/components/pedido-finalizado.js.map +1 -1
- package/dist/components/phone-cancel-input.js.map +1 -1
- package/dist/components/pin-form.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/index.esm.js +1 -1
- package/dist/crmbonus-component-wake/p-08af385f.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-08af385f.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-09e26da2.entry.js +2 -0
- package/dist/crmbonus-component-wake/{p-136d44bb.entry.js.map → p-09e26da2.entry.js.map} +1 -1
- package/dist/crmbonus-component-wake/p-3eba0eba.js +2 -0
- package/dist/crmbonus-component-wake/p-3eba0eba.js.map +1 -0
- package/dist/crmbonus-component-wake/p-50d1cbaa.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-50d1cbaa.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-53b6a7e8.entry.js.map +1 -1
- package/dist/crmbonus-component-wake/p-5cfc2702.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-5cfc2702.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-68de3204.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-68de3204.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-73efceb1.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-73efceb1.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-ac32b78a.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-ac32b78a.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/{p-ba369e65.js → p-af3ba015.js} +1 -1
- package/dist/crmbonus-component-wake/p-af3ba015.js.map +1 -0
- package/dist/crmbonus-component-wake/p-b57fbd6d.js +2 -0
- package/dist/crmbonus-component-wake/p-b57fbd6d.js.map +1 -0
- package/dist/env.js +1 -1
- package/dist/env.js.map +1 -1
- package/dist/esm/{cart.helper-06aa7d0a.js → cart.helper-8be1bc35.js} +42 -3
- package/dist/esm/cart.helper-8be1bc35.js.map +1 -0
- package/dist/esm/countdown-timer.entry.js +41 -11
- package/dist/esm/countdown-timer.entry.js.map +1 -1
- package/dist/esm/crm-bonus-form.entry.js +1 -2
- package/dist/esm/crm-bonus-form.entry.js.map +1 -1
- package/dist/esm/crm-bonus-note.entry.js +27 -10
- package/dist/esm/crm-bonus-note.entry.js.map +1 -1
- package/dist/esm/crm-bonus.entry.js +10 -5
- package/dist/esm/crm-bonus.entry.js.map +1 -1
- package/dist/esm/crm-giftback-form_2.entry.js +26 -8
- package/dist/esm/crm-giftback-form_2.entry.js.map +1 -1
- package/dist/esm/crm-tooltip_4.entry.js +26 -13
- package/dist/esm/crm-tooltip_4.entry.js.map +1 -1
- package/dist/esm/crmbonus-component-wake.js +1 -1
- package/dist/{cjs/crmbonus.service-f0301a29.js → esm/crmbonus.service-5bc16be9.js} +37 -23
- package/dist/esm/crmbonus.service-5bc16be9.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pedido-finalizado.entry.js +3 -5
- package/dist/esm/pedido-finalizado.entry.js.map +1 -1
- package/dist/esm/phone-cancel-input.entry.js.map +1 -1
- package/dist/esm/{utils-d642b4db.js → utils-dec6df66.js} +1 -2
- package/dist/esm/utils-dec6df66.js.map +1 -0
- package/dist/types/components/countdown-timer/countdown-timer.d.ts +7 -0
- package/dist/types/components/crm-bonus/crm-bonus.d.ts +2 -0
- package/dist/types/components/giftback-form/giftback-form.d.ts +3 -0
- package/dist/types/components/giftback-form/subcomponents/giftback-info/giftback-info.d.ts +8 -1
- package/dist/types/components.d.ts +10 -0
- package/dist/types/dto/reserved-info.dto.d.ts +17 -0
- package/dist/types/helpers/cart.helper.d.ts +3 -0
- package/dist/types/helpers/payload.interface.d.ts +7 -0
- package/dist/types/home/darlison/Projects/Bycoders/crmbonus/crmbonus-component/.stencil/env.d.ts +1 -1
- package/dist/types/services/crmbonus.service.d.ts +3 -0
- package/package.json +1 -1
- package/dist/cjs/cart.helper-06f44f70.js.map +0 -1
- package/dist/cjs/crmbonus.service-f0301a29.js.map +0 -1
- package/dist/cjs/keys.storage-de7744aa.js +0 -17
- package/dist/cjs/keys.storage-de7744aa.js.map +0 -1
- package/dist/cjs/utils-e9413ee3.js.map +0 -1
- package/dist/components/p-20621444.js.map +0 -1
- package/dist/components/p-292a2414.js.map +0 -1
- package/dist/components/p-57e02602.js.map +0 -1
- package/dist/components/p-5a1ccb18.js +0 -62
- package/dist/components/p-5a1ccb18.js.map +0 -1
- package/dist/components/p-77ecbcc9.js.map +0 -1
- package/dist/components/p-ba369e65.js.map +0 -1
- package/dist/components/p-f9aeffc1.js +0 -12
- package/dist/components/p-f9aeffc1.js.map +0 -1
- package/dist/crmbonus-component-wake/p-136d44bb.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-20621444.js +0 -2
- package/dist/crmbonus-component-wake/p-20621444.js.map +0 -1
- package/dist/crmbonus-component-wake/p-292a2414.js +0 -2
- package/dist/crmbonus-component-wake/p-292a2414.js.map +0 -1
- package/dist/crmbonus-component-wake/p-2d5beecd.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-2d5beecd.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-4efcc675.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-4efcc675.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-53418d3b.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-53418d3b.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-7a45fdab.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-7a45fdab.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-8dfd0953.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-8dfd0953.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-ba369e65.js.map +0 -1
- package/dist/crmbonus-component-wake/p-c8e7a79f.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-c8e7a79f.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-f9aeffc1.js +0 -2
- package/dist/crmbonus-component-wake/p-f9aeffc1.js.map +0 -1
- package/dist/esm/cart.helper-06aa7d0a.js.map +0 -1
- package/dist/esm/crmbonus.service-930edf47.js.map +0 -1
- package/dist/esm/keys.storage-8c76fcd7.js +0 -12
- package/dist/esm/keys.storage-8c76fcd7.js.map +0 -1
- package/dist/esm/utils-d642b4db.js.map +0 -1
@@ -0,0 +1,2 @@
|
|
1
|
+
import{r as t,h as s}from"./p-8c362346.js";import{C as i,U as o}from"./p-3eba0eba.js";import{d as e,S as a}from"./p-ecc51430.js";import{i as n}from"./p-e8c19a64.js";import{g as r,a as c,C as h}from"./p-b57fbd6d.js";var d;(function(t){t["P"]="Promocao"})(d||(d={}));function l(t=[]){const s=[];for(const i of t){let t=u(i.Ajustes);s.push({sku:i.SKU,value:i.PrecoPor*i.Quantidade,productVariantId:i.ProdutoVarianteId.toString(),quantity:i.Quantidade,discount:t*-1})}return s}function u(t=[]){let s=0;for(const i of t){if(i.Tipo===d.P){s+=i.Valor}}return s}const f=".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 m=f;const p=class{constructor(s){t(this,s);this.crmBonusService=i.getInstance();this.cart=undefined;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=e;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(a.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 r();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()}))}))}));n.changeLanguage(n.language);await this.handleLoad();await this.loadSession();await this.loadConfigStore()}async loadConfigStore(){const[t,s]=await Promise.all([this.crmBonusService.getCustomization(this.cartWake.store.name),c(this.cartWake.id,this.cartWake.store.name)]);console.log("[infoBonus]",s);this.reservedInfo=s;if(t.keepStoreFrontStyle){this.styles=null}}async handleLoad(){try{this.cartWake=this.cart?new h(JSON.parse(this.cart)):await r();if(this.cartWake.user.id){this.customer=await this.crmBonusService.getCustomer(this.cartWake.user.id,this.cartWake.store.name);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.session=await this.crmBonusService.getToken(this.cartWake.store.name);setTimeout((()=>{this.loadSession()}),15e5)}async buildAndGetProducts(t){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));const[i={Valor:0}]=t.Ajustes.filter((t=>t.Tipo==="Formula"));if(t){e.push(Object.assign(Object.assign({},s),{PrecoPor:t.PrecoPor+i.Valor*-1,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(a.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(a.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(a.STEP_NAME);this.showModal=true}render(){return s("loading-container",{key:"20e05271df4405a6ca83fe154a3305ef74358004",loading:this.loading_reprocess},s("crm-giftback-form",{key:"c67857b2ea47c32fd5ca1419cc7cc5909f0bc310",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"]}};p.style=m;export{p as crm_bonus};
|
2
|
+
//# sourceMappingURL=p-50d1cbaa.entry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["AjustesTipoEnum","buildProductsByWake","productsWake","products","pw","discounts","getDiscount","Ajustes","push","sku","SKU","value","PrecoPor","Quantidade","productVariantId","ProdutoVarianteId","toString","quantity","discount","ajustes","Tipo","P","Valor","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","i18next","changeLanguage","language","handleLoad","loadSession","loadConfigStore","customization","infoBonus","Promise","all","getCustomization","store","getInfoBonusByCartIdAndStoreName","id","reservedInfo","keepStoreFrontStyle","styles","cart","CartWake","JSON","parse","user","customer","getCustomer","amount","canCancel","amountCancel","buildAndGetProducts","error","session","getToken","key","productsString","stringify","setItem","products_in_cache","product_cart","pro","filter","p","ajuste","aj","Object","assign","sendPin","_phone","replace","Number","sent","STEP_PIN","showModal","_b","_a","response","data","sendPinName","customerName","handleCloseModal","save","cancel","removeItem","handleSendPin","STEP_NAME","render","h","customStyles","style","position","ref","storeName","cartId","loadProducts","loadAll"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=shadow","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["export interface IProduct {\n productVariantId: string;\n sku: string;\n value: number;\n quantity: number;\n discount: number;\n}\n\nexport enum AjustesTipoEnum {\n P = \"Promocao\" \n}\n\nexport interface IAjustes {\n Tipo: AjustesTipoEnum;\n Valor: number;\n}\n\nexport interface IUser {\n id: number;\n}\n\nexport interface IStore {\n name: string;\n}\n\nexport interface IProductWake {\n ProdutoVarianteId: number;\n SKU: string;\n PrecoPor: number;\n Quantidade: number;\n Ajustes: IAjustes[];\n}\n\nexport interface ICustomer {\n birthDate: string;\n document: string;\n name: string;\n phone: string;\n}\n\nexport interface IProccesPinBonusDto {\n storeName: string;\n name: string;\n checkoutId: string;\n checkoutProducts: Array<IProduct>;\n storeId: string;\n userId: string;\n cellphone: number;\n pin: string;\n\n}\n\nexport interface IBonus {\n hasBonus: boolean;\n bonusBalance: number;\n totalBonus: number;\n minimumPurchase: number;\n bonusIds: string;\n firstValidityDate: string\n history: [\n {\n validityStart: string;\n validityEnd: string;\n value: number\n },\n {\n validityStart: string;\n validityEnd: string\n value: number\n }\n ]\n storeId: number;\n userId: number;\n cartId: string\n calculatedValue: number;\n totalValue: number\n}\n\n\nexport interface IReserveDTO {\n storeName: string;\n cartId: string;\n grossValue: number;\n redeemedBonus: number;\n ticket: string;\n storeId: string;\n userId: number;\n}","import { AjustesTipoEnum, IAjustes, IProduct, IProductWake } from \"../dto/validate.pin.bonus\";\n\nexport function buildProductsByWake(productsWake: Array<IProductWake> = []): Array<IProduct> {\n\n const products: Array<IProduct> = [];\n\n for ( const pw of productsWake ) {\n let discounts = getDiscount(pw.Ajustes)\n\n products.push(\n {\n sku: pw.SKU,\n value: (pw.PrecoPor * pw.Quantidade),\n productVariantId: pw.ProdutoVarianteId.toString(),\n quantity: pw.Quantidade,\n discount: (discounts * -1)\n }\n )\n }\n\n return products;\n}\n\nfunction getDiscount(ajustes: IAjustes[] = []) {\n \n let discounts = 0;\n \n for(const discount of ajustes) {\n if(discount.Tipo === AjustesTipoEnum.P) {\n discounts += discount.Valor;\n }\n }\n\n return discounts;\n}","\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n /* font-size: 20px; */\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n /* font-size: 14px; */\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, Method, Prop, State, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { defaultStyles, StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\nimport { getCart, getInfoBonusByCartIdAndStoreName } from '../../helpers/cart.helper';\nimport { CartWake } from '../../objectvalues/cart.wake';\nimport { USED_KEY } from '../../utils/keys.storage';\nimport { ReservedInfoDTO } from '../../dto/reserved-info.dto';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n assetsDirs: ['assets'],\n // scoped: true\n shadow: true\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @Prop() cart;\n\n @State() showModal: boolean = false;\n\n @State() cartWake: CartWake;\n\n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n @State() styles = defaultStyles;\n @State() reservedInfo: ReservedInfoDTO;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n\n try {\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async setloading() {\n this.loading_reprocess = !this.loading_reprocess;\n }\n\n @Method()\n async reprocess() {\n console.log(\"[CRMBONUS] - reprocess\")\n this.loading_reprocess = true\n\n try {\n\n const isUse = localStorage.getItem(USED_KEY);\n\n if (!isUse) return;\n\n this.cartWake = await getCart();\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n async componentWillLoad() {\n window.addEventListener('productRemovedFromCart', async () => {\n console.log('[CRMBONUS] - productRemovedFromCart');\n await this.reprocess()\n });\n\n window.addEventListener('productAddedToCart', async () => {\n console.log('[CRMBONUS] - productAddedToCart');\n await this.reprocess();\n });\n\n document.querySelectorAll('form').forEach((el) => {\n el.addEventListener(\"submit\", () => {\n console.log(\"[CRMBONUS] - Formulário está sendo submetido!\");\n // você pode marcar como \"em submissão\" aqui\n\n setTimeout(async () => {\n await this.reprocess();\n })\n });\n })\n\n\n i18next.changeLanguage(i18next.language);\n\n await this.handleLoad();\n\n await this.loadSession();\n await this.loadConfigStore()\n }\n\n async loadConfigStore() {\n\n const [customization, infoBonus] = await Promise.all([\n this.crmBonusService.getCustomization(this.cartWake.store.name),\n getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name)\n ]);\n\n console.log('[infoBonus]', infoBonus);\n\n this.reservedInfo = infoBonus;\n\n if (customization.keepStoreFrontStyle) {\n this.styles = null;\n }\n }\n\n async handleLoad() {\n try {\n\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\n\n if (this.cartWake.user.id) {\n this.customer = await this.crmBonusService.getCustomer(this.cartWake.user.id, this.cartWake.store.name);\n console.log('customer', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartWake.id);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n await this.buildAndGetProducts(this.cartWake.products);\n } catch (error) {\n console.log('info customer')\n }\n }\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.cartWake.store.name);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts(productsWake: IProductWake[]) {\n\n const key = `bc-products:${this.cartWake.id}`;\n\n const productsString = JSON.stringify(productsWake)\n\n localStorage.setItem(key, productsString);\n\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsWake) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === \"Formula\")\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor + (ajuste.Valor * -1),\n Quantidade: pro.Quantidade,\n Ajustes: pro.Ajustes\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return buildProductsByWake(this.cartWake.products);\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartWake.id, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartWake.id);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartWake.id);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n customStyles={this.styles}\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.cartWake.store.name}\n products={this.buildProducts()}\n cartId={this.cartWake.id}\n customer={this.customer}\n loadProducts={() => this.buildProducts()}\n loadAll={() => this.handleLoad()}\n reservedInfo={this.reservedInfo}\n\n />\n </loading-container>\n )\n }\n}\n"],"mappings":"uNAQA,IAAYA,GAAZ,SAAYA,GACRA,EAAA,eACH,EAFD,CAAYA,MAAe,K,SCNXC,EAAoBC,EAAoC,IAEpE,MAAMC,EAA4B,GAElC,IAAM,MAAMC,KAAMF,EAAe,CAC7B,IAAIG,EAAYC,EAAYF,EAAGG,SAE/BJ,EAASK,KACL,CACIC,IAAKL,EAAGM,IACRC,MAAQP,EAAGQ,SAAWR,EAAGS,WACzBC,iBAAkBV,EAAGW,kBAAkBC,WACvCC,SAAUb,EAAGS,WACbK,SAAWb,GAAa,G,CAKpC,OAAOF,CACX,CAEA,SAASG,EAAYa,EAAsB,IAEvC,IAAId,EAAY,EAEhB,IAAI,MAAMa,KAAYC,EAAS,CAC3B,GAAGD,EAASE,OAASpB,EAAgBqB,EAAG,CACpChB,GAAaa,EAASI,K,EAI9B,OAAOjB,CACX,CClCA,MAAMkB,EAAc,q8BACpB,MAAAC,EAAeD,E,MCmBFE,EAAQ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|
-
{"version":3,"names":["PhoneCancelInput","validatePhone","phone","this","phoneInputMask","getPhone","sendPin","render","h","key","class","initialValue","value","ref","disabled","loading","onClick","size","color"],"sources":["src/components/_crm-bonus-form/subcomponents/phone-cancel/phone.cancel.input.tsx"],"sourcesContent":["import { Component, Prop, h } from \"@stencil/core\";\n\n@Component({\n tag: 'phone-cancel-input',\n shadow: true\n})\nexport class PhoneCancelInput {\n\n private phoneInputMask: HTMLPhoneInputMaskElement;\n\n @Prop() sendPin: Function;\n @Prop() loading: boolean;\n @Prop() value: string;\n\n async validatePhone() {\n const phone = await this.phoneInputMask.getPhone();\n await this.sendPin(phone);\n }\n\n render() {\n return (\n <div class=\"form-container\">\n <phone-input-mask initialValue={`Valor aplicado R$ ${this.value}`} ref={ref => this.phoneInputMask = ref} disabled={true} />\n <button class={`btn btn-success btnCrm ${this.loading ? 'disabled' : ''} `} disabled={this.loading} onClick={() => this.validatePhone()}>\n {\n !this.loading ? \"Cancelar\" : <loading-spinner size=\"11px\" color=\"#fff\" />\n }\n </button>\n </div>\n )
|
1
|
+
{"version":3,"names":["PhoneCancelInput","validatePhone","phone","this","phoneInputMask","getPhone","sendPin","render","h","key","class","initialValue","value","ref","disabled","loading","onClick","size","color"],"sources":["src/components/_crm-bonus-form/subcomponents/phone-cancel/phone.cancel.input.tsx"],"sourcesContent":["import { Component, Prop, h } from \"@stencil/core\";\n\n@Component({\n tag: 'phone-cancel-input',\n shadow: true\n})\nexport class PhoneCancelInput {\n\n private phoneInputMask: HTMLPhoneInputMaskElement;\n\n @Prop() sendPin: Function;\n @Prop() loading: boolean;\n @Prop() value: string;\n\n async validatePhone() {\n const phone = await this.phoneInputMask.getPhone();\n await this.sendPin(phone);\n }\n\n render() {\n return (\n <div class=\"form-container\">\n <phone-input-mask initialValue={`Valor aplicado R$ ${this.value}`} ref={ref => this.phoneInputMask = ref} disabled={true} />\n <button class={`btn btn-success btnCrm ${this.loading ? 'disabled' : ''} `} disabled={this.loading} onClick={() => this.validatePhone()}>\n {\n !this.loading ? \"Cancelar\" : <loading-spinner size=\"11px\" color=\"#fff\" />\n }\n </button>\n </div>\n );\n }\n}"],"mappings":"iDAMaA,EAAgB,M,4FAQzB,mBAAMC,GACF,MAAMC,QAAcC,KAAKC,eAAeC,iBAClCF,KAAKG,QAAQJ,E,CAGvB,MAAAK,GACI,OACIC,EAAA,OAAAC,IAAA,2CAAKC,MAAM,kBACPF,EAAA,oBAAAC,IAAA,2CAAkBE,aAAc,qBAAqBR,KAAKS,QAASC,IAAKA,GAAOV,KAAKC,eAAiBS,EAAKC,SAAU,OACpHN,EAAA,UAAAC,IAAA,2CAAQC,MAAO,0BAA0BP,KAAKY,QAAU,WAAa,MAAOD,SAAUX,KAAKY,QAASC,QAAS,IAAMb,KAAKF,kBAE/GE,KAAKY,QAAU,WAAaP,EAAA,mBAAiBS,KAAK,OAAOC,MAAM,U","ignoreList":[]}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{r as t,h as e}from"./p-8c362346.js";const n=class{constructor(e){t(this,e);this.downtime=undefined;this.initialValue=0;this.dates={expiration:new Date,createdAt:new Date};this.seconds=0;this.minutes=undefined}componentWillLoad(){const t=this.buildTime();this.iniciarContador(t)}buildTime(){const t=localStorage.getItem("bc:time");if(t){return Number(t)}const e=new Date(this.dates.expiration);const n=new Date(this.dates.createdAt);const s=e.getTime()-n.getTime();if(s<=0){return s}const r=s/1e3;const i=Math.floor(r/60);const c=Math.floor(r%60);const o=i>=10?i:`0${i}`;const a=c>=10?c:`0${c}`;this.minutes=`${o}:${a}`;return r}iniciarContador(t){let e=t;const n=setInterval((()=>{const t=Math.floor(e/60);const s=(e%60).toFixed();let r=`${String(t).padStart(2,"0")}:${String(s).padStart(2,"0")}`;if(e<0){clearInterval(n);r="00:00";localStorage.removeItem("bc:time");return}e--;localStorage.setItem("bc:time",e);this.minutes=r}),1e3)}disconnectedCallback(){clearInterval(this.intervalId)}padLeft(){const t=this.seconds/60;const e=this.seconds%60;if(t<1)return`${e}s`;return`${parseInt(t.toString())}m ${e}s`}render(){return e("label",{key:"8fd06b21879dd42305970d6b29f1ed6bc93e5d69"},this.minutes)}};export{n as countdown_timer};
|
2
|
+
//# sourceMappingURL=p-5cfc2702.entry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["CountdownTimer","expiration","Date","createdAt","componentWillLoad","time","this","buildTime","iniciarContador","initial","localStorage","getItem","Number","dataFinal","dates","agora","diferencaMs","getTime","diferencaSegundos","minutos","Math","floor","segundos","m","s","minutes","params","segundosRestantes","intervalo","setInterval","minutosExibidos","segundosExibidos","toFixed","textContent","String","padStart","clearInterval","removeItem","setItem","disconnectedCallback","intervalId","padLeft","seconds","parseInt","toString","render","h","key"],"sources":["src/components/countdown-timer/countdown-timer.tsx"],"sourcesContent":["import { Component, h, Prop, State } from '@stencil/core';\n\n@Component({\n tag: 'countdown-timer',\n shadow: true,\n})\nexport class CountdownTimer {\n\n @Prop() downtime: () => void;\n @Prop() initialValue: number = 0;\n\n @Prop() dates = {\n expiration: new Date(),\n createdAt: new Date()\n };\n\n\n @State() seconds: number = 0;\n @State() minutes: string;\n\n private intervalId: NodeJS.Timer;\n\n componentWillLoad() {\n const time = this.buildTime();\n this.iniciarContador(time);\n }\n\n private buildTime(): number {\n\n const initial = localStorage.getItem(\"bc:time\");\n\n if (initial) {\n return Number(initial);\n }\n\n const dataFinal: Date = new Date(this.dates.expiration);\n const agora: Date = new Date(this.dates.createdAt);\n\n const diferencaMs = dataFinal.getTime() - agora.getTime();\n\n if (diferencaMs <= 0) {\n return diferencaMs;\n }\n\n const diferencaSegundos = diferencaMs / 1000; // Converter milissegundos para segundos\n const minutos = Math.floor(diferencaSegundos / 60); // Calcular minutos\n const segundos = Math.floor(diferencaSegundos % 60); // Calcular segundos restantes\n\n const m = minutos >= 10 ? minutos : `0${minutos}`\n const s = segundos >= 10 ? segundos : `0${segundos}`\n\n this.minutes = `${m}:${s}`;\n\n return diferencaSegundos;\n\n }\n\n iniciarContador(params) {\n let segundosRestantes = params;\n const intervalo = setInterval(() => {\n const minutosExibidos = Math.floor(segundosRestantes / 60);\n const segundosExibidos = (segundosRestantes % 60).toFixed();\n\n let textContent =\n `${String(minutosExibidos).padStart(2, '0')}:${String(segundosExibidos).padStart(2, '0')}`;\n\n if (segundosRestantes < 0) {\n clearInterval(intervalo);\n textContent = \"00:00\";\n localStorage.removeItem(\"bc:time\");\n return;\n }\n\n segundosRestantes--;\n\n localStorage.setItem(\"bc:time\", segundosRestantes);\n this.minutes = textContent\n }, 1000);\n }\n\n disconnectedCallback() {\n clearInterval(this.intervalId);\n }\n\n padLeft() {\n const minutes = this.seconds / 60;\n const seconds = this.seconds % 60;\n\n if (minutes < 1) return `${seconds}s`\n\n return `${parseInt(minutes.toString())}m ${seconds}s`\n }\n\n render() {\n return (\n <label>{this.minutes}</label>\n );\n }\n}\n"],"mappings":"iDAMaA,EAAc,M,mEAGQ,E,WAEf,CACZC,WAAY,IAAIC,KAChBC,UAAW,IAAID,M,aAIQ,E,uBAK3B,iBAAAE,GACI,MAAMC,EAAOC,KAAKC,YAClBD,KAAKE,gBAAgBH,E,CAGjB,SAAAE,GAEJ,MAAME,EAAUC,aAAaC,QAAQ,WAErC,GAAIF,EAAS,CACT,OAAOG,OAAOH,E,CAGlB,MAAMI,EAAkB,IAAIX,KAAKI,KAAKQ,MAAMb,YAC5C,MAAMc,EAAc,IAAIb,KAAKI,KAAKQ,MAAMX,WAExC,MAAMa,EAAcH,EAAUI,UAAYF,EAAME,UAEhD,GAAID,GAAe,EAAG,CAClB,OAAOA,C,CAGX,MAAME,EAAoBF,EAAc,IACxC,MAAMG,EAAUC,KAAKC,MAAMH,EAAoB,IAC/C,MAAMI,EAAWF,KAAKC,MAAMH,EAAoB,IAEhD,MAAMK,EAAIJ,GAAW,GAAKA,EAAU,IAAIA,IACxC,MAAMK,EAAIF,GAAY,GAAKA,EAAW,IAAIA,IAE1ChB,KAAKmB,QAAU,GAAGF,KAAKC,IAEvB,OAAON,C,CAIX,eAAAV,CAAgBkB,GACZ,IAAIC,EAAoBD,EACxB,MAAME,EAAYC,aAAY,KAC1B,MAAMC,EAAkBV,KAAKC,MAAMM,EAAoB,IACvD,MAAMI,GAAoBJ,EAAoB,IAAIK,UAElD,IAAIC,EACA,GAAGC,OAAOJ,GAAiBK,SAAS,EAAG,QAAQD,OAAOH,GAAkBI,SAAS,EAAG,OAExF,GAAIR,EAAoB,EAAG,CACvBS,cAAcR,GACdK,EAAc,QACdvB,aAAa2B,WAAW,WACxB,M,CAGJV,IAEAjB,aAAa4B,QAAQ,UAAWX,GAChCrB,KAAKmB,QAAUQ,CAAW,GAC3B,I,CAGP,oBAAAM,GACIH,cAAc9B,KAAKkC,W,CAGvB,OAAAC,GACI,MAAMhB,EAAUnB,KAAKoC,QAAU,GAC/B,MAAMA,EAAUpC,KAAKoC,QAAU,GAE/B,GAAIjB,EAAU,EAAG,MAAO,GAAGiB,KAE3B,MAAO,GAAGC,SAASlB,EAAQmB,gBAAgBF,I,CAG/C,MAAAG,GACI,OACIC,EAAA,SAAAC,IAAA,4CAAQzC,KAAKmB,Q","ignoreList":[]}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{r as t,h as i}from"./p-8c362346.js";import{C as s,g as e,U as a}from"./p-3eba0eba.js";import{S as o}from"./p-ecc51430.js";import{g as n}from"./p-1b441909.js";import{i as c}from"./p-e8c19a64.js";import{p as h}from"./p-b57fbd6d.js";const r="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";const d=r;const l=class{constructor(i){t(this,i);this.crmBonusService=s.getInstance();this.storeName=undefined;this.cartId=undefined;this.products=undefined;this.customer=undefined;this.loadProducts=undefined;this.loadAll=undefined;this.customStyles=undefined;this.reservedInfo=undefined;this.value=undefined;this.loading=false;this.message=undefined;this.phone=undefined;this.pinInfo=undefined;this.step=o.STEP_RESERVE;this.bonus=undefined;this.sucess="";this.error="";this.config=undefined;this.hasApplyBonus=false}async setStep(t){this.step=t}async processBonus(t=[],i=false){await this.loadProducts();this.sucess="";console.log("processBonus",[]);if(i){this.products=t}const s=localStorage.getItem(e(this.cartId));if(s){const t=JSON.parse(s);this.bonus=t;this.phone=t.phone;this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018")}}async handleSendPin(t){await this.loadAll();this.message="";if(!t){this.message="Informe seu telefone";return}this.phone=t;this.sendPin()}async componentWillLoad(){this.sucess="";this.error="";this.config=n(this.storeName);const t=this.getPhoneNumberAgain();if(t){this.step=o.STEP_PHONE;return}await this.processBonus()}getPhoneNumberAgain(){const t=localStorage.getItem(e(this.cartId));if(!t)return true;const i=JSON.parse(t);return!i.hasBonus}convertStringToNumber(){const t=this.phone.replace(/\D/g,"");return Number(t)}async sendPin(){var t,i,s;this.loading=true;this.message="";this.sucess="";this.error="";try{const i=this.convertStringToNumber();const s=localStorage.getItem(`bc:${this.phone}`);if(!s){this.pinInfo=await this.crmBonusService.sendPin(i,(t=this.customer)===null||t===void 0?void 0:t.name,this.storeName)}if(s){const t=JSON.parse(s);this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018");this.step=o.STEP_RESERVE}else{this.step=o.STEP_PIN}}catch(t){this.message=(s=(i=t===null||t===void 0?void 0:t.response)===null||i===void 0?void 0:i.data)===null||s===void 0?void 0:s.message}finally{this.loading=false}}changePhone(){this.sucess="";this.error="";this.step=o.STEP_PHONE}async validateBonus(t){var i,s,n;await this.loadProducts();const c=localStorage.getItem(a);if(c=="dontUse"){this.step=o.STEP_RESERVE;return}this.loading=true;this.sucess="";this.error="";const h={pin:t,cellphone:this.convertStringToNumber(),storeId:this.pinInfo.storeId.toString(),userId:this.pinInfo.userId.toString(),checkoutId:this.cartId,checkoutProducts:this.products,name:(i=this.customer)===null||i===void 0?void 0:i.name,storeName:this.storeName};try{this.bonus=await this.crmBonusService.validatePinBonus(h);if(!this.bonus.hasBonus){localStorage.setItem(e(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));this.loading=false;this.step=o.STEP_NO_BONUS;return}this.sucess="Código validado com sucesso!";localStorage.setItem(e(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));localStorage.setItem(`bc:${this.phone}`,JSON.stringify(this.bonus));localStorage.setItem(a,"use");localStorage.setItem(this.cartId,this.bonus.bonusBalance.toString());await this.updateMetadata();this.step=o.STEP_RESERVE}catch(t){const i=(n=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||n===void 0?void 0:n.response;if(i&&i.includes("Pin")){this.error="Código inválido!"}else{this.error=i;this.step=o.STEP_NO_BONUS}}finally{this.loading=false}}async updateMetadata(){try{if(!this.reservedInfo.isBonusProcessed)return;if(this.reservedInfo.isExpired()){console.log("[CRM:updateMetadata]");await h(this.storeName,this.cartId,{createdAt:Date.now(),url:window.location.href});localStorage.removeItem("bc:time")}}catch(t){console.error("[CRMBONUS:updateMetadata]: ",t)}}handleCancel(){this.cancel()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartId);localStorage.setItem(a,"dontUse");this.save(0)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async reserveApply(t){this.loading=true;this.message="";try{await this.reserve(t);this.save(t)}catch(t){this.message="ocorreu um error ao solicitar a aplicação do bonus! tente novamente";this.step=o.STEP_NO_BONUS;localStorage.removeItem(this.cartId)}finally{this.loading=false}}save(t){localStorage.setItem(this.cartId,t.toString())}async reserve(t){await this.crmBonusService.reserve({redeemedBonus:t,cartId:this.cartId,ticket:this.cartId,grossValue:Number(this.bonus.totalValue),storeName:this.storeName,storeId:this.bonus.storeId.toString(),userId:this.bonus.userId})}render(){return i("div",{key:"8e0415c740327afcfe26d3c9bffa31d5902275c5",class:"crm-container-form fbits-responsive-carrinho-desconto",style:this.customStyles},i("label",{key:"194c30eddf8b11f5f4e807543d4883c7d2142609",class:"crm-title"},this.config.giftbackTitle),this.step===o.STEP_PHONE&&i("phone-form",{key:"dcf325716e8c13c2aa5a6d9fcb8dd841a0e63828",value:this.customer.phone,config:this.config,loading:this.loading,handlerSubmit:t=>this.handleSendPin(t)}),this.step===o.STEP_PIN&&i("pin-form",{key:"2f978f70fadc4c96ac3f439a89092ac086378b8b",config:this.config,phone:this.phone,cancel:()=>this.changePhone(),resend:()=>this.sendPin(),validate:t=>this.validateBonus(t),loading:this.loading},this.sucess&&i("p",{key:"c4f628efffa8b160940ed727daf4bd75e3541e6e",class:"crm-message-info"},this.sucess),this.error&&i("p",{key:"923b9775109435b5b9bb54640672be066023fd2d",class:"crm-message-error"},this.error)),this.step===o.STEP_RESERVE&&i("giftback-info",{key:"2d9c19a37c3ff59518891dc512c4109c6b12c6b4",storeName:this.storeName,infoBonus:this.reservedInfo,config:this.config,loading:this.loading,cancel:()=>this.handleCancel(),bonus:this.bonus,reserve:()=>this.processBonus()}),this.step===o.STEP_NO_BONUS&&i("div",{key:"1fafa25f50b6a3ebbd8fbb53fc796419c2f7a45c",class:"container-message"},c.t("noGiftback",{storename:this.config.giftbackTitle})))}};l.style=d;const f=".loading-container{position:absolute;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center;z-index:1000;}.loading-spinner{width:50px;height:50px;border:5px solid rgba(255, 255, 255, 0.3);border-top:5px solid white;border-radius:50%;animation:spin 1s linear infinite;}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.relative-xy{position:relative}";const u=f;const m=class{constructor(i){t(this,i);this.loading=true}render(){return i("div",{key:"06a7a57acb07c91ca75d00dd42ca568ac708a3ef",class:"relative-xy"},this.loading&&i("div",{key:"6eee6954ce47b3a60cc9d3f599aa826c30e522db",class:"loading-container"},i("div",{key:"8747ac17ca30704d18739ccd1cf7d31fbbb05419",class:"loading-spinner"})),i("slot",{key:"32ffc7a17474372cf35fe7812fa4f193d00aa224"}))}};m.style=u;export{l as crm_giftback_form,m as loading_container};
|
2
|
+
//# sourceMappingURL=p-68de3204.entry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["giftbackFormCss","CrmGiftbackFormStyle0","CrmBonus","this","crmBonusService","CrmBonusService","getInstance","StepFormEnum","STEP_RESERVE","setStep","step","processBonus","products","hasNewProduct","loadProducts","sucess","console","log","_bonus","localStorage","getItem","getKeyReserveByCartId","cartId","bonus","JSON","parse","phone","pinInfo","storeId","userId","validateBonus","handleSendPin","loadAll","message","sendPin","componentWillLoad","error","config","getInfoCustomization","storeName","phoneAgain","getPhoneNumberAgain","STEP_PHONE","consulta_bonus","hasBonus","convertStringToNumber","_phone","replace","Number","loading","pinInfoCache","_a","customer","name","STEP_PIN","_c","_b","response","data","changePhone","pin","used_or_no","USED_KEY","payload","cellphone","toString","checkoutId","checkoutProducts","validatePinBonus","setItem","stringify","Object","assign","STEP_NO_BONUS","bonusBalance","updateMetadata","_error","includes","reservedInfo","isBonusProcessed","isExpired","persisteMetadata","createdAt","Date","now","url","window","location","href","removeItem","handleCancel","cancel","save","reserveApply","amount","reserve","redeemedBonus","ticket","grossValue","totalValue","render","h","key","class","style","customStyles","giftbackTitle","value","handlerSubmit","resend","validate","infoBonus","i18next","t","storename","loadingContainerCss","LoadingContainerStyle0","LoadingContainer"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx","src/components/loading-container/loading-container.css?tag=loading-container","src/components/loading-container/loading-container.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n /* font-size: var(--crmfont-sizebodymd); */\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n /* font-size: 14px; */\n font-size: .875rem;\n line-height: 1.25rem;\n \n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n /* font-size: 16px; */\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n /* font-size: 12px; */\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n /* font-size: 12px; */\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { USED_KEY, getKeyReserveByCartId } from \"../../utils/keys.storage\";\nimport { persisteMetadata } from \"../../helpers/cart.helper\";\nimport { ReservedInfoDTO } from \"../../dto/reserved-info.dto\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css',\n shadow: false\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n @Prop({ attribute: 'storename' }) storeName;\n @Prop() cartId;\n @Prop() products: Array<IProduct>;\n @Prop() customer: ICustomer;\n @Prop() loadProducts: () => void;\n @Prop() loadAll: () => void;\n\n @Prop() customStyles;\n @Prop() reservedInfo: ReservedInfoDTO;\n\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_RESERVE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n @State() hasApplyBonus = false;\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus(products: IProduct[] = [], hasNewProduct = false) {\n await this.loadProducts()\n this.sucess = \"\";\n\n console.log('processBonus', [])\n if (hasNewProduct) {\n this.products = products;\n }\n\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.bonus = bonus;\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n //this.step = StepFormEnum.STEP_RESERVE;\n\n }\n }\n\n async handleSendPin(phone: string) {\n await this.loadAll()\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin();\n }\n\n async componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n const phoneAgain = this.getPhoneNumberAgain();\n\n if (phoneAgain) {\n this.step = StepFormEnum.STEP_PHONE;\n return\n }\n\n await this.processBonus();\n\n }\n\n getPhoneNumberAgain() {\n const consulta_bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (!consulta_bonus) return true;\n\n const bonus = JSON.parse(consulta_bonus);\n\n return !bonus.hasBonus;\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber();\n const pinInfoCache = localStorage.getItem(`bc:${this.phone}`);\n\n if (!pinInfoCache) {\n this.pinInfo = await this.crmBonusService.sendPin(_phone, this.customer?.name, this.storeName);\n }\n\n if (pinInfoCache) {\n\n const bonus = JSON.parse(pinInfoCache);\n\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n this.step = StepFormEnum.STEP_RESERVE;\n } else {\n this.step = StepFormEnum.STEP_PIN;\n }\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n await this.loadProducts();\n\n const used_or_no = localStorage.getItem(USED_KEY);\n\n if (used_or_no == \"dontUse\") {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.convertStringToNumber(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.userId.toString(),\n checkoutId: this.cartId,\n checkoutProducts: this.products,\n name: this.customer?.name,\n storeName: this.storeName\n }\n\n try {\n this.bonus = await this.crmBonusService.validatePinBonus(payload);\n\n if (!this.bonus.hasBonus) {\n\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n localStorage.setItem(`bc:${this.phone}`, JSON.stringify(this.bonus));\n\n localStorage.setItem(USED_KEY, \"use\");\n localStorage.setItem(this.cartId, this.bonus.bonusBalance.toString());\n\n await this.updateMetadata();\n\n this.step = StepFormEnum.STEP_RESERVE;\n\n } catch (error) {\n const _error: string = error?.response?.data?.response;\n\n if (_error && _error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n } finally {\n this.loading = false;\n }\n }\n\n private async updateMetadata() {\n try {\n\n if(!this.reservedInfo.isBonusProcessed) return;\n\n if (this.reservedInfo.isExpired()) {\n console.log('[CRM:updateMetadata]')\n await persisteMetadata(this.storeName, this.cartId, {\n createdAt: Date.now(),\n url: window.location.href\n });\n\n localStorage.removeItem(\"bc:time\");\n }\n } catch (error) {\n console.error('[CRMBONUS:updateMetadata]: ', error);\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n\n localStorage.setItem(USED_KEY, \"dontUse\");\n this.save(0)\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\n await this.crmBonusService.reserve({\n redeemedBonus: amount,\n cartId: this.cartId,\n ticket: this.cartId,\n grossValue: Number(this.bonus.totalValue),\n storeName: this.storeName,\n storeId: this.bonus.storeId.toString(),\n userId: this.bonus.userId\n });\n }\n\n render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" style={this.customStyles} >\n\n {/* <loading-container /> */}\n\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n storeName={this.storeName}\n infoBonus={this.reservedInfo}\n config={this.config}\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={() => this.processBonus()}\n />\n }\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}","/* Estilo para centralizar o container do loading */\n.loading-container {\n position: absolute;\n /* Fixa o loading na tela */\n top: 0;\n left: 0;\n width: 100%;\n /* Tamanho total da tela */\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n /* Fundo semitransparente */\n display: flex;\n /* Centraliza o conteúdo */\n justify-content: center;\n align-items: center;\n z-index: 1000;\n /* Coloca o loading acima de outros elementos */\n}\n\n/* Estilo do spinner (círculo giratório) */\n.loading-spinner {\n width: 50px;\n height: 50px;\n border: 5px solid rgba(255, 255, 255, 0.3);\n /* Borda semitransparente */\n border-top: 5px solid white;\n /* Borda que será animada */\n border-radius: 50%;\n /* Faz o círculo */\n animation: spin 1s linear infinite;\n /* Gira continuamente */\n}\n\n/* Keyframes para a animação de rotação */\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.relative-xy {\n position: relative;\n}","import { Component, Prop, h } from \"@stencil/core\";\n\n@Component({\n tag: 'loading-container',\n styleUrl: 'loading-container.css'\n})\nexport class LoadingContainer {\n\n @Prop() loading: boolean = true;\n\n render() {\n return (\n <div class=\"relative-xy\">\n {\n this.loading && (\n <div class=\"loading-container\">\n <div class=\"loading-spinner\">\n\n </div>\n \n </div>\n )\n }\n <slot></slot>\n </div>\n )\n }\n}"],"mappings":"6OAAA,MAAMA,EAAkB,m3BACxB,MAAAC,EAAeD,E,MCgBFE,EAAQ,M,yBAGXC,KAAAC,gBAAmCC,EAAgBC,c,4OAa/B,M,6EAIEC,EAAaC,a,iCAGjB,G,WACD,G,yCAEA,K,CAGzB,aAAMC,CAAQC,GACZP,KAAKO,KAAOA,C,CAId,kBAAMC,CAAaC,EAAuB,GAAIC,EAAgB,aACtDV,KAAKW,eACXX,KAAKY,OAAS,GAEdC,QAAQC,IAAI,eAAgB,IAC5B,GAAIJ,EAAe,CACjBV,KAAKS,SAAWA,C,CAGlB,MAAMM,EAASC,aAAaC,QAAQC,EAAsBlB,KAAKmB,SAE/D,GAAIJ,EAAQ,CAEV,MAAMK,EAAQC,KAAKC,MAAMP,GAEzBf,KAAKoB,MAAQA,EAEbpB,KAAKuB,MAAQH,EAAMG,MACnBvB,KAAKwB,QAAU,CACbC,QAASL,EAAMK,QACfC,OAAQN,EAAMM,cAGV1B,KAAK2B,cAAc,O,EAM7B,mBAAMC,CAAcL,SACZvB,KAAK6B,UACX7B,KAAK8B,QA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OpB,KAAKoB,MACZwE,QAAS,IAAM5F,KAAKQ,iBAKtBR,KAAKO,OAASH,EAAakE,eAEzB4B,EAAA,OAAAC,IAAA,2CAAKC,MAAM,qBACRS,EAAQC,EAAE,aAAc,CAAEC,UAAW/G,KAAKkC,OAAOqE,iB,aC9VhE,MAAMS,EAAsB,+bAC5B,MAAAC,EAAeD,E,MCKFE,EAAgB,M,sCAEE,I,CAE3B,MAAAjB,GACI,OACIC,EAAA,OAAAC,IAAA,2CAAKC,MAAM,eAEHpG,KAAK8C,SACDoD,EAAA,OAAAC,IAAA,2CAAKC,MAAM,qBACPF,EAAA,OAAAC,IAAA,2CAAKC,MAAM,qBAOvBF,EAAA,QAAAC,IAAA,6C","ignoreList":[]}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{r as e,h as i,H as t}from"./p-8c362346.js";import{i as n}from"./p-e8c19a64.js";import{U as o}from"./p-3eba0eba.js";import{d as a,a as c}from"./p-af3ba015.js";import{p as r}from"./p-b57fbd6d.js";const d="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xMiAxNy43NUMxMi40MTQyIDE3Ljc1IDEyLjc1IDE3LjQxNDIgMTIuNzUgMTdWMTFDMTIuNzUgMTAuNTg1OCAxMi40MTQyIDEwLjI1IDEyIDEwLjI1QzExLjU4NTggMTAuMjUgMTEuMjUgMTAuNTg1OCAxMS4yNSAxMVYxN0MxMS4yNSAxNy40MTQyIDExLjU4NTggMTcuNzUgMTIgMTcuNzVaIiBmaWxsPSIjMUMyNzRDIi8+DQo8cGF0aCBkPSJNMTIgN0MxMi41NTIzIDcgMTMgNy40NDc3MiAxMyA4QzEzIDguNTUyMjggMTIuNTUyMyA5IDEyIDlDMTEuNDQ3NyA5IDExIDguNTUyMjggMTEgOEMxMSA3LjQ0NzcyIDExLjQ0NzcgNyAxMiA3WiIgZmlsbD0iIzFDMjc0QyIvPg0KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xLjI1IDEyQzEuMjUgNi4wNjI5NCA2LjA2Mjk0IDEuMjUgMTIgMS4yNUMxNy45MzcxIDEuMjUgMjIuNzUgNi4wNjI5NCAyMi43NSAxMkMyMi43NSAxNy45MzcxIDE3LjkzNzEgMjIuNzUgMTIgMjIuNzVDNi4wNjI5NCAyMi43NSAxLjI1IDE3LjkzNzEgMS4yNSAxMlpNMTIgMi43NUM2Ljg5MTM3IDIuNzUgMi43NSA2Ljg5MTM3IDIuNzUgMTJDMi43NSAxNy4xMDg2IDYuODkxMzcgMjEuMjUgMTIgMjEuMjVDMTcuMTA4NiAyMS4yNSAyMS4yNSAxNy4xMDg2IDIxLjI1IDEyQzIxLjI1IDYuODkxMzcgMTcuMTA4NiAyLjc1IDEyIDIuNzVaIiBmaWxsPSIjMUMyNzRDIi8+DQo8L3N2Zz4=";const s=".crm-tooltip-container {\n display: flex;\n\n & img {\n width: 16px;\n margin-left: 3px;\n position: relative;\n }\n}\n\n.crm-tooltip {\n position: relative;\n display: inline-block;\n}\n\n.crm-tooltip .tooltiptext {\n visibility: hidden;\n background-color: black;\n color: #fff;\n text-align: center;\n padding: 8px 12px;\n border-radius: 0px;\n position: absolute;\n z-index: 1;\n min-width: 271px;\n top: 100%;\n left: 50%;\n margin-left: -238px;\n}\n\n@container (max-width: 410px) {\n .crm-tooltip .tooltiptext {\n margin-left: -14px;\n }\n\n .crm-tooltip #crm-role-description {\n margin-left: -151px;\n }\n}\n\n@container (max-width: 250px) {\n .crm-tooltip .tooltiptext {\n margin-left: -201px;\n }\n}\n\n.crm-tooltip:hover .tooltiptext {\n visibility: visible;\n}";const l=s;const p=class{constructor(i){e(this,i);this.text=undefined;this.identity=undefined}render(){return i("div",{key:"3582af9cc751c10b237ab086a711ecaaedaded27",class:"crm-tooltip-container crm-tooltip"},i("img",{key:"4f8c3e3da55ec000759864d8facde5002c759426",src:d}),i("span",{key:"7f1f591d486d51c31adc5c383dcbbcce6732f765",id:this.identity,class:"tooltiptext"},this.text))}};p.style=l;const f=":host{--text-color:#6D6D5F}.giftback-container{display:flex;flex-direction:column;gap:14px}h3{margin-bottom:8px;color:#333}.container-description{display:flex;align-items:center;gap:5px;margin:0 0 10px 0}.container-description p{font-weight:400;margin:0px}p{color:#000}.value-display h2{color:#6D6D5F;margin:16px 0}input[type='range']{width:100%;margin:12px 0;-webkit-appearance:none;background:#ddd;height:4px;border-radius:4px;outline:none;padding:3px 0px 3px 3px}input[type=\"range\"]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;background:rgb(109, 109, 95);border-radius:50%;cursor:pointer}.options{margin:0px 0;display:flex;gap:10px;flex-direction:column}.options label{display:flex;margin:0px 0;color:#333;align-items:center}.options input[type='radio']{margin-right:8px;height:16px;width:16px}.options input[type='radio']{appearance:none;-webkit-appearance:none;margin-right:8px;width:16px;height:16px;border:2px solid #ddd;border-radius:50%;background-color:#fff;cursor:pointer;transition:all 0.3s;padding:0px}.options input[type='radio']:checked{border-color:#000;background-color:#FAFAFA;border:4px solid #000}.info-box{background-color:#f9f9f9;border:1px solid #e0e0e0;border-radius:4px;padding:8px;color:#262626;line-height:20px}.info-icon{cursor:pointer;color:#888}h3{margin-bottom:8px;color:#333}.slider-wrapper{position:relative;margin:21px 0px 0px 0px}.slider{width:100%;-webkit-appearance:none;background:#ddd;height:4px;border-radius:2px;outline:none}.slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--text-color);border-radius:50%;cursor:pointer}.slider-value{position:absolute;top:-30px;font-weight:700;color:var(--text-color);transform:translateX(-50%);white-space:nowrap;}.options-option{display:flex}";const h=f;const b=class{constructor(i){e(this,i);this.usedValue=0;this.selectedOption="none";this.loading=false;this.bonus={totalBonus:0,cartId:"",minimumPurchase:0,bonusBalance:0,calculatedValue:0,firstValidityDate:"",totalValue:0};this.reserve=undefined;this.cancel=undefined;this.config=undefined;this.infoBonus=undefined;this.storeName=undefined;this.sliderPosition=0;this.sliderValuePosition=0;this.loadingTime=false}changedBonus(){this.updateBonus()}updateBonus(){this.usedValue=this.bonus.bonusBalance;this.buildPositionSlider(0,this.bonus.totalBonus)}componentWillLoad(){this.updateBonus();this.selectedOption=localStorage.getItem(o)}handleSliderChange(e){const i=e.target;this.usedValue=parseFloat(i.value);this.buildPositionSlider(parseFloat(i.min),parseFloat(i.max))}componentDidLoad(){var e;if(this.bonus){this._refIinputRange.value=(e=this.bonus)===null||e===void 0?void 0:e.bonusBalance.toString()}}buildPositionSlider(e,i){const t=i*.1;const n=(this.usedValue-e)/(i-e)*100;this.sliderPosition=n;this.sliderValuePosition=n+(this.usedValue<=t?10:0)}async handleOptionChange(e){this.selectedOption=e;localStorage.setItem(o,e);localStorage.removeItem("bc:time-allow");switch(this.selectedOption){case"use":await this.reserve(this.usedValue);break;case"dontUse":await this.cancel();break}}showTime(){if(!this.infoBonus)return false;return!this.infoBonus.isExpired()}getTime(){var e,i;const t=new Date((i=(e=this.infoBonus)===null||e===void 0?void 0:e.metadata)===null||i===void 0?void 0:i.createdAt);const n=new Date(t);n.setMinutes(n.getMinutes()+6);return{createdAt:t,expiration:n}}async downtime(){await r(this.storeName,this.bonus.cartId,{createdAt:null})}render(){var e,t;const o=this.bonus.minimumPurchase-this.bonus.totalValue;const r=n.t("giftDescription",{amount:`${this.bonus.totalBonus.toFixed(2).replace(".",",")}`,custom_name:"Giftback"});const d=a(o);return i("div",{key:"a86a8d4456ffda158bc75e6e43147503bba77da3",class:"giftback-container"},i("div",{key:"c891c439db4c2da4ccfcab92df28293e7a009f3f",class:"container-description"},i("p",{key:"be590b46b37b2b021c97bda3cdc30f6c236bd0e9",innerHTML:r}),i("crm-tooltip",{key:"8ef31c5e27dc9b83366e8cd99d0a00035db4744e",identity:"crm-role-description",text:n.t("labelUseGiftback",{minimumPurchase:this.bonus.minimumPurchase,expírationDate:c(this.bonus.firstValidityDate)})})),i("div",{key:"9b679e11adc1aa626b547e32dc5e35bbc0202b75",class:"slider-wrapper"},i("div",{key:"df732d13dadc8d58ecaad022aea3b004640fee51",class:"slider-value",style:{left:`calc(${this.sliderValuePosition}% - 20px)`}},"R$ ",this.usedValue.toFixed(2).replace(".",",")),i("input",{key:"22f06e0778eae76caf456577703161ecc5b44541",ref:e=>this._refIinputRange=e,id:"position_value_id",disabled:true,type:"range",min:"0",max:this.bonus.totalBonus,value:this.usedValue,class:"slider",step:"0.01",onInput:e=>this.handleSliderChange(e),style:{background:`linear-gradient(to right, #6D6D5F ${this.sliderPosition}%, #ddd ${this.sliderPosition}%)`}})),d.isComplete&&i("p",{key:"5e3a41f04ac519093ae792427313a088e3c2714a"},n.t("maxAmount")),!d.isComplete&&i("div",{key:"22ffa8e7ec5f896569398f4426dad6f805867923",class:"container-description"},i("p",{key:"f75c135130cfc1a5a76fe49d6da9219bbbb9c6ea"},"Adicione ",i("strong",{key:"dd5bdae84c8fb91ea3baeea3f85ba511c3b0f1b7"},"R$ ",o<0?"0,00":o.toFixed(2).replace(".",","))," ao carrinho para atingir o valor máximo!"),i("crm-tooltip",{key:"c91ff2664fbfc6bf20253764d374a82e5461fd3c",identity:"crm-max-description",text:n.t("labelamountPartial")})),i("div",{key:"939eb1983893ad1946f620fe13274e4b7b3e556b",class:"options"},i("div",{key:"3a65941099e08476365b0f60c59698644a7816c0",class:"options-option"},i("input",{key:"5f5c36f87a81edfe4ec6602bc14c0a7d9ef0c7ab",disabled:this.showTime(),type:"radio",name:"giftbackOption",value:"use",checked:this.selectedOption==="use",onChange:()=>this.handleOptionChange("use")}),i("p",{key:"cd94d13c30fb8ac308627081d06455860c333c98"},"Usar o meu ",(e=this.config)===null||e===void 0?void 0:e.giftbackTitle)),i("div",{key:"0a9229b7ea36a31551c7cefb49cbfd435ce93f9c",class:"options-option"},i("input",{key:"a8a195e042b1b93beddfa25615d85fc6a248f7a0",disabled:this.showTime(),type:"radio",name:"giftbackOption",value:"dontUse",checked:this.selectedOption==="dontUse",onChange:()=>this.handleOptionChange("dontUse")}),i("p",{key:"5bb2d69d189e19e55e7552a9807fe82c57514c79"},"Não usar o meu ",(t=this.config)===null||t===void 0?void 0:t.giftbackTitle))),this.showTime()&&i("div",{key:"24f91ae971733aa15a61b0bca6089006bab90855",class:"info-box"},"Após ",i("countdown-timer",{key:"52393e979fc45ac4eaf2ca9757f0f7c87d8efa0e",dates:this.getTime(),downtime:()=>{this.loadingTime=true}}),", você poderá alterar sua escolha de usar ou não o Giftback."),i("div",{key:"ebdcfafb89fe697a1f845f7a864e96788a3da852",class:"info-box"},"O Giftback será aplicado na próxima etapa."))}static get watchers(){return{bonus:["changedBonus"]}}};b.style=h;const g="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";const x=g;const u=class{constructor(i){e(this,i);this.value=undefined;this.loading=undefined;this.handlerSubmit=undefined;this.config=undefined}async handlePhone(){const e=await this.phoneInputMask.getPhone();await this.handlerSubmit(e)}render(){var e;return i(t,{key:"33cfa4dfdd805c81743db679267b82a63fa753e7",class:"crm-phone-form"},i("p",{key:"0ef790c33e48c646898feb1a5cdb98cea7e5be43",class:"crm-subtitle"},"Digite o seu celular para verificar se há desconto disponível nessa compra:"),i("phone-input-mask",{key:"46eb2b3b3741ffce1ff7d28b39c6964180919e1e",initialValue:this.value,ref:e=>this.phoneInputMask=e}),i("crm-button",{key:"9b75600c3c8e0352eab7778f5f281b71035383d8",txtBtn:((e=this.config)===null||e===void 0?void 0:e.btnApplyBonusLabel)||"Avançar",loading:this.loading,handleClick:()=>this.handlePhone()}))}};u.style=x;const m=":host{display:block}.form-container-pin{display:flex;flex-direction:column;align-items:center}.pin-container{display:flex;justify-content:start;gap:10px}.pin-container input{width:100%;height:48px;text-align:center;border:1px solid #ccc;border-radius:5px}button{padding:10px 20px;background-color:#ddd;border:none;border-radius:5px;cursor:pointer}.success{color:green;margin-top:10px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;border-radius:10px;padding:15px;min-height:30px;min-width:120px;cursor:pointer}.button-cancel{top:50%;background-color:#ffffff;color:#1e1c1c;border:1px solid gray;border-radius:10px;padding:10px;min-height:30px;min-width:120px;cursor:pointer}.crm-description{width:100%;display:flex;gap:9px;flex-wrap:wrap}.crm-description a{font-weight:bold;cursor:pointer;text-decoration:underline}.crm-description div{display:flex;gap:5px}";const y=m;const k="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";const M=k;const I=class{constructor(i){e(this,i);this.validate=undefined;this.cancel=undefined;this.resend=undefined;this.sent=undefined;this.loading=false;this.phone=undefined;this.config=undefined;this.pin=["","","",""];this.isVerified=false;this.canResend=false}componentWillLoad(){this.canResend=false}handleInput(e,i){const t=e.target;const n=t.value.slice(0,1);this.pin[i]=n;if(n&&i<this.pin.length-1){const e=t.nextElementSibling;e===null||e===void 0?void 0:e.focus()}this.pin=[...this.pin]}validatePin(){this.validate(this.pin.join(""))}verifyPin(){const e=this.pin.join("");if(e==="9999"){this.isVerified=true}}handleTimeout(){this.canResend=true}async handleResend(){await this.resend();this.canResend=false;this.pin=["","","",""]}render(){var e;return i("div",{key:"15aa6a8fe4e0fa3ea1a35e68b7853a4ca392899c",class:"crm-phone-form"},i("label",{key:"83d48a38bc6cbbdbd391d7253a1e1fc3d01c44d2",class:"crm-subtitle"},n.t("pin-sutitle")," ",i("strong",{key:"e88a16f28032afb4746dc8f97e83e2794b75f3fd"},"+55 ",this.phone)),i("div",{key:"516969313ac099dfa1e4761784ef5f4e5c5225c3",class:"pin-container"},this.pin.map(((e,t)=>i("input",{type:"text",maxLength:1,value:this.pin[t],onInput:e=>this.handleInput(e,t)})))),i("slot",{key:"b0ffbe2329a9e010766f3cf8e52943ebdbfe101e"}),i("p",{key:"91e9372e69f32ce93806ca194bf6347cd0a0a3ce",class:"crm-description"}," Não recebeu?",!this.canResend&&i("label",{key:"ed22df22e0498434ff3d6a187387aa8ddc48f6ef"}," Reenviar em ",i("countdown-timer",{key:"a81630d82997e9b74ceb08b52cd818d0aa81f00e",initialValue:30,downtime:()=>this.handleTimeout()})," "),this.canResend&&i("div",{key:"417c6dc13b0e87993c8dbb71d9e263678e1025d8"},i("a",{key:"9832f3c85b503e820d2452d76dc60a008ec250c9",onClick:()=>this.handleResend()},"Reenviar"),i("a",{key:"9c6ff0ab7b1e0f46235eed0a2e0c2142f3bd41f6",onClick:()=>this.cancel()},"Trocar número"))),i("crm-button",{key:"f347d33b491d5dae491ce5ed77e7f20734cfa76b",txtBtn:((e=this.config)===null||e===void 0?void 0:e.btnApplyBonusLabel)||"Avançar",loading:this.loading,handleClick:()=>this.validatePin()}))}};I.style=y+M;export{p as crm_tooltip,b as giftback_info,u as phone_form,I as pin_form};
|
2
|
+
//# sourceMappingURL=p-73efceb1.entry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["infoCircleSvgrepoComSvg","crmTooltipCss","CrmTooltipStyle0","Tooltip","render","h","key","class","src","info","id","this","identity","text","giftbackInfoCss","GiftbackInfoStyle0","GiftbackInfo","totalBonus","cartId","minimumPurchase","bonusBalance","calculatedValue","firstValidityDate","totalValue","changedBonus","updateBonus","usedValue","bonus","buildPositionSlider","componentWillLoad","selectedOption","localStorage","getItem","USED_KEY","handleSliderChange","event","input","target","parseFloat","value","min","max","componentDidLoad","_refIinputRange","_a","toString","percentage_init","percentage","sliderPosition","sliderValuePosition","handleOptionChange","option","setItem","removeItem","reserve","cancel","showTime","infoBonus","isExpired","getTime","createdAt","Date","_b","metadata","expiration","setMinutes","getMinutes","downtime","persisteMetadata","storeName","remainingGiftback","translateDescription","i18next","t","amount","toFixed","replace","custom_name","limit","defineLimit","innerHTML","formatDateToBr","style","left","ref","disabled","type","step","onInput","background","isComplete","name","checked","onChange","config","giftbackTitle","dates","loadingTime","giftbackFormCss","PhoneFormStyle0","PhoneForm","handlePhone","phone","phoneInputMask","getPhone","handlerSubmit","Host","initialValue","txtBtn","btnApplyBonusLabel","loading","handleClick","pinFormCss","PinFormStyle0","PinFormStyle1","GiftbackPin","canResend","handleInput","index","slice","pin","length","nextInput","nextElementSibling","focus","validatePin","validate","join","verifyPin","pinCode","isVerified","handleTimeout","handleResend","resend","map","_","maxLength","onClick"],"sources":["src/assets/svg/info-circle-svgrepo-com.svg","src/components/tooltip/crm-tooltip.css?tag=crm-tooltip","src/components/tooltip/tooltip.tsx","src/components/giftback-form/subcomponents/giftback-info/giftback-info.css?tag=giftback-info","src/components/giftback-form/subcomponents/giftback-info/giftback-info.tsx","src/components/giftback-form/giftback-form.css?tag=phone-form","src/components/giftback-form/subcomponents/phone-form/phone-form.tsx","src/components/giftback-form/subcomponents/pin-form/pin-form.css?tag=pin-form&encapsulation=shadow","src/components/giftback-form/giftback-form.css?tag=pin-form&encapsulation=shadow","src/components/giftback-form/subcomponents/pin-form/pin-form.tsx"],"sourcesContent":["<?xml version=\"1.0\" encoding=\"utf-8\"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->\r\n<svg width=\"800px\" height=\"800px\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<path d=\"M12 17.75C12.4142 17.75 12.75 17.4142 12.75 17V11C12.75 10.5858 12.4142 10.25 12 10.25C11.5858 10.25 11.25 10.5858 11.25 11V17C11.25 17.4142 11.5858 17.75 12 17.75Z\" fill=\"#1C274C\"/>\r\n<path d=\"M12 7C12.5523 7 13 7.44772 13 8C13 8.55228 12.5523 9 12 9C11.4477 9 11 8.55228 11 8C11 7.44772 11.4477 7 12 7Z\" fill=\"#1C274C\"/>\r\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M1.25 12C1.25 6.06294 6.06294 1.25 12 1.25C17.9371 1.25 22.75 6.06294 22.75 12C22.75 17.9371 17.9371 22.75 12 22.75C6.06294 22.75 1.25 17.9371 1.25 12ZM12 2.75C6.89137 2.75 2.75 6.89137 2.75 12C2.75 17.1086 6.89137 21.25 12 21.25C17.1086 21.25 21.25 17.1086 21.25 12C21.25 6.89137 17.1086 2.75 12 2.75Z\" fill=\"#1C274C\"/>\r\n</svg>",".crm-tooltip-container {\n display: flex;\n\n & img {\n width: 16px;\n margin-left: 3px;\n position: relative;\n }\n}\n\n.crm-tooltip {\n position: relative;\n display: inline-block;\n}\n\n.crm-tooltip .tooltiptext {\n visibility: hidden;\n background-color: black;\n color: #fff;\n text-align: center;\n padding: 8px 12px;\n border-radius: 0px;\n position: absolute;\n z-index: 1;\n min-width: 271px;\n top: 100%;\n left: 50%;\n margin-left: -238px;\n}\n\n@container (max-width: 410px) {\n .crm-tooltip .tooltiptext {\n margin-left: -14px;\n }\n\n .crm-tooltip #crm-role-description {\n margin-left: -151px;\n }\n}\n\n@container (max-width: 250px) {\n .crm-tooltip .tooltiptext {\n margin-left: -201px;\n }\n}\n\n.crm-tooltip:hover .tooltiptext {\n visibility: visible;\n}","import { Component, h, Prop } from \"@stencil/core\";\nimport info from '../../assets/svg/info-circle-svgrepo-com.svg';\n\n\n@Component({\n tag: 'crm-tooltip',\n styleUrl: 'crm-tooltip.css'\n})\nexport class Tooltip {\n\n @Prop() text: string;\n @Prop() identity: string;\n\n render() {\n return (\n <div class=\"crm-tooltip-container crm-tooltip\">\n <img src={info} />\n <span id={this.identity} class=\"tooltiptext\">{this.text}</span>\n </div>\n );\n }\n}",":host {\n --text-color: #6D6D5F\n}\n\n.giftback-container {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\nh3 {\n /* font-size: 1.2rem; */\n margin-bottom: 8px;\n color: #333;\n}\n\n.container-description {\n display: flex;\n align-items: center;\n gap: 5px;\n margin: 0 0 10px 0;\n}\n\n.container-description p {\n /* font-size: 14px; */\n font-weight: 400;\n margin: 0px;\n}\n\n\np {\n /* font-size: 14px; */\n color: #000;\n}\n\n.value-display h2 {\n color: #6D6D5F;\n /* Verde para o valor atual */\n /* font-size: 1.6rem; */\n margin: 16px 0;\n}\n\ninput[type='range'] {\n width: 100%;\n margin: 12px 0;\n -webkit-appearance: none;\n background: #ddd;\n height: 4px;\n border-radius: 4px;\n outline: none;\n padding: 3px 0px 3px 3px;\n}\n\n/* input[type='range']::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 16px;\n height: 16px;\n background: var(--text-color);\n border-radius: 50%;\n cursor: pointer;\n} */\n\ninput[type=\"range\"]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 20px;\n height: 20px;\n background: rgb(109, 109, 95);\n /* Cor do botão */\n border-radius: 50%;\n cursor: pointer;\n}\n\n.options {\n margin: 0px 0;\n display: flex;\n gap: 10px;\n flex-direction: column;\n}\n\n.options label {\n display: flex;\n margin: 0px 0;\n /* font-size: 0.9rem; */\n color: #333;\n align-items: center;\n}\n\n.options input[type='radio'] {\n margin-right: 8px;\n height: 16px;\n width: 16px;\n}\n\n.options input[type='radio'] {\n appearance: none;\n -webkit-appearance: none;\n margin-right: 8px;\n width: 16px;\n height: 16px;\n border: 2px solid #ddd;\n border-radius: 50%;\n background-color: #fff;\n cursor: pointer;\n transition: all 0.3s;\n padding: 0px;\n}\n\n.options input[type='radio']:checked {\n border-color: #000;\n background-color: #FAFAFA;\n border: 4px solid #000;\n}\n\n.info-box {\n background-color: #f9f9f9;\n border: 1px solid #e0e0e0;\n border-radius: 4px;\n padding: 8px;\n /* font-size: 14px; */\n color: #262626;\n line-height: 20px;\n}\n\n.info-icon {\n /* font-size: 0.9rem; */\n cursor: pointer;\n color: #888;\n}\n\nh3 {\n /* font-size: 1.2rem; */\n margin-bottom: 8px;\n color: #333;\n}\n\n.slider-wrapper {\n position: relative;\n margin: 21px 0px 0px 0px;\n}\n\n.slider {\n width: 100%;\n -webkit-appearance: none;\n background: #ddd;\n height: 4px;\n border-radius: 2px;\n outline: none;\n}\n\n.slider::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 16px;\n height: 16px;\n background: var(--text-color);\n /* Azul para o slider */\n border-radius: 50%;\n cursor: pointer;\n}\n\n.slider-value {\n position: absolute;\n top: -30px;\n /* Posição acima do slider */\n /* font-size: 16px; */\n font-weight: 700;\n color: var(--text-color);\n /* Verde para o texto */\n transform: translateX(-50%);\n white-space: nowrap;\n /* margin-left: 23px; */\n}\n\n.options-option {\n display: flex;\n}\n\n\n/* ########################################## */\n","import { Component, Prop, State, Watch, h } from \"@stencil/core\";\nimport { IBonus } from \"../../../../dto/validate.pin.bonus\";\n\nimport i18next from '../../../../i18n/i18n'\nimport { USED_KEY } from \"../../../../utils/keys.storage\";\nimport { defineLimit, formatDateToBr } from \"../../../../utils/utils\";\nimport { IInfoStore } from \"../../../../helpers/info.config.helper\";\nimport { ReservedInfoDTO } from \"../../../../dto/reserved-info.dto\";\nimport { persisteMetadata } from \"../../../../helpers/cart.helper\";\n\n@Component({\n tag: 'giftback-info',\n styleUrls: ['giftback-info.css']\n})\nexport class GiftbackInfo {\n\n private _refIinputRange: HTMLInputElement;\n\n @State() usedValue: number = 0;\n @State() selectedOption: string = 'none';\n\n @Prop() loading: boolean = false;\n @Prop() bonus: Partial<IBonus> = {\n totalBonus: 0,\n cartId: \"\",\n minimumPurchase: 0,\n bonusBalance: 0,\n calculatedValue: 0,\n firstValidityDate: \"\",\n totalValue: 0\n };\n @Prop() reserve: (amountRedeemed: number) => void;\n @Prop() cancel: () => void;\n @Prop() config: IInfoStore;\n @Prop() infoBonus: ReservedInfoDTO;\n @Prop() storeName: string\n\n @State() sliderPosition: number = 0;\n @State() sliderValuePosition: number = 0;\n\n @State() loadingTime = false;\n\n @Watch(\"bonus\")\n changedBonus() {\n this.updateBonus()\n }\n\n private updateBonus() {\n this.usedValue = this.bonus.bonusBalance;\n this.buildPositionSlider(0, this.bonus.totalBonus);\n }\n\n componentWillLoad() {\n this.updateBonus();\n this.selectedOption = localStorage.getItem(USED_KEY);\n }\n\n handleSliderChange(event: Event) {\n const input = event.target as HTMLInputElement;\n this.usedValue = parseFloat(input.value);\n\n // Calculando a posição do texto com base no valor do slider\n // const percentage = ((this.usedValue - parseInt(input.min)) / (parseInt(input.max) - parseInt(input.min))) * 100;\n // this.sliderPosition = percentage;\n\n this.buildPositionSlider(parseFloat(input.min), parseFloat(input.max))\n }\n\n componentDidLoad() {\n if(this.bonus) {\n this._refIinputRange.value = this.bonus?.bonusBalance.toString();\n }\n }\n\n private buildPositionSlider(min: number, max: number) {\n\n const percentage_init = max * 0.1;\n\n // Calculando a posição do texto com base no valor do slider\n const percentage = ((this.usedValue - min) / (max - min)) * 100;\n\n this.sliderPosition = percentage;\n this.sliderValuePosition = percentage + (this.usedValue <= percentage_init ? 10 : 0);\n }\n\n async handleOptionChange(option: string) {\n this.selectedOption = option;\n\n localStorage.setItem(USED_KEY, option);\n\n localStorage.removeItem(\"bc:time-allow\")\n\n switch (this.selectedOption) {\n case 'use':\n await this.reserve(this.usedValue);\n break;\n case 'dontUse':\n await this.cancel();\n break;\n default:\n }\n }\n\n showTime() {\n if(!this.infoBonus) return false;\n\n return !this.infoBonus.isExpired();\n\n // return this.infoBonus.isBonusProcessed\n }\n\n getTime() {\n \n const createdAt = new Date(this.infoBonus?.metadata?.createdAt);\n const expiration = new Date(createdAt);\n expiration.setMinutes(expiration.getMinutes() + 6);\n\n return {\n createdAt,\n expiration\n }\n }\n\n async downtime() {\n await persisteMetadata(this.storeName, this.bonus.cartId, {\n createdAt: null,\n })\n }\n\n render() {\n const remainingGiftback = this.bonus.minimumPurchase - this.bonus.totalValue;\n\n const translateDescription = i18next.t(\"giftDescription\", { amount: `${this.bonus.totalBonus.toFixed(2).replace(\".\", \",\")}`, custom_name: \"Giftback\" })\n\n const limit = defineLimit(remainingGiftback);\n\n return (\n\n <div class=\"giftback-container\">\n <div class=\"container-description\">\n <p innerHTML={translateDescription}></p>\n <crm-tooltip identity=\"crm-role-description\" text={i18next.t(\"labelUseGiftback\", { minimumPurchase: this.bonus.minimumPurchase, expírationDate: formatDateToBr(this.bonus.firstValidityDate) })} />\n </div>\n <div class=\"slider-wrapper\">\n <div\n class=\"slider-value\"\n style={{\n left: `calc(${this.sliderValuePosition}% - 20px)`, // Ajuste para centralizar o texto\n\n }}\n >\n R$ {this.usedValue.toFixed(2).replace(\".\", \",\")}\n </div>\n <input\n ref={ref => this._refIinputRange = ref}\n id=\"position_value_id\"\n disabled\n type=\"range\"\n min=\"0\"\n max={this.bonus.totalBonus}\n value={this.usedValue}\n class=\"slider\"\n step=\"0.01\"\n onInput={(event) => this.handleSliderChange(event)}\n style={{\n background: `linear-gradient(to right, #6D6D5F ${this.sliderPosition}%, #ddd ${this.sliderPosition}%)`,\n }}\n />\n </div>\n\n {\n limit.isComplete && (\n <p>\n {i18next.t(\"maxAmount\")}\n </p>\n )\n }\n\n {\n !limit.isComplete && (\n <div class=\"container-description\">\n <p>\n Adicione <strong>R$ {remainingGiftback < 0 ? \"0,00\" : remainingGiftback.toFixed(2).replace(\".\", \",\")}</strong> ao carrinho para atingir o valor\n máximo!\n </p>\n <crm-tooltip identity=\"crm-max-description\" text={i18next.t(\"labelamountPartial\")} />\n </div>\n )\n }\n\n\n <div class=\"options\">\n <div class=\"options-option\">\n <input\n disabled={this.showTime()}\n type=\"radio\"\n name=\"giftbackOption\"\n value=\"use\"\n checked={this.selectedOption === 'use'}\n onChange={() => this.handleOptionChange('use')}\n />\n <p>Usar o meu {this.config?.giftbackTitle}</p>\n </div>\n <div class=\"options-option\">\n <input\n disabled={this.showTime()}\n type=\"radio\"\n name=\"giftbackOption\"\n value=\"dontUse\"\n checked={this.selectedOption === 'dontUse'}\n onChange={() => this.handleOptionChange('dontUse')}\n />\n <p>Não usar o meu {this.config?.giftbackTitle}</p>\n </div>\n </div>\n\n {\n this.showTime() &&\n (\n <div class=\"info-box\">\n Após <countdown-timer dates={this.getTime()} downtime={() => { this.loadingTime = true }} />, você poderá alterar sua escolha de usar ou não o Giftback.\n </div>\n )\n }\n\n\n <div class=\"info-box\">\n O Giftback será aplicado na próxima etapa.\n </div>\n </div>\n );\n }\n}","* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n /* font-size: var(--crmfont-sizebodymd); */\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n /* font-size: 14px; */\n font-size: .875rem;\n line-height: 1.25rem;\n \n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n /* font-size: 16px; */\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n /* font-size: 12px; */\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n /* font-size: 12px; */\n}","import { Component, Host, Prop, h } from \"@stencil/core\";\nimport { IInfoStore } from \"../../../../helpers/info.config.helper\";\n\n@Component({\n tag: 'phone-form',\n styleUrl: '../../giftback-form.css',\n shadow: false\n})\nexport class PhoneForm {\n\n private phoneInputMask: HTMLPhoneInputMaskElement;\n\n @Prop() value: string;\n @Prop() loading: boolean;\n @Prop() handlerSubmit: (phone: string) => void;\n\n @Prop() config: IInfoStore;\n\n\n async handlePhone() {\n\n const phone = await this.phoneInputMask.getPhone()\n\n await this.handlerSubmit(phone);\n }\n\n\n render() {\n return (\n <Host class=\"crm-phone-form\">\n <p class=\"crm-subtitle\" >Digite o seu celular para verificar se há desconto disponível nessa compra:</p>\n <phone-input-mask initialValue={this.value} ref={ref => this.phoneInputMask = ref} />\n\n <crm-button txtBtn={this.config?.btnApplyBonusLabel || \"Avançar\"} loading={this.loading} handleClick={() => this.handlePhone() } />\n </Host>\n )\n }\n}",":host {\n display: block;\n}\n\n.form-container-pin {\n display: flex;\n flex-direction: column;\n align-items: center;\n}\n\n.pin-container {\n display: flex;\n /* margin: 26px 0; */\n justify-content: start;\n gap: 10px;\n}\n\n.pin-container input {\n width: 100%;\n height: 48px;\n /* font-size: 14px; */\n text-align: center;\n border: 1px solid #ccc;\n border-radius: 5px;\n}\n\nbutton {\n padding: 10px 20px;\n background-color: #ddd;\n border: none;\n border-radius: 5px;\n cursor: pointer;\n}\n\n\n.success {\n color: green;\n margin-top: 10px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n border-radius: 10px;\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n /* font-size: 20px; */\n cursor: pointer;\n}\n\n.button-cancel {\n top: 50%;\n background-color: #ffffff;\n color: #1e1c1c;\n border: 1px solid gray;\n border-radius: 10px;\n padding: 10px;\n min-height: 30px;\n min-width: 120px;\n /* font-size: 19px; */\n cursor: pointer;\n}\n\n.crm-description {\n /* font-size: 14px; */\n width: 100%;\n display: flex;\n gap: 9px;\n flex-wrap: wrap;\n}\n\n.crm-description a {\n font-weight: bold;\n cursor: pointer;\n text-decoration: underline;\n}\n\n.crm-description div {\n display: flex;\n gap: 5px;\n}","* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n /* font-size: var(--crmfont-sizebodymd); */\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n /* font-size: 14px; */\n font-size: .875rem;\n line-height: 1.25rem;\n \n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n /* font-size: 16px; */\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n /* font-size: 12px; */\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n /* font-size: 12px; */\n}","import { Component, h, Prop, State } from '@stencil/core';\nimport { IPinSent } from '../../../../dto/pin.sent';\nimport i18next from '../../../../i18n/i18n'\nimport { IInfoStore } from '../../../../helpers/info.config.helper';\n\n@Component({\n tag: 'pin-form',\n styleUrls: ['pin-form.css', '../../giftback-form.css'],\n shadow: true,\n})\nexport class GiftbackPin {\n\n @Prop() validate: (pin: string) => void;\n @Prop() cancel: () => void;\n @Prop() resend: () => void;\n\n @Prop() sent: IPinSent;\n @Prop() loading: boolean = false;\n @Prop() phone: string;\n @Prop() config: IInfoStore;\n\n @State() pin: string[] = ['', '', '', ''];\n @State() isVerified: boolean = false;\n @State() canResend: boolean = false;\n\n componentWillLoad() {\n this.canResend = false;\n }\n\n handleInput(event: Event, index: number) {\n const input = event.target as HTMLInputElement;\n const value = input.value.slice(0, 1); // Limitar a um único dígito\n this.pin[index] = value;\n\n // Focar no próximo campo, se possível\n if (value && index < this.pin.length - 1) {\n const nextInput = input.nextElementSibling as HTMLInputElement;\n nextInput?.focus();\n }\n\n this.pin = [...this.pin];\n }\n\n validatePin() {\n this.validate(this.pin.join(\"\"))\n }\n\n verifyPin() {\n const pinCode = this.pin.join('');\n if (pinCode === '9999') {\n this.isVerified = true;\n }\n }\n\n handleTimeout() {\n this.canResend = true;\n }\n\n async handleResend() {\n await this.resend();\n\n this.canResend = false;\n this.pin = ['', '', '', '']\n }\n\n render() {\n return (\n <div class=\"crm-phone-form\">\n <label class=\"crm-subtitle\" >{i18next.t('pin-sutitle')} <strong>+55 {this.phone}</strong></label>\n <div class=\"pin-container\">\n {this.pin.map((_, index) => (\n <input\n type=\"text\"\n maxLength={1}\n value={this.pin[index]}\n onInput={(event) => this.handleInput(event, index)}\n />\n ))}\n </div>\n\n <slot></slot>\n\n <p class=\"crm-description\"> Não recebeu?\n {\n !this.canResend && <label> Reenviar em <countdown-timer initialValue={30} downtime={() => this.handleTimeout()} /> </label>\n }\n {\n this.canResend && (\n <div >\n <a onClick={() => this.handleResend()}>Reenviar</a>\n <a onClick={() => this.cancel()}>Trocar número</a>\n </div>\n )\n }\n </p>\n <crm-button txtBtn={this.config?.btnApplyBonusLabel || \"Avançar\"} loading={this.loading} handleClick={() => this.validatePin()} />\n </div >\n );\n }\n}\n"],"mappings":"yMAAA,MAAMA,EAA0B,yvCCAhC,MAAMC,EAAgB,03BACtB,MAAAC,EAAeD,E,MCOFE,EAAO,M,qEAKhB,MAAAC,GACI,OACIC,EAAA,OAAAC,IAAA,2CAAKC,MAAM,qCACPF,EAAA,OAAAC,IAAA,2CAAKE,IAAKC,IACVJ,EAAA,QAAAC,IAAA,2CAAMI,GAAIC,KAAKC,SAAUL,MAAM,eAAeI,KAAKE,M,aCjBnE,MAAMC,EAAkB,kyDACxB,MAAAC,EAAeD,E,MCaFE,EAAY,M,wCAIQ,E,oBACK,O,aAEP,M,WACM,CAC7BC,WAAY,EACZC,OAAQ,GACRC,gBAAiB,EACjBC,aAAc,EACdC,gBAAiB,EACjBC,kBAAmB,GACnBC,WAAY,G,yIAQkB,E,yBACK,E,iBAEhB,K,CAGvB,YAAAC,GACIb,KAAKc,a,CAGD,WAAAA,GACJd,KAAKe,UAAYf,KAAKgB,MAAMP,aAC5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AAQC,EAAE,eAAc,IAAEpE,EAAA,UAAAC,IAAA,mDAAaK,KAAK2F,QAC1EjG,EAAA,OAAAC,IAAA,2CAAKC,MAAM,iBACNI,KAAK6G,IAAIc,KAAI,CAACC,EAAGjB,IACdjH,EAAA,SACIiF,KAAK,OACLkD,UAAW,EACXjG,MAAO5B,KAAK6G,IAAIF,GAChB9B,QAAUrD,GAAUxB,KAAK0G,YAAYlF,EAAOmF,QAKxDjH,EAAA,QAAAC,IAAA,6CAEAD,EAAA,KAAAC,IAAA,2CAAGC,MAAM,mBAAiB,iBAEjBI,KAAKyG,WAAa/G,EAAA,SAAAC,IAAA,4DAAoBD,EAAA,mBAAAC,IAAA,2CAAiBqG,aAAc,GAAIxC,SAAU,IAAMxD,KAAKwH,kBAAmB,KAGlHxH,KAAKyG,WACD/G,EAAA,OAAAC,IAAA,4CACID,EAAA,KAAAC,IAAA,2CAAGmI,QAAS,IAAM9H,KAAKyH,gBAAc,YACrC/H,EAAA,KAAAC,IAAA,2CAAGmI,QAAS,IAAM9H,KAAK4C,UAAQ,mBAK/ClD,EAAA,cAAAC,IAAA,2CAAYsG,SAAQhE,EAAAjC,KAAKmF,UAAM,MAAAlD,SAAA,SAAAA,EAAEiE,qBAAsB,UAAWC,QAASnG,KAAKmG,QAASC,YAAa,IAAMpG,KAAKkH,gB","ignoreList":[]}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{r as e,h as n}from"./p-8c362346.js";import{g as t}from"./p-1b441909.js";import{g as i}from"./p-3eba0eba.js";import{i as a}from"./p-e8c19a64.js";import{C as o,g as c,a as s}from"./p-b57fbd6d.js";import{d}from"./p-ecc51430.js";const l="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiLz4KPHBhdGggZD0iTTE1IDkuOTQ3MjhDMTQuNSA5LjMgMTMuOCA4LjUgMTIgOC41QzEwLjIgOC41IDkgOS41MTM5MyA5IDkuOTQ3MjhDOSAxMC4zODA2IDkuMDY3ODYgMTAuOTI3NyAxMCAxMS41QzEwLjc1MjIgMTEuOTYxOCAxMi42Njg0IDEyLjA0MzkgMTMuNSAxMi41QzE0LjY3OSAxMy4xNDY3IDE0Ljg0OTcgMTMuODIwMiAxNC44NDk3IDE0LjA1MjJDMTQuODQ5NyAxNC42ODM3IDEzLjQxNzUgMTUuNDg1MiAxMiAxNS41QzEwLjUzNiAxNS41MTUzIDkuNSAxNC43IDkgMTQuMDUyMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTIgN1YxNyIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==";function r(){if(localStorage.getItem("bc:time-allow")){return}const e=localStorage.getItem("bc:time");if(!e){localStorage.setItem("bc:time","360");localStorage.setItem("bc:time-allow","true");return}}const g=".note-container {\n border: 1px solid #dddddd;\n padding: 0 15px 15px;\n margin: 0 0 26px 0px;\n display: flex;\n flex-direction: column;\n gap: 13px;\n\n\n & .description {\n display: flex;\n flex-direction: column;\n gap: 13px;\n }\n}\n\n.note-container hr {\n border: 1px solid #CCC;\n}\n\n.note-container .back-cart {\n display: flex;\n text-align: center;\n}\n\n.note-header {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n}\n\n.note-title {\n font-weight: 700;\n text-align: left;\n display: flex;\n gap: 6px;\n align-items: center;\n margin-top: 11px;\n color: #000;\n}\n\n.note-description {\n color: #6d6d5f;\n padding: 0;\n margin: 0 auto;\n}\n\n.back-cart {\n /* font-size: .9em; */\n color: #27272A;\n text-decoration: none;\n cursor: pointer;\n margin-top: 11px;\n}\n\n.note-description-2 {\n color: var(--crm-scheme-fg-main-inverse, #262626);\n /* font-size: var(--crm-font-size-body-lg, 16px); */\n font-style: normal;\n font-weight: var(--crm-font-weight-body-bold, 400);\n line-height: var(--crm-line-height-body-md, 20px);\n letter-spacing: var(--crm-letter-spacing-title-md, 0px);\n margin-top: 11px;\n color: #000;\n}\n\n.note-description-not {\n /* font-size: 16px; */\n}";const b=g;const f=class{constructor(n){e(this,n);this.cart=undefined;this.cartWake=undefined;this.url=undefined;this.config=undefined;this.bonus=undefined;this.showEdit=false;this.styles=d}async componentWillLoad(){await this.upadateCheckToFreteAndGetUrl()}async upadateCheckToFreteAndGetUrl(){var e,n;this.cartWake=this.cart?new o(JSON.parse(this.cart)):await c();const a=i(this.cartWake.id);try{const t=await s(this.cartWake.id,this.cartWake.store.name);if(t.bonusBalance){localStorage.setItem(this.cartWake.id,t.bonusBalance);localStorage.setItem(a,JSON.stringify({hasBonus:true}))}if(t.isBonusProcessed){this.startTime()}if((e=t===null||t===void 0?void 0:t.metadata)===null||e===void 0?void 0:e.url){this.url=(n=t===null||t===void 0?void 0:t.metadata)===null||n===void 0?void 0:n.url}}catch(e){localStorage.removeItem(a);localStorage.removeItem(this.cartWake.id)}this.config=t(this.cartWake.store.name);if(this.config.keepStoreFrontStyle){this.styles=null}const d=document.getElementsByName("forma-envio");d.forEach((e=>{e.checked=false}))}handleHide(){const e=localStorage.getItem(this.cartWake.id);return!!e}getAmount(){const e=localStorage.getItem(this.cartWake.id);return e?Number(e).toFixed(2).replace(".",",")||"0,00":"0,00"}async backCart(){window.location.href=this.url}startTime(){if(!localStorage.getItem("bc:time-allow")){localStorage.removeItem("bc:time")}r()}hasBonus(){const e=localStorage.getItem(i(this.cartWake.id));const n={hasBonus:false,requestBonus:false};if(e){this.bonus=JSON.parse(e);n.hasBonus=this.bonus.hasBonus;n.requestBonus=true}return n}getTime(){const e=localStorage.getItem("bc:time");return e?Number(e):0}render(){var e;const t=((e=this.config)===null||e===void 0?void 0:e.giftbackTitle)||"Giftback";const i=this.hasBonus();return n("div",{key:"fd8ca59342bc33fc8db3a9a399e3614ed86959bd"},n("div",{key:"6a0e0bce936f02c956cc0c31ca61f98e2793d99f",class:"note-container",style:this.styles},n("div",{key:"1170f4012c0e22f213ec2446ee41b9298ac3ec3b",class:"note-header"},n("p",{key:"b195b60edada5bdea110449dd9485fbcc0e50ea2",class:"note-title"},n("img",{key:"313b7a196f2ee87b89e69c8d8d6cd38b2380d513",src:l,width:23}),this.config.giftbackTitle),i.hasBonus&&n("div",{key:"0d086a75b97b113785c6be6a91c51852b4daa520"},this.showEdit&&n("p",{key:"0e9a7c9fab9310d88231de48191f9cfc10fe2119",class:"back-cart",onClick:()=>this.backCart()},a.t("edit")),!this.showEdit&&n("countdown-timer",{key:"4a064288b3fc08fed7b27148fc148930af605f35",initialValue:this.getTime(),downtime:()=>{this.showEdit=true}}))),i.hasBonus&&n("p",{key:"762bab2b91604e2d4a773c06ea602d401df6790f",class:"note-description-2"},a.t("withApplyBonus",{giftbackname:t})," ",n("strong",{key:"43c4638723b7014d2f7296a1f36b16cd62bd3115"},"R$ ",this.getAmount(),".")),i.requestBonus&&!i.hasBonus&&n("p",{key:"139565c352e860b3e9c4638e2f62e27d3f4381a2",class:"note-description-not"},a.t("noBonus",{giftbackname:t})),!i.requestBonus&&n("div",{key:"99e63a5fa9756422df50baca30aa574d7cefedec",class:"description"},n("p",{key:"6696ee6017cf88ccd00943cfeedd38bd631582b8",class:"note-description-not"},a.t("noBonus",{giftbackname:t})))))}};f.style=b;export{f as crm_bonus_note};
|
2
|
+
//# sourceMappingURL=p-ac32b78a.entry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["moneyDollarsSvgrepoComSvg","setTime","localStorage","getItem","time","setItem","crmBonusNoteCss","CrmBonusNoteStyle0","CrmBonusNote","defaultStyles","componentWillLoad","this","upadateCheckToFreteAndGetUrl","cartWake","cart","CartWake","JSON","parse","getCart","key","getKeyReserveByCartId","id","info","getInfoBonusByCartIdAndStoreName","store","name","bonusBalance","stringify","hasBonus","isBonusProcessed","startTime","_a","metadata","url","_b","error","removeItem","config","getInfoCustomization","keepStoreFrontStyle","styles","envios","document","getElementsByName","forEach","envio","checked","handleHide","amount","getAmount","Number","toFixed","replace","backCart","window","location","href","_bonus","requestBonus","bonus","getTime","render","giftbackname","giftbackTitle","infobonus","h","class","style","src","money","width","showEdit","onClick","i18next","t","initialValue","downtime"],"sources":["src/assets/svg/money-dollars-svgrepo-com.svg","src/helpers/time.helper.ts","src/components/note/crm-bonus-note.css?tag=crm-bonus-note","src/components/note/crm-bonus-note.tsx"],"sourcesContent":["<?xml version=\"1.0\" encoding=\"utf-8\"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->\n<svg width=\"800px\" height=\"800px\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"#000000\" stroke-width=\"2\"/>\n<path d=\"M15 9.94728C14.5 9.3 13.8 8.5 12 8.5C10.2 8.5 9 9.51393 9 9.94728C9 10.3806 9.06786 10.9277 10 11.5C10.7522 11.9618 12.6684 12.0439 13.5 12.5C14.679 13.1467 14.8497 13.8202 14.8497 14.0522C14.8497 14.6837 13.4175 15.4852 12 15.5C10.536 15.5153 9.5 14.7 9 14.0522\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 7V17\" stroke=\"#000000\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>","export function setTime() {\n\n if(localStorage.getItem(\"bc:time-allow\")) {\n return\n }\n\n const time = localStorage.getItem(\"bc:time\");\n\n if(!time) {\n localStorage.setItem(\"bc:time\", \"360\");\n localStorage.setItem(\"bc:time-allow\", \"true\");\n return\n } \n}",".note-container {\n border: 1px solid #dddddd;\n padding: 0 15px 15px;\n margin: 0 0 26px 0px;\n display: flex;\n flex-direction: column;\n gap: 13px;\n\n\n & .description {\n display: flex;\n flex-direction: column;\n gap: 13px;\n }\n}\n\n.note-container hr {\n border: 1px solid #CCC;\n}\n\n.note-container .back-cart {\n display: flex;\n text-align: center;\n}\n\n.note-header {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n}\n\n.note-title {\n font-weight: 700;\n text-align: left;\n display: flex;\n gap: 6px;\n align-items: center;\n margin-top: 11px;\n color: #000;\n}\n\n.note-description {\n color: #6d6d5f;\n padding: 0;\n margin: 0 auto;\n}\n\n.back-cart {\n /* font-size: .9em; */\n color: #27272A;\n text-decoration: none;\n cursor: pointer;\n margin-top: 11px;\n}\n\n.note-description-2 {\n color: var(--crm-scheme-fg-main-inverse, #262626);\n /* font-size: var(--crm-font-size-body-lg, 16px); */\n font-style: normal;\n font-weight: var(--crm-font-weight-body-bold, 400);\n line-height: var(--crm-line-height-body-md, 20px);\n letter-spacing: var(--crm-letter-spacing-title-md, 0px);\n margin-top: 11px;\n color: #000;\n}\n\n.note-description-not {\n /* font-size: 16px; */\n}","import { Component, Prop, State, h } from \"@stencil/core\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport money from '../../assets/svg/money-dollars-svgrepo-com.svg'\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\nimport i18next from \"../../i18n/i18n\"\nimport { IBonus } from \"../../components\";\nimport { setTime } from \"../../helpers/time.helper\";\nimport { CartWake } from \"../../objectvalues/cart.wake\";\nimport { getCart, getInfoBonusByCartIdAndStoreName } from \"../../helpers/cart.helper\";\nimport { defaultStyles } from \"../../contants\";\n\n@Component({\n tag: 'crm-bonus-note',\n styleUrl: 'crm-bonus-note.css'\n})\nexport class CrmBonusNote {\n\n @Prop() cart;\n\n @State() cartWake: CartWake;\n @State() url: string;\n @State() config: IInfoStore;\n @State() bonus: IBonus;\n @State() showEdit: boolean = false;\n @State() styles = defaultStyles;\n async componentWillLoad() {\n await this.upadateCheckToFreteAndGetUrl();\n }\n\n async upadateCheckToFreteAndGetUrl() {\n\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\n\n const key = getKeyReserveByCartId(this.cartWake.id);\n try {\n const info = await getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name);\n\n if (info.bonusBalance) {\n localStorage.setItem(this.cartWake.id, info.bonusBalance);\n localStorage.setItem(key, JSON.stringify({\n hasBonus: true,\n }));\n }\n\n if (info.isBonusProcessed) {\n this.startTime();\n }\n\n if(info?.metadata?.url) {\n this.url = info?.metadata?.url;\n }\n\n } catch (error) {\n localStorage.removeItem(key);\n localStorage.removeItem(this.cartWake.id);\n }\n\n this.config = getInfoCustomization(this.cartWake.store.name);\n\n if (this.config.keepStoreFrontStyle) {\n this.styles = null;\n }\n\n const envios = document.getElementsByName('forma-envio');\n envios.forEach((envio: any) => {\n envio.checked = false;\n });\n\n }\n\n handleHide() {\n const amount = localStorage.getItem(this.cartWake.id);\n return !!amount;\n }\n\n getAmount() {\n const amount = localStorage.getItem(this.cartWake.id);\n\n return amount ? Number(amount).toFixed(2).replace(\".\", \",\") || \"0,00\" : \"0,00\";\n }\n\n async backCart() {\n window.location.href = this.url;\n }\n\n\n private startTime() {\n\n if (!localStorage.getItem(\"bc:time-allow\")) {\n localStorage.removeItem(\"bc:time\")\n }\n\n setTime();\n }\n\n\n hasBonus() {\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartWake.id));\n\n const info = {\n hasBonus: false,\n requestBonus: false\n }\n\n if (_bonus) {\n this.bonus = JSON.parse(_bonus);\n info.hasBonus = this.bonus.hasBonus;\n info.requestBonus = true;\n }\n\n return info;\n }\n\n getTime() {\n const time = localStorage.getItem(\"bc:time\")\n\n return time ? Number(time) : 0;\n }\n\n render() {\n\n const giftbackname = this.config?.giftbackTitle || \"Giftback\";\n\n const infobonus = this.hasBonus()\n\n return (\n <div>\n <div class=\"note-container\" style={this.styles}>\n <div class=\"note-header\">\n\n <p class=\"note-title\">\n <img src={money} width={23} />\n {this.config.giftbackTitle}\n </p>\n {\n infobonus.hasBonus && (\n <div>\n {this.showEdit && (\n <p class=\"back-cart\" onClick={() => this.backCart()}>\n {i18next.t(\"edit\")}\n </p>\n )}\n {!this.showEdit && <countdown-timer initialValue={this.getTime()} downtime={() => { this.showEdit = true }} />}\n </div>\n )\n }\n </div>\n\n {\n infobonus.hasBonus &&\n (\n <p class=\"note-description-2\">\n {i18next.t(\"withApplyBonus\", { giftbackname: giftbackname })} <strong>R$ {this.getAmount()}.</strong>\n </p>\n )\n }\n\n {\n (infobonus.requestBonus && !infobonus.hasBonus) &&\n (\n <p class=\"note-description-not\">\n {i18next.t(\"noBonus\", { giftbackname: giftbackname })}\n </p>\n )\n }\n\n {\n !infobonus.requestBonus &&\n (\n <div class=\"description\">\n <p class=\"note-description-not\">\n {i18next.t(\"noBonus\", { giftbackname: giftbackname })}\n </p>\n </div>\n )\n }\n </div>\n </div>\n )\n }\n}"],"mappings":"wOAAA,MAAMA,EAA4B,6gC,SCAlBC,IAEZ,GAAGC,aAAaC,QAAQ,iBAAkB,CACtC,M,CAGJ,MAAMC,EAAOF,aAAaC,QAAQ,WAElC,IAAIC,EAAM,CACNF,aAAaG,QAAQ,UAAW,OAChCH,aAAaG,QAAQ,gBAAiB,QACtC,M,CAER,CCbA,MAAMC,EAAkB,i1CACxB,MAAAC,EAAeD,E,MCeFE,EAAY,M,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AYR,KAAKsC,YAAW,MAMjGe,EAAUN,eAAiBM,EAAUpC,UAElCqC,EAAA,KAAA9C,IAAA,2CAAG+C,MAAM,wBACJO,EAAQC,EAAE,UAAW,CAAEZ,aAAcA,MAM7CE,EAAUN,cAEPO,EAAA,OAAA9C,IAAA,2CAAK+C,MAAM,eACPD,EAAA,KAAA9C,IAAA,2CAAG+C,MAAM,wBACJO,EAAQC,EAAE,UAAW,CAAEZ,aAAcA,O","ignoreList":[]}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
function n(n,t,r){return(n||"")+(t?` ${t}`:"")+(r?` ${r}`:"")}function t(n){return{remainingGiftback:n<0?"0,00":n.toFixed(2).replace(".",","),isComplete:n<0}}function r(n){const[t]=n.split(" ");if(t.length!=10){return""}return t.split("-").reverse().join("/")}export{r as a,t as d,n as f};
|
2
|
-
//# sourceMappingURL=p-
|
2
|
+
//# sourceMappingURL=p-af3ba015.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["format","first","middle","last","defineLimit","remainingGiftback","toFixed","replace","isComplete","formatDateToBr","dateTime","date","split","length","reverse","join"],"sources":["src/utils/utils.ts"],"sourcesContent":["export function format(first?: string, middle?: string, last?: string): string {\n return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');\n}\n\nexport function defineLimit(remainingGiftback: number) {\n\n return {\n remainingGiftback: remainingGiftback < 0 ? \"0,00\" : remainingGiftback.toFixed(2).replace(\".\", \",\"),\n isComplete: (remainingGiftback < 0)\n }\n}\n\nexport function formatDateToBr(dateTime: string) {\n\n const [date] = dateTime.split(\" \");\n\n if (date.length != 10) {\n return \"\"\n }\n\n return date.split(\"-\").reverse().join(\"/\");\n}\n\n\n// Decodifica entidades HTML, se houver\nexport const decodeHtmlEntities = (str: string) => {\n const parser = new DOMParser();\n const doc = parser.parseFromString(str, 'text/html');\n\n return doc.documentElement.textContent || str;\n};\n"],"mappings":"SAAgBA,EAAOC,EAAgBC,EAAiBC,GACtD,OAAQF,GAAS,KAAOC,EAAS,IAAIA,IAAW,KAAOC,EAAO,IAAIA,IAAS,GAC7E,C,SAEgBC,EAAYC,GAE1B,MAAO,CACLA,kBAAmBA,EAAoB,EAAI,OAASA,EAAkBC,QAAQ,GAAGC,QAAQ,IAAK,KAC9FC,WAAaH,EAAoB,EAErC,C,SAEgBI,EAAeC,GAE7B,MAAOC,GAAQD,EAASE,MAAM,KAE9B,GAAID,EAAKE,QAAU,GAAI,CACrB,MAAO,E,CAGT,OAAOF,EAAKC,MAAM,KAAKE,UAAUC,KAAK,IACxC,Q","ignoreList":[]}
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{C as t,a as s}from"./p-3eba0eba.js";class o{constructor(t){var s;this.products=[];this.id=t.Metadados.id||t.Id;this.middlewareId=(s=t.Metadados)===null||s===void 0?void 0:s.id;this.orderId=t.PedidoId;this.buildUserInfo(t);this.buildStoreInfo(t);this.products=this.buildStoreCart(t.Produtos)}buildStoreCart(t=[]){const s=localStorage.getItem("bc:cart");if(!s){return this.saveStore(t)}const o=JSON.parse(s);if(t.length!==o.length){return this.saveStore(t)}for(const s of t){const[n]=o.filter((t=>t.ProdutoVarianteId==s.ProdutoVarianteId));if(n){return t}}return o}saveStore(t){localStorage.setItem("bc:cart",JSON.stringify(t));return t}buildUserInfo(t){this.user={id:t.Usuario?t.Usuario.Id:null}}buildStoreInfo(t){var s;this.store={name:(s=t.Loja)===null||s===void 0?void 0:s.Nome}}}class n{static of(t){const s=new n;s.bonusBalance=t.bonusBalance;s.bonusIds=t.bonusIds;s.calculatedValue=t.calculatedValue;s.cartId=t.cartId;s.metadata=t.metadata;s.orderId=t.orderId;s.status=t.status;s.totalDiscount=t.totalDiscount;s.totalValue=t.totalValue;s.isBonusProcessed=t.isBonusProcessed;return s}isExpired(){var t;const s=(t=this===null||this===void 0?void 0:this.metadata)===null||t===void 0?void 0:t.createdAt;if(!s)return true;const o=Date.now();const n=o-s;const r=n/(1e3*60);console.log("diffMinutes",r);return r>6}}const r=t.getInstance();const i=async()=>{const t=e();console.log("[URL STORE]: ",t);const s=await r.getInfoCart(t);return new o(s)};const c=async(t,s)=>{const o=await r.getInfoBonus(t,s);return n.of(o)};const a=async(t,s,o={})=>{await r.patchInfoBonus({storeName:t,cartId:s,metadata:o})};const e=()=>{const t=window.location.origin;if(t.includes("localhost")){return s}if(t.includes("checkout")){return t}if(t.includes("fbits")){return t}if(t.includes("www.")){return t.replace("www","checkout")}return`${window.location.protocol}//checkout.${window.location.host}`};export{o as C,c as a,i as g,a as p};
|
2
|
+
//# sourceMappingURL=p-b57fbd6d.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["CartWake","constructor","cart","this","products","id","Metadados","Id","middlewareId","_a","orderId","PedidoId","buildUserInfo","buildStoreInfo","buildStoreCart","Produtos","newProducts","cache","localStorage","getItem","saveStore","cacheProducts","JSON","parse","length","p","cp","filter","cpp","ProdutoVarianteId","setItem","stringify","user","Usuario","store","name","Loja","Nome","ReservedInfoDTO","of","payload","info","bonusBalance","bonusIds","calculatedValue","cartId","metadata","status","totalDiscount","totalValue","isBonusProcessed","isExpired","createdAt","current","Date","now","diffms","diffMinutes","console","log","crmBonusService","CrmBonusService","getInstance","getCart","async","baseUrl","buildUrlBase","getInfoCart","getInfoBonusByCartIdAndStoreName","storeName","getInfoBonus","persisteMetadata","patchInfoBonus","url","window","location","origin","includes","CHECKOUT_CART_WAKE","replace","protocol","host"],"sources":["src/objectvalues/cart.wake.ts","src/dto/reserved-info.dto.ts","src/helpers/cart.helper.ts"],"sourcesContent":["import { IProductWake, IStore, IUser } from \"../dto/validate.pin.bonus\";\n\nexport class CartWake {\n id: string;\n middlewareId: string;\n orderId: number;\n products: IProductWake[] = [];\n user: IUser;\n store: IStore;\n\n constructor(cart) {\n this.id = cart.Metadados.id || cart.Id;\n this.middlewareId = cart.Metadados?.id;\n this.orderId = cart.PedidoId;\n this.buildUserInfo(cart);\n this.buildStoreInfo(cart);\n this.products = this.buildStoreCart( cart.Produtos);\n }\n\n private buildStoreCart(newProducts = []) {\n const cache = localStorage.getItem(\"bc:cart\");\n\n if(!cache) {\n return this.saveStore(newProducts)\n \n }\n \n const cacheProducts:IProductWake[] = JSON.parse(cache);\n\n if(newProducts.length !== cacheProducts.length) {\n return this.saveStore(newProducts);\n }\n\n for (const p of newProducts) {\n const [cp] = cacheProducts.filter(cpp => cpp.ProdutoVarianteId == p.ProdutoVarianteId);\n\n if(cp) {\n cp.Quantidade != p.Quantidade;\n\n return newProducts;\n }\n }\n\n return cacheProducts;\n\n }\n\n\n private saveStore(newProducts) {\n localStorage.setItem(\"bc:cart\", JSON.stringify(newProducts));\n\n return newProducts;\n }\n\n private buildUserInfo(cart) {\n this.user = {\n id: cart.Usuario ? cart.Usuario.Id : null\n }\n }\n\n private buildStoreInfo(cart) {\n this.store = {\n name: cart.Loja?.Nome\n }\n }\n}","export class ReservedInfoDTO {\n bonusBalance: string;\n bonusIds: string;\n calculatedValue: string;\n cartId: string;\n metadata: {\n url: string,\n createdAt: number\n }\n orderId: string;\n status: number;\n totalDiscount: string;\n totalValue: string;\n isBonusProcessed?: boolean;\n\n\n public static of(payload: any) {\n const info = new ReservedInfoDTO();\n info.bonusBalance = payload.bonusBalance;\n info.bonusIds = payload.bonusIds;\n info.calculatedValue = payload.calculatedValue;\n info.cartId = payload.cartId;\n info.metadata = payload.metadata;\n info.orderId = payload.orderId;\n info.status = payload.status;\n info.totalDiscount = payload.totalDiscount;\n info.totalValue = payload.totalValue;\n info.isBonusProcessed = payload.isBonusProcessed;\n return info;\n }\n\n public isExpired(): boolean {\n const createdAt = this?.metadata?.createdAt;\n if(!createdAt) return true; \n \n const current = Date.now();\n\n const diffms = current - createdAt;\n\n const diffMinutes = diffms / (1000 * 60);\n\n console.log('diffMinutes', diffMinutes);\n\n return diffMinutes > 6;\n\n }\n\n}","import { CHECKOUT_CART_WAKE } from \"../../env\";\nimport { CartWake } from \"../objectvalues/cart.wake\";\nimport { CrmBonusService } from \"../services/crmbonus.service\";\nimport { ReservedInfoDTO } from '../dto/reserved-info.dto'\n\nconst crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\nexport const getCart = async (): Promise<CartWake> => {\n const baseUrl = buildUrlBase(); // window.location.origin; //\"https://bycoders.fbits.store\" //window.location.origin;\n \n console.log('[URL STORE]: ', baseUrl)\n\n const cart = await crmBonusService.getInfoCart(baseUrl);\n\n return new CartWake(cart);\n}\n\nexport const getInfoBonusByCartIdAndStoreName = async (cartId, storeName) => {\n const info = await crmBonusService.getInfoBonus(cartId, storeName)\n\n return ReservedInfoDTO.of(info);\n}\n\nexport const persisteMetadata = async (storeName: string, cartId: string, metadata = {}) => {\n await crmBonusService.patchInfoBonus({\n storeName,\n cartId,\n metadata\n })\n}\n\nconst buildUrlBase = () => {\n\n const url = window.location.origin; //\"https://bycoders.checkout.fbits.store\" //\n\n if(url.includes('localhost')) {\n return CHECKOUT_CART_WAKE;\n }\n\n if(url.includes('checkout')) {\n return url;\n }\n\n if(url.includes('fbits')) {\n return url;\n }\n\n if(url.includes(\"www.\")) {\n return url.replace(\"www\", \"checkout\")\n }\n\n return `${window.location.protocol}//checkout.${window.location.host}`;\n\n}"],"mappings":"iDAEaA,EAQT,WAAAC,CAAYC,G,MAJZC,KAAAC,SAA2B,GAKvBD,KAAKE,GAAKH,EAAKI,UAAUD,IAAMH,EAAKK,GACpCJ,KAAKK,cAAeC,EAAAP,EAAKI,aAAS,MAAAG,SAAA,SAAAA,EAAEJ,GACpCF,KAAKO,QAAUR,EAAKS,SACpBR,KAAKS,cAAcV,GACnBC,KAAKU,eAAeX,GACpBC,KAAKC,SAAWD,KAAKW,eAAgBZ,EAAKa,S,CAGtC,cAAAD,CAAeE,EAAc,IACjC,MAAMC,EAAQC,aAAaC,QAAQ,WAEnC,IAAIF,EAAO,CACP,OAAOd,KAAKiB,UAAUJ,E,CAI1B,MAAMK,EAA+BC,KAAKC,MAAMN,GAEhD,GAAGD,EAAYQ,SAAWH,EAAcG,OAA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AAQC,IAAI,gBAAiBM,GAE7B,MAAM/D,QAAa0D,EAAgBO,YAAYF,GAE/C,OAAO,IAAIjE,EAASE,EAAK,E,MAGhBkE,EAAmCJ,MAAOnB,EAAQwB,KAC3D,MAAM5B,QAAamB,EAAgBU,aAAazB,EAAQwB,GAExD,OAAO/B,EAAgBC,GAAGE,EAAK,E,MAGtB8B,EAAmBP,MAAOK,EAAmBxB,EAAgBC,EAAW,YAC3Ec,EAAgBY,eAAe,CACjCH,YACAxB,SACAC,YACF,EAGN,MAAMoB,EAAe,KAEjB,MAAMO,EAAOC,OAAOC,SAASC,OAE7B,GAAGH,EAAII,SAAS,aAAc,CAC1B,OAAOC,C,CAGX,GAAGL,EAAII,SAAS,YAAa,CACzB,OAAOJ,C,CAGX,GAAGA,EAAII,SAAS,SAAU,CACtB,OAAOJ,C,CAGX,GAAGA,EAAII,SAAS,QAAS,CACrB,OAAOJ,EAAIM,QAAQ,MAAO,W,CAG9B,MAAO,GAAGL,OAAOC,SAASK,sBAAsBN,OAAOC,SAASM,MAAM,S","ignoreList":[]}
|
package/dist/env.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export const CRM_BONUS_API_URL = "https://wake.crmbonus.com/api"; //"http://localhost:4000/api";// "https://wake-middleware.crmbonus.com/api"; //"https://wake-middleware.crmbonus.com/api";// "https://crmbonus-wake-hub-staging-5daedbc4e22b.herokuapp.com/api" //"https://crmbonus-service-staging-d15ba5377115.herokuapp.com"; //"https://typically-workable-perch.ngrok-free.app"; // "http://localhost:3500";
|
1
|
+
export const CRM_BONUS_API_URL = "https://wake-middleware.crmbonus.com/api"; //"http://localhost:4000/api";// "https://wake-middleware.crmbonus.com/api"; //"https://wake-middleware.crmbonus.com/api";// "https://crmbonus-wake-hub-staging-5daedbc4e22b.herokuapp.com/api" //"https://crmbonus-service-staging-d15ba5377115.herokuapp.com"; //"https://typically-workable-perch.ngrok-free.app"; // "http://localhost:3500";
|
2
2
|
export const CHECKOUT_CART_WAKE = "http://localhost:3001";
|
3
3
|
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"env.js","sourceRoot":"","sources":["../env.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,iBAAiB,GAAG
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../env.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,iBAAiB,GAAG,0CAA0C,CAAC,CAAC,iVAAiV;AAC9Z,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAA","sourcesContent":["\nexport const CRM_BONUS_API_URL = \"https://wake-middleware.crmbonus.com/api\"; //\"http://localhost:4000/api\";// \"https://wake-middleware.crmbonus.com/api\"; //\"https://wake-middleware.crmbonus.com/api\";// \"https://crmbonus-wake-hub-staging-5daedbc4e22b.herokuapp.com/api\" //\"https://crmbonus-service-staging-d15ba5377115.herokuapp.com\"; //\"https://typically-workable-perch.ngrok-free.app\"; // \"http://localhost:3500\";\nexport const CHECKOUT_CART_WAKE = \"http://localhost:3001\""]}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { C as CrmBonusService, a as CHECKOUT_CART_WAKE } from './crmbonus.service-
|
1
|
+
import { C as CrmBonusService, a as CHECKOUT_CART_WAKE } from './crmbonus.service-5bc16be9.js';
|
2
2
|
|
3
3
|
class CartWake {
|
4
4
|
constructor(cart) {
|
@@ -45,6 +45,34 @@ class CartWake {
|
|
45
45
|
}
|
46
46
|
}
|
47
47
|
|
48
|
+
class ReservedInfoDTO {
|
49
|
+
static of(payload) {
|
50
|
+
const info = new ReservedInfoDTO();
|
51
|
+
info.bonusBalance = payload.bonusBalance;
|
52
|
+
info.bonusIds = payload.bonusIds;
|
53
|
+
info.calculatedValue = payload.calculatedValue;
|
54
|
+
info.cartId = payload.cartId;
|
55
|
+
info.metadata = payload.metadata;
|
56
|
+
info.orderId = payload.orderId;
|
57
|
+
info.status = payload.status;
|
58
|
+
info.totalDiscount = payload.totalDiscount;
|
59
|
+
info.totalValue = payload.totalValue;
|
60
|
+
info.isBonusProcessed = payload.isBonusProcessed;
|
61
|
+
return info;
|
62
|
+
}
|
63
|
+
isExpired() {
|
64
|
+
var _a;
|
65
|
+
const createdAt = (_a = this === null || this === void 0 ? void 0 : this.metadata) === null || _a === void 0 ? void 0 : _a.createdAt;
|
66
|
+
if (!createdAt)
|
67
|
+
return true;
|
68
|
+
const current = Date.now();
|
69
|
+
const diffms = current - createdAt;
|
70
|
+
const diffMinutes = diffms / (1000 * 60);
|
71
|
+
console.log('diffMinutes', diffMinutes);
|
72
|
+
return diffMinutes > 6;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
48
76
|
const crmBonusService = CrmBonusService.getInstance();
|
49
77
|
const getCart = async () => {
|
50
78
|
const baseUrl = buildUrlBase(); // window.location.origin; //"https://bycoders.fbits.store" //window.location.origin;
|
@@ -52,6 +80,17 @@ const getCart = async () => {
|
|
52
80
|
const cart = await crmBonusService.getInfoCart(baseUrl);
|
53
81
|
return new CartWake(cart);
|
54
82
|
};
|
83
|
+
const getInfoBonusByCartIdAndStoreName = async (cartId, storeName) => {
|
84
|
+
const info = await crmBonusService.getInfoBonus(cartId, storeName);
|
85
|
+
return ReservedInfoDTO.of(info);
|
86
|
+
};
|
87
|
+
const persisteMetadata = async (storeName, cartId, metadata = {}) => {
|
88
|
+
await crmBonusService.patchInfoBonus({
|
89
|
+
storeName,
|
90
|
+
cartId,
|
91
|
+
metadata
|
92
|
+
});
|
93
|
+
};
|
55
94
|
const buildUrlBase = () => {
|
56
95
|
const url = window.location.origin; //"https://bycoders.checkout.fbits.store" //
|
57
96
|
if (url.includes('localhost')) {
|
@@ -69,6 +108,6 @@ const buildUrlBase = () => {
|
|
69
108
|
return `${window.location.protocol}//checkout.${window.location.host}`;
|
70
109
|
};
|
71
110
|
|
72
|
-
export { CartWake as C, getCart as g };
|
111
|
+
export { CartWake as C, getInfoBonusByCartIdAndStoreName as a, get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AED,IAAG,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QACzB,OAAO,GAAG,CAAC;KACd;IAED,IAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACtB,OAAO,GAAG,CAAC;KACd;IAED,IAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QACrB,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;KACxC;IAED,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAc,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAE3E,CAAC;;;;","names":[],"sources":["src/objectvalues/cart.wake.ts","src/dto/reserved-info.dto.ts","src/helpers/cart.helper.ts"],"sourcesContent":["import { IProductWake, IStore, IUser } from \"../dto/validate.pin.bonus\";\n\nexport class CartWake {\n id: string;\n middlewareId: string;\n orderId: number;\n products: IProductWake[] = [];\n user: IUser;\n store: IStore;\n\n constructor(cart) {\n this.id = cart.Metadados.id || cart.Id;\n this.middlewareId = cart.Metadados?.id;\n this.orderId = cart.PedidoId;\n this.buildUserInfo(cart);\n this.buildStoreInfo(cart);\n this.products = this.buildStoreCart( cart.Produtos);\n }\n\n private buildStoreCart(newProducts = []) {\n const cache = localStorage.getItem(\"bc:cart\");\n\n if(!cache) {\n return this.saveStore(newProducts)\n \n }\n \n const cacheProducts:IProductWake[] = JSON.parse(cache);\n\n if(newProducts.length !== cacheProducts.length) {\n return this.saveStore(newProducts);\n }\n\n for (const p of newProducts) {\n const [cp] = cacheProducts.filter(cpp => cpp.ProdutoVarianteId == p.ProdutoVarianteId);\n\n if(cp) {\n cp.Quantidade != p.Quantidade;\n\n return newProducts;\n }\n }\n\n return cacheProducts;\n\n }\n\n\n private saveStore(newProducts) {\n localStorage.setItem(\"bc:cart\", JSON.stringify(newProducts));\n\n return newProducts;\n }\n\n private buildUserInfo(cart) {\n this.user = {\n id: cart.Usuario ? cart.Usuario.Id : null\n }\n }\n\n private buildStoreInfo(cart) {\n this.store = {\n name: cart.Loja?.Nome\n }\n }\n}","export class ReservedInfoDTO {\n bonusBalance: string;\n bonusIds: string;\n calculatedValue: string;\n cartId: string;\n metadata: {\n url: string,\n createdAt: number\n }\n orderId: string;\n status: number;\n totalDiscount: string;\n totalValue: string;\n isBonusProcessed?: boolean;\n\n\n public static of(payload: any) {\n const info = new ReservedInfoDTO();\n info.bonusBalance = payload.bonusBalance;\n info.bonusIds = payload.bonusIds;\n info.calculatedValue = payload.calculatedValue;\n info.cartId = payload.cartId;\n info.metadata = payload.metadata;\n info.orderId = payload.orderId;\n info.status = payload.status;\n info.totalDiscount = payload.totalDiscount;\n info.totalValue = payload.totalValue;\n info.isBonusProcessed = payload.isBonusProcessed;\n return info;\n }\n\n public isExpired(): boolean {\n const createdAt = this?.metadata?.createdAt;\n if(!createdAt) return true; \n \n const current = Date.now();\n\n const diffms = current - createdAt;\n\n const diffMinutes = diffms / (1000 * 60);\n\n console.log('diffMinutes', diffMinutes);\n\n return diffMinutes > 6;\n\n }\n\n}","import { CHECKOUT_CART_WAKE } from \"../../env\";\nimport { CartWake } from \"../objectvalues/cart.wake\";\nimport { CrmBonusService } from \"../services/crmbonus.service\";\nimport { ReservedInfoDTO } from '../dto/reserved-info.dto'\n\nconst crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\nexport const getCart = async (): Promise<CartWake> => {\n const baseUrl = buildUrlBase(); // window.location.origin; //\"https://bycoders.fbits.store\" //window.location.origin;\n \n console.log('[URL STORE]: ', baseUrl)\n\n const cart = await crmBonusService.getInfoCart(baseUrl);\n\n return new CartWake(cart);\n}\n\nexport const getInfoBonusByCartIdAndStoreName = async (cartId, storeName) => {\n const info = await crmBonusService.getInfoBonus(cartId, storeName)\n\n return ReservedInfoDTO.of(info);\n}\n\nexport const persisteMetadata = async (storeName: string, cartId: string, metadata = {}) => {\n await crmBonusService.patchInfoBonus({\n storeName,\n cartId,\n metadata\n })\n}\n\nconst buildUrlBase = () => {\n\n const url = window.location.origin; //\"https://bycoders.checkout.fbits.store\" //\n\n if(url.includes('localhost')) {\n return CHECKOUT_CART_WAKE;\n }\n\n if(url.includes('checkout')) {\n return url;\n }\n\n if(url.includes('fbits')) {\n return url;\n }\n\n if(url.includes(\"www.\")) {\n return url.replace(\"www\", \"checkout\")\n }\n\n return `${window.location.protocol}//checkout.${window.location.host}`;\n\n}"],"version":3}
|
@@ -5,22 +5,52 @@ const CountdownTimer = class {
|
|
5
5
|
registerInstance(this, hostRef);
|
6
6
|
this.downtime = undefined;
|
7
7
|
this.initialValue = 0;
|
8
|
+
this.dates = {
|
9
|
+
expiration: new Date(),
|
10
|
+
createdAt: new Date()
|
11
|
+
};
|
8
12
|
this.seconds = 0;
|
13
|
+
this.minutes = undefined;
|
9
14
|
}
|
10
15
|
componentWillLoad() {
|
16
|
+
const time = this.buildTime();
|
17
|
+
this.iniciarContador(time);
|
18
|
+
}
|
19
|
+
buildTime() {
|
11
20
|
const initial = localStorage.getItem("bc:time");
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
if (initial) {
|
22
|
+
return Number(initial);
|
23
|
+
}
|
24
|
+
const dataFinal = new Date(this.dates.expiration);
|
25
|
+
const agora = new Date(this.dates.createdAt);
|
26
|
+
const diferencaMs = dataFinal.getTime() - agora.getTime();
|
27
|
+
if (diferencaMs <= 0) {
|
28
|
+
return diferencaMs;
|
29
|
+
}
|
30
|
+
const diferencaSegundos = diferencaMs / 1000; // Converter milissegundos para segundos
|
31
|
+
const minutos = Math.floor(diferencaSegundos / 60); // Calcular minutos
|
32
|
+
const segundos = Math.floor(diferencaSegundos % 60); // Calcular segundos restantes
|
33
|
+
const m = minutos >= 10 ? minutos : `0${minutos}`;
|
34
|
+
const s = segundos >= 10 ? segundos : `0${segundos}`;
|
35
|
+
this.minutes = `${m}:${s}`;
|
36
|
+
return diferencaSegundos;
|
37
|
+
}
|
38
|
+
iniciarContador(params) {
|
39
|
+
let segundosRestantes = params;
|
40
|
+
const intervalo = setInterval(() => {
|
41
|
+
const minutosExibidos = Math.floor(segundosRestantes / 60);
|
42
|
+
const segundosExibidos = (segundosRestantes % 60).toFixed();
|
43
|
+
let textContent = `${String(minutosExibidos).padStart(2, '0')}:${String(segundosExibidos).padStart(2, '0')}`;
|
44
|
+
if (segundosRestantes < 0) {
|
45
|
+
clearInterval(intervalo);
|
46
|
+
textContent = "00:00";
|
21
47
|
localStorage.removeItem("bc:time");
|
48
|
+
return;
|
22
49
|
}
|
23
|
-
|
50
|
+
segundosRestantes--;
|
51
|
+
localStorage.setItem("bc:time", segundosRestantes);
|
52
|
+
this.minutes = textContent;
|
53
|
+
}, 1000);
|
24
54
|
}
|
25
55
|
disconnectedCallback() {
|
26
56
|
clearInterval(this.intervalId);
|
@@ -33,7 +63,7 @@ const CountdownTimer = class {
|
|
33
63
|
return `${parseInt(minutes.toString())}m ${seconds}s`;
|
34
64
|
}
|
35
65
|
render() {
|
36
|
-
return (h("label", { key: '
|
66
|
+
return (h("label", { key: '8fd06b21879dd42305970d6b29f1ed6bc93e5d69' }, this.minutes));
|
37
67
|
}
|
38
68
|
};
|
39
69
|
|