crmbonus-component-wake 2.0.74 → 2.0.75

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.
@@ -36,9 +36,10 @@ const CrmBonus = class {
36
36
  }
37
37
  async resetBonus() {
38
38
  console.log('[START RESET BONUS]!!!!!');
39
- // const exists = localStorage.getItem(getKeyReserveByCartId(this.cartId))
40
- // if(!exists) return;
41
- await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
39
+ const used = localStorage.getItem("bc:used");
40
+ if (used == "use") {
41
+ await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
42
+ }
42
43
  try {
43
44
  await this.crmBonusRef.processBonus();
44
45
  console.log('[BONUS RESETADO]!!!!!');
@@ -189,7 +190,7 @@ const CrmBonus = class {
189
190
  this.showModal = true;
190
191
  }
191
192
  render() {
192
- return (index.h("crm-giftback-form", { key: '62d209d69589c4e4c30462e3800755cdd4102d84', ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer })
193
+ return (index.h("crm-giftback-form", { key: '0cba16a775789a465f453f2837155360d2cdf537', ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer })
193
194
  // <div class="section-cart-crm">
194
195
  // <p class="text-left fbits-responsive-carrinho-desconto-texto">Giftback</p>
195
196
  // <div class="container-button">
@@ -1 +1 @@
1
- {"file":"crm-bonus.entry.cjs.js","mappings":";;;;;;;;;AAAA,MAAM,WAAW,GAAG,uoCAAuoC,CAAC;AAC5pC,uBAAe,WAAW;;MCab,QAAQ;;;QAEX,oBAAe,GAAoBA,gCAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;;IAOn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/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\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, Watch, 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'\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 @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\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\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n // const exists = localStorage.getItem(getKeyReserveByCartId(this.cartId))\n\n // if(!exists) return;\n\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n\n try {\n await this.crmBonusRef.processBonus();\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 @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.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.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.storeName);;\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.storeName);;\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 this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, 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.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\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 <crm-giftback-form\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n // <div class=\"section-cart-crm\">\n // <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n // <div class=\"container-button\">\n // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n // {\n // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n // }\n // </div>\n // <p class=\"message-alert\" >{this.message}</p>\n // <app-modal\n // isOpen={this.showModal}\n // modalTitle={`Giftback`}\n // onModalClosed={() => (this.showModal = false)}\n // >\n // <crm-bonus-form\n // loadingModal={this.loading}\n // saveStore={(amount: number) => this.save(amount)}\n // ref={ref => this.crmBonusRef = ref}\n // sent={this.sent}\n // phone={this.phone}\n // cancel={() => this.handleCloseModal()}\n // storeName={this.storeName}\n // products={this.buildProducts()}\n // cartId={this.cartId} customer={this.customer}\n // handleCustomerName={(name: string) => this.sendPinName(name)}\n // />\n // </app-modal>\n // </div>\n )\n }\n}\n"],"version":3}
1
+ {"file":"crm-bonus.entry.cjs.js","mappings":";;;;;;;;;AAAA,MAAM,WAAW,GAAG,uoCAAuoC,CAAC;AAC5pC,u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IAED,MAAM;QAEJ,QACEE,gFACE,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,GACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BH;KACF;;;;;;;;;;","names":["CrmBonusService","StepFormEnum","i18next","h"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\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, Watch, 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'\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 @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\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\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n const used = localStorage.getItem(\"bc:used\");\n\n if (used == \"use\") {\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n }\n\n try {\n await this.crmBonusRef.processBonus();\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 @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.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.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.storeName);;\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.storeName);;\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 this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, 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.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\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 <crm-giftback-form\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n // <div class=\"section-cart-crm\">\n // <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n // <div class=\"container-button\">\n // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n // {\n // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n // }\n // </div>\n // <p class=\"message-alert\" >{this.message}</p>\n // <app-modal\n // isOpen={this.showModal}\n // modalTitle={`Giftback`}\n // onModalClosed={() => (this.showModal = false)}\n // >\n // <crm-bonus-form\n // loadingModal={this.loading}\n // saveStore={(amount: number) => this.save(amount)}\n // ref={ref => this.crmBonusRef = ref}\n // sent={this.sent}\n // phone={this.phone}\n // cancel={() => this.handleCloseModal()}\n // storeName={this.storeName}\n // products={this.buildProducts()}\n // cartId={this.cartId} customer={this.customer}\n // handleCustomerName={(name: string) => this.sendPinName(name)}\n // />\n // </app-modal>\n // </div>\n )\n }\n}\n"],"version":3}
@@ -27,9 +27,10 @@ export class CrmBonus {
27
27
  }
28
28
  async resetBonus() {
29
29
  console.log('[START RESET BONUS]!!!!!');
30
- // const exists = localStorage.getItem(getKeyReserveByCartId(this.cartId))
31
- // if(!exists) return;
32
- await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
30
+ const used = localStorage.getItem("bc:used");
31
+ if (used == "use") {
32
+ await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
33
+ }
33
34
  try {
34
35
  await this.crmBonusRef.processBonus();
35
36
  console.log('[BONUS RESETADO]!!!!!');
@@ -182,7 +183,7 @@ export class CrmBonus {
182
183
  this.showModal = true;
183
184
  }
184
185
  render() {
185
- return (h("crm-giftback-form", { key: '62d209d69589c4e4c30462e3800755cdd4102d84', ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer })
186
+ return (h("crm-giftback-form", { key: '0cba16a775789a465f453f2837155360d2cdf537', ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer })
186
187
  // <div class="section-cart-crm">
187
188
  // <p class="text-left fbits-responsive-carrinho-desconto-texto">Giftback</p>
188
189
  // <div class="container-button">
@@ -1 +1 @@
1
- {"version":3,"file":"crm-bonus.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus/crm-bonus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAE,eAAe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AAS;SACV,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Method, Prop, State, Watch, 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'\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 @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\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\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n // const exists = localStorage.getItem(getKeyReserveByCartId(this.cartId))\n\n // if(!exists) return;\n\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n\n try {\n await this.crmBonusRef.processBonus();\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 @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.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.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.storeName);;\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.storeName);;\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 this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, 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.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\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 <crm-giftback-form\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n // <div class=\"section-cart-crm\">\n // <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n // <div class=\"container-button\">\n // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n // {\n // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n // }\n // </div>\n // <p class=\"message-alert\" >{this.message}</p>\n // <app-modal\n // isOpen={this.showModal}\n // modalTitle={`Giftback`}\n // onModalClosed={() => (this.showModal = false)}\n // >\n // <crm-bonus-form\n // loadingModal={this.loading}\n // saveStore={(amount: number) => this.save(amount)}\n // ref={ref => this.crmBonusRef = ref}\n // sent={this.sent}\n // phone={this.phone}\n // cancel={() => this.handleCloseModal()}\n // storeName={this.storeName}\n // products={this.buildProducts()}\n // cartId={this.cartId} customer={this.customer}\n // handleCustomerName={(name: string) => this.sendPinName(name)}\n // />\n // </app-modal>\n // </div>\n )\n }\n}\n"]}
1
+ {"version":3,"file":"crm-bonus.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus/crm-bonus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,OAAO,MAAM,iBAAiB,CAAA;AAQrC,MAAM,OAAO,QAAQ;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;;IAOnC,KAAK,CAAC,UAAU;QACd,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QACxC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE7C,IAAI,IAAI,IAAI,KAAK,EAAE,CAAC;YAClB,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACtE,CAAC;QAED,IA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M;QAEJ,OAAO,CACL,0EACE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,GACvB;QACF,iCAAiC;QACjC,+EAA+E;QAC/E,mCAAmC;QACnC,yEAAyE;QACzE,QAAQ;QACR,mIAAmI;QACnI,kIAAkI;QAClI,QAAQ;QACR,WAAW;QACX,iDAAiD;QACjD,eAAe;QACf,8BAA8B;QAC9B,8BAA8B;QAC9B,qDAAqD;QACrD,MAAM;QACN,sBAAsB;QACtB,oCAAoC;QACpC,0DAA0D;QAC1D,4CAA4C;QAC5C,yBAAyB;QACzB,2BAA2B;QAC3B,+CAA+C;QAC/C,mCAAmC;QACnC,wCAAwC;QACxC,sDAAsD;QACtD,sEAAsE;QACtE,SAAS;QACT,iBAAiB;QACjB,SAAS;SACV,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Method, Prop, State, Watch, 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'\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 @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\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\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n const used = localStorage.getItem(\"bc:used\");\n\n if (used == \"use\") {\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n }\n\n try {\n await this.crmBonusRef.processBonus();\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 @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.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.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.storeName);;\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.storeName);;\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 this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, 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.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\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 <crm-giftback-form\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n // <div class=\"section-cart-crm\">\n // <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n // <div class=\"container-button\">\n // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n // {\n // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n // }\n // </div>\n // <p class=\"message-alert\" >{this.message}</p>\n // <app-modal\n // isOpen={this.showModal}\n // modalTitle={`Giftback`}\n // onModalClosed={() => (this.showModal = false)}\n // >\n // <crm-bonus-form\n // loadingModal={this.loading}\n // saveStore={(amount: number) => this.save(amount)}\n // ref={ref => this.crmBonusRef = ref}\n // sent={this.sent}\n // phone={this.phone}\n // cancel={() => this.handleCloseModal()}\n // storeName={this.storeName}\n // products={this.buildProducts()}\n // cartId={this.cartId} customer={this.customer}\n // handleCustomerName={(name: string) => this.sendPinName(name)}\n // />\n // </app-modal>\n // </div>\n )\n }\n}\n"]}
@@ -41,9 +41,10 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
41
41
  }
42
42
  async resetBonus() {
43
43
  console.log('[START RESET BONUS]!!!!!');
44
- // const exists = localStorage.getItem(getKeyReserveByCartId(this.cartId))
45
- // if(!exists) return;
46
- await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
44
+ const used = localStorage.getItem("bc:used");
45
+ if (used == "use") {
46
+ await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
47
+ }
47
48
  try {
48
49
  await this.crmBonusRef.processBonus();
49
50
  console.log('[BONUS RESETADO]!!!!!');
@@ -194,7 +195,7 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
194
195
  this.showModal = true;
195
196
  }
196
197
  render() {
197
- return (h("crm-giftback-form", { key: '62d209d69589c4e4c30462e3800755cdd4102d84', ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer })
198
+ return (h("crm-giftback-form", { key: '0cba16a775789a465f453f2837155360d2cdf537', ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer })
198
199
  // <div class="section-cart-crm">
199
200
  // <p class="text-left fbits-responsive-carrinho-desconto-texto">Giftback</p>
200
201
  // <div class="container-button">
@@ -1 +1 @@
1
- {"file":"crm-bonus.js","mappings":";;;;;;;;;;;;;AAAA,MAAM,WAAW,GAAG,uoCAAuoC,CAAC;AAC5pC,uBAAe,WAAW;;MCabA,UAAQ;;;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;;IAOnC,MAAM,UAAU;QACd,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;;;QAKxC,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAEpE,IAAI;YACF,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;SACtC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aAAa,CAAC,KAAa;QAC/B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,KAAK,EAAE;YACV,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC;YACtC,OAAO;SACR;QAED,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;SAC3B;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;KACvB;IAED,MAAM;QAEJ,QACE,0EACE,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,GACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BH;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CrmBonus","i18next"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\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, Watch, 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'\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 @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\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\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n // const exists = localStorage.getItem(getKeyReserveByCartId(this.cartId))\n\n // if(!exists) return;\n\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n\n try {\n await this.crmBonusRef.processBonus();\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 @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.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.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.storeName);;\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.storeName);;\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 this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, 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.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\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 <crm-giftback-form\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n // <div class=\"section-cart-crm\">\n // <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n // <div class=\"container-button\">\n // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n // {\n // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n // }\n // </div>\n // <p class=\"message-alert\" >{this.message}</p>\n // <app-modal\n // isOpen={this.showModal}\n // modalTitle={`Giftback`}\n // onModalClosed={() => (this.showModal = false)}\n // >\n // <crm-bonus-form\n // loadingModal={this.loading}\n // saveStore={(amount: number) => this.save(amount)}\n // ref={ref => this.crmBonusRef = ref}\n // sent={this.sent}\n // phone={this.phone}\n // cancel={() => this.handleCloseModal()}\n // storeName={this.storeName}\n // products={this.buildProducts()}\n // cartId={this.cartId} customer={this.customer}\n // handleCustomerName={(name: string) => this.sendPinName(name)}\n // />\n // </app-modal>\n // </div>\n )\n }\n}\n"],"version":3}
1
+ {"file":"crm-bonus.js","mappings":";;;;;;;;;;;;;AAAA,MAAM,WAAW,GAAG,uoCAAuoC,CAAC;AAC5pC,uBAAe,WAAW;;MCabA,UAAQ;;;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK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C,QAAQ,GACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BH;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CrmBonus","i18next"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\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, Watch, 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'\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 @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\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\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n const used = localStorage.getItem(\"bc:used\");\n\n if (used == \"use\") {\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n }\n\n try {\n await this.crmBonusRef.processBonus();\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 @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.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.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.storeName);;\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.storeName);;\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 this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, 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.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\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 <crm-giftback-form\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n // <div class=\"section-cart-crm\">\n // <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n // <div class=\"container-button\">\n // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n // {\n // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n // }\n // </div>\n // <p class=\"message-alert\" >{this.message}</p>\n // <app-modal\n // isOpen={this.showModal}\n // modalTitle={`Giftback`}\n // onModalClosed={() => (this.showModal = false)}\n // >\n // <crm-bonus-form\n // loadingModal={this.loading}\n // saveStore={(amount: number) => this.save(amount)}\n // ref={ref => this.crmBonusRef = ref}\n // sent={this.sent}\n // phone={this.phone}\n // cancel={() => this.handleCloseModal()}\n // storeName={this.storeName}\n // products={this.buildProducts()}\n // cartId={this.cartId} customer={this.customer}\n // handleCustomerName={(name: string) => this.sendPinName(name)}\n // />\n // </app-modal>\n // </div>\n )\n }\n}\n"],"version":3}
@@ -1,2 +1,2 @@
1
- import{p as e,b as n}from"./p-45c0296c.js";export{s as setNonce}from"./p-45c0296c.js";import{g as a}from"./p-e1255160.js";var o=()=>{const n=import.meta.url;const a={};if(n!==""){a.resourcesUrl=new URL(".",n).href}return e(a)};o().then((async e=>{await a();return n([["p-49b323ef",[[2,"crm-bonus",{userId:[2,"userid"],storeName:[8,"storename"],productsInString:[1,"products"],cartId:[8,"cartid"],showModal:[32],products:[32],customer:[32],loading:[32],message:[32],phone:[32],canCancel:[32],amountCancel:[32],sent:[32],session:[32],resetBonus:[64]},null,{productsInString:["watchProducts"]}]]],["p-c121f6fc",[[1,"crm-bonus-form",{storeName:[8,"storename"],cartId:[8,"cart-id"],products:[16],customer:[16],sent:[16],stepNext:[2,"step-next"],phone:[2],loadingModal:[4,"loading-modal"],saveStore:[16],cancel:[16],handleCustomerName:[16],loading:[32],step:[32],message:[32],bonus:[32],setStep:[64]}]]],["p-d95bd37f",[[0,"phone-cancel-input",{sendPin:[16],loading:[4],value:[1]}]]],["p-450423b5",[[0,"phone-input",{sendPin:[16],loading:[4],value:[1]}]]],["p-a950d747",[[1,"app-modal",{isOpen:[516,"is-open"],modalTitle:[1,"modal-title"]}]]],["p-a465c900",[[0,"crm-bonus-note",{cartId:[8,"cartid"],storename:[8],url:[32],config:[32]}]]],["p-64441d8f",[[0,"pedido-finalizado",{cartId:[1,"cartid"],orderId:[2,"orderid"],metadadoString:[1,"metadado"]}]]],["p-0152eebc",[[0,"crm-button",{txtBtn:[1,"txt-btn"],loading:[4],handleClick:[16]}]]],["p-b7103956",[[1,"phone-input-mask",{initialValue:[1,"initial-value"],disabled:[4],phone:[32],message:[32],getPhone:[64]}]]],["p-da97c793",[[1,"loading-spinner",{size:[1],color:[1]}]]],["p-0160f5f5",[[0,"phone-form",{value:[1],loading:[4],handlerSubmit:[16],config:[16]}],[1,"pin-form",{validate:[16],cancel:[16],resend:[16],sent:[16],loading:[4],phone:[1],config:[16],pin:[32],isVerified:[32],canResend:[32]}],[0,"giftback-info",{loading:[4],bonus:[16],reserve:[16],cancel:[16],usedValue:[32],selectedOption:[32],sliderPosition:[32]},null,{bonus:["changedBonus"]}],[1,"countdown-timer",{downtime:[16],counter:[32]}]]],["p-feadb94b",[[0,"crm-giftback-form",{storeName:[8,"storename"],cartId:[8,"cart-id"],products:[16],customer:[16],value:[32],loading:[32],message:[32],phone:[32],pinInfo:[32],step:[32],bonus:[32],sucess:[32],error:[32],config:[32],hasApplyBonus:[32],setStep:[64],processBonus:[64]}]]],["p-5d209c28",[[1,"giftback-pin",{sent:[16],validate:[16],cancel:[16],loading:[4],pin:[32],isVerified:[32]}],[1,"giftback-progress",{loading:[4],bonus:[16],reserve:[16],cancel:[16],usedValue:[32]}],[0,"name-input",{value:[1],loading:[4],applyName:[16],cancel:[16],newValue:[32],message:[32]}],[1,"giftback-finish"]]]],e)}));
1
+ import{p as e,b as n}from"./p-45c0296c.js";export{s as setNonce}from"./p-45c0296c.js";import{g as a}from"./p-e1255160.js";var o=()=>{const n=import.meta.url;const a={};if(n!==""){a.resourcesUrl=new URL(".",n).href}return e(a)};o().then((async e=>{await a();return n([["p-5881e9d8",[[2,"crm-bonus",{userId:[2,"userid"],storeName:[8,"storename"],productsInString:[1,"products"],cartId:[8,"cartid"],showModal:[32],products:[32],customer:[32],loading:[32],message:[32],phone:[32],canCancel:[32],amountCancel:[32],sent:[32],session:[32],resetBonus:[64]},null,{productsInString:["watchProducts"]}]]],["p-c121f6fc",[[1,"crm-bonus-form",{storeName:[8,"storename"],cartId:[8,"cart-id"],products:[16],customer:[16],sent:[16],stepNext:[2,"step-next"],phone:[2],loadingModal:[4,"loading-modal"],saveStore:[16],cancel:[16],handleCustomerName:[16],loading:[32],step:[32],message:[32],bonus:[32],setStep:[64]}]]],["p-d95bd37f",[[0,"phone-cancel-input",{sendPin:[16],loading:[4],value:[1]}]]],["p-450423b5",[[0,"phone-input",{sendPin:[16],loading:[4],value:[1]}]]],["p-a950d747",[[1,"app-modal",{isOpen:[516,"is-open"],modalTitle:[1,"modal-title"]}]]],["p-a465c900",[[0,"crm-bonus-note",{cartId:[8,"cartid"],storename:[8],url:[32],config:[32]}]]],["p-64441d8f",[[0,"pedido-finalizado",{cartId:[1,"cartid"],orderId:[2,"orderid"],metadadoString:[1,"metadado"]}]]],["p-0152eebc",[[0,"crm-button",{txtBtn:[1,"txt-btn"],loading:[4],handleClick:[16]}]]],["p-b7103956",[[1,"phone-input-mask",{initialValue:[1,"initial-value"],disabled:[4],phone:[32],message:[32],getPhone:[64]}]]],["p-da97c793",[[1,"loading-spinner",{size:[1],color:[1]}]]],["p-0160f5f5",[[0,"phone-form",{value:[1],loading:[4],handlerSubmit:[16],config:[16]}],[1,"pin-form",{validate:[16],cancel:[16],resend:[16],sent:[16],loading:[4],phone:[1],config:[16],pin:[32],isVerified:[32],canResend:[32]}],[0,"giftback-info",{loading:[4],bonus:[16],reserve:[16],cancel:[16],usedValue:[32],selectedOption:[32],sliderPosition:[32]},null,{bonus:["changedBonus"]}],[1,"countdown-timer",{downtime:[16],counter:[32]}]]],["p-feadb94b",[[0,"crm-giftback-form",{storeName:[8,"storename"],cartId:[8,"cart-id"],products:[16],customer:[16],value:[32],loading:[32],message:[32],phone:[32],pinInfo:[32],step:[32],bonus:[32],sucess:[32],error:[32],config:[32],hasApplyBonus:[32],setStep:[64],processBonus:[64]}]]],["p-5d209c28",[[1,"giftback-pin",{sent:[16],validate:[16],cancel:[16],loading:[4],pin:[32],isVerified:[32]}],[1,"giftback-progress",{loading:[4],bonus:[16],reserve:[16],cancel:[16],usedValue:[32]}],[0,"name-input",{value:[1],loading:[4],applyName:[16],cancel:[16],newValue:[32],message:[32]}],[1,"giftback-finish"]]]],e)}));
2
2
  //# sourceMappingURL=crmbonus-component-wake.esm.js.map
@@ -0,0 +1,2 @@
1
+ import{r as t,h as s}from"./p-45c0296c.js";import{C as i}from"./p-a7ddcab4.js";import{S as e}from"./p-a561251a.js";import{i as n}from"./p-fb505488.js";const o=".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 a=o;const r=class{constructor(s){t(this,s);this.crmBonusService=i.getInstance();this.showModal=false;this.userId=undefined;this.storeName=undefined;this.productsInString=undefined;this.cartId=undefined;this.products=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}async resetBonus(){console.log("[START RESET BONUS]!!!!!");const t=localStorage.getItem("bc:used");if(t=="use"){await this.crmBonusService.cancelBonus(this.cartId,this.storeName)}try{await this.crmBonusRef.processBonus();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 watchProducts(t){try{console.log("[update products list]");this.productsInString=t;await this.handleLoad();await this.resetBonus()}catch(t){console.debug("[watchProducts]",t.message)}}async componentWillLoad(){n.changeLanguage(n.language);await this.loadSession();await this.loadConfigStore();await this.handleLoad()}async loadConfigStore(){await this.crmBonusService.getCustomization(this.storeName)}async handleLoad(){try{if(this.userId){this.customer=await this.crmBonusService.getCustomer(this.userId,this.storeName)}const t=localStorage.getItem(this.cartId);if(t){this.canCancel=true;this.amountCancel=t}}catch(t){console.log("info customer")}this.buildAndGetProducts()}async loadSession(){this.session=await this.crmBonusService.getToken(this.storeName);setTimeout((()=>{this.loadSession()}),15e5)}async buildAndGetProducts(){const t=`bc-products:${this.cartId}`;localStorage.setItem(t,this.productsInString);const s=JSON.parse(this.productsInString);const i=JSON.parse(localStorage.getItem(t));const e=[];for(const t of s){const[s]=i.filter((s=>s.ProdutoVarianteId==t.ProdutoVarianteId));if(s){e.push(Object.assign(Object.assign({},t),{PrecoPor:s.PrecoPor}))}else{e.push(t)}}this.products=e}async sendPin(t){var s,i;this.loading=true;this.message="";try{const s=t.replace(/\D/g,"");this.phone=Number(s);this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.storeName);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.storeName);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 this.products.map((t=>({sku:t.SKU,value:t.PrecoPor*t.Quantidade,productVariantId:t.ProdutoVarianteId.toString(),quantity:t.Quantidade})))}handleCloseModal(){this.showModal=false}save(t){localStorage.setItem(this.cartId,t.toString());this.canCancel=true;this.amountCancel=t.toString()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartId);this.canCancel=false;localStorage.removeItem(this.cartId)}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("crm-giftback-form",{key:"0cba16a775789a465f453f2837155360d2cdf537",ref:t=>this.crmBonusRef=t,storeName:this.storeName,products:this.buildProducts(),cartId:this.cartId,customer:this.customer})}static get assetsDirs(){return["assets"]}static get watchers(){return{productsInString:["watchProducts"]}}};r.style=a;export{r as crm_bonus};
2
+ //# sourceMappingURL=p-5881e9d8.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["crmBonusCss","CrmBonusStyle0","CrmBonus","this","crmBonusService","CrmBonusService","getInstance","birthDate","document","name","phone","resetBonus","console","log","used","localStorage","getItem","cancelBonus","cartId","storeName","crmBonusRef","processBonus","err","loading","setStep","StepFormEnum","STEP_PHONE","watchProducts","newValue","productsInString","handleLoad","debug","message","componentWillLoad","i18next","changeLanguage","language","loadSession","loadConfigStore","getCustomization","userId","customer","getCustomer","amount","canCancel","amountCancel","error","buildAndGetProducts","session","getToken","setTimeout","key","setItem","productsInCart","JSON","parse","products_in_cache","products","product_cart","pro","filter","p","ProdutoVarianteId","push","Object","assign","PrecoPor","sendPin","_phone","replace","Number","sent","STEP_PIN","showModal","_b","_a","response","data","sendPinName","customerName","buildProducts","map","product","sku","SKU","value","Quantidade","productVariantId","toString","quantity","handleCloseModal","save","cancel","removeItem","handleSendPin","STEP_NAME","render","h","ref"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\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, Watch, 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'\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 @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\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\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n const used = localStorage.getItem(\"bc:used\");\n\n if (used == \"use\") {\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n }\n\n try {\n await this.crmBonusRef.processBonus();\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 @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.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.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.storeName);;\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.storeName);;\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 this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, 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.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\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 <crm-giftback-form\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n // <div class=\"section-cart-crm\">\n // <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n // <div class=\"container-button\">\n // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n // {\n // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n // }\n // </div>\n // <p class=\"message-alert\" >{this.message}</p>\n // <app-modal\n // isOpen={this.showModal}\n // modalTitle={`Giftback`}\n // onModalClosed={() => (this.showModal = false)}\n // >\n // <crm-bonus-form\n // loadingModal={this.loading}\n // saveStore={(amount: number) => this.save(amount)}\n // ref={ref => this.crmBonusRef = ref}\n // sent={this.sent}\n // phone={this.phone}\n // cancel={() => this.handleCloseModal()}\n // storeName={this.storeName}\n // products={this.buildProducts()}\n // cartId={this.cartId} customer={this.customer}\n // handleCustomerName={(name: string) => this.sendPinName(name)}\n // />\n // </app-modal>\n // </div>\n )\n }\n}\n"],"mappings":"uJAAA,MAAMA,EAAc,woCACpB,MAAAC,EAAeD,E,MCaFE,EAAQ,M,yBAEXC,KAAAC,gBAAmCC,EAAgBC,c,eAI7B,M,2IAOC,CAC7BC,UAAW,GACXC,SAAU,GACVC,KAAM,GACNC,MAAO,I,aAGmB,M,2DAGE,M,uEAO9B,gBAAMC,G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]!!!!!');
35
- // const exists = localStorage.getItem(getKeyReserveByCartId(this.cartId))
36
- // if(!exists) return;
37
- await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
35
+ const used = localStorage.getItem("bc:used");
36
+ if (used == "use") {
37
+ await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
38
+ }
38
39
  try {
39
40
  await this.crmBonusRef.processBonus();
40
41
  console.log('[BONUS RESETADO]!!!!!');
@@ -185,7 +186,7 @@ const CrmBonus = class {
185
186
  this.showModal = true;
186
187
  }
187
188
  render() {
188
- return (h("crm-giftback-form", { key: '62d209d69589c4e4c30462e3800755cdd4102d84', ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer })
189
+ return (h("crm-giftback-form", { key: '0cba16a775789a465f453f2837155360d2cdf537', ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer })
189
190
  // <div class="section-cart-crm">
190
191
  // <p class="text-left fbits-responsive-carrinho-desconto-texto">Giftback</p>
191
192
  // <div class="container-button">
@@ -1 +1 @@
1
- {"file":"crm-bonus.entry.js","mappings":";;;;;AAAA,MAAM,WAAW,GAAG,uoCAAuoC,CAAC;AAC5pC,uBAAe,WAAW;;MCab,QAAQ;;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;;IAOnC,MAAM,UAAU;QACd,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;;;QAKxC,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAEpE,IAAI;YACF,MAAM,IAAI,CAAC,WAA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CAAA;SACjE;gBAAS;YACR,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;SACtB;KACF;IAED,MAAM,aAAa,CAAC,KAAa;QAC/B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,KAAK,EAAE;YACV,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC;YACtC,OAAO;SACR;QAED,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;SAC3B;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;KACvB;IAED,MAAM;QAEJ,QACE,0EACE,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,GACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BH;KACF;;;;;;;;;;","names":["i18next"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\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, Watch, 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'\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 @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\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\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n // const exists = localStorage.getItem(getKeyReserveByCartId(this.cartId))\n\n // if(!exists) return;\n\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n\n try {\n await this.crmBonusRef.processBonus();\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 @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.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.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.storeName);;\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.storeName);;\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 this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, 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.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\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 <crm-giftback-form\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n // <div class=\"section-cart-crm\">\n // <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n // <div class=\"container-button\">\n // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n // {\n // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n // }\n // </div>\n // <p class=\"message-alert\" >{this.message}</p>\n // <app-modal\n // isOpen={this.showModal}\n // modalTitle={`Giftback`}\n // onModalClosed={() => (this.showModal = false)}\n // >\n // <crm-bonus-form\n // loadingModal={this.loading}\n // saveStore={(amount: number) => this.save(amount)}\n // ref={ref => this.crmBonusRef = ref}\n // sent={this.sent}\n // phone={this.phone}\n // cancel={() => this.handleCloseModal()}\n // storeName={this.storeName}\n // products={this.buildProducts()}\n // cartId={this.cartId} customer={this.customer}\n // handleCustomerName={(name: string) => this.sendPinName(name)}\n // />\n // </app-modal>\n // </div>\n )\n }\n}\n"],"version":3}
1
+ {"file":"crm-bonus.entry.js","mappings":";;;;;AAAA,MAAM,WAAW,GAAG,uoCAAuoC,CAAC;AAC5pC,uBAAe,WAAW;;MCab,QAAQ;;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;;IAO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;;;;;;;;;;;;;;;;;;;;;UA8BH;KACF;;;;;;;;;;","names":["i18next"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\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, Watch, 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'\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 @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\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\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n const used = localStorage.getItem(\"bc:used\");\n\n if (used == \"use\") {\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n }\n\n try {\n await this.crmBonusRef.processBonus();\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 @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.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.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.storeName);;\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.storeName);;\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 this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, 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.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\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 <crm-giftback-form\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n // <div class=\"section-cart-crm\">\n // <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n // <div class=\"container-button\">\n // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n // {\n // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n // }\n // </div>\n // <p class=\"message-alert\" >{this.message}</p>\n // <app-modal\n // isOpen={this.showModal}\n // modalTitle={`Giftback`}\n // onModalClosed={() => (this.showModal = false)}\n // >\n // <crm-bonus-form\n // loadingModal={this.loading}\n // saveStore={(amount: number) => this.save(amount)}\n // ref={ref => this.crmBonusRef = ref}\n // sent={this.sent}\n // phone={this.phone}\n // cancel={() => this.handleCloseModal()}\n // storeName={this.storeName}\n // products={this.buildProducts()}\n // cartId={this.cartId} customer={this.customer}\n // handleCustomerName={(name: string) => this.sendPinName(name)}\n // />\n // </app-modal>\n // </div>\n )\n }\n}\n"],"version":3}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crmbonus-component-wake",
3
- "version": "2.0.74",
3
+ "version": "2.0.75",
4
4
  "description": "Stencil Component Starter",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -1,2 +0,0 @@
1
- import{r as t,h as s}from"./p-45c0296c.js";import{C as i}from"./p-a7ddcab4.js";import{S as e}from"./p-a561251a.js";import{i as n}from"./p-fb505488.js";const o=".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 a=o;const r=class{constructor(s){t(this,s);this.crmBonusService=i.getInstance();this.showModal=false;this.userId=undefined;this.storeName=undefined;this.productsInString=undefined;this.cartId=undefined;this.products=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}async resetBonus(){console.log("[START RESET BONUS]!!!!!");await this.crmBonusService.cancelBonus(this.cartId,this.storeName);try{await this.crmBonusRef.processBonus();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 watchProducts(t){try{console.log("[update products list]");this.productsInString=t;await this.handleLoad();await this.resetBonus()}catch(t){console.debug("[watchProducts]",t.message)}}async componentWillLoad(){n.changeLanguage(n.language);await this.loadSession();await this.loadConfigStore();await this.handleLoad()}async loadConfigStore(){await this.crmBonusService.getCustomization(this.storeName)}async handleLoad(){try{if(this.userId){this.customer=await this.crmBonusService.getCustomer(this.userId,this.storeName)}const t=localStorage.getItem(this.cartId);if(t){this.canCancel=true;this.amountCancel=t}}catch(t){console.log("info customer")}this.buildAndGetProducts()}async loadSession(){this.session=await this.crmBonusService.getToken(this.storeName);setTimeout((()=>{this.loadSession()}),15e5)}async buildAndGetProducts(){const t=`bc-products:${this.cartId}`;localStorage.setItem(t,this.productsInString);const s=JSON.parse(this.productsInString);const i=JSON.parse(localStorage.getItem(t));const e=[];for(const t of s){const[s]=i.filter((s=>s.ProdutoVarianteId==t.ProdutoVarianteId));if(s){e.push(Object.assign(Object.assign({},t),{PrecoPor:s.PrecoPor}))}else{e.push(t)}}this.products=e}async sendPin(t){var s,i;this.loading=true;this.message="";try{const s=t.replace(/\D/g,"");this.phone=Number(s);this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.storeName);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.storeName);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 this.products.map((t=>({sku:t.SKU,value:t.PrecoPor*t.Quantidade,productVariantId:t.ProdutoVarianteId.toString(),quantity:t.Quantidade})))}handleCloseModal(){this.showModal=false}save(t){localStorage.setItem(this.cartId,t.toString());this.canCancel=true;this.amountCancel=t.toString()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartId);this.canCancel=false;localStorage.removeItem(this.cartId)}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("crm-giftback-form",{key:"62d209d69589c4e4c30462e3800755cdd4102d84",ref:t=>this.crmBonusRef=t,storeName:this.storeName,products:this.buildProducts(),cartId:this.cartId,customer:this.customer})}static get assetsDirs(){return["assets"]}static get watchers(){return{productsInString:["watchProducts"]}}};r.style=a;export{r as crm_bonus};
2
- //# sourceMappingURL=p-49b323ef.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["crmBonusCss","CrmBonusStyle0","CrmBonus","this","crmBonusService","CrmBonusService","getInstance","birthDate","document","name","phone","resetBonus","console","log","cancelBonus","cartId","storeName","crmBonusRef","processBonus","err","loading","setStep","StepFormEnum","STEP_PHONE","watchProducts","newValue","productsInString","handleLoad","debug","message","componentWillLoad","i18next","changeLanguage","language","loadSession","loadConfigStore","getCustomization","userId","customer","getCustomer","amount","localStorage","getItem","canCancel","amountCancel","error","buildAndGetProducts","session","getToken","setTimeout","key","setItem","productsInCart","JSON","parse","products_in_cache","products","product_cart","pro","filter","p","ProdutoVarianteId","push","Object","assign","PrecoPor","sendPin","_phone","replace","Number","sent","STEP_PIN","showModal","_b","_a","response","data","sendPinName","customerName","buildProducts","map","product","sku","SKU","value","Quantidade","productVariantId","toString","quantity","handleCloseModal","save","cancel","removeItem","handleSendPin","STEP_NAME","render","h","ref"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\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, Watch, 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'\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 @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\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\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n // const exists = localStorage.getItem(getKeyReserveByCartId(this.cartId))\n\n // if(!exists) return;\n\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n\n try {\n await this.crmBonusRef.processBonus();\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 @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.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.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.storeName);;\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.storeName);;\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 this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, 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.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\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 <crm-giftback-form\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n // <div class=\"section-cart-crm\">\n // <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n // <div class=\"container-button\">\n // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n // {\n // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n // }\n // </div>\n // <p class=\"message-alert\" >{this.message}</p>\n // <app-modal\n // isOpen={this.showModal}\n // modalTitle={`Giftback`}\n // onModalClosed={() => (this.showModal = false)}\n // >\n // <crm-bonus-form\n // loadingModal={this.loading}\n // saveStore={(amount: number) => this.save(amount)}\n // ref={ref => this.crmBonusRef = ref}\n // sent={this.sent}\n // phone={this.phone}\n // cancel={() => this.handleCloseModal()}\n // storeName={this.storeName}\n // products={this.buildProducts()}\n // cartId={this.cartId} customer={this.customer}\n // handleCustomerName={(name: string) => this.sendPinName(name)}\n // />\n // </app-modal>\n // </div>\n )\n }\n}\n"],"mappings":"uJAAA,MAAMA,EAAc,woCACpB,MAAAC,EAAeD,E,MCaFE,EA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