crmbonus-component-wake 1.0.41 → 1.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/cjs/app-modal_4.cjs.entry.js +15 -10
  2. package/dist/cjs/app-modal_4.cjs.entry.js.map +1 -1
  3. package/dist/cjs/crm-bonus.cjs.entry.js +4 -4
  4. package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -1
  5. package/dist/cjs/{crmbonus.service-e46a5941.js → crmbonus.service-ad521d7d.js} +12 -12
  6. package/dist/cjs/crmbonus.service-ad521d7d.js.map +1 -0
  7. package/dist/cjs/pedido-finalizado.cjs.entry.js +1 -1
  8. package/dist/collection/components/crm-bonus/crm-bonus.js +3 -3
  9. package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
  10. package/dist/collection/components/crm-bonus-form/crm-bonus-form.js +14 -9
  11. package/dist/collection/components/crm-bonus-form/crm-bonus-form.js.map +1 -1
  12. package/dist/collection/dto/validate.pin.bonus.js.map +1 -1
  13. package/dist/collection/services/crmbonus.service.js +10 -10
  14. package/dist/collection/services/crmbonus.service.js.map +1 -1
  15. package/dist/components/crm-bonus-form.js +1 -1
  16. package/dist/components/crm-bonus.js +5 -5
  17. package/dist/components/crm-bonus.js.map +1 -1
  18. package/dist/components/{p-84832959.js → p-0ebfe0d3.js} +16 -11
  19. package/dist/components/p-0ebfe0d3.js.map +1 -0
  20. package/dist/components/{p-a7e4526b.js → p-aeaad64e.js} +12 -12
  21. package/dist/components/p-aeaad64e.js.map +1 -0
  22. package/dist/components/pedido-finalizado.js +1 -1
  23. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
  24. package/dist/crmbonus-component-wake/{p-e67e5649.entry.js → p-04db24fc.entry.js} +2 -2
  25. package/dist/crmbonus-component-wake/p-04db24fc.entry.js.map +1 -0
  26. package/dist/crmbonus-component-wake/p-60249052.entry.js +2 -0
  27. package/dist/crmbonus-component-wake/p-60249052.entry.js.map +1 -0
  28. package/dist/crmbonus-component-wake/{p-3fa8e7b2.entry.js → p-6de2e9c3.entry.js} +2 -2
  29. package/dist/crmbonus-component-wake/{p-a7e4526b.js → p-aeaad64e.js} +2 -2
  30. package/dist/crmbonus-component-wake/p-aeaad64e.js.map +1 -0
  31. package/dist/env.js +1 -1
  32. package/dist/env.js.map +1 -1
  33. package/dist/esm/app-modal_4.entry.js +15 -10
  34. package/dist/esm/app-modal_4.entry.js.map +1 -1
  35. package/dist/esm/crm-bonus.entry.js +4 -4
  36. package/dist/esm/crm-bonus.entry.js.map +1 -1
  37. package/dist/esm/{crmbonus.service-1b7f193d.js → crmbonus.service-dda2d96b.js} +12 -12
  38. package/dist/esm/crmbonus.service-dda2d96b.js.map +1 -0
  39. package/dist/esm/pedido-finalizado.entry.js +1 -1
  40. package/dist/types/dto/validate.pin.bonus.d.ts +14 -9
  41. package/dist/types/home/darlison/Projects/crmbonus/app/crmbonus-component/.stencil/env.d.ts +1 -1
  42. package/dist/types/services/crmbonus.service.d.ts +1 -1
  43. package/package.json +1 -1
  44. package/dist/cjs/crmbonus.service-e46a5941.js.map +0 -1
  45. package/dist/components/p-84832959.js.map +0 -1
  46. package/dist/components/p-a7e4526b.js.map +0 -1
  47. package/dist/crmbonus-component-wake/p-a7e4526b.js.map +0 -1
  48. package/dist/crmbonus-component-wake/p-b5e9ea5d.entry.js +0 -2
  49. package/dist/crmbonus-component-wake/p-b5e9ea5d.entry.js.map +0 -1
  50. package/dist/crmbonus-component-wake/p-e67e5649.entry.js.map +0 -1
  51. package/dist/esm/crmbonus.service-1b7f193d.js.map +0 -1
  52. /package/dist/crmbonus-component-wake/{p-3fa8e7b2.entry.js.map → p-6de2e9c3.entry.js.map} +0 -0
@@ -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,IAAI,EAAE,K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AK,CAAC;gBAE7C,uEACE,YAAY,EAAE,IAAI,CAAC,OAAO,EAC1B,SAAS,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAChD,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,EACrC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAC5C,kBAAkB,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAC5D,CACQ,CACR,CACP,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, State, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n shadow: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = new CrmBonusService();\n\n private crmBonusRef: HTMLCrmBonusFormElement;\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\n async componentWillLoad() {\n await this.handleLoad();\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n console.log('user', this.customer);\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 buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n const cache_products = localStorage.getItem(key)\n\n if (!cache_products) {\n localStorage.setItem(key, this.productsInString);\n }\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), variantId: product.ProdutoVarianteId, qtd: 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, this.storeName);\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 return (\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,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,MAAM,OAAO,QAAQ;;QAEX,oBAAe,GAAoB,IAAI,eAAe,EAAE,CAAC;yBAInC,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;IAKnC,KAAK,CAAC,iBAAiB;QACrB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;gBACpF,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrC,CAAC;YAED,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAEjD,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;YAC7B,CAAC;QAEH,CAAC;QAAC,OAAO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C,CAAA,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,GAAI,CAEvH;YACN,0DAAG,KAAK,EAAC,eAAe,IAAG,IAAI,CAAC,OAAO,CAAK;YAC5C,kEACE,MAAM,EAAE,IAAI,CAAC,SAAS,EACtB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;gBAE7C,uEACE,YAAY,EAAE,IAAI,CAAC,OAAO,EAC1B,SAAS,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAChD,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,EACrC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAC5C,kBAAkB,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAC5D,CACQ,CACR,CACP,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Prop, State, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n shadow: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = new CrmBonusService();\n\n private crmBonusRef: HTMLCrmBonusFormElement;\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\n async componentWillLoad() {\n await this.handleLoad();\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n console.log('user', this.customer);\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 buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n const cache_products = localStorage.getItem(key)\n\n if (!cache_products) {\n localStorage.setItem(key, this.productsInString);\n }\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, this.storeName);\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 return (\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"]}
@@ -35,10 +35,12 @@ export class CrmBonusForm {
35
35
  const payload = {
36
36
  pin: pin,
37
37
  cellphone: this.phone.toString(),
38
- loja_id: this.sent.storeId,
39
- user_id: this.sent.userId,
40
- cartId: this.cartId,
41
- products: this.products
38
+ storeId: this.sent.storeId.toString(),
39
+ userId: this.sent.userId.toString(),
40
+ checkoutId: this.cartId,
41
+ checkoutProducts: this.products,
42
+ name: null,
43
+ storeName: this.storeName
42
44
  };
43
45
  try {
44
46
  this.bonus = await this.crmBonusService.validatePinBonus(payload, this.storeName);
@@ -70,18 +72,21 @@ export class CrmBonusForm {
70
72
  }
71
73
  async reserve(amount) {
72
74
  await this.crmBonusService.reserve({
73
- redeemed_bonus: amount,
74
- cart_id: this.cartId,
75
+ redeemedBonus: amount,
76
+ cartId: this.cartId,
75
77
  ticket: this.cartId,
76
- gross_value: this.bonus.totalValue,
77
- }, this.storeName);
78
+ grossValue: Number(this.bonus.totalValue),
79
+ storeName: this.storeName,
80
+ storeId: this.bonus.storeId.toString(),
81
+ userId: this.bonus.userId
82
+ });
78
83
  }
79
84
  handleCancel() {
80
85
  this.step = StepFormEnum.STEP_PHONE;
81
86
  this.cancel();
82
87
  }
83
88
  render() {
84
- return (h(Host, { key: 'f6a7cd35839626b3c0e2597381e5526cbf169ce3' }, this.step == StepFormEnum.STEP_NAME && h("name-input", { key: '1fe4bbbc3700acb899ce58083a532ad15f48b95b', loading: this.loadingModal, value: this.customer.name, applyName: (name) => this.handleCustomerName(name) }), this.step === StepFormEnum.STEP_PIN && h("giftback-pin", { key: '01b7dca40f3864eee97b3f831e6d764a7486f002', cancel: () => this.handleCancel(), sent: this.sent, validate: (data) => this.validateBonus(data), loading: this.loading }), this.step === StepFormEnum.STEP_RESERVE && h("giftback-progress", { key: '2de9188e93b309ee4fbb84081332d8389f6389c7', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === StepFormEnum.STEP_APPLY && h("giftback-finish", { key: '35f5e99289da7eefefd282cb5b0df96536c71d72' }), h("p", { key: 'ee33107ba9b3c211d6744d57cd51720d5709e421', class: "message-error" }, this.message)));
89
+ return (h(Host, { key: '42f30d9d144911d341eac720507b3eba4f1bae72' }, this.step == StepFormEnum.STEP_NAME && h("name-input", { key: 'fb1668693ceb8c359d7bd6f4ed4e375206f9769f', loading: this.loadingModal, value: this.customer.name, applyName: (name) => this.handleCustomerName(name) }), this.step === StepFormEnum.STEP_PIN && h("giftback-pin", { key: 'bffbdd4db2f183ac8947fdbaa1216f8b6851d76b', cancel: () => this.handleCancel(), sent: this.sent, validate: (data) => this.validateBonus(data), loading: this.loading }), this.step === StepFormEnum.STEP_RESERVE && h("giftback-progress", { key: '411ef7c01bb9a83e30559873d7d087d8f31f6969', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === StepFormEnum.STEP_APPLY && h("giftback-finish", { key: 'f4924e85e201d692ebcbe67bee5070a66d4b730a' }), h("p", { key: '9b364a2cabc105fb5512e544a86fbc48b91b9c90', class: "message-error" }, this.message)));
85
90
  }
86
91
  static get is() { return "crm-bonus-form"; }
87
92
  static get encapsulation() { return "shadow"; }
@@ -1 +1 @@
1
- {"version":3,"file":"crm-bonus-form.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus-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;;;;;;;;CACJ","sourcesContent":["import { Component, Host, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent';\n\n@Component({\n tag: 'crm-bonus-form',\n styleUrl: 'crm-bonus-form.css',\n shadow: true\n})\nexport class CrmBonusForm {\n\n private crmBonusService: CrmBonusService = new CrmBonusService();\n\n @Prop({ attribute: 'storename' }) storeName;\n @Prop() cartId;\n @Prop() products: Array<IProduct>;\n @Prop() customer: ICustomer = {\n phone: \"\",\n birthDate: \"\",\n document: \"\",\n name: \"\"\n };\n @Prop() sent: IPinSent;\n @Prop() stepNext: StepFormEnum;\n @Prop() phone: number;\n @Prop() loadingModal: boolean;\n\n @Prop() saveStore: (amount: number) => void;\n\n @Prop() cancel: () => void;\n\n @Prop() handleCustomerName: (name: string) => void;\n\n @State() loading: boolean = false;\n\n @State() step: number = StepFormEnum.STEP_NAME;\n\n @State() message: string;\n\n @State() bonus: IBonus;\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n public async validateBonus(pin: string) {\n this.loading = true;\n this.message = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n loja_id: this.sent.storeId,\n user_id: this.sent.userId,\n cartId: this.cartId,\n products: this.products\n }\n\n try {\n this.bonus = await this.crmBonusService.validatePinBonus(payload, this.storeName);\n\n console.log('[this.bonus]', this.bonus);\n this.step = StepFormEnum.STEP_RESERVE;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false;\n }\n console.log('payload', payload)\n }\n\n public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n\n this.step = StepFormEnum.STEP_APPLY;\n\n this.saveStore(amount);\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n } finally {\n this.loading = false;\n }\n }\n\n public async reserve(amount: number) {\n await this.crmBonusService.reserve({\n redeemed_bonus: amount,\n cart_id: this.cartId,\n ticket: this.cartId,\n gross_value: this.bonus.totalValue,\n }, this.storeName);\n }\n\n public handleCancel() {\n this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n render() {\n return (\n <Host>\n {/* {this.step === StepFormEnum.STEP_PHONE && <phone-input value={this.customer.phone} sendPin={(phone) => this.sendPin(phone)} loading={this.loading} />} */}\n \n {this.step == StepFormEnum.STEP_NAME && <name-input loading={this.loadingModal} value={this.customer.name} applyName={(name) => this.handleCustomerName(name)} />}\n {this.step === StepFormEnum.STEP_PIN && <giftback-pin cancel={() => this.handleCancel()} sent={this.sent} validate={(data) => this.validateBonus(data)} loading={this.loading} />}\n\n {this.step === StepFormEnum.STEP_RESERVE && <giftback-progress loading={this.loading} cancel={() => this.handleCancel()} bonus={this.bonus} reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)} />}\n {this.step === StepFormEnum.STEP_APPLY && <giftback-finish />}\n <p class=\"message-error\">{this.message}</p>\n </Host>\n )\n }\n}"]}
1
+ {"version":3,"file":"crm-bonus-form.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus-form/crm-bonus-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,MAAM,OAAO,YAAY;;QAEb,oBAAe,GAAoB,IAAI,eAAe,EAAE,CAAC;;;;wBAKnC;YAC1B,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;SACX;;;;;;;;uBAY2B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AAkB,CAAC,IAAI,CAAC,GAAI;YAChK,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,QAAQ,IAAI,qEAAc,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,GAAI;YAEhL,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,YAAY,IAAI,0EAAmB,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,cAAsB,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,GAAI;YACrN,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,UAAU,IAAI,yEAAmB;YAC7D,0DAAG,KAAK,EAAC,eAAe,IAAE,IAAI,CAAC,OAAO,CAAK,CACxC,CACV,CAAA;IACL,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import { Component, Host, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent';\n\n@Component({\n tag: 'crm-bonus-form',\n styleUrl: 'crm-bonus-form.css',\n shadow: true\n})\nexport class CrmBonusForm {\n\n private crmBonusService: CrmBonusService = new CrmBonusService();\n\n @Prop({ attribute: 'storename' }) storeName;\n @Prop() cartId;\n @Prop() products: Array<IProduct>;\n @Prop() customer: ICustomer = {\n phone: \"\",\n birthDate: \"\",\n document: \"\",\n name: \"\"\n };\n @Prop() sent: IPinSent;\n @Prop() stepNext: StepFormEnum;\n @Prop() phone: number;\n @Prop() loadingModal: boolean;\n\n @Prop() saveStore: (amount: number) => void;\n\n @Prop() cancel: () => void;\n\n @Prop() handleCustomerName: (name: string) => void;\n\n @State() loading: boolean = false;\n\n @State() step: number = StepFormEnum.STEP_NAME;\n\n @State() message: string;\n\n @State() bonus: IBonus;\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n public async validateBonus(pin: string) {\n this.loading = true;\n this.message = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.sent.storeId.toString(),\n userId: this.sent.userId.toString(),\n checkoutId: this.cartId,\n checkoutProducts: this.products,\n name: null,\n storeName: this.storeName\n }\n\n try {\n this.bonus = await this.crmBonusService.validatePinBonus(payload, this.storeName);\n\n console.log('[this.bonus]', this.bonus);\n this.step = StepFormEnum.STEP_RESERVE;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false;\n }\n console.log('payload', payload)\n }\n\n public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n\n this.step = StepFormEnum.STEP_APPLY;\n\n this.saveStore(amount);\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n } finally {\n this.loading = false;\n }\n }\n\n public async reserve(amount: number) {\n await this.crmBonusService.reserve({\n redeemedBonus: amount,\n cartId: this.cartId,\n ticket: this.cartId,\n grossValue: Number(this.bonus.totalValue),\n storeName: this.storeName,\n storeId: this.bonus.storeId.toString(),\n userId: this.bonus.userId\n });\n }\n\n public handleCancel() {\n this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n render() {\n return (\n <Host>\n {/* {this.step === StepFormEnum.STEP_PHONE && <phone-input value={this.customer.phone} sendPin={(phone) => this.sendPin(phone)} loading={this.loading} />} */}\n \n {this.step == StepFormEnum.STEP_NAME && <name-input loading={this.loadingModal} value={this.customer.name} applyName={(name) => this.handleCustomerName(name)} />}\n {this.step === StepFormEnum.STEP_PIN && <giftback-pin cancel={() => this.handleCancel()} sent={this.sent} validate={(data) => this.validateBonus(data)} loading={this.loading} />}\n\n {this.step === StepFormEnum.STEP_RESERVE && <giftback-progress loading={this.loading} cancel={() => this.handleCancel()} bonus={this.bonus} reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)} />}\n {this.step === StepFormEnum.STEP_APPLY && <giftback-finish />}\n <p class=\"message-error\">{this.message}</p>\n </Host>\n )\n }\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"validate.pin.bonus.js","sourceRoot":"","sources":["../../../src/dto/validate.pin.bonus.ts"],"names":[],"mappings":"","sourcesContent":["export interface IProduct {\n variantId: number;\n sku: string;\n value: number;\n qtd: number;\n}\n\nexport interface IProductWake {\n ProdutoVarianteId: number;\n SKU: string;\n PrecoPor: number;\n Quantidade: number;\n}\n\nexport interface ICustomer {\n birthDate: string;\n document: string;\n name: string;\n phone: string;\n}\n\nexport interface IProccesPinBonusDto {\n cartId: string;\n products: Array<IProduct>;\n loja_id: number;\n user_id: number;\n cellphone: string;\n pin: string;\n\n}\n\nexport interface IBonus {\n hasBonus: boolean;\n bonusBalance: number;\n totalBonus: number;\n minimumPurchase: number;\n bonusIds: string;\n firstValidityDate: string\n history: [\n {\n validityStart: string;\n validityEnd: string;\n value: number\n },\n {\n validityStart: string;\n validityEnd: string\n value: number\n }\n ]\n storeId: number;\n userId: number;\n cartId: string\n calculatedValue: number;\n totalValue: number\n}\n\n\nexport interface IReserveDTO {\n cart_id: string,\n gross_value: number,\n redeemed_bonus: number,\n ticket: string\n}"]}
1
+ {"version":3,"file":"validate.pin.bonus.js","sourceRoot":"","sources":["../../../src/dto/validate.pin.bonus.ts"],"names":[],"mappings":"","sourcesContent":["export interface IProduct {\n productVariantId: string;\n sku: string;\n value: number;\n quantity: number;\n}\n\nexport interface IProductWake {\n ProdutoVarianteId: number;\n SKU: string;\n PrecoPor: number;\n Quantidade: number;\n}\n\nexport interface ICustomer {\n birthDate: string;\n document: string;\n name: string;\n phone: string;\n}\n\nexport interface IProccesPinBonusDto {\n storeName: string;\n name: string;\n checkoutId: string;\n checkoutProducts: Array<IProduct>;\n storeId: string;\n userId: string;\n cellphone: string;\n pin: string;\n\n}\n\nexport interface IBonus {\n hasBonus: boolean;\n bonusBalance: number;\n totalBonus: number;\n minimumPurchase: number;\n bonusIds: string;\n firstValidityDate: string\n history: [\n {\n validityStart: string;\n validityEnd: string;\n value: number\n },\n {\n validityStart: string;\n validityEnd: string\n value: number\n }\n ]\n storeId: number;\n userId: number;\n cartId: string\n calculatedValue: number;\n totalValue: number\n}\n\n\nexport interface IReserveDTO {\n storeName: string;\n cartId: string;\n grossValue: number;\n redeemedBonus: number;\n ticket: string;\n storeId: string;\n userId: number;\n}"]}
@@ -11,35 +11,35 @@ export class CrmBonusService {
11
11
  });
12
12
  }
13
13
  async getCustomer(userId, store) {
14
- const response = await this.axiosInstance.get(`/api/wake/store/${store}/customer/${userId}`, { headers: { 'Content-Type': 'application/json' } });
14
+ const response = await this.axiosInstance.get(`/store/${store}/customer/${userId}`, { headers: { 'Content-Type': 'application/json' } });
15
15
  console.log('response.data', response.data);
16
16
  return response.data;
17
17
  }
18
18
  async updateOrder(updateOrderDTO) {
19
- const response = await this.axiosInstance.put(`/api/carts/update_cart/${updateOrderDTO.cartId}`, {
19
+ const response = await this.axiosInstance.patch(`/checkouts/${updateOrderDTO.cartId}/updateOrder`, {
20
20
  orderId: updateOrderDTO.orderId,
21
- cartIdCrm: updateOrderDTO.cartIdCrm
21
+ externalId: updateOrderDTO.cartIdCrm
22
22
  }, { headers: { 'Content-Type': 'application/json' } });
23
23
  console.log('response', response.data);
24
24
  }
25
25
  async sendPin(phone, name, store) {
26
- const response = await this.axiosInstance.post("/api/crm-bonus/send-pin", { celular: phone, nome: name }, { headers: { store } });
26
+ const response = await this.axiosInstance.post("/crmbonus/send-pin", { cellphone: phone, name: name, storeName: store }, { headers: { store } });
27
27
  return {
28
- storeId: response.data.store_id,
29
- userId: response.data.user_id
28
+ storeId: response.data.storeId,
29
+ userId: response.data.userId
30
30
  };
31
31
  }
32
32
  async validatePinBonus(payload, store) {
33
33
  console.log('[validatePinBonus]', payload);
34
- const response = await this.axiosInstance.post("/api/crm-bonus/process-pin-bonus", payload, { headers: { store } });
34
+ const response = await this.axiosInstance.post("/crmbonus/process-pin-bonus", payload, { headers: { store } });
35
35
  return response.data;
36
36
  }
37
- async reserve(payload, store) {
38
- const response = await this.axiosInstance.post("/api/crm-bonus/redeem-bonus", payload, { headers: { store } });
37
+ async reserve(payload) {
38
+ const response = await this.axiosInstance.post("/crmbonus/redeem-bonus", payload);
39
39
  return response.data;
40
40
  }
41
41
  async cancel(cartId, store) {
42
- const response = await this.axiosInstance.post("/api/crm-bonus/cancel-apply-bonus", {
42
+ const response = await this.axiosInstance.post("/crmbonus/cancel-apply-bonus", {
43
43
  ticket: cartId
44
44
  }, { headers: { store } });
45
45
  return response.data;
@@ -1 +1 @@
1
- {"version":3,"file":"crmbonus.service.js","sourceRoot":"","sources":["../../../src/services/crmbonus.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAK7C,MAAM,OAAO,eAAe;IAGxB;QACI,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;YAC9B,OAAO,EAAE,iBAAiB;YAC1B,OAAO,EAAE;gBACP,cAAc,EAA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B,EAAE,KAAa;QAC9D,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAI,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,kCAAkC,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;QAEpH,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAoB,EAAE,KAAa;QAC7C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,6BAA6B,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC/G,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,KAAa;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,mCAAmC,EAAE;YAChF,MAAM,EAAE,MAAM;SACjB,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;CACJ","sourcesContent":["import axios, { AxiosInstance } from 'axios';\nimport { CRM_BONUS_API_URL } from '../../env'\nimport { IPinSent } from '../dto/pin.sent';\nimport { IBonus, IProccesPinBonusDto, IReserveDTO } from '../dto/validate.pin.bonus';\nimport { UpdateOrderDTO } from '../dto/update.order.dto';\n\nexport class CrmBonusService {\n private axiosInstance: AxiosInstance;\n\n constructor() {\n this.axiosInstance = axios.create({\n baseURL: CRM_BONUS_API_URL,\n headers: {\n 'Content-Type': 'application/json',\n 'accept': 'application/json',\n },\n });\n }\n\n async getCustomer(userId: number, store: string) {\n const response = await this.axiosInstance.get(`/api/wake/store/${store}/customer/${userId}`, { headers: { 'Content-Type': 'application/json' } })\n console.log('response.data', response.data)\n return response.data\n }\n\n async updateOrder(updateOrderDTO: UpdateOrderDTO){\n const response = await this.axiosInstance.put(`/api/carts/update_cart/${updateOrderDTO.cartId}`, \n { \n orderId: updateOrderDTO.orderId,\n cartIdCrm: updateOrderDTO.cartIdCrm\n }, { headers: { 'Content-Type': 'application/json' } })\n\n console.log('response', response.data)\n \n }\n\n async sendPin(phone: number, name: string, store: string): Promise<IPinSent> {\n const response = await this.axiosInstance.post(\"/api/crm-bonus/send-pin\", { celular: phone, nome: name }, { headers: { store } });\n return {\n storeId: response.data.store_id,\n userId: response.data.user_id\n }\n }\n\n async validatePinBonus(payload: IProccesPinBonusDto, store: string): Promise<IBonus> {\n console.log('[validatePinBonus]', payload);\n\n const response = await this.axiosInstance.post(\"/api/crm-bonus/process-pin-bonus\", payload, { headers: { store } })\n\n return response.data;\n }\n\n async reserve(payload: IReserveDTO, store: string) {\n const response = await this.axiosInstance.post(\"/api/crm-bonus/redeem-bonus\", payload, { headers: { store } });\n return response.data;\n }\n\n async cancel(cartId: string, store: string) {\n const response = await this.axiosInstance.post(\"/api/crm-bonus/cancel-apply-bonus\", {\n ticket: cartId\n }, { headers: { store } });\n return response.data;\n }\n}"]}
1
+ {"version":3,"file":"crmbonus.service.js","sourceRoot":"","sources":["../../../src/services/crmbonus.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAK7C,MAAM,OAAO,eAAe;IAGxB;QACI,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;YAC9B,OAAO,EAAE,iBAAiB;YAC1B,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,QAAQ,EAAE,kBAAkB;aAC7B;SACF,CAAC,CAAC;IACT,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,KAAa;QAC3C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,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6BAA6B,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAA;QAE/G,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAoB;QAC9B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;QAClF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,KAAa;QACtC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,8BAA8B,EAAE;YAC3E,MAAM,EAAE,MAAM;SACjB,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;CACJ","sourcesContent":["import axios, { AxiosInstance } from 'axios';\nimport { CRM_BONUS_API_URL } from '../../env'\nimport { IPinSent } from '../dto/pin.sent';\nimport { IBonus, IProccesPinBonusDto, IReserveDTO } from '../dto/validate.pin.bonus';\nimport { UpdateOrderDTO } from '../dto/update.order.dto';\n\nexport class CrmBonusService {\n private axiosInstance: AxiosInstance;\n\n constructor() {\n this.axiosInstance = axios.create({\n baseURL: CRM_BONUS_API_URL,\n headers: {\n 'Content-Type': 'application/json',\n 'accept': 'application/json',\n },\n });\n }\n\n async getCustomer(userId: number, store: string) {\n const response = await this.axiosInstance.get(`/store/${store}/customer/${userId}`, { headers: { 'Content-Type': 'application/json' } })\n console.log('response.data', response.data)\n return response.data\n }\n\n async updateOrder(updateOrderDTO: UpdateOrderDTO){\n const response = await this.axiosInstance.patch(`/checkouts/${updateOrderDTO.cartId}/updateOrder`, \n { \n orderId: updateOrderDTO.orderId,\n externalId: updateOrderDTO.cartIdCrm\n }, { headers: { 'Content-Type': 'application/json' } })\n\n console.log('response', response.data)\n \n }\n\n async sendPin(phone: number, name: string, store: string): Promise<IPinSent> {\n const response = await this.axiosInstance.post(\"/crmbonus/send-pin\", { cellphone: phone, name: name, storeName: store }, { headers: { store } });\n return {\n storeId: response.data.storeId,\n userId: response.data.userId\n }\n }\n\n async validatePinBonus(payload: IProccesPinBonusDto, store: string): Promise<IBonus> {\n console.log('[validatePinBonus]', payload);\n\n const response = await this.axiosInstance.post(\"/crmbonus/process-pin-bonus\", payload, { headers: { store } })\n\n return response.data;\n }\n\n async reserve(payload: IReserveDTO) {\n const response = await this.axiosInstance.post(\"/crmbonus/redeem-bonus\", payload);\n return response.data;\n }\n\n async cancel(cartId: string, store: string) {\n const response = await this.axiosInstance.post(\"/crmbonus/cancel-apply-bonus\", {\n ticket: cartId\n }, { headers: { store } });\n return response.data;\n }\n}"]}
@@ -1,4 +1,4 @@
1
- import { C as CrmBonusForm$1, d as defineCustomElement$1 } from './p-84832959.js';
1
+ import { C as CrmBonusForm$1, d as defineCustomElement$1 } from './p-0ebfe0d3.js';
2
2
 
3
3
  const CrmBonusForm = CrmBonusForm$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,6 +1,6 @@
1
1
  import { p as proxyCustomElement, H, h } from './p-faf7103e.js';
2
- import { C as CrmBonusService } from './p-a7e4526b.js';
3
- import { d as defineCustomElement$a, S as StepFormEnum } from './p-84832959.js';
2
+ import { C as CrmBonusService } from './p-aeaad64e.js';
3
+ import { d as defineCustomElement$a, S as StepFormEnum } from './p-0ebfe0d3.js';
4
4
  import { d as defineCustomElement$b } from './p-1dbb0f43.js';
5
5
  import { d as defineCustomElement$9 } from './p-530006e6.js';
6
6
  import { d as defineCustomElement$8 } from './p-0e99f907.js';
@@ -115,7 +115,7 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
115
115
  }
116
116
  }
117
117
  buildProducts() {
118
- return this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), variantId: product.ProdutoVarianteId, qtd: product.Quantidade }));
118
+ return this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }));
119
119
  }
120
120
  handleCloseModal() {
121
121
  this.showModal = false;
@@ -156,8 +156,8 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
156
156
  this.showModal = true;
157
157
  }
158
158
  render() {
159
- return (h("div", { key: '9b15bdabac5b030dc7aa4373808dc3bca9ac485d', class: "section-cart-crm" }, h("p", { key: '14a89837f5b0c1586f49dfbb21421ce252518e0f', class: "text-left fbits-responsive-carrinho-desconto-texto" }, "Giftback"), h("div", { key: '79e82922c6733244a3895a0f0c9a3ac455246728', class: "container-button" }, this.canCancel ? h("phone-cancel-input", { value: this.amountCancel, sendPin: () => { this.cancel(); }, loading: this.loading })
160
- : h("phone-input", { value: this.customer.phone, sendPin: (phone) => { this.handleSendPin(phone); }, loading: this.loading })), h("p", { key: 'fae118256c6311fc01b5181acdddc32cad1b15fd', class: "message-alert" }, this.message), h("app-modal", { key: '8a17387e014340cb7276603dda48b54e356f76ed', isOpen: this.showModal, modalTitle: `Giftback`, onModalClosed: () => (this.showModal = false) }, h("crm-bonus-form", { key: '05353d2b0bae94c531d7048409141d394b025020', loadingModal: this.loading, saveStore: (amount) => this.save(amount), ref: ref => this.crmBonusRef = ref, sent: this.sent, phone: this.phone, cancel: () => this.handleCloseModal(), storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer, handleCustomerName: (name) => this.sendPinName(name) }))));
159
+ return (h("div", { key: 'b7fba875c1ae6e160ed019daecf2bc9f9d0d0296', class: "section-cart-crm" }, h("p", { key: 'b5e93f5b71b9dada90ca05682316c4b98657449b', class: "text-left fbits-responsive-carrinho-desconto-texto" }, "Giftback"), h("div", { key: '4662d8297a7d97a68bd5d08e119f5be4d90d2518', class: "container-button" }, this.canCancel ? h("phone-cancel-input", { value: this.amountCancel, sendPin: () => { this.cancel(); }, loading: this.loading })
160
+ : h("phone-input", { value: this.customer.phone, sendPin: (phone) => { this.handleSendPin(phone); }, loading: this.loading })), h("p", { key: '302ec7adb4cc51598c1af2664cbdef8b8552c19e', class: "message-alert" }, this.message), h("app-modal", { key: 'c32d7a682f7334cee9c7c9e8d269141a3292901f', isOpen: this.showModal, modalTitle: `Giftback`, onModalClosed: () => (this.showModal = false) }, h("crm-bonus-form", { key: '33fabd73d4686520a289c8a4881db709177e63e3', loadingModal: this.loading, saveStore: (amount) => this.save(amount), ref: ref => this.crmBonusRef = ref, sent: this.sent, phone: this.phone, cancel: () => this.handleCloseModal(), storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer, handleCustomerName: (name) => this.sendPinName(name) }))));
161
161
  }
162
162
  static get assetsDirs() { return ["assets"]; }
163
163
  static get style() { return CrmBonusStyle0; }
@@ -1 +1 @@
1
- {"file":"crm-bonus.js","mappings":";;;;;;;;;;;;;AAAA,MAAM,WAAW,GAAG,y/BAAy/B,CAAC;AAC9gC,uBAAe,WAAW;;MCWbA,UAAQ;;;;;QAEX,oBAAe,GAAoB,IAAI,eAAe,EAAE,CAAC;yBAInC,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;IAKnC,MAAM,iBAAiB;QACrB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;KACzB;IAED,MAAM,UAAU;QACd,IAAI;YACF,IAAI,IAAI,CAAC,MAAM,EAAE;gBACf,IAAI,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;gBACpF,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;aACpC;YAED,MA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AS,GAAG,KAAK,CAAC,IAE7C,uEACE,YAAY,EAAE,IAAI,CAAC,OAAO,EAC1B,SAAS,EAAE,CAAC,MAAc,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAChD,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,MAAM,IAAI,CAAC,gBAAgB,EAAE,EACrC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAC5C,kBAAkB,EAAE,CAAC,IAAY,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAC5D,CACQ,CACR,EACP;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CrmBonus"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=shadow","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["/* :host {\n display: block;\n} */\n\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, Prop, State, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n shadow: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = new CrmBonusService();\n\n private crmBonusRef: HTMLCrmBonusFormElement;\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\n async componentWillLoad() {\n await this.handleLoad();\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n console.log('user', this.customer);\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 buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n const cache_products = localStorage.getItem(key)\n\n if (!cache_products) {\n localStorage.setItem(key, this.productsInString);\n }\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), variantId: product.ProdutoVarianteId, qtd: 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, this.storeName);\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 return (\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,y/BAAy/B,CAAC;AAC9gC,uBAAe,WAAW;;MCWbA,UAAQ;;;;;QAEX,oBAAe,GAAoB,IAAI,eAAe,EAAE,C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"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=shadow","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["/* :host {\n display: block;\n} */\n\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, Prop, State, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n shadow: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = new CrmBonusService();\n\n private crmBonusRef: HTMLCrmBonusFormElement;\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\n async componentWillLoad() {\n await this.handleLoad();\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n console.log('user', this.customer);\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 buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n const cache_products = localStorage.getItem(key)\n\n if (!cache_products) {\n localStorage.setItem(key, this.productsInString);\n }\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, this.storeName);\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 return (\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,5 +1,5 @@
1
1
  import { p as proxyCustomElement, H, h, d as Host } from './p-faf7103e.js';
2
- import { C as CrmBonusService } from './p-a7e4526b.js';
2
+ import { C as CrmBonusService } from './p-aeaad64e.js';
3
3
  import { d as defineCustomElement$5 } from './p-530006e6.js';
4
4
  import { d as defineCustomElement$4 } from './p-0e99f907.js';
5
5
  import { d as defineCustomElement$3 } from './p-e2727638.js';
@@ -55,10 +55,12 @@ const CrmBonusForm = /*@__PURE__*/ proxyCustomElement(class CrmBonusForm extends
55
55
  const payload = {
56
56
  pin: pin,
57
57
  cellphone: this.phone.toString(),
58
- loja_id: this.sent.storeId,
59
- user_id: this.sent.userId,
60
- cartId: this.cartId,
61
- products: this.products
58
+ storeId: this.sent.storeId.toString(),
59
+ userId: this.sent.userId.toString(),
60
+ checkoutId: this.cartId,
61
+ checkoutProducts: this.products,
62
+ name: null,
63
+ storeName: this.storeName
62
64
  };
63
65
  try {
64
66
  this.bonus = await this.crmBonusService.validatePinBonus(payload, this.storeName);
@@ -90,18 +92,21 @@ const CrmBonusForm = /*@__PURE__*/ proxyCustomElement(class CrmBonusForm extends
90
92
  }
91
93
  async reserve(amount) {
92
94
  await this.crmBonusService.reserve({
93
- redeemed_bonus: amount,
94
- cart_id: this.cartId,
95
+ redeemedBonus: amount,
96
+ cartId: this.cartId,
95
97
  ticket: this.cartId,
96
- gross_value: this.bonus.totalValue,
97
- }, this.storeName);
98
+ grossValue: Number(this.bonus.totalValue),
99
+ storeName: this.storeName,
100
+ storeId: this.bonus.storeId.toString(),
101
+ userId: this.bonus.userId
102
+ });
98
103
  }
99
104
  handleCancel() {
100
105
  this.step = StepFormEnum.STEP_PHONE;
101
106
  this.cancel();
102
107
  }
103
108
  render() {
104
- return (h(Host, { key: 'f6a7cd35839626b3c0e2597381e5526cbf169ce3' }, this.step == StepFormEnum.STEP_NAME && h("name-input", { key: '1fe4bbbc3700acb899ce58083a532ad15f48b95b', loading: this.loadingModal, value: this.customer.name, applyName: (name) => this.handleCustomerName(name) }), this.step === StepFormEnum.STEP_PIN && h("giftback-pin", { key: '01b7dca40f3864eee97b3f831e6d764a7486f002', cancel: () => this.handleCancel(), sent: this.sent, validate: (data) => this.validateBonus(data), loading: this.loading }), this.step === StepFormEnum.STEP_RESERVE && h("giftback-progress", { key: '2de9188e93b309ee4fbb84081332d8389f6389c7', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === StepFormEnum.STEP_APPLY && h("giftback-finish", { key: '35f5e99289da7eefefd282cb5b0df96536c71d72' }), h("p", { key: 'ee33107ba9b3c211d6744d57cd51720d5709e421', class: "message-error" }, this.message)));
109
+ return (h(Host, { key: '42f30d9d144911d341eac720507b3eba4f1bae72' }, this.step == StepFormEnum.STEP_NAME && h("name-input", { key: 'fb1668693ceb8c359d7bd6f4ed4e375206f9769f', loading: this.loadingModal, value: this.customer.name, applyName: (name) => this.handleCustomerName(name) }), this.step === StepFormEnum.STEP_PIN && h("giftback-pin", { key: 'bffbdd4db2f183ac8947fdbaa1216f8b6851d76b', cancel: () => this.handleCancel(), sent: this.sent, validate: (data) => this.validateBonus(data), loading: this.loading }), this.step === StepFormEnum.STEP_RESERVE && h("giftback-progress", { key: '411ef7c01bb9a83e30559873d7d087d8f31f6969', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === StepFormEnum.STEP_APPLY && h("giftback-finish", { key: 'f4924e85e201d692ebcbe67bee5070a66d4b730a' }), h("p", { key: '9b364a2cabc105fb5512e544a86fbc48b91b9c90', class: "message-error" }, this.message)));
105
110
  }
106
111
  static get style() { return CrmBonusFormStyle0; }
107
112
  }, [1, "crm-bonus-form", {
@@ -164,4 +169,4 @@ defineCustomElement();
164
169
 
165
170
  export { CrmBonusForm as C, StepFormEnum as S, defineCustomElement as d };
166
171
 
167
- //# sourceMappingURL=p-84832959.js.map
172
+ //# sourceMappingURL=p-0ebfe0d3.js.map
@@ -0,0 +1 @@
1
+ {"file":"p-0ebfe0d3.js","mappings":";;;;;;;;IAAY;AAAZ,WAAY,YAAY;IACpB,yDAAa,CAAA;IACb,2DAAc,CAAA;IACd,uDAAY,CAAA;IACZ,+DAAgB,CAAA;IAChB,2DAAc,CAAA;AAClB,CAAC,EANW,YAAY,KAAZ,YAAY;;ACAxB,MAAM,eAAe,GAAG,wOAAwO,CAAC;AACjQ,2BAAe,eAAe;;MCUjB,YAAY;;;;;QAEb,oBAAe,GAAoB,IAAI,eAAe,EAAE,CAAC;;;;wBAKnC;YAC1B,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;SACX;;;;;;;;uBAY2B,KAAK;oBAET,YAAY,CAAC,SAAS;;;;IAO9C,MAAM,OAAO,CAAC,IAAkB;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACnB;IAEM,MAAM,aAAa,CAAC,GAAW;;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,MAAM,OAAO,GAAwB;YACjC,GAAG,EAAE,GAAG;YACR,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YAChC,OAAO,EAAE,IAAI,CA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AAI,CAAC,YAAY,CAAC,cAAc,CAAC,GAAI,EACrN,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,UAAU,IAAI,yEAAmB,EAC7D,0DAAG,KAAK,EAAC,eAAe,IAAE,IAAI,CAAC,OAAO,CAAK,CACxC,EACV;KACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/contants/index.ts","src/components/crm-bonus-form/crm-bonus-form.css?tag=crm-bonus-form&encapsulation=shadow","src/components/crm-bonus-form/crm-bonus-form.tsx"],"sourcesContent":["export enum StepFormEnum {\n STEP_NAME = 0,\n STEP_PHONE = 1,\n STEP_PIN = 2,\n STEP_RESERVE = 3,\n STEP_APPLY = 4\n}",".form-container {\n width: 100%;\n display: flex;\n justify-content: center;\n justify-content: space-around;\n}\n\n.disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n.message-error {\n color: #d11111;\n font-weight: bold;\n font-family: Arial;\n font-size: small;\n margin-left: 16px;\n}","import { Component, Host, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent';\n\n@Component({\n tag: 'crm-bonus-form',\n styleUrl: 'crm-bonus-form.css',\n shadow: true\n})\nexport class CrmBonusForm {\n\n private crmBonusService: CrmBonusService = new CrmBonusService();\n\n @Prop({ attribute: 'storename' }) storeName;\n @Prop() cartId;\n @Prop() products: Array<IProduct>;\n @Prop() customer: ICustomer = {\n phone: \"\",\n birthDate: \"\",\n document: \"\",\n name: \"\"\n };\n @Prop() sent: IPinSent;\n @Prop() stepNext: StepFormEnum;\n @Prop() phone: number;\n @Prop() loadingModal: boolean;\n\n @Prop() saveStore: (amount: number) => void;\n\n @Prop() cancel: () => void;\n\n @Prop() handleCustomerName: (name: string) => void;\n\n @State() loading: boolean = false;\n\n @State() step: number = StepFormEnum.STEP_NAME;\n\n @State() message: string;\n\n @State() bonus: IBonus;\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n public async validateBonus(pin: string) {\n this.loading = true;\n this.message = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.sent.storeId.toString(),\n userId: this.sent.userId.toString(),\n checkoutId: this.cartId,\n checkoutProducts: this.products,\n name: null,\n storeName: this.storeName\n }\n\n try {\n this.bonus = await this.crmBonusService.validatePinBonus(payload, this.storeName);\n\n console.log('[this.bonus]', this.bonus);\n this.step = StepFormEnum.STEP_RESERVE;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false;\n }\n console.log('payload', payload)\n }\n\n public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n\n this.step = StepFormEnum.STEP_APPLY;\n\n this.saveStore(amount);\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n } finally {\n this.loading = false;\n }\n }\n\n public async reserve(amount: number) {\n await this.crmBonusService.reserve({\n redeemedBonus: amount,\n cartId: this.cartId,\n ticket: this.cartId,\n grossValue: Number(this.bonus.totalValue),\n storeName: this.storeName,\n storeId: this.bonus.storeId.toString(),\n userId: this.bonus.userId\n });\n }\n\n public handleCancel() {\n this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n render() {\n return (\n <Host>\n {/* {this.step === StepFormEnum.STEP_PHONE && <phone-input value={this.customer.phone} sendPin={(phone) => this.sendPin(phone)} loading={this.loading} />} */}\n \n {this.step == StepFormEnum.STEP_NAME && <name-input loading={this.loadingModal} value={this.customer.name} applyName={(name) => this.handleCustomerName(name)} />}\n {this.step === StepFormEnum.STEP_PIN && <giftback-pin cancel={() => this.handleCancel()} sent={this.sent} validate={(data) => this.validateBonus(data)} loading={this.loading} />}\n\n {this.step === StepFormEnum.STEP_RESERVE && <giftback-progress loading={this.loading} cancel={() => this.handleCancel()} bonus={this.bonus} reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)} />}\n {this.step === StepFormEnum.STEP_APPLY && <giftback-finish />}\n <p class=\"message-error\">{this.message}</p>\n </Host>\n )\n }\n}"],"version":3}
@@ -3749,7 +3749,7 @@ axios.default = axios;
3749
3749
  // this module should only have a default export
3750
3750
  const axios$1 = axios;
3751
3751
 
3752
- const CRM_BONUS_API_URL = "https://crmbonus-service-staging-d15ba5377115.herokuapp.com"; //"https://typically-workable-perch.ngrok-free.app"; // "http://localhost:3500";
3752
+ const CRM_BONUS_API_URL = "https://crmbonus-wake-hub-staging-5daedbc4e22b.herokuapp.com/api"; //"https://crmbonus-service-staging-d15ba5377115.herokuapp.com"; //"https://typically-workable-perch.ngrok-free.app"; // "http://localhost:3500";
3753
3753
 
3754
3754
  class CrmBonusService {
3755
3755
  constructor() {
@@ -3762,35 +3762,35 @@ class CrmBonusService {
3762
3762
  });
3763
3763
  }
3764
3764
  async getCustomer(userId, store) {
3765
- const response = await this.axiosInstance.get(`/api/wake/store/${store}/customer/${userId}`, { headers: { 'Content-Type': 'application/json' } });
3765
+ const response = await this.axiosInstance.get(`/store/${store}/customer/${userId}`, { headers: { 'Content-Type': 'application/json' } });
3766
3766
  console.log('response.data', response.data);
3767
3767
  return response.data;
3768
3768
  }
3769
3769
  async updateOrder(updateOrderDTO) {
3770
- const response = await this.axiosInstance.put(`/api/carts/update_cart/${updateOrderDTO.cartId}`, {
3770
+ const response = await this.axiosInstance.patch(`/checkouts/${updateOrderDTO.cartId}/updateOrder`, {
3771
3771
  orderId: updateOrderDTO.orderId,
3772
- cartIdCrm: updateOrderDTO.cartIdCrm
3772
+ externalId: updateOrderDTO.cartIdCrm
3773
3773
  }, { headers: { 'Content-Type': 'application/json' } });
3774
3774
  console.log('response', response.data);
3775
3775
  }
3776
3776
  async sendPin(phone, name, store) {
3777
- const response = await this.axiosInstance.post("/api/crm-bonus/send-pin", { celular: phone, nome: name }, { headers: { store } });
3777
+ const response = await this.axiosInstance.post("/crmbonus/send-pin", { cellphone: phone, name: name, storeName: store }, { headers: { store } });
3778
3778
  return {
3779
- storeId: response.data.store_id,
3780
- userId: response.data.user_id
3779
+ storeId: response.data.storeId,
3780
+ userId: response.data.userId
3781
3781
  };
3782
3782
  }
3783
3783
  async validatePinBonus(payload, store) {
3784
3784
  console.log('[validatePinBonus]', payload);
3785
- const response = await this.axiosInstance.post("/api/crm-bonus/process-pin-bonus", payload, { headers: { store } });
3785
+ const response = await this.axiosInstance.post("/crmbonus/process-pin-bonus", payload, { headers: { store } });
3786
3786
  return response.data;
3787
3787
  }
3788
- async reserve(payload, store) {
3789
- const response = await this.axiosInstance.post("/api/crm-bonus/redeem-bonus", payload, { headers: { store } });
3788
+ async reserve(payload) {
3789
+ const response = await this.axiosInstance.post("/crmbonus/redeem-bonus", payload);
3790
3790
  return response.data;
3791
3791
  }
3792
3792
  async cancel(cartId, store) {
3793
- const response = await this.axiosInstance.post("/api/crm-bonus/cancel-apply-bonus", {
3793
+ const response = await this.axiosInstance.post("/crmbonus/cancel-apply-bonus", {
3794
3794
  ticket: cartId
3795
3795
  }, { headers: { store } });
3796
3796
  return response.data;
@@ -3799,4 +3799,4 @@ class CrmBonusService {
3799
3799
 
3800
3800
  export { CrmBonusService as C };
3801
3801
 
3802
- //# sourceMappingURL=p-a7e4526b.js.map
3802
+ //# sourceMappingURL=p-aeaad64e.js.map