crmbonus-component-wake 2.0.117 → 2.0.119

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.
Files changed (55) hide show
  1. package/dist/cjs/{cart.helper-63c75a64.js → cart.helper-09e4daf4.js} +2 -2
  2. package/dist/cjs/{cart.helper-63c75a64.js.map → cart.helper-09e4daf4.js.map} +1 -1
  3. package/dist/cjs/crm-bonus-form.cjs.entry.js +1 -1
  4. package/dist/cjs/crm-bonus-note.cjs.entry.js +2 -2
  5. package/dist/cjs/crm-bonus.cjs.entry.js +4 -4
  6. package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -1
  7. package/dist/cjs/crm-giftback-form_2.cjs.entry.js +1 -1
  8. package/dist/cjs/{crmbonus.service-566fc43f.js → crmbonus.service-8dff0944.js} +2 -2
  9. package/dist/cjs/{crmbonus.service-566fc43f.js.map → crmbonus.service-8dff0944.js.map} +1 -1
  10. package/dist/cjs/pedido-finalizado.cjs.entry.js +2 -2
  11. package/dist/collection/components/crm-bonus/crm-bonus.js +2 -2
  12. package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
  13. package/dist/components/crm-bonus-form.js +1 -1
  14. package/dist/components/crm-bonus-note.js +1 -1
  15. package/dist/components/crm-bonus.js +5 -5
  16. package/dist/components/crm-bonus.js.map +1 -1
  17. package/dist/components/crm-giftback-form.js +1 -1
  18. package/dist/components/{p-a61d6a12.js → p-06a20bea.js} +2 -2
  19. package/dist/components/{p-a61d6a12.js.map → p-06a20bea.js.map} +1 -1
  20. package/dist/components/{p-c0ce1213.js → p-22dc683b.js} +2 -2
  21. package/dist/components/{p-c0ce1213.js.map → p-22dc683b.js.map} +1 -1
  22. package/dist/components/{p-e9895f08.js → p-2f3e90b8.js} +2 -2
  23. package/dist/components/{p-e9895f08.js.map → p-2f3e90b8.js.map} +1 -1
  24. package/dist/components/pedido-finalizado.js +2 -2
  25. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
  26. package/dist/crmbonus-component-wake/{p-a61d6a12.js → p-06a20bea.js} +2 -2
  27. package/dist/crmbonus-component-wake/{p-e9895f08.js → p-2f3e90b8.js} +2 -2
  28. package/dist/crmbonus-component-wake/{p-e9895f08.js.map → p-2f3e90b8.js.map} +1 -1
  29. package/dist/crmbonus-component-wake/p-4a36599f.entry.js +2 -0
  30. package/dist/crmbonus-component-wake/p-4a36599f.entry.js.map +1 -0
  31. package/dist/crmbonus-component-wake/{p-432e371d.entry.js → p-55eef7f5.entry.js} +2 -2
  32. package/dist/crmbonus-component-wake/{p-a63f44b6.entry.js → p-6f63c678.entry.js} +2 -2
  33. package/dist/crmbonus-component-wake/{p-7e6797e3.entry.js → p-da78db17.entry.js} +2 -2
  34. package/dist/crmbonus-component-wake/{p-571f0bb1.entry.js → p-fd697405.entry.js} +2 -2
  35. package/dist/env.js +1 -1
  36. package/dist/env.js.map +1 -1
  37. package/dist/esm/{cart.helper-69d64e28.js → cart.helper-035a4633.js} +2 -2
  38. package/dist/esm/{cart.helper-69d64e28.js.map → cart.helper-035a4633.js.map} +1 -1
  39. package/dist/esm/crm-bonus-form.entry.js +1 -1
  40. package/dist/esm/crm-bonus-note.entry.js +2 -2
  41. package/dist/esm/crm-bonus.entry.js +4 -4
  42. package/dist/esm/crm-bonus.entry.js.map +1 -1
  43. package/dist/esm/crm-giftback-form_2.entry.js +1 -1
  44. package/dist/esm/{crmbonus.service-ad8702ce.js → crmbonus.service-d99af814.js} +2 -2
  45. package/dist/esm/{crmbonus.service-ad8702ce.js.map → crmbonus.service-d99af814.js.map} +1 -1
  46. package/dist/esm/pedido-finalizado.entry.js +2 -2
  47. package/dist/types/home/darlison/Projects/Bycoders/crmbonus/crmbonus-component/.stencil/env.d.ts +1 -1
  48. package/package.json +1 -1
  49. package/dist/crmbonus-component-wake/p-7df4432d.entry.js +0 -2
  50. package/dist/crmbonus-component-wake/p-7df4432d.entry.js.map +0 -1
  51. /package/dist/crmbonus-component-wake/{p-a61d6a12.js.map → p-06a20bea.js.map} +0 -0
  52. /package/dist/crmbonus-component-wake/{p-432e371d.entry.js.map → p-55eef7f5.entry.js.map} +0 -0
  53. /package/dist/crmbonus-component-wake/{p-a63f44b6.entry.js.map → p-6f63c678.entry.js.map} +0 -0
  54. /package/dist/crmbonus-component-wake/{p-7e6797e3.entry.js.map → p-da78db17.entry.js.map} +0 -0
  55. /package/dist/crmbonus-component-wake/{p-571f0bb1.entry.js.map → p-fd697405.entry.js.map} +0 -0
@@ -0,0 +1,2 @@
1
+ import{r as t,h as s}from"./p-3d6152b1.js";import{C as i}from"./p-2f3e90b8.js";import{S as e}from"./p-7cfea8fe.js";import{i as o}from"./p-e8c19a64.js";import{C as n,g as a}from"./p-06a20bea.js";import"./p-f9aeffc1.js";var r;(function(t){t["P"]="Promocao"})(r||(r={}));function c(t=[]){const s=[];for(const i of t){let t=h(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 h(t=[]){let s=0;for(const i of t){if(i.Tipo===r.P){s+=i.Valor}}return s}const l=".container-button.sc-crm-bonus{cursor:pointer;padding:5px 5px 5px 14px}.section-crm.sc-crm-bonus{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm.sc-crm-bonus{margin-top:10px}.section-cart-crm.sc-crm-bonus p.sc-crm-bonus{padding:0;margin:0px 0px 0px 15px}.button.sc-crm-bonus{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;font-size:20px;cursor:pointer;margin-left:10px;height:70px}.form-container.sc-crm-bonus{width:97%;display:flex;justify-content:space-around}.btn.sc-crm-bonus{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;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.sc-crm-bonus .btnCrm.sc-crm-bonus{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert.sc-crm-bonus{font-family:sans-serif;color:#df4d4d;margin-top:5px}";const d=l;const u=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}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(e.STEP_PHONE)}finally{this.loading=false}}async reprocess(){this.loading_reprocess=true;try{this.cartWake=this.cart?new n(JSON.parse(this.cart)):await a();console.log("cart",this.cartWake);await this.resetBonus()}catch(t){console.debug("[watchProducts]",t.message)}finally{this.loading_reprocess=false}}async componentWillLoad(){o.changeLanguage(o.language);await this.handleLoad();await this.loadSession();await this.loadConfigStore()}async loadConfigStore(){await this.crmBonusService.getCustomization(this.cartWake.store.name)}async handleLoad(){try{this.cartWake=this.cart?new n(JSON.parse(this.cart)):await a();console.log("cart",this.cartWake);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(){console.log("this.storeName",this.cartWake.store.name);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 e=JSON.parse(localStorage.getItem(s));const o=[];for(const s of t){const[t]=e.filter((t=>t.ProdutoVarianteId==s.ProdutoVarianteId));const[i={Valor:0}]=t.Ajustes.filter((t=>t.Tipo==="Formula"));if(t){o.push(Object.assign(Object.assign({},s),{PrecoPor:t.PrecoPor+i.Valor*-1,Quantidade:t.Quantidade,Ajustes:t.Ajustes}))}else{o.push(s)}}this.cartWake.products=o}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(e.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(e.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 c(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(e.STEP_NAME);this.showModal=true}render(){return s("loading-container",{key:"906e5a3145d78da469fef1e65ad94aefd960e3d9",loading:this.loading_reprocess},s("crm-giftback-form",{key:"464f3ea45a5929fc10e722b4f7ce4024d58660eb",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()}))}static get assetsDirs(){return["assets"]}};u.style=d;export{u as crm_bonus};
2
+ //# sourceMappingURL=p-4a36599f.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","resetBonus","console","log","crmBonusRef","processBonus","buildProducts","err","loading","setStep","StepFormEnum","STEP_PHONE","reprocess","loading_reprocess","cartWake","cart","CartWake","JSON","parse","getCart","debug","message","componentWillLoad","i18next","changeLanguage","language","handleLoad","loadSession","loadConfigStore","getCustomization","store","user","id","customer","getCustomer","amount","localStorage","getItem","canCancel","amountCancel","buildAndGetProducts","error","session","getToken","setTimeout","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","style","position","ref","storeName","cartId","loadProducts"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","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 font-family: sans-serif;\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 { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\nimport { getCart } from '../../helpers/cart.helper';\nimport { CartWake } from '../../objectvalues/cart.wake';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\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\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 reprocess() {\n this.loading_reprocess = true\n\n try {\n\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\n\n console.log('cart', this.cartWake)\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n // @Watch(\"productsInString\")\n // async watchProducts(newValue: string) {\n // try {\n // console.log('[update products list]');\n // this.productsInString = newValue;\n // await this.handleLoad();\n\n // await this.resetBonus();\n // } catch (err) {\n // console.debug('[watchProducts]', err.message);\n // }\n // }\n\n async componentWillLoad() {\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 await this.crmBonusService.getCustomization(this.cartWake.store.name);\n }\n\n async handleLoad() {\n try {\n\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\n\n console.log('cart', this.cartWake)\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 console.log('this.storeName', this.cartWake.store.name)\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 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\n />\n </loading-container>\n )\n }\n}\n"],"mappings":"0NAQA,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,woCACpB,MAAAC,EAAeD,E,MCgB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AAc3E,GAClBP,KAAK4B,QAAU,GACf,IAAKrB,EAAO,CACVP,KAAK4B,QAAU,uBACf,M,CAGF5B,KAAKwC,SAASjC,MAAQA,EACtB,MAAM2D,EAAS3D,EAAM4D,QAAQ,MAAO,IACpCnE,KAAKO,MAAQ6D,OAAOF,GAEpB,GAAIlE,KAAKwC,SAASlC,KAAM,CACtB,OAAON,KAAKiE,QAAQ1D,E,OAGhBP,KAAKW,YAAYK,QAAQC,EAAakE,WAC5CnF,KAAKuE,UAAY,I,CAGnB,MAAAa,GAEE,OACEC,EAAA,qBAAAjC,IAAA,2CAAmBrC,QAASf,KAAKoB,mBAC/BiE,EAAA,qBAAAjC,IAAA,2CACEkC,MAAO,CAAEC,SAAU,YACnBC,IAAKA,GAAOxF,KAAKW,YAAc6E,EAC/BC,UAAWzF,KAAKqB,SAASgB,MAAM/B,KAC/B7B,SAAUuB,KAAKa,gBACf6E,OAAQ1F,KAAKqB,SAASkB,GACtBC,SAAUxC,KAAKwC,SACfmD,aAAc,IAAM3F,KAAKa,kB","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import{r as t,h as i}from"./p-3d6152b1.js";import{C as e}from"./p-e9895f08.js";import{S as s}from"./p-7cfea8fe.js";import{g as o}from"./p-75ba7b9a.js";import{i as a}from"./p-e8c19a64.js";import{g as n,U as r}from"./p-f9aeffc1.js";const c="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-family:Roboto;font-size:var(--crmfont-sizebodymd);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:14px;color:var(--crm-btn);font-weight:100}.crm-title{font-weight:700;line-height:20px;color:#262626;font-size:16px}.crm-message-info{color:#619013;font-weight:500;font-size:12px}.crm-message-error{color:#E11D48;font-weight:500;font-size:12px}";const h=c;const d=class{constructor(i){t(this,i);this.crmBonusService=e.getInstance();this.storeName=undefined;this.cartId=undefined;this.products=undefined;this.customer=undefined;this.loadProducts=undefined;this.value=undefined;this.loading=false;this.message=undefined;this.phone=undefined;this.pinInfo=undefined;this.step=s.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){this.sucess="";console.log("processBonus",[]);if(i){this.products=t}const e=localStorage.getItem(n(this.cartId));if(e){const t=JSON.parse(e);this.bonus=t;this.phone=t.phone;this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018")}}async handleSendPin(t){this.message="";if(!t){this.message="Informe seu telefone";return}this.phone=t;this.sendPin()}async componentWillLoad(){this.sucess="";this.error="";this.config=o(this.storeName);const t=this.getPhoneNumberAgain();if(t){this.step=s.STEP_PHONE;return}await this.processBonus()}getPhoneNumberAgain(){const t=localStorage.getItem(n(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,e;this.loading=true;this.message="";this.sucess="";this.error="";try{const i=this.convertStringToNumber();const e=localStorage.getItem(`bc:${this.phone}`);if(!e){this.pinInfo=await this.crmBonusService.sendPin(i,(t=this.customer)===null||t===void 0?void 0:t.name,this.storeName)}if(e){const t=JSON.parse(e);this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018");this.step=s.STEP_RESERVE}else{this.step=s.STEP_PIN}}catch(t){this.message=(e=(i=t===null||t===void 0?void 0:t.response)===null||i===void 0?void 0:i.data)===null||e===void 0?void 0:e.message}finally{this.loading=false}}changePhone(){this.sucess="";this.error="";this.step=s.STEP_PHONE}async validateBonus(t){var i,e,o;this.loadProducts();const a=localStorage.getItem(r);if(a=="dontUse"){this.step=s.STEP_RESERVE;return}this.loading=true;this.sucess="";this.error="";const c={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(c);if(!this.bonus.hasBonus){localStorage.setItem(n(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));this.loading=false;this.step=s.STEP_NO_BONUS;return}this.sucess="Código validado com sucesso!";localStorage.setItem(n(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));localStorage.setItem(`bc:${this.phone}`,JSON.stringify(this.bonus));localStorage.setItem(r,"use");localStorage.setItem(this.cartId,this.bonus.bonusBalance.toString());this.step=s.STEP_RESERVE}catch(t){const i=(o=(e=t===null||t===void 0?void 0:t.response)===null||e===void 0?void 0:e.data)===null||o===void 0?void 0:o.message;if(i.includes("Pin")){this.error="Código inválido!"}else{this.error=i;this.step=s.STEP_NO_BONUS}}finally{this.loading=false}}handleCancel(){this.cancel()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartId);localStorage.setItem(r,"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=s.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:"8856b0021380c06a1b6d0fe377d0836de0308e40",class:"crm-container-form fbits-responsive-carrinho-desconto"},i("label",{key:"ef51aa9f64f7438ae887f5af0688df3c216d810c",class:"crm-title"},this.config.giftbackTitle),this.step===s.STEP_PHONE&&i("phone-form",{key:"12cd253b89c74738fe27a3ef0a2a46ce50b4f71d",value:this.customer.phone,config:this.config,loading:this.loading,handlerSubmit:t=>this.handleSendPin(t)}),this.step===s.STEP_PIN&&i("pin-form",{key:"fb7c11d2d94e0035be7615d342cd6e9bf04924e4",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:"5c8071135ce7f287cb6203f78d0c05988eee3d13",class:"crm-message-info"},this.sucess),this.error&&i("p",{key:"e0516266cfa7886049a4d751595318ceaf0131f7",class:"crm-message-error"},this.error)),this.step===s.STEP_RESERVE&&i("giftback-info",{key:"b36f43a03dd113bc743c985b4327762647aea00c",config:this.config,loading:this.loading,cancel:()=>this.handleCancel(),bonus:this.bonus,reserve:()=>this.processBonus()}),this.step===s.STEP_NO_BONUS&&i("div",{key:"cfeacde74e0b598e2ab93a86af5dc6838ef040cb",class:"container-message"},a.t("noGiftback",{storename:this.config.giftbackTitle})))}};d.style=h;const l=".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 f=l;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=f;export{d as crm_giftback_form,m as loading_container};
2
- //# sourceMappingURL=p-432e371d.entry.js.map
1
+ import{r as t,h as i}from"./p-3d6152b1.js";import{C as e}from"./p-2f3e90b8.js";import{S as s}from"./p-7cfea8fe.js";import{g as o}from"./p-75ba7b9a.js";import{i as a}from"./p-e8c19a64.js";import{g as n,U as r}from"./p-f9aeffc1.js";const c="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-family:Roboto;font-size:var(--crmfont-sizebodymd);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:14px;color:var(--crm-btn);font-weight:100}.crm-title{font-weight:700;line-height:20px;color:#262626;font-size:16px}.crm-message-info{color:#619013;font-weight:500;font-size:12px}.crm-message-error{color:#E11D48;font-weight:500;font-size:12px}";const h=c;const d=class{constructor(i){t(this,i);this.crmBonusService=e.getInstance();this.storeName=undefined;this.cartId=undefined;this.products=undefined;this.customer=undefined;this.loadProducts=undefined;this.value=undefined;this.loading=false;this.message=undefined;this.phone=undefined;this.pinInfo=undefined;this.step=s.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){this.sucess="";console.log("processBonus",[]);if(i){this.products=t}const e=localStorage.getItem(n(this.cartId));if(e){const t=JSON.parse(e);this.bonus=t;this.phone=t.phone;this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018")}}async handleSendPin(t){this.message="";if(!t){this.message="Informe seu telefone";return}this.phone=t;this.sendPin()}async componentWillLoad(){this.sucess="";this.error="";this.config=o(this.storeName);const t=this.getPhoneNumberAgain();if(t){this.step=s.STEP_PHONE;return}await this.processBonus()}getPhoneNumberAgain(){const t=localStorage.getItem(n(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,e;this.loading=true;this.message="";this.sucess="";this.error="";try{const i=this.convertStringToNumber();const e=localStorage.getItem(`bc:${this.phone}`);if(!e){this.pinInfo=await this.crmBonusService.sendPin(i,(t=this.customer)===null||t===void 0?void 0:t.name,this.storeName)}if(e){const t=JSON.parse(e);this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018");this.step=s.STEP_RESERVE}else{this.step=s.STEP_PIN}}catch(t){this.message=(e=(i=t===null||t===void 0?void 0:t.response)===null||i===void 0?void 0:i.data)===null||e===void 0?void 0:e.message}finally{this.loading=false}}changePhone(){this.sucess="";this.error="";this.step=s.STEP_PHONE}async validateBonus(t){var i,e,o;this.loadProducts();const a=localStorage.getItem(r);if(a=="dontUse"){this.step=s.STEP_RESERVE;return}this.loading=true;this.sucess="";this.error="";const c={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(c);if(!this.bonus.hasBonus){localStorage.setItem(n(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));this.loading=false;this.step=s.STEP_NO_BONUS;return}this.sucess="Código validado com sucesso!";localStorage.setItem(n(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));localStorage.setItem(`bc:${this.phone}`,JSON.stringify(this.bonus));localStorage.setItem(r,"use");localStorage.setItem(this.cartId,this.bonus.bonusBalance.toString());this.step=s.STEP_RESERVE}catch(t){const i=(o=(e=t===null||t===void 0?void 0:t.response)===null||e===void 0?void 0:e.data)===null||o===void 0?void 0:o.message;if(i.includes("Pin")){this.error="Código inválido!"}else{this.error=i;this.step=s.STEP_NO_BONUS}}finally{this.loading=false}}handleCancel(){this.cancel()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartId);localStorage.setItem(r,"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=s.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:"8856b0021380c06a1b6d0fe377d0836de0308e40",class:"crm-container-form fbits-responsive-carrinho-desconto"},i("label",{key:"ef51aa9f64f7438ae887f5af0688df3c216d810c",class:"crm-title"},this.config.giftbackTitle),this.step===s.STEP_PHONE&&i("phone-form",{key:"12cd253b89c74738fe27a3ef0a2a46ce50b4f71d",value:this.customer.phone,config:this.config,loading:this.loading,handlerSubmit:t=>this.handleSendPin(t)}),this.step===s.STEP_PIN&&i("pin-form",{key:"fb7c11d2d94e0035be7615d342cd6e9bf04924e4",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:"5c8071135ce7f287cb6203f78d0c05988eee3d13",class:"crm-message-info"},this.sucess),this.error&&i("p",{key:"e0516266cfa7886049a4d751595318ceaf0131f7",class:"crm-message-error"},this.error)),this.step===s.STEP_RESERVE&&i("giftback-info",{key:"b36f43a03dd113bc743c985b4327762647aea00c",config:this.config,loading:this.loading,cancel:()=>this.handleCancel(),bonus:this.bonus,reserve:()=>this.processBonus()}),this.step===s.STEP_NO_BONUS&&i("div",{key:"cfeacde74e0b598e2ab93a86af5dc6838ef040cb",class:"container-message"},a.t("noGiftback",{storename:this.config.giftbackTitle})))}};d.style=h;const l=".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 f=l;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=f;export{d as crm_giftback_form,m as loading_container};
2
+ //# sourceMappingURL=p-55eef7f5.entry.js.map
@@ -1,2 +1,2 @@
1
- import{r as t,h as s,H as e}from"./p-3d6152b1.js";import{C as i}from"./p-e9895f08.js";import{S as a}from"./p-7cfea8fe.js";import"./p-f9aeffc1.js";const n=".form-container{width:100%;display:flex;justify-content:center;justify-content:space-around}.disabled{opacity:0.6;cursor:not-allowed}.message-error{color:#d11111;font-weight:bold;font-family:Arial;font-size:small;margin-left:16px}";const h=n;const d=class{constructor(s){t(this,s);this.crmBonusService=i.getInstance();this.storeName=undefined;this.cartId=undefined;this.products=undefined;this.customer={phone:"",birthDate:"",document:"",name:""};this.sent=undefined;this.stepNext=undefined;this.phone=undefined;this.loadingModal=undefined;this.saveStore=undefined;this.cancel=undefined;this.handleCustomerName=undefined;this.loading=false;this.step=a.STEP_NAME;this.message=undefined;this.bonus=undefined}async setStep(t){this.step=t}async validateBonus(t){var s,e;this.loading=true;this.message="";const i={pin:t,cellphone:parseInt(this.phone.toString()),storeId:this.sent.storeId.toString(),userId:this.sent.userId.toString(),checkoutId:this.cartId,checkoutProducts:this.products,name:null,storeName:this.storeName};try{this.bonus=await this.crmBonusService.validatePinBonus(i);this.step=a.STEP_RESERVE}catch(t){this.message=(e=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||e===void 0?void 0:e.message}finally{this.loading=false}}async reserveApply(t){this.loading=true;this.message="";try{await this.reserve(t);this.step=a.STEP_APPLY;this.saveStore(t)}catch(t){this.message="ocorreu um error ao solicitar a aplicação do bonus! tente novamente"}finally{this.loading=false}}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})}handleCancel(){this.step=a.STEP_PHONE;this.cancel()}render(){return s(e,{key:"2d736cd603436521bf15f0ef8eaf0670ad9f6a42"},this.step==a.STEP_NAME&&s("name-input",{key:"bfa12463c1f29bb65814368790f201dcab869dd9",loading:this.loadingModal,value:this.customer.name,applyName:t=>this.handleCustomerName(t)}),this.step===a.STEP_PIN&&s("giftback-pin",{key:"3fdf1c285b5d777289b42fcfbcf80dfc92579f29",cancel:()=>this.handleCancel(),sent:this.sent,validate:t=>this.validateBonus(t),loading:this.loading}),this.step===a.STEP_RESERVE&&s("giftback-progress",{key:"f06df8cab7361a51d1b89b4f0f0a1a8ceb7a7e30",loading:this.loading,cancel:()=>this.handleCancel(),bonus:this.bonus,reserve:t=>this.reserveApply(t)}),this.step===a.STEP_APPLY&&s("giftback-finish",{key:"eaacf1438652b04cfd607e5bac81dffbe4b542bb"}),s("p",{key:"a2014780bbb5dfb23cf6165500f43c6fcca700d3",class:"message-error"},this.message))}};d.style=h;export{d as crm_bonus_form};
2
- //# sourceMappingURL=p-a63f44b6.entry.js.map
1
+ import{r as t,h as s,H as e}from"./p-3d6152b1.js";import{C as i}from"./p-2f3e90b8.js";import{S as a}from"./p-7cfea8fe.js";import"./p-f9aeffc1.js";const n=".form-container{width:100%;display:flex;justify-content:center;justify-content:space-around}.disabled{opacity:0.6;cursor:not-allowed}.message-error{color:#d11111;font-weight:bold;font-family:Arial;font-size:small;margin-left:16px}";const h=n;const d=class{constructor(s){t(this,s);this.crmBonusService=i.getInstance();this.storeName=undefined;this.cartId=undefined;this.products=undefined;this.customer={phone:"",birthDate:"",document:"",name:""};this.sent=undefined;this.stepNext=undefined;this.phone=undefined;this.loadingModal=undefined;this.saveStore=undefined;this.cancel=undefined;this.handleCustomerName=undefined;this.loading=false;this.step=a.STEP_NAME;this.message=undefined;this.bonus=undefined}async setStep(t){this.step=t}async validateBonus(t){var s,e;this.loading=true;this.message="";const i={pin:t,cellphone:parseInt(this.phone.toString()),storeId:this.sent.storeId.toString(),userId:this.sent.userId.toString(),checkoutId:this.cartId,checkoutProducts:this.products,name:null,storeName:this.storeName};try{this.bonus=await this.crmBonusService.validatePinBonus(i);this.step=a.STEP_RESERVE}catch(t){this.message=(e=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||e===void 0?void 0:e.message}finally{this.loading=false}}async reserveApply(t){this.loading=true;this.message="";try{await this.reserve(t);this.step=a.STEP_APPLY;this.saveStore(t)}catch(t){this.message="ocorreu um error ao solicitar a aplicação do bonus! tente novamente"}finally{this.loading=false}}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})}handleCancel(){this.step=a.STEP_PHONE;this.cancel()}render(){return s(e,{key:"2d736cd603436521bf15f0ef8eaf0670ad9f6a42"},this.step==a.STEP_NAME&&s("name-input",{key:"bfa12463c1f29bb65814368790f201dcab869dd9",loading:this.loadingModal,value:this.customer.name,applyName:t=>this.handleCustomerName(t)}),this.step===a.STEP_PIN&&s("giftback-pin",{key:"3fdf1c285b5d777289b42fcfbcf80dfc92579f29",cancel:()=>this.handleCancel(),sent:this.sent,validate:t=>this.validateBonus(t),loading:this.loading}),this.step===a.STEP_RESERVE&&s("giftback-progress",{key:"f06df8cab7361a51d1b89b4f0f0a1a8ceb7a7e30",loading:this.loading,cancel:()=>this.handleCancel(),bonus:this.bonus,reserve:t=>this.reserveApply(t)}),this.step===a.STEP_APPLY&&s("giftback-finish",{key:"eaacf1438652b04cfd607e5bac81dffbe4b542bb"}),s("p",{key:"a2014780bbb5dfb23cf6165500f43c6fcca700d3",class:"message-error"},this.message))}};d.style=h;export{d as crm_bonus_form};
2
+ //# sourceMappingURL=p-6f63c678.entry.js.map
@@ -1,2 +1,2 @@
1
- import{r as a,h as t}from"./p-3d6152b1.js";import{C as o}from"./p-e9895f08.js";import{C as r,g as s}from"./p-a61d6a12.js";import"./p-f9aeffc1.js";const d=class{constructor(t){a(this,t);this.cart=undefined}async componentWillLoad(){await this.handleOrder()}async handleOrder(){console.log("this.cart",this.cart);const a=this.cart?new r(JSON.parse(this.cart)):await s();if(a.id&&a.orderId){o.getInstance().updateOrder({cartId:a.id,orderId:a.orderId,cartIdCrm:a.middlewareId});const t=`bc-products:${a.id}`;localStorage.removeItem(t);localStorage.removeItem(a.id)}}render(){return t("div",{key:"d79a815efc708a2d818fa6adf22464a45e7fa546"})}};export{d as pedido_finalizado};
2
- //# sourceMappingURL=p-7e6797e3.entry.js.map
1
+ import{r as a,h as t}from"./p-3d6152b1.js";import{C as o}from"./p-2f3e90b8.js";import{C as r,g as s}from"./p-06a20bea.js";import"./p-f9aeffc1.js";const e=class{constructor(t){a(this,t);this.cart=undefined}async componentWillLoad(){await this.handleOrder()}async handleOrder(){console.log("this.cart",this.cart);const a=this.cart?new r(JSON.parse(this.cart)):await s();if(a.id&&a.orderId){o.getInstance().updateOrder({cartId:a.id,orderId:a.orderId,cartIdCrm:a.middlewareId});const t=`bc-products:${a.id}`;localStorage.removeItem(t);localStorage.removeItem(a.id)}}render(){return t("div",{key:"d79a815efc708a2d818fa6adf22464a45e7fa546"})}};export{e as pedido_finalizado};
2
+ //# sourceMappingURL=p-da78db17.entry.js.map
@@ -1,2 +1,2 @@
1
- import{r as e,h as n}from"./p-3d6152b1.js";import{g as t}from"./p-75ba7b9a.js";import{g as a}from"./p-f9aeffc1.js";import{i}from"./p-e8c19a64.js";import{C as o,g as c}from"./p-a61d6a12.js";import"./p-e9895f08.js";const s="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiLz4KPHBhdGggZD0iTTE1IDkuOTQ3MjhDMTQuNSA5LjMgMTMuOCA4LjUgMTIgOC41QzEwLjIgOC41IDkgOS41MTM5MyA5IDkuOTQ3MjhDOSAxMC4zODA2IDkuMDY3ODYgMTAuOTI3NyAxMCAxMS41QzEwLjc1MjIgMTEuOTYxOCAxMi42Njg0IDEyLjA0MzkgMTMuNSAxMi41QzE0LjY3OSAxMy4xNDY3IDE0Ljg0OTcgMTMuODIwMiAxNC44NDk3IDE0LjA1MjJDMTQuODQ5NyAxNC42ODM3IDEzLjQxNzUgMTUuNDg1MiAxMiAxNS41QzEwLjUzNiAxNS41MTUzIDkuNSAxNC43IDkgMTQuMDUyMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTIgN1YxNyIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==";function d(){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 r=".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 font-family: Arial;\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-family: Roboto;\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 l=r;const b=class{constructor(n){e(this,n);this.cart=undefined;this.cartWake=undefined;this.url=undefined;this.config=undefined;this.bonus=undefined;this.showEdit=false}async componentWillLoad(){await this.upadateCheckToFreteAndGetUrl();this.startTime()}async upadateCheckToFreteAndGetUrl(){this.cartWake=this.cart?new o(JSON.parse(this.cart)):await c();console.log("upadateCheckToFreteAndGetUrl",this.cartWake);this.config=t(this.cartWake.store.name);const e=document.getElementsByName("forma-envio");e.forEach((e=>{e.checked=false}));this.url=window.location.origin}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(document.location.pathname=="/Fechamento"){if(!localStorage.getItem("bc:time-allow")){localStorage.removeItem("bc:time")}d()}}hasBonus(){const e=localStorage.getItem(a(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 a=this.hasBonus();return n("div",{key:"11537eabb06edb8f49cce047d651ab55ffd1c1b0"},n("div",{key:"58d26bab91654dfd75e0fca2d802986324b71a18",class:"note-container"},n("div",{key:"f6201ec26dabefea977fa656c8c22619bedcee4d",class:"note-header"},n("p",{key:"20c9b53a94aad8a9ae3ae0b75e52078cf3d39b80",class:"note-title"},n("img",{key:"72608e0baf9a13b57b8e84da682258e6d86487fc",src:s,width:23}),this.config.giftbackTitle),a.hasBonus&&n("div",{key:"bd142a2e8e3b923fa7a070bcba5f50b14186da47"},this.showEdit&&n("p",{key:"25051cb4249fe33c99d21ca2a5508b9ba18b506e",class:"back-cart",onClick:()=>this.backCart()},i.t("edit")),!this.showEdit&&n("countdown-timer",{key:"a92863ef2e60a3fecd177278ba03a5cf0810a56a",initialValue:this.getTime(),downtime:()=>{this.showEdit=true}}))),a.hasBonus&&n("p",{key:"21127d419c87f4abe379944aed876dc0a852ee62",class:"note-description-2"},i.t("withApplyBonus",{giftbackname:t})," ",n("strong",{key:"b3a9e3f0ce782230424e6404630759b0828a4538"},"R$ ",this.getAmount(),".")),a.requestBonus&&!a.hasBonus&&n("p",{key:"3e6044bbcf105ea5fab84f649df6cea974ff9554",class:"note-description-not"},i.t("noBonus",{giftbackname:t})),!a.requestBonus&&n("div",{key:"60fe78fe92cf6039df0e9472fe75a5cd40d10726",class:"description"},n("p",{key:"fc0b62ed50c1abb35c2d2b765e27dd00c7e60e3c",class:"note-description-not"},i.t("backCart")),n("crm-button",{key:"1a03a45bb4fcc6c141eca2aa51babbb5f77a5171",txtBtn:"VOLTAR AO CARRINHO",handleClick:()=>this.backCart()}))))}};b.style=l;export{b as crm_bonus_note};
2
- //# sourceMappingURL=p-571f0bb1.entry.js.map
1
+ import{r as e,h as n}from"./p-3d6152b1.js";import{g as t}from"./p-75ba7b9a.js";import{g as a}from"./p-f9aeffc1.js";import{i}from"./p-e8c19a64.js";import{C as o,g as c}from"./p-06a20bea.js";import"./p-2f3e90b8.js";const s="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiLz4KPHBhdGggZD0iTTE1IDkuOTQ3MjhDMTQuNSA5LjMgMTMuOCA4LjUgMTIgOC41QzEwLjIgOC41IDkgOS41MTM5MyA5IDkuOTQ3MjhDOSAxMC4zODA2IDkuMDY3ODYgMTAuOTI3NyAxMCAxMS41QzEwLjc1MjIgMTEuOTYxOCAxMi42Njg0IDEyLjA0MzkgMTMuNSAxMi41QzE0LjY3OSAxMy4xNDY3IDE0Ljg0OTcgMTMuODIwMiAxNC44NDk3IDE0LjA1MjJDMTQuODQ5NyAxNC42ODM3IDEzLjQxNzUgMTUuNDg1MiAxMiAxNS41QzEwLjUzNiAxNS41MTUzIDkuNSAxNC43IDkgMTQuMDUyMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTIgN1YxNyIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==";function d(){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 r=".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 font-family: Arial;\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-family: Roboto;\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 l=r;const b=class{constructor(n){e(this,n);this.cart=undefined;this.cartWake=undefined;this.url=undefined;this.config=undefined;this.bonus=undefined;this.showEdit=false}async componentWillLoad(){await this.upadateCheckToFreteAndGetUrl();this.startTime()}async upadateCheckToFreteAndGetUrl(){this.cartWake=this.cart?new o(JSON.parse(this.cart)):await c();console.log("upadateCheckToFreteAndGetUrl",this.cartWake);this.config=t(this.cartWake.store.name);const e=document.getElementsByName("forma-envio");e.forEach((e=>{e.checked=false}));this.url=window.location.origin}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(document.location.pathname=="/Fechamento"){if(!localStorage.getItem("bc:time-allow")){localStorage.removeItem("bc:time")}d()}}hasBonus(){const e=localStorage.getItem(a(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 a=this.hasBonus();return n("div",{key:"11537eabb06edb8f49cce047d651ab55ffd1c1b0"},n("div",{key:"58d26bab91654dfd75e0fca2d802986324b71a18",class:"note-container"},n("div",{key:"f6201ec26dabefea977fa656c8c22619bedcee4d",class:"note-header"},n("p",{key:"20c9b53a94aad8a9ae3ae0b75e52078cf3d39b80",class:"note-title"},n("img",{key:"72608e0baf9a13b57b8e84da682258e6d86487fc",src:s,width:23}),this.config.giftbackTitle),a.hasBonus&&n("div",{key:"bd142a2e8e3b923fa7a070bcba5f50b14186da47"},this.showEdit&&n("p",{key:"25051cb4249fe33c99d21ca2a5508b9ba18b506e",class:"back-cart",onClick:()=>this.backCart()},i.t("edit")),!this.showEdit&&n("countdown-timer",{key:"a92863ef2e60a3fecd177278ba03a5cf0810a56a",initialValue:this.getTime(),downtime:()=>{this.showEdit=true}}))),a.hasBonus&&n("p",{key:"21127d419c87f4abe379944aed876dc0a852ee62",class:"note-description-2"},i.t("withApplyBonus",{giftbackname:t})," ",n("strong",{key:"b3a9e3f0ce782230424e6404630759b0828a4538"},"R$ ",this.getAmount(),".")),a.requestBonus&&!a.hasBonus&&n("p",{key:"3e6044bbcf105ea5fab84f649df6cea974ff9554",class:"note-description-not"},i.t("noBonus",{giftbackname:t})),!a.requestBonus&&n("div",{key:"60fe78fe92cf6039df0e9472fe75a5cd40d10726",class:"description"},n("p",{key:"fc0b62ed50c1abb35c2d2b765e27dd00c7e60e3c",class:"note-description-not"},i.t("backCart")),n("crm-button",{key:"1a03a45bb4fcc6c141eca2aa51babbb5f77a5171",txtBtn:"VOLTAR AO CARRINHO",handleClick:()=>this.backCart()}))))}};b.style=l;export{b as crm_bonus_note};
2
+ //# sourceMappingURL=p-fd697405.entry.js.map
package/dist/env.js CHANGED
@@ -1,3 +1,3 @@
1
- export const CRM_BONUS_API_URL = "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,2BAA2B,CAAC,CAAA,mTAAmT;AAChX,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAA","sourcesContent":["\nexport const CRM_BONUS_API_URL = \"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
+ {"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-ad8702ce.js';
1
+ import { C as CrmBonusService, a as CHECKOUT_CART_WAKE } from './crmbonus.service-d99af814.js';
2
2
 
3
3
  class CartWake {
4
4
  constructor(cart) {
@@ -47,4 +47,4 @@ const buildUrlBase = () => {
47
47
 
48
48
  export { CartWake as C, getCart as g };
49
49
 
50
- //# sourceMappingURL=cart.helper-69d64e28.js.map
50
+ //# sourceMappingURL=cart.helper-035a4633.js.map
@@ -1 +1 @@
1
- {"file":"cart.helper-69d64e28.js","mappings":";;MAEa,QAAQ;IAQjB,YAAY,IAAI;;QAJhB,aAAQ,GAAmB,EAAE,CAAC;QAK1B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,EAAE,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;KAChC;IAEO,aAAa,CAAC,IAAI;QACtB,IAAI,CAAC,IAAI,GAAG;YACR,EAAE,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;SAC5C,CAAA;KACJ;IAEO,cAAc,CAAC,IAAI;;QACvB,IAAI,CAAC,KAAK,GAAG;YACT,IAAI,EAAE,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI;SACxB,CAAA;KACJ;;;ACzBL,MAAM,eAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;MAE1D,OAAO,GAAG;IACnB,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;IAE/B,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;IAErC,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAExD,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC9B,EAAC;AAED,MAAM,YAAY,GAAG;IAEjB,MAAM,GAAG,GAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IAEpC,IAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QAC1B,OAAO,kBAAkB,CAAC;KAC7B;IAED,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,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/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 = cart.Produtos\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}","import { CHECKOUT_CART_WAKE } from \"../../env\";\nimport { CartWake } from \"../objectvalues/cart.wake\";\nimport { CrmBonusService } from \"../services/crmbonus.service\";\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\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 return `${window.location.protocol}//checkout.${window.location.host}`;\n\n}"],"version":3}
1
+ {"file":"cart.helper-035a4633.js","mappings":";;MAEa,QAAQ;IAQjB,YAAY,IAAI;;QAJhB,aAAQ,GAAmB,EAAE,CAAC;QAK1B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,EAAE,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;KAChC;IAEO,aAAa,CAAC,IAAI;QACtB,IAAI,CAAC,IAAI,GAAG;YACR,EAAE,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI;SAC5C,CAAA;KACJ;IAEO,cAAc,CAAC,IAAI;;QACvB,IAAI,CAAC,KAAK,GAAG;YACT,IAAI,EAAE,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI;SACxB,CAAA;KACJ;;;ACzBL,MAAM,eAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;MAE1D,OAAO,GAAG;IACnB,MAAM,OAAO,GAAG,YAAY,EAAE,CAAC;IAE/B,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;IAErC,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAExD,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC9B,EAAC;AAED,MAAM,YAAY,GAAG;IAEjB,MAAM,GAAG,GAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IAEpC,IAAG,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;QAC1B,OAAO,kBAAkB,CAAC;KAC7B;IAED,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,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/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 = cart.Produtos\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}","import { CHECKOUT_CART_WAKE } from \"../../env\";\nimport { CartWake } from \"../objectvalues/cart.wake\";\nimport { CrmBonusService } from \"../services/crmbonus.service\";\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\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 return `${window.location.protocol}//checkout.${window.location.host}`;\n\n}"],"version":3}
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, H as Host } from './index-e8724c8f.js';
2
- import { C as CrmBonusService } from './crmbonus.service-ad8702ce.js';
2
+ import { C as CrmBonusService } from './crmbonus.service-d99af814.js';
3
3
  import { S as StepFormEnum } from './index-5b567099.js';
4
4
  import './keys.storage-8c76fcd7.js';
5
5
 
@@ -2,8 +2,8 @@ import { r as registerInstance, h } from './index-e8724c8f.js';
2
2
  import { g as getInfoCustomization } from './info.config.helper-42d9ddf9.js';
3
3
  import { g as getKeyReserveByCartId } from './keys.storage-8c76fcd7.js';
4
4
  import { i as instance } from './i18n-e8150dff.js';
5
- import { C as CartWake, g as getCart } from './cart.helper-69d64e28.js';
6
- import './crmbonus.service-ad8702ce.js';
5
+ import { C as CartWake, g as getCart } from './cart.helper-035a4633.js';
6
+ import './crmbonus.service-d99af814.js';
7
7
 
8
8
  const moneyDollarsSvgrepoComSvg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiLz4KPHBhdGggZD0iTTE1IDkuOTQ3MjhDMTQuNSA5LjMgMTMuOCA4LjUgMTIgOC41QzEwLjIgOC41IDkgOS41MTM5MyA5IDkuOTQ3MjhDOSAxMC4zODA2IDkuMDY3ODYgMTAuOTI3NyAxMCAxMS41QzEwLjc1MjIgMTEuOTYxOCAxMi42Njg0IDEyLjA0MzkgMTMuNSAxMi41QzE0LjY3OSAxMy4xNDY3IDE0Ljg0OTcgMTMuODIwMiAxNC44NDk3IDE0LjA1MjJDMTQuODQ5NyAxNC42ODM3IDEzLjQxNzUgMTUuNDg1MiAxMiAxNS41QzEwLjUzNiAxNS41MTUzIDkuNSAxNC43IDkgMTQuMDUyMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTIgN1YxNyIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==';
9
9
 
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, h } from './index-e8724c8f.js';
2
- import { C as CrmBonusService } from './crmbonus.service-ad8702ce.js';
2
+ import { C as CrmBonusService } from './crmbonus.service-d99af814.js';
3
3
  import { S as StepFormEnum } from './index-5b567099.js';
4
4
  import { i as instance } from './i18n-e8150dff.js';
5
- import { C as CartWake, g as getCart } from './cart.helper-69d64e28.js';
5
+ import { C as CartWake, g as getCart } from './cart.helper-035a4633.js';
6
6
  import './keys.storage-8c76fcd7.js';
7
7
 
8
8
  var AjustesTipoEnum;
@@ -110,7 +110,7 @@ const CrmBonus = class {
110
110
  }
111
111
  async handleLoad() {
112
112
  try {
113
- this.cartWake = this.cart ? new CartWake(this.cart) : await getCart();
113
+ this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();
114
114
  console.log('cart', this.cartWake);
115
115
  if (this.cartWake.user.id) {
116
116
  this.customer = await this.crmBonusService.getCustomer(this.cartWake.user.id, this.cartWake.store.name);
@@ -229,7 +229,7 @@ const CrmBonus = class {
229
229
  this.showModal = true;
230
230
  }
231
231
  render() {
232
- return (h("loading-container", { key: 'aaf89a1bdcfec70d7175049061bc728194f1dc82', loading: this.loading_reprocess }, h("crm-giftback-form", { key: '96322e1d19ad37846af67000055fd2741cfb0020', style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.cartWake.store.name, products: this.buildProducts(), cartId: this.cartWake.id, customer: this.customer, loadProducts: () => this.buildProducts() })));
232
+ return (h("loading-container", { key: '906e5a3145d78da469fef1e65ad94aefd960e3d9', loading: this.loading_reprocess }, h("crm-giftback-form", { key: '464f3ea45a5929fc10e722b4f7ce4024d58660eb', style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.cartWake.store.name, products: this.buildProducts(), cartId: this.cartWake.id, customer: this.customer, loadProducts: () => this.buildProducts() })));
233
233
  }
234
234
  static get assetsDirs() { return ["assets"]; }
235
235
  };
@@ -1 +1 @@
1
- {"file":"crm-bonus.entry.js","mappings":";;;;;;;AAQA,IAAY,eAEX;AAFD,WAAY,eAAe;IACvB,iCAAc,CAAA;AAClB,CAAC,EAFW,eAAe,KAAf,eAAe;;SCNX,mBAAmB,CAAC,eAAoC,EAAE;IAEtE,MAAM,QAAQ,GAAoB,EAAE,CAAC;IAErC,KAAM,MAAM,EAAE,IAAI,YAAY,EAA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M,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;SAC3B;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;KACvB;IAED,MAAM;QAEJ,QACE,0EAAmB,OAAO,EAAE,IAAI,CAAC,iBAAiB,IAChD,0EACE,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAC/B,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EACnC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,GAExC,CACgB,EACrB;KACF;;;;;;;","names":["i18next"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","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 font-family: sans-serif;\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 { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\nimport { getCart } from '../../helpers/cart.helper';\nimport { CartWake } from '../../objectvalues/cart.wake';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\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\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 reprocess() {\n this.loading_reprocess = true\n\n try {\n\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\n\n console.log('cart', this.cartWake)\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n // @Watch(\"productsInString\")\n // async watchProducts(newValue: string) {\n // try {\n // console.log('[update products list]');\n // this.productsInString = newValue;\n // await this.handleLoad();\n\n // await this.resetBonus();\n // } catch (err) {\n // console.debug('[watchProducts]', err.message);\n // }\n // }\n\n async componentWillLoad() {\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 await this.crmBonusService.getCustomization(this.cartWake.store.name);\n }\n\n async handleLoad() {\n try {\n\n this.cartWake = this.cart ? new CartWake(this.cart) : await getCart();\n\n console.log('cart', this.cartWake)\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 console.log('this.storeName', this.cartWake.store.name)\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 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\n />\n </loading-container>\n )\n }\n}\n"],"version":3}
1
+ {"file":"crm-bonus.entry.js","mappings":";;;;;;;AAQA,IAAY,eAEX;AAFD,WAAY,eAAe;IACvB,iCAAc,CAAA;AAClB,CAAC,EAFW,eAAe,KAAf,eAAe;;SCNX,mBAAmB,CAAC,eAAoC,EAAE;IAEtE,MAAM,QAAQ,GAAoB,EAAE,CAAC;IAErC,KAAM,MAAM,EAAE,IAAI,YAAY,EAAG;QAC7B,IAAI,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,CAAA;QAEvC,QAAQ,CAAC,IAAI,CACT;YACI,GAAG,EAAE,EAAE,CAAC,GAAG;YACX,KAAK,GAAG,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC;YACpC,gBAAgB,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,EAAE;YACjD,QAAQ,EAAE,EAAE,CAAC,UAAU;YACvB,QAAQ,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC;SAC7B,CACJ,CAAA;KACJ;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED,SAAS,WAAW,CAAC,UAAsB,EAAE;IAEzC,IA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AAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EACnC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,GAExC,CACgB,EACrB;KACF;;;;;;;","names":["i18next"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","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 font-family: sans-serif;\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 { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\nimport { getCart } from '../../helpers/cart.helper';\nimport { CartWake } from '../../objectvalues/cart.wake';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\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\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 reprocess() {\n this.loading_reprocess = true\n\n try {\n\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\n\n console.log('cart', this.cartWake)\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n // @Watch(\"productsInString\")\n // async watchProducts(newValue: string) {\n // try {\n // console.log('[update products list]');\n // this.productsInString = newValue;\n // await this.handleLoad();\n\n // await this.resetBonus();\n // } catch (err) {\n // console.debug('[watchProducts]', err.message);\n // }\n // }\n\n async componentWillLoad() {\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 await this.crmBonusService.getCustomization(this.cartWake.store.name);\n }\n\n async handleLoad() {\n try {\n\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\n\n console.log('cart', this.cartWake)\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 console.log('this.storeName', this.cartWake.store.name)\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 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\n />\n </loading-container>\n )\n }\n}\n"],"version":3}
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h } from './index-e8724c8f.js';
2
- import { C as CrmBonusService } from './crmbonus.service-ad8702ce.js';
2
+ import { C as CrmBonusService } from './crmbonus.service-d99af814.js';
3
3
  import { S as StepFormEnum } from './index-5b567099.js';
4
4
  import { g as getInfoCustomization } from './info.config.helper-42d9ddf9.js';
5
5
  import { i as instance } from './i18n-e8150dff.js';
@@ -3751,7 +3751,7 @@ axios.default = axios;
3751
3751
  // this module should only have a default export
3752
3752
  const axios$1 = axios;
3753
3753
 
3754
- const CRM_BONUS_API_URL = "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";
3754
+ 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";
3755
3755
  const CHECKOUT_CART_WAKE = "http://localhost:3001";
3756
3756
 
3757
3757
  class CrmBonusService {
@@ -3871,4 +3871,4 @@ CrmBonusService._instance = null;
3871
3871
 
3872
3872
  export { CrmBonusService as C, CHECKOUT_CART_WAKE as a };
3873
3873
 
3874
- //# sourceMappingURL=crmbonus.service-ad8702ce.js.map
3874
+ //# sourceMappingURL=crmbonus.service-d99af814.js.map