crmbonus-component-wake 2.1.1 → 2.1.3

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 (70) hide show
  1. package/dist/cjs/{cart.helper-d4d8d619.js → cart.helper-7a19bf52.js} +2 -2
  2. package/dist/cjs/{cart.helper-d4d8d619.js.map → cart.helper-7a19bf52.js.map} +1 -1
  3. package/dist/cjs/crm-bonus-form.cjs.entry.js +1 -1
  4. package/dist/cjs/crm-bonus-note.cjs.entry.js +2 -2
  5. package/dist/cjs/crm-bonus.cjs.entry.js +3 -3
  6. package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -1
  7. package/dist/cjs/crm-giftback-form_2.cjs.entry.js +9 -6
  8. package/dist/cjs/crm-giftback-form_2.cjs.entry.js.map +1 -1
  9. package/dist/cjs/crmbonus-component-wake.cjs.js +1 -1
  10. package/dist/cjs/{crmbonus.service-9067d00d.js → crmbonus.service-29b20f84.js} +6 -2
  11. package/dist/cjs/crmbonus.service-29b20f84.js.map +1 -0
  12. package/dist/cjs/loader.cjs.js +1 -1
  13. package/dist/cjs/pedido-finalizado.cjs.entry.js +2 -2
  14. package/dist/collection/components/crm-bonus/crm-bonus.js +1 -1
  15. package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
  16. package/dist/collection/components/giftback-form/giftback-form.js +23 -5
  17. package/dist/collection/components/giftback-form/giftback-form.js.map +1 -1
  18. package/dist/collection/services/crmbonus.service.js +5 -1
  19. package/dist/collection/services/crmbonus.service.js.map +1 -1
  20. package/dist/components/crm-bonus-form.js +1 -1
  21. package/dist/components/crm-bonus-note.js +1 -1
  22. package/dist/components/crm-bonus.js +4 -4
  23. package/dist/components/crm-bonus.js.map +1 -1
  24. package/dist/components/crm-giftback-form.js +1 -1
  25. package/dist/components/{p-5443db37.js → p-1e24584e.js} +11 -7
  26. package/dist/components/p-1e24584e.js.map +1 -0
  27. package/dist/components/{p-6eda79c3.js → p-6fcb9ae7.js} +6 -2
  28. package/dist/components/p-6fcb9ae7.js.map +1 -0
  29. package/dist/components/{p-abbfbc98.js → p-fd3c0a85.js} +2 -2
  30. package/dist/components/{p-abbfbc98.js.map → p-fd3c0a85.js.map} +1 -1
  31. package/dist/components/pedido-finalizado.js +2 -2
  32. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
  33. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js.map +1 -1
  34. package/dist/crmbonus-component-wake/{p-a33f7c24.entry.js → p-675c8418.entry.js} +2 -2
  35. package/dist/crmbonus-component-wake/{p-6eda79c3.js → p-6fcb9ae7.js} +2 -2
  36. package/dist/crmbonus-component-wake/{p-6eda79c3.js.map → p-6fcb9ae7.js.map} +1 -1
  37. package/dist/crmbonus-component-wake/p-74422314.entry.js +2 -0
  38. package/dist/crmbonus-component-wake/p-74422314.entry.js.map +1 -0
  39. package/dist/crmbonus-component-wake/{p-fad20959.entry.js → p-810a51c4.entry.js} +2 -2
  40. package/dist/crmbonus-component-wake/{p-c23f3a07.entry.js → p-b45a5e48.entry.js} +2 -2
  41. package/dist/crmbonus-component-wake/{p-e8bd92d1.entry.js → p-c2ff4536.entry.js} +2 -2
  42. package/dist/crmbonus-component-wake/p-c2ff4536.entry.js.map +1 -0
  43. package/dist/crmbonus-component-wake/{p-abbfbc98.js → p-fd3c0a85.js} +2 -2
  44. package/dist/esm/{cart.helper-30a40560.js → cart.helper-c516d57f.js} +2 -2
  45. package/dist/esm/{cart.helper-30a40560.js.map → cart.helper-c516d57f.js.map} +1 -1
  46. package/dist/esm/crm-bonus-form.entry.js +1 -1
  47. package/dist/esm/crm-bonus-note.entry.js +2 -2
  48. package/dist/esm/crm-bonus.entry.js +3 -3
  49. package/dist/esm/crm-bonus.entry.js.map +1 -1
  50. package/dist/esm/crm-giftback-form_2.entry.js +9 -6
  51. package/dist/esm/crm-giftback-form_2.entry.js.map +1 -1
  52. package/dist/esm/crmbonus-component-wake.js +1 -1
  53. package/dist/esm/{crmbonus.service-42fbd7fa.js → crmbonus.service-224a080a.js} +6 -2
  54. package/dist/esm/crmbonus.service-224a080a.js.map +1 -0
  55. package/dist/esm/loader.js +1 -1
  56. package/dist/esm/pedido-finalizado.entry.js +2 -2
  57. package/dist/types/components/giftback-form/giftback-form.d.ts +1 -0
  58. package/dist/types/components.d.ts +2 -0
  59. package/package.json +1 -1
  60. package/dist/cjs/crmbonus.service-9067d00d.js.map +0 -1
  61. package/dist/components/p-5443db37.js.map +0 -1
  62. package/dist/components/p-6eda79c3.js.map +0 -1
  63. package/dist/crmbonus-component-wake/p-8df3f949.entry.js +0 -2
  64. package/dist/crmbonus-component-wake/p-8df3f949.entry.js.map +0 -1
  65. package/dist/crmbonus-component-wake/p-e8bd92d1.entry.js.map +0 -1
  66. package/dist/esm/crmbonus.service-42fbd7fa.js.map +0 -1
  67. /package/dist/crmbonus-component-wake/{p-a33f7c24.entry.js.map → p-675c8418.entry.js.map} +0 -0
  68. /package/dist/crmbonus-component-wake/{p-fad20959.entry.js.map → p-810a51c4.entry.js.map} +0 -0
  69. /package/dist/crmbonus-component-wake/{p-c23f3a07.entry.js.map → p-b45a5e48.entry.js.map} +0 -0
  70. /package/dist/crmbonus-component-wake/{p-abbfbc98.js.map → p-fd3c0a85.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const crmbonus_service = require('./crmbonus.service-9067d00d.js');
3
+ const crmbonus_service = require('./crmbonus.service-29b20f84.js');
4
4
 
5
5
  class CartWake {
6
6
  constructor(cart) {
@@ -74,4 +74,4 @@ const buildUrlBase = () => {
74
74
  exports.CartWake = CartWake;
75
75
  exports.getCart = getCart;
76
76
 
77
- //# sourceMappingURL=cart.helper-d4d8d619.js.map
77
+ //# sourceMappingURL=cart.helper-7a19bf52.js.map
@@ -1 +1 @@
1
- {"file":"cart.helper-d4d8d619.js","mappings":";;;;MAEa,QAAQ;IAQjB,YAAY,IAAI;;QAJhB,aAAQ,GAAmB,EAAE,CAAC;QA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.ts"],"sourcesContent":["import { IProductWake, IStore, IUser } from \"../dto/validate.pin.bonus\";\n\nexport class CartWake {\n id: string;\n middlewareId: string;\n orderId: number;\n products: IProductWake[] = [];\n user: IUser;\n store: IStore;\n\n constructor(cart) {\n this.id = cart.Metadados.id || cart.Id;\n this.middlewareId = cart.Metadados?.id;\n this.orderId = cart.PedidoId;\n this.buildUserInfo(cart);\n this.buildStoreInfo(cart);\n this.products = this.buildStoreCart( cart.Produtos);\n }\n\n private buildStoreCart(newProducts = []) {\n const cache = localStorage.getItem(\"bc:cart\");\n\n if(!cache) {\n return this.saveStore(newProducts)\n \n }\n \n const cacheProducts:IProductWake[] = JSON.parse(cache);\n\n if(newProducts.length !== cacheProducts.length) {\n return this.saveStore(newProducts);\n }\n\n for (const p of newProducts) {\n const [cp] = cacheProducts.filter(cpp => cpp.ProdutoVarianteId == p.ProdutoVarianteId);\n\n if(cp) {\n cp.Quantidade != p.Quantidade;\n\n return newProducts;\n }\n }\n\n return cacheProducts;\n\n }\n\n\n private saveStore(newProducts) {\n localStorage.setItem(\"bc:cart\", JSON.stringify(newProducts));\n\n return newProducts;\n }\n\n private buildUserInfo(cart) {\n this.user = {\n id: cart.Usuario ? cart.Usuario.Id : null\n }\n }\n\n private buildStoreInfo(cart) {\n this.store = {\n name: cart.Loja?.Nome\n }\n }\n}","import { CHECKOUT_CART_WAKE } from \"../../env\";\nimport { CartWake } from \"../objectvalues/cart.wake\";\nimport { CrmBonusService } from \"../services/crmbonus.service\";\n\nconst crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\nexport const getCart = async (): Promise<CartWake> => {\n const baseUrl = buildUrlBase(); // window.location.origin; //\"https://bycoders.fbits.store\" //window.location.origin;\n \n console.log('[URL STORE]: ', baseUrl)\n\n const cart = await crmBonusService.getInfoCart(baseUrl);\n\n return new CartWake(cart);\n}\n\nconst buildUrlBase = () => {\n\n const url = window.location.origin; //\"https://bycoders.checkout.fbits.store\" //\n\n if(url.includes('localhost')) {\n return CHECKOUT_CART_WAKE;\n }\n\n if(url.includes('checkout')) {\n return url;\n }\n\n if(url.includes('fbits')) {\n return url;\n }\n\n if(url.includes(\"www.\")) {\n return url.replace(\"www\", \"checkout\")\n }\n\n return `${window.location.protocol}//checkout.${window.location.host}`;\n\n}"],"version":3}
1
+ {"file":"cart.helper-7a19bf52.js","mappings":";;;;MAEa,QAAQ;IAQjB,YAAY,IAAI;;QAJhB,aAAQ,GAAmB,EAAE,CAAC;QAK1B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,MAAA,IAAI,CAAC,SAAS,0CAAE,EAAE,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC7B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;KACvD;IAEO,cAAc,CAAC,WAAW,GAAG,EAAE;QACnC,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE9C,IAAG,CAAC,KAAK,EAAE;YACP,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;SAErC;QAED,MAAM,aAAa,GAAkB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEvD,IAAG,WAAW,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,EAAE;YAC5C,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;SACtC;QAED,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE;YACzB,MAAM,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,iBAAiB,IAAI,CAAC,CAAC,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,CAAC,MAAM,CAAC,EAAE;QACrB,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;KACxC;IAED,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,cAAc,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AAE3E,CAAC;;;;;","names":["CrmBonusService","CHECKOUT_CART_WAKE"],"sources":["src/objectvalues/cart.wake.ts","src/helpers/cart.helper.ts"],"sourcesContent":["import { IProductWake, IStore, IUser } from \"../dto/validate.pin.bonus\";\n\nexport class CartWake {\n id: string;\n middlewareId: string;\n orderId: number;\n products: IProductWake[] = [];\n user: IUser;\n store: IStore;\n\n constructor(cart) {\n this.id = cart.Metadados.id || cart.Id;\n this.middlewareId = cart.Metadados?.id;\n this.orderId = cart.PedidoId;\n this.buildUserInfo(cart);\n this.buildStoreInfo(cart);\n this.products = this.buildStoreCart( cart.Produtos);\n }\n\n private buildStoreCart(newProducts = []) {\n const cache = localStorage.getItem(\"bc:cart\");\n\n if(!cache) {\n return this.saveStore(newProducts)\n \n }\n \n const cacheProducts:IProductWake[] = JSON.parse(cache);\n\n if(newProducts.length !== cacheProducts.length) {\n return this.saveStore(newProducts);\n }\n\n for (const p of newProducts) {\n const [cp] = cacheProducts.filter(cpp => cpp.ProdutoVarianteId == p.ProdutoVarianteId);\n\n if(cp) {\n cp.Quantidade != p.Quantidade;\n\n return newProducts;\n }\n }\n\n return cacheProducts;\n\n }\n\n\n private saveStore(newProducts) {\n localStorage.setItem(\"bc:cart\", JSON.stringify(newProducts));\n\n return newProducts;\n }\n\n private buildUserInfo(cart) {\n this.user = {\n id: cart.Usuario ? cart.Usuario.Id : null\n }\n }\n\n private buildStoreInfo(cart) {\n this.store = {\n name: cart.Loja?.Nome\n }\n }\n}","import { CHECKOUT_CART_WAKE } from \"../../env\";\nimport { CartWake } from \"../objectvalues/cart.wake\";\nimport { CrmBonusService } from \"../services/crmbonus.service\";\n\nconst crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\nexport const getCart = async (): Promise<CartWake> => {\n const baseUrl = buildUrlBase(); // window.location.origin; //\"https://bycoders.fbits.store\" //window.location.origin;\n \n console.log('[URL STORE]: ', baseUrl)\n\n const cart = await crmBonusService.getInfoCart(baseUrl);\n\n return new CartWake(cart);\n}\n\nconst buildUrlBase = () => {\n\n const url = window.location.origin; //\"https://bycoders.checkout.fbits.store\" //\n\n if(url.includes('localhost')) {\n return CHECKOUT_CART_WAKE;\n }\n\n if(url.includes('checkout')) {\n return url;\n }\n\n if(url.includes('fbits')) {\n return url;\n }\n\n if(url.includes(\"www.\")) {\n return url.replace(\"www\", \"checkout\")\n }\n\n return `${window.location.protocol}//checkout.${window.location.host}`;\n\n}"],"version":3}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d11684bd.js');
6
- const crmbonus_service = require('./crmbonus.service-9067d00d.js');
6
+ const crmbonus_service = require('./crmbonus.service-29b20f84.js');
7
7
  const index$1 = require('./index-6054ed44.js');
8
8
  require('./keys.storage-de7744aa.js');
9
9
 
@@ -6,8 +6,8 @@ const index = require('./index-d11684bd.js');
6
6
  const info_config_helper = require('./info.config.helper-c5d9f781.js');
7
7
  const keys_storage = require('./keys.storage-de7744aa.js');
8
8
  const i18n = require('./i18n-f2a6f60e.js');
9
- const cart_helper = require('./cart.helper-d4d8d619.js');
10
- require('./crmbonus.service-9067d00d.js');
9
+ const cart_helper = require('./cart.helper-7a19bf52.js');
10
+ require('./crmbonus.service-29b20f84.js');
11
11
 
12
12
  const moneyDollarsSvgrepoComSvg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPgo8c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMCIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiLz4KPHBhdGggZD0iTTE1IDkuOTQ3MjhDMTQuNSA5LjMgMTMuOCA4LjUgMTIgOC41QzEwLjIgOC41IDkgOS41MTM5MyA5IDkuOTQ3MjhDOSAxMC4zODA2IDkuMDY3ODYgMTAuOTI3NyAxMCAxMS41QzEwLjc1MjIgMTEuOTYxOCAxMi42Njg0IDEyLjA0MzkgMTMuNSAxMi41QzE0LjY3OSAxMy4xNDY3IDE0Ljg0OTcgMTMuODIwMiAxNC44NDk3IDE0LjA1MjJDMTQuODQ5NyAxNC42ODM3IDEzLjQxNzUgMTUuNDg1MiAxMiAxNS41QzEwLjUzNiAxNS41MTUzIDkuNSAxNC43IDkgMTQuMDUyMiIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTIgN1YxNyIgc3Ryb2tlPSIjMDAwMDAwIiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPg==';
13
13
 
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d11684bd.js');
6
- const crmbonus_service = require('./crmbonus.service-9067d00d.js');
6
+ const crmbonus_service = require('./crmbonus.service-29b20f84.js');
7
7
  const index$1 = require('./index-6054ed44.js');
8
8
  const i18n = require('./i18n-f2a6f60e.js');
9
- const cart_helper = require('./cart.helper-d4d8d619.js');
9
+ const cart_helper = require('./cart.helper-7a19bf52.js');
10
10
  const keys_storage = require('./keys.storage-de7744aa.js');
11
11
 
12
12
  var AjustesTipoEnum;
@@ -238,7 +238,7 @@ const CrmBonus = class {
238
238
  this.showModal = true;
239
239
  }
240
240
  render() {
241
- return (index.h("loading-container", { key: '21fafa4b9339db4a55ba454d05eecc0e4a8a2763', loading: this.loading_reprocess }, index.h("crm-giftback-form", { key: 'ef564d7e6794664b107d3996c8d081eafebfecb6', style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.cartWake.store.name, products: this.buildProducts(), cartId: this.cartWake.id, customer: this.customer, loadProducts: () => this.buildProducts() })));
241
+ return (index.h("loading-container", { key: '21fafa4b9339db4a55ba454d05eecc0e4a8a2763', loading: this.loading_reprocess }, index.h("crm-giftback-form", { key: 'c753ef52ba4ccc324d72c243e95496bfc15c47d7', style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.cartWake.store.name, products: this.buildProducts(), cartId: this.cartWake.id, customer: this.customer, loadProducts: () => this.buildProducts(), loadAll: () => this.handleLoad() })));
242
242
  }
243
243
  static get assetsDirs() { return ["assets"]; }
244
244
  };
@@ -1 +1 @@
1
- {"file":"crm-bonus.entry.cjs.js","mappings":";;;;;;;;;;;AAQA,IAAY,eAEX;AAFD,WAAY,eAAe;IACvB,iCAAc,CAAA;AAClB,CAAC,EAFW,eAAe,KAAf,eAAe;;SCNX,mBAAmB,CAAC,eAAoC,EAAE;IAEtE,MAAM,QAAQ,GAAoB,EAAE,CAAC;IAErC,KAAM,MAAM,EAAE,IAAI,YAAY,EAAG;QAC7B,IAAI,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,CAAA;QAEvC,QAAQ,CAAC,IAAI,CACT;YACI,GAAG,EAAE,EAAE,CAAC,GAAG;YACX,KAAK,GAAG,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC;YACpC,gBAAgB,EAAE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SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;KACvB;IAED,MAAM;QAEJ,QACEK,gFAAmB,OAAO,EAAE,IAAI,CAAC,iBAAiB,IAChDA,gFACE,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAC/B,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EACnC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,GAExC,CACgB,EACrB;KACF;;;;;;;","names":["CrmBonusService","StepFormEnum","USED_KEY","getCart","i18next","CartWake","h"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["export interface IProduct {\n productVariantId: string;\n sku: string;\n value: number;\n quantity: number;\n discount: number;\n}\n\nexport enum AjustesTipoEnum {\n P = \"Promocao\" \n}\n\nexport interface IAjustes {\n Tipo: AjustesTipoEnum;\n Valor: number;\n}\n\nexport interface IUser {\n id: number;\n}\n\nexport interface IStore {\n name: string;\n}\n\nexport interface IProductWake {\n ProdutoVarianteId: number;\n SKU: string;\n PrecoPor: number;\n Quantidade: number;\n Ajustes: IAjustes[];\n}\n\nexport interface ICustomer {\n birthDate: string;\n document: string;\n name: string;\n phone: string;\n}\n\nexport interface IProccesPinBonusDto {\n storeName: string;\n name: string;\n checkoutId: string;\n checkoutProducts: Array<IProduct>;\n storeId: string;\n userId: string;\n cellphone: number;\n pin: string;\n\n}\n\nexport interface IBonus {\n hasBonus: boolean;\n bonusBalance: number;\n totalBonus: number;\n minimumPurchase: number;\n bonusIds: string;\n firstValidityDate: string\n history: [\n {\n validityStart: string;\n validityEnd: string;\n value: number\n },\n {\n validityStart: string;\n validityEnd: string\n value: number\n }\n ]\n storeId: number;\n userId: number;\n cartId: string\n calculatedValue: number;\n totalValue: number\n}\n\n\nexport interface IReserveDTO {\n storeName: string;\n cartId: string;\n grossValue: number;\n redeemedBonus: number;\n ticket: string;\n storeId: string;\n userId: number;\n}","import { AjustesTipoEnum, IAjustes, IProduct, IProductWake } from \"../dto/validate.pin.bonus\";\n\nexport function buildProductsByWake(productsWake: Array<IProductWake> = []): Array<IProduct> {\n\n const products: Array<IProduct> = [];\n\n for ( const pw of productsWake ) {\n let discounts = getDiscount(pw.Ajustes)\n\n products.push(\n {\n sku: pw.SKU,\n value: (pw.PrecoPor * pw.Quantidade),\n productVariantId: pw.ProdutoVarianteId.toString(),\n quantity: pw.Quantidade,\n discount: (discounts * -1)\n }\n )\n }\n\n return products;\n}\n\nfunction getDiscount(ajustes: IAjustes[] = []) {\n \n let discounts = 0;\n \n for(const discount of ajustes) {\n if(discount.Tipo === AjustesTipoEnum.P) {\n discounts += discount.Valor;\n }\n }\n\n return discounts;\n}","\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, Method, Prop, State, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\nimport { getCart } from '../../helpers/cart.helper';\nimport { CartWake } from '../../objectvalues/cart.wake';\nimport { USED_KEY } from '../../utils/keys.storage';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @Prop() cart;\n\n @State() showModal: boolean = false;\n \n @State() cartWake: CartWake;\n \n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n \n try {\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async setloading() {\n this.loading_reprocess = !this.loading_reprocess;\n }\n\n @Method()\n async reprocess() {\n this.loading_reprocess = true\n\n try {\n\n const isUse = localStorage.getItem(USED_KEY);\n\n if(!isUse) return;\n\n this.cartWake = await getCart();\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n // @Watch(\"productsInString\")\n // async watchProducts(newValue: string) {\n // try {\n // console.log('[update products list]');\n // this.productsInString = newValue;\n // await this.handleLoad();\n\n // await this.resetBonus();\n // } catch (err) {\n // console.debug('[watchProducts]', err.message);\n // }\n // }\n\n async componentWillLoad() {\n i18next.changeLanguage(i18next.language);\n\n await this.handleLoad();\n\n await this.loadSession();\n await this.loadConfigStore()\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.cartWake.store.name);\n }\n\n async handleLoad() {\n try {\n\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\n\n console.log('[handleLoad]', this.cartWake)\n\n if (this.cartWake.user.id) {\n this.customer = await this.crmBonusService.getCustomer(this.cartWake.user.id, this.cartWake.store.name);\n console.log('customer', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartWake.id);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n await this.buildAndGetProducts(this.cartWake.products);\n } catch (error) {\n console.log('info customer')\n }\n }\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.cartWake.store.name);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts(productsWake: IProductWake[]) {\n\n console.log('productsWake', productsWake)\n\n const key = `bc-products:${this.cartWake.id}`;\n\n const productsString = JSON.stringify(productsWake)\n\n localStorage.setItem(key, productsString);\n\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsWake) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === \"Formula\")\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor + (ajuste.Valor * -1),\n Quantidade: pro.Quantidade,\n Ajustes: pro.Ajustes\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return buildProductsByWake(this.cartWake.products);\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartWake.id, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartWake.id);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartWake.id);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.cartWake.store.name}\n products={this.buildProducts()}\n cartId={this.cartWake.id}\n customer={this.customer}\n loadProducts={() => this.buildProducts()}\n\n />\n </loading-container>\n )\n }\n}\n"],"version":3}
1
+ {"file":"crm-bonus.entry.cjs.js","mappings":";;;;;;;;;;;AAQA,IAAY,eAEX;AAFD,WAAY,eAAe;IACvB,iCAAc,CAAA;AAClB,CAAC,EAFW,eAAe,KAAf,eAAe;;SCNX,mBAAmB,CAAC,eAAoC,EAAE;IAEtE,MAAM,QAAQ,GAAoB,EAAE,CAAC;IAErC,KAAM,MAAM,EAAE,IAAI,YAAY,EAAG;QAC7B,IAAI,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,CAAA;QAEvC,QAAQ,CAAC,IAAI,CACT;YACI,GAAG,EAAE,EAAE,CAAC,GAAG;YACX,KAAK,GAAG,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC;YACpC,gBAAgB,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,EAAE;YACjD,QAAQ,EAAE,EAAE,CAAC,UAAU;YACvB,QAAQ,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC;SAC7B,CACJ,CAAA;KACJ;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED,SAAS,WAAW,CAAC,UAAsB,EAAE;IAEzC,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAI,MAAM,QAAQ,IAAI,OAAO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CAAC,IAAI,EACnC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,EACxC,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE,GAEhC,CACgB,EACrB;KACF;;;;;;;","names":["CrmBonusService","StepFormEnum","USED_KEY","getCart","i18next","CartWake","h"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["export interface IProduct {\n productVariantId: string;\n sku: string;\n value: number;\n quantity: number;\n discount: number;\n}\n\nexport enum AjustesTipoEnum {\n P = \"Promocao\" \n}\n\nexport interface IAjustes {\n Tipo: AjustesTipoEnum;\n Valor: number;\n}\n\nexport interface IUser {\n id: number;\n}\n\nexport interface IStore {\n name: string;\n}\n\nexport interface IProductWake {\n ProdutoVarianteId: number;\n SKU: string;\n PrecoPor: number;\n Quantidade: number;\n Ajustes: IAjustes[];\n}\n\nexport interface ICustomer {\n birthDate: string;\n document: string;\n name: string;\n phone: string;\n}\n\nexport interface IProccesPinBonusDto {\n storeName: string;\n name: string;\n checkoutId: string;\n checkoutProducts: Array<IProduct>;\n storeId: string;\n userId: string;\n cellphone: number;\n pin: string;\n\n}\n\nexport interface IBonus {\n hasBonus: boolean;\n bonusBalance: number;\n totalBonus: number;\n minimumPurchase: number;\n bonusIds: string;\n firstValidityDate: string\n history: [\n {\n validityStart: string;\n validityEnd: string;\n value: number\n },\n {\n validityStart: string;\n validityEnd: string\n value: number\n }\n ]\n storeId: number;\n userId: number;\n cartId: string\n calculatedValue: number;\n totalValue: number\n}\n\n\nexport interface IReserveDTO {\n storeName: string;\n cartId: string;\n grossValue: number;\n redeemedBonus: number;\n ticket: string;\n storeId: string;\n userId: number;\n}","import { AjustesTipoEnum, IAjustes, IProduct, IProductWake } from \"../dto/validate.pin.bonus\";\n\nexport function buildProductsByWake(productsWake: Array<IProductWake> = []): Array<IProduct> {\n\n const products: Array<IProduct> = [];\n\n for ( const pw of productsWake ) {\n let discounts = getDiscount(pw.Ajustes)\n\n products.push(\n {\n sku: pw.SKU,\n value: (pw.PrecoPor * pw.Quantidade),\n productVariantId: pw.ProdutoVarianteId.toString(),\n quantity: pw.Quantidade,\n discount: (discounts * -1)\n }\n )\n }\n\n return products;\n}\n\nfunction getDiscount(ajustes: IAjustes[] = []) {\n \n let discounts = 0;\n \n for(const discount of ajustes) {\n if(discount.Tipo === AjustesTipoEnum.P) {\n discounts += discount.Valor;\n }\n }\n\n return discounts;\n}","\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, Method, Prop, State, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\nimport { getCart } from '../../helpers/cart.helper';\nimport { CartWake } from '../../objectvalues/cart.wake';\nimport { USED_KEY } from '../../utils/keys.storage';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @Prop() cart;\n\n @State() showModal: boolean = false;\n \n @State() cartWake: CartWake;\n \n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n \n try {\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async setloading() {\n this.loading_reprocess = !this.loading_reprocess;\n }\n\n @Method()\n async reprocess() {\n this.loading_reprocess = true\n\n try {\n\n const isUse = localStorage.getItem(USED_KEY);\n\n if(!isUse) return;\n\n this.cartWake = await getCart();\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n // @Watch(\"productsInString\")\n // async watchProducts(newValue: string) {\n // try {\n // console.log('[update products list]');\n // this.productsInString = newValue;\n // await this.handleLoad();\n\n // await this.resetBonus();\n // } catch (err) {\n // console.debug('[watchProducts]', err.message);\n // }\n // }\n\n async componentWillLoad() {\n i18next.changeLanguage(i18next.language);\n\n await this.handleLoad();\n\n await this.loadSession();\n await this.loadConfigStore()\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.cartWake.store.name);\n }\n\n async handleLoad() {\n try {\n\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\n\n console.log('[handleLoad]', this.cartWake)\n\n if (this.cartWake.user.id) {\n this.customer = await this.crmBonusService.getCustomer(this.cartWake.user.id, this.cartWake.store.name);\n console.log('customer', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartWake.id);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n await this.buildAndGetProducts(this.cartWake.products);\n } catch (error) {\n console.log('info customer')\n }\n }\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.cartWake.store.name);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts(productsWake: IProductWake[]) {\n\n console.log('productsWake', productsWake)\n\n const key = `bc-products:${this.cartWake.id}`;\n\n const productsString = JSON.stringify(productsWake)\n\n localStorage.setItem(key, productsString);\n\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsWake) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === \"Formula\")\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor + (ajuste.Valor * -1),\n Quantidade: pro.Quantidade,\n Ajustes: pro.Ajustes\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return buildProductsByWake(this.cartWake.products);\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartWake.id, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartWake.id);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartWake.id);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.cartWake.store.name}\n products={this.buildProducts()}\n cartId={this.cartWake.id}\n customer={this.customer}\n loadProducts={() => this.buildProducts()}\n loadAll={() => this.handleLoad()}\n\n />\n </loading-container>\n )\n }\n}\n"],"version":3}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d11684bd.js');
6
- const crmbonus_service = require('./crmbonus.service-9067d00d.js');
6
+ const crmbonus_service = require('./crmbonus.service-29b20f84.js');
7
7
  const index$1 = require('./index-6054ed44.js');
8
8
  const info_config_helper = require('./info.config.helper-c5d9f781.js');
9
9
  const i18n = require('./i18n-f2a6f60e.js');
@@ -22,6 +22,7 @@ const CrmBonus = class {
22
22
  this.products = undefined;
23
23
  this.customer = undefined;
24
24
  this.loadProducts = undefined;
25
+ this.loadAll = undefined;
25
26
  this.value = undefined;
26
27
  this.loading = false;
27
28
  this.message = undefined;
@@ -38,6 +39,7 @@ const CrmBonus = class {
38
39
  this.step = step;
39
40
  }
40
41
  async processBonus(products = [], hasNewProduct = false) {
42
+ await this.loadProducts();
41
43
  this.sucess = "";
42
44
  console.log('processBonus', []);
43
45
  if (hasNewProduct) {
@@ -57,6 +59,7 @@ const CrmBonus = class {
57
59
  }
58
60
  }
59
61
  async handleSendPin(phone) {
62
+ await this.loadAll();
60
63
  this.message = "";
61
64
  if (!phone) {
62
65
  this.message = "Informe seu telefone";
@@ -224,11 +227,11 @@ const CrmBonus = class {
224
227
  });
225
228
  }
226
229
  render() {
227
- return (index.h("div", { key: '6c4697a291f53468febca649827943dcf170ebf0', class: "crm-container-form fbits-responsive-carrinho-desconto" }, index.h("label", { key: '03d30744802d895cf0e3debada89a002553ed086', class: "crm-title" }, this.config.giftbackTitle), this.step === index$1.StepFormEnum.STEP_PHONE &&
228
- index.h("phone-form", { key: 'c587112386a887f01b3c34f219ee2bbc70793977', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === index$1.StepFormEnum.STEP_PIN &&
229
- index.h("pin-form", { key: '77ea15afe3c337b99fd9f6b61a6371145970e910', config: this.config, phone: this.phone, cancel: () => this.changePhone(), resend: () => this.sendPin(), validate: (data) => this.validateBonus(data), loading: this.loading }, this.sucess && index.h("p", { key: '8be745c614e20e582e8d060cc582432b471dc1c8', class: "crm-message-info" }, this.sucess), this.error && index.h("p", { key: '38095e8e2f34b9113273ca060a505f25131e9140', class: "crm-message-error" }, this.error)), this.step === index$1.StepFormEnum.STEP_RESERVE &&
230
- index.h("giftback-info", { key: 'f76e120f6e7ccf5a353b69bc78d8d10ae9fc34de', config: this.config, loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: () => this.processBonus() }), this.step === index$1.StepFormEnum.STEP_NO_BONUS &&
231
- (index.h("div", { key: 'bb59357639b70c4f2a23a14f1ed7beace379dacb', class: "container-message" }, i18n.instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
230
+ return (index.h("div", { key: 'a4e01a04387f7096b248c58d2e95c2c2f9a1e7ce', class: "crm-container-form fbits-responsive-carrinho-desconto" }, index.h("label", { key: '6e9114a6c521ceadf1db8b1d8702611eeb0a5878', class: "crm-title" }, this.config.giftbackTitle), this.step === index$1.StepFormEnum.STEP_PHONE &&
231
+ index.h("phone-form", { key: '1d0ad3fbdcd87b7fb158c159b80d8cb8ab991566', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === index$1.StepFormEnum.STEP_PIN &&
232
+ index.h("pin-form", { key: 'a529d32b2728e3cdf33a14dd749eea5260616406', config: this.config, phone: this.phone, cancel: () => this.changePhone(), resend: () => this.sendPin(), validate: (data) => this.validateBonus(data), loading: this.loading }, this.sucess && index.h("p", { key: 'c7bab1556a5b96790ea2821182a55291f7afac18', class: "crm-message-info" }, this.sucess), this.error && index.h("p", { key: '4a279db5b053381b12a82cf6475701a1a4ce55b5', class: "crm-message-error" }, this.error)), this.step === index$1.StepFormEnum.STEP_RESERVE &&
233
+ index.h("giftback-info", { key: 'ef920736aa808f31e146e05ba950c84350c83f8a', config: this.config, loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: () => this.processBonus() }), this.step === index$1.StepFormEnum.STEP_NO_BONUS &&
234
+ (index.h("div", { key: 'd84e1484c78b3a27fb35adc0588078c9a2ceadb1', class: "container-message" }, i18n.instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
232
235
  }
233
236
  };
234
237
  CrmBonus.style = CrmGiftbackFormStyle0;
@@ -1 +1 @@
1
- {"file":"crm-giftback-form.loading-container.entry.cjs.js","mappings":";;;;;;;;;;;AAAA,MAAM,eAAe,GAAG,i+BAAi+B,CAAC;AAC1/B,8BAAe,eAAe;;MCajB,QAAQ;;;;QAGX,oBAAe,GAAoBA,gCAAe,CAAC,WAAW,EAAE,CAAC;;;;;;;uBAS7C,KAAK;;;;oBAIHC,oBAAY,CAAC,YAAY;;sBAG7B,EAAE;qBACH,EAAE;;6BAGF,KAAK;;IAI9B,MAAM,OAAO,CAAC,IAAkB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACjB;IAGD,MAAM,YAAY,CAAC,WAAuB,EAAE,EAAE,aAAa,GAAG,KAAK;QACjE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QAEjB,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;QAC/B,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;SAC1B;QAED,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAACC,kCAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAExE,IAAI,MAAM,EAAE;YAEV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YAEhC,IAAI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EACE,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,EACjC,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,GAClC,EAIF,IAAI,CAAC,IAAI,KAAKJ,oBAAY,CAAC,aAAa;aAEtCI,kEAAK,KAAK,EAAC,mBAAmB,IAC3BC,aAAO,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAC9D,CACP,CAGC,EACP;KACF;;;;AC1UH,MAAM,mBAAmB,GAAG,8bAA8b,CAAC;AAC3d,+BAAe,mBAAmB;;MCKrB,gBAAgB;;;uBAEE,IAAI;;IAE/B,MAAM;QACF,QACID,kEAAK,KAAK,EAAC,aAAa,IAEhB,IAAI,CAAC,OAAO,KACRA,kEAAK,KAAK,EAAC,mBAAmB,IAC1BA,kEAAK,KAAK,EAAC,iBAAiB,GAEtB,CAEJ,CACT,EAELA,oEAAa,CACX,EACT;KACJ;;;;;;;","names":["CrmBonusService","StepFormEnum","getKeyReserveByCartId","getInfoCustomization","USED_KEY","h","i18next"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx","src/components/loading-container/loading-container.css?tag=loading-container","src/components/loading-container/loading-container.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n font-family: Roboto;\n font-size: var(--crmfont-sizebodymd);\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n font-size: 14px;\n color: var(--crm-btn);\n font-weight: 100;\n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n font-size: 16px;\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n font-size: 12px;\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n font-size: 12px;\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { USED_KEY, getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n @Prop({ attribute: 'storename' }) storeName;\n @Prop() cartId;\n @Prop() products: Array<IProduct>;\n @Prop() customer: ICustomer;\n @Prop() loadProducts: () => void;\n\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_RESERVE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus(products: IProduct[] = [], hasNewProduct = false) {\n this.sucess = \"\";\n\n console.log('processBonus', [])\n if (hasNewProduct) {\n this.products = products;\n }\n\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.bonus = bonus;\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n //this.step = StepFormEnum.STEP_RESERVE;\n\n }\n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin();\n }\n\n async componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n const phoneAgain = this.getPhoneNumberAgain();\n\n if (phoneAgain) {\n this.step = StepFormEnum.STEP_PHONE;\n return\n }\n\n await this.processBonus();\n\n }\n\n getPhoneNumberAgain() {\n const consulta_bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (!consulta_bonus) return true;\n\n const bonus = JSON.parse(consulta_bonus);\n\n return !bonus.hasBonus;\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber();\n const pinInfoCache = localStorage.getItem(`bc:${this.phone}`);\n\n if (!pinInfoCache) {\n this.pinInfo = await this.crmBonusService.sendPin(_phone, this.customer?.name, this.storeName);\n }\n\n if (pinInfoCache) {\n\n const bonus = JSON.parse(pinInfoCache);\n\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n this.step = StepFormEnum.STEP_RESERVE;\n } else {\n this.step = StepFormEnum.STEP_PIN;\n }\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n await this.loadProducts();\n\n const used_or_no = localStorage.getItem(USED_KEY);\n\n if (used_or_no == \"dontUse\") {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.convertStringToNumber(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.userId.toString(),\n checkoutId: this.cartId,\n checkoutProducts: this.products,\n name: this.customer?.name,\n storeName: this.storeName\n }\n\n try {\n this.bonus = await this.crmBonusService.validatePinBonus(payload);\n\n if (!this.bonus.hasBonus) {\n\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n localStorage.setItem(`bc:${this.phone}`, JSON.stringify(this.bonus));\n\n localStorage.setItem(USED_KEY, \"use\");\n localStorage.setItem(this.cartId, this.bonus.bonusBalance.toString());\n\n this.step = StepFormEnum.STEP_RESERVE;\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n\n localStorage.setItem(USED_KEY, \"dontUse\");\n this.save(0)\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\n await this.crmBonusService.reserve({\n redeemedBonus: amount,\n cartId: this.cartId,\n ticket: this.cartId,\n grossValue: Number(this.bonus.totalValue),\n storeName: this.storeName,\n storeId: this.bonus.storeId.toString(),\n userId: this.bonus.userId\n });\n }\n\n render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n\n {/* <loading-container /> */}\n\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n config={this.config}\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={() => this.processBonus()}\n />\n }\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}","/* Estilo para centralizar o container do loading */\n.loading-container {\n position: absolute;\n /* Fixa o loading na tela */\n top: 0;\n left: 0;\n width: 100%;\n /* Tamanho total da tela */\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n /* Fundo semitransparente */\n display: flex;\n /* Centraliza o conteúdo */\n justify-content: center;\n align-items: center;\n z-index: 1000;\n /* Coloca o loading acima de outros elementos */\n}\n\n/* Estilo do spinner (círculo giratório) */\n.loading-spinner {\n width: 50px;\n height: 50px;\n border: 5px solid rgba(255, 255, 255, 0.3);\n /* Borda semitransparente */\n border-top: 5px solid white;\n /* Borda que será animada */\n border-radius: 50%;\n /* Faz o círculo */\n animation: spin 1s linear infinite;\n /* Gira continuamente */\n}\n\n/* Keyframes para a animação de rotação */\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.relative-xy {\n position: relative;\n}","import { Component, Prop, h } from \"@stencil/core\";\n\n@Component({\n tag: 'loading-container',\n styleUrl: 'loading-container.css'\n})\nexport class LoadingContainer {\n\n @Prop() loading: boolean = true;\n\n render() {\n return (\n <div class=\"relative-xy\">\n {\n this.loading && (\n <div class=\"loading-container\">\n <div class=\"loading-spinner\">\n\n </div>\n \n </div>\n )\n }\n <slot></slot>\n </div>\n )\n }\n}"],"version":3}
1
+ {"file":"crm-giftback-form.loading-container.entry.cjs.js","mappings":";;;;;;;;;;;AAAA,MAAM,eAAe,GAAG,i+BAAi+B,CAAC;AAC1/B,8BAAe,eAAe;;MCajB,QAAQ;;;;QAGX,oBAAe,GAAoBA,gCAAe,CAAC,WAAW,EAAE,CAAC;;;;;;;;uBAU7C,KAAK;;;;oBAIHC,oBAAY,CAAC,YAAY;;sBAG7B,EAAE;qBACH,EAAE;;6BAGF,KAAK;;IAI9B,MAAM,OAAO,CAAC,IAAkB;QAC9B,IAAI,CA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B,GAEtB,CAEJ,CACT,EAELA,oEAAa,CACX,EACT;KACJ;;;;;;;","names":["CrmBonusService","StepFormEnum","getKeyReserveByCartId","getInfoCustomization","USED_KEY","h","i18next"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx","src/components/loading-container/loading-container.css?tag=loading-container","src/components/loading-container/loading-container.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n font-family: Roboto;\n font-size: var(--crmfont-sizebodymd);\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n font-size: 14px;\n color: var(--crm-btn);\n font-weight: 100;\n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n font-size: 16px;\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n font-size: 12px;\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n font-size: 12px;\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { USED_KEY, getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n @Prop({ attribute: 'storename' }) storeName;\n @Prop() cartId;\n @Prop() products: Array<IProduct>;\n @Prop() customer: ICustomer;\n @Prop() loadProducts: () => void;\n @Prop() loadAll: () => void;\n\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_RESERVE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus(products: IProduct[] = [], hasNewProduct = false) {\n await this.loadProducts()\n this.sucess = \"\";\n\n console.log('processBonus', [])\n if (hasNewProduct) {\n this.products = products;\n }\n\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.bonus = bonus;\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n //this.step = StepFormEnum.STEP_RESERVE;\n\n }\n }\n\n async handleSendPin(phone: string) {\n await this.loadAll()\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin();\n }\n\n async componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n const phoneAgain = this.getPhoneNumberAgain();\n\n if (phoneAgain) {\n this.step = StepFormEnum.STEP_PHONE;\n return\n }\n\n await this.processBonus();\n\n }\n\n getPhoneNumberAgain() {\n const consulta_bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (!consulta_bonus) return true;\n\n const bonus = JSON.parse(consulta_bonus);\n\n return !bonus.hasBonus;\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber();\n const pinInfoCache = localStorage.getItem(`bc:${this.phone}`);\n\n if (!pinInfoCache) {\n this.pinInfo = await this.crmBonusService.sendPin(_phone, this.customer?.name, this.storeName);\n }\n\n if (pinInfoCache) {\n\n const bonus = JSON.parse(pinInfoCache);\n\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n this.step = StepFormEnum.STEP_RESERVE;\n } else {\n this.step = StepFormEnum.STEP_PIN;\n }\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n await this.loadProducts();\n\n const used_or_no = localStorage.getItem(USED_KEY);\n\n if (used_or_no == \"dontUse\") {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.convertStringToNumber(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.userId.toString(),\n checkoutId: this.cartId,\n checkoutProducts: this.products,\n name: this.customer?.name,\n storeName: this.storeName\n }\n\n try {\n this.bonus = await this.crmBonusService.validatePinBonus(payload);\n\n if (!this.bonus.hasBonus) {\n\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n localStorage.setItem(`bc:${this.phone}`, JSON.stringify(this.bonus));\n\n localStorage.setItem(USED_KEY, \"use\");\n localStorage.setItem(this.cartId, this.bonus.bonusBalance.toString());\n\n this.step = StepFormEnum.STEP_RESERVE;\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n\n localStorage.setItem(USED_KEY, \"dontUse\");\n this.save(0)\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\n await this.crmBonusService.reserve({\n redeemedBonus: amount,\n cartId: this.cartId,\n ticket: this.cartId,\n grossValue: Number(this.bonus.totalValue),\n storeName: this.storeName,\n storeId: this.bonus.storeId.toString(),\n userId: this.bonus.userId\n });\n }\n\n render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n\n {/* <loading-container /> */}\n\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n config={this.config}\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={() => this.processBonus()}\n />\n }\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}","/* Estilo para centralizar o container do loading */\n.loading-container {\n position: absolute;\n /* Fixa o loading na tela */\n top: 0;\n left: 0;\n width: 100%;\n /* Tamanho total da tela */\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n /* Fundo semitransparente */\n display: flex;\n /* Centraliza o conteúdo */\n justify-content: center;\n align-items: center;\n z-index: 1000;\n /* Coloca o loading acima de outros elementos */\n}\n\n/* Estilo do spinner (círculo giratório) */\n.loading-spinner {\n width: 50px;\n height: 50px;\n border: 5px solid rgba(255, 255, 255, 0.3);\n /* Borda semitransparente */\n border-top: 5px solid white;\n /* Borda que será animada */\n border-radius: 50%;\n /* Faz o círculo */\n animation: spin 1s linear infinite;\n /* Gira continuamente */\n}\n\n/* Keyframes para a animação de rotação */\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.relative-xy {\n position: relative;\n}","import { Component, Prop, h } from \"@stencil/core\";\n\n@Component({\n tag: 'loading-container',\n styleUrl: 'loading-container.css'\n})\nexport class LoadingContainer {\n\n @Prop() loading: boolean = true;\n\n render() {\n return (\n <div class=\"relative-xy\">\n {\n this.loading && (\n <div class=\"loading-container\">\n <div class=\"loading-spinner\">\n\n </div>\n \n </div>\n )\n }\n <slot></slot>\n </div>\n )\n }\n}"],"version":3}
@@ -19,7 +19,7 @@ var patchBrowser = () => {
19
19
 
20
20
  patchBrowser().then(async (options) => {
21
21
  await appGlobals.globalScripts();
22
- return index.bootstrapLazy([["crm-bonus.cjs",[[2,"crm-bonus",{"cart":[8],"showModal":[32],"cartWake":[32],"customer":[32],"loading":[32],"message":[32],"phone":[32],"canCancel":[32],"amountCancel":[32],"sent":[32],"session":[32],"loading_reprocess":[32],"resetBonus":[64],"setloading":[64],"reprocess":[64]}]]],["crm-bonus-form.cjs",[[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]}]]],["crm-bonus-note.cjs",[[0,"crm-bonus-note",{"cart":[8],"cartWake":[32],"url":[32],"config":[32],"bonus":[32],"showEdit":[32]}]]],["phone-cancel-input.cjs",[[0,"phone-cancel-input",{"sendPin":[16],"loading":[4],"value":[1]}]]],["phone-input.cjs",[[0,"phone-input",{"sendPin":[16],"loading":[4],"value":[1]}]]],["app-modal.cjs",[[1,"app-modal",{"isOpen":[516,"is-open"],"modalTitle":[1,"modal-title"]}]]],["pedido-finalizado.cjs",[[0,"pedido-finalizado",{"cart":[8]}]]],["phone-input-mask.cjs",[[1,"phone-input-mask",{"initialValue":[1,"initial-value"],"disabled":[4],"phone":[32],"message":[32],"getPhone":[64]}]]],["loading-spinner.cjs",[[1,"loading-spinner",{"size":[1],"color":[1]}]]],["countdown-timer_2.cjs",[[0,"crm-button",{"txtBtn":[1,"txt-btn"],"loading":[4],"handleClick":[16]}],[1,"countdown-timer",{"downtime":[16],"initialValue":[2,"initial-value"],"seconds":[32]}]]],["crm-tooltip_4.cjs",[[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],"config":[16],"usedValue":[32],"selectedOption":[32],"sliderPosition":[32],"sliderValuePosition":[32],"loadingTime":[32]},null,{"bonus":["changedBonus"]}],[0,"crm-tooltip",{"text":[1],"identity":[1]}]]],["crm-giftback-form_2.cjs",[[0,"crm-giftback-form",{"storeName":[8,"storename"],"cartId":[8,"cart-id"],"products":[16],"customer":[16],"loadProducts":[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]}],[4,"loading-container",{"loading":[4]}]]],["giftback-finish_4.cjs",[[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"]]]], options);
22
+ return index.bootstrapLazy([["crm-bonus.cjs",[[2,"crm-bonus",{"cart":[8],"showModal":[32],"cartWake":[32],"customer":[32],"loading":[32],"message":[32],"phone":[32],"canCancel":[32],"amountCancel":[32],"sent":[32],"session":[32],"loading_reprocess":[32],"resetBonus":[64],"setloading":[64],"reprocess":[64]}]]],["crm-bonus-form.cjs",[[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]}]]],["crm-bonus-note.cjs",[[0,"crm-bonus-note",{"cart":[8],"cartWake":[32],"url":[32],"config":[32],"bonus":[32],"showEdit":[32]}]]],["phone-cancel-input.cjs",[[0,"phone-cancel-input",{"sendPin":[16],"loading":[4],"value":[1]}]]],["phone-input.cjs",[[0,"phone-input",{"sendPin":[16],"loading":[4],"value":[1]}]]],["app-modal.cjs",[[1,"app-modal",{"isOpen":[516,"is-open"],"modalTitle":[1,"modal-title"]}]]],["pedido-finalizado.cjs",[[0,"pedido-finalizado",{"cart":[8]}]]],["phone-input-mask.cjs",[[1,"phone-input-mask",{"initialValue":[1,"initial-value"],"disabled":[4],"phone":[32],"message":[32],"getPhone":[64]}]]],["loading-spinner.cjs",[[1,"loading-spinner",{"size":[1],"color":[1]}]]],["countdown-timer_2.cjs",[[0,"crm-button",{"txtBtn":[1,"txt-btn"],"loading":[4],"handleClick":[16]}],[1,"countdown-timer",{"downtime":[16],"initialValue":[2,"initial-value"],"seconds":[32]}]]],["crm-tooltip_4.cjs",[[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],"config":[16],"usedValue":[32],"selectedOption":[32],"sliderPosition":[32],"sliderValuePosition":[32],"loadingTime":[32]},null,{"bonus":["changedBonus"]}],[0,"crm-tooltip",{"text":[1],"identity":[1]}]]],["crm-giftback-form_2.cjs",[[0,"crm-giftback-form",{"storeName":[8,"storename"],"cartId":[8,"cart-id"],"products":[16],"customer":[16],"loadProducts":[16],"loadAll":[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]}],[4,"loading-container",{"loading":[4]}]]],["giftback-finish_4.cjs",[[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"]]]], options);
23
23
  });
24
24
 
25
25
  exports.setNonce = index.setNonce;
@@ -3865,7 +3865,11 @@ class CrmBonusService {
3865
3865
  }
3866
3866
  async getInfoCart(checkoutBase) {
3867
3867
  // return {"CEP":null,"Usuario":null,"Loja":{"Nome":"bycoders","IsInternacional":false,"MoedaPagamento":"R$","Google":{"Analytics":{"Ativo":true,"Ids":["G-B0F0CP55V0","G-B0F0CP55V0"]},"TagManager":{"Ativo":true,"Id":"GTM-P2XLDJGF"}},"Ebit":{"Modal":false,"Id":""},"AlliNSDK":{"Id":null},"AlliNBTG":{"Id":null},"Buscape":{"Id":""},"Modulos":["Pricing","Orders","Formula"]},"Produtos":[{"ProdutoVarianteId":336660,"ProdutoId":150142,"Nome":"Teste roupa 2","UrlImagem":"https://bycoders.fbitsstatic.net/img/p/sem-foto.jpg","Quantidade":1,"PrecoDe":10.0000,"PrecoPor":10.00,"Brinde":false,"IsDigital":false,"PrecoPorComAjustesProduto":0.0,"SKU":"233445","Categoria":"Masculino","CategoriasGoogle":[],"Fabricante":"","PrazoEntrega":{"Titulo":"","Descricao":"","SegundoTitulo":"","SegundaDescricao":"","PrazoProduto":0},"Atributos":[],"Metadados":{},"Informacoes":[],"Recorrencia":null,"Url":"https://bycoders.fbits.store/produto/150142","ParcelamentoQuantidade":0,"ParcelamentoValor":0.0,"ParcelamentoJuro":false,"Valores":[],"Ajustes":[]},{"ProdutoVarianteId":256639,"ProdutoId":70129,"Nome":"Mochila Nike Classic","UrlImagem":"https://bycoders.fbitsstatic.net/img/p/256639/256639-1.jpg?w=100&h=100&v=no-change&qs=ignore","Quantidade":1,"PrecoDe":319.0000,"PrecoPor":219.00,"Brinde":false,"IsDigital":false,"PrecoPorComAjustesProduto":0.0,"SKU":"Moc7101","Categoria":"Acessórios","CategoriasGoogle":[],"Fabricante":"Nike","PrazoEntrega":{"Titulo":"","Descricao":"","SegundoTitulo":"","SegundaDescricao":"","PrazoProduto":5},"Atributos":[],"Metadados":{},"Informacoes":[],"Recorrencia":null,"Url":"https://bycoders.fbits.store/produto/70129","ParcelamentoQuantidade":0,"ParcelamentoValor":0.0,"ParcelamentoJuro":false,"Valores":[],"Ajustes":[]}],"Metadados":{},"Login":"","ValorFrete":0.0,"SubTotal":229.00,"ValorTotal":229.00,"Cupom":"","Pedido":null,"Pedidos":null,"Frete":null,"DataAlteracao":"2025-03-10T11:55:58.327","Id":"31daeac1-9283-44dc-bc4c-ee02892cf3f0","Origem":null,"AllDigital":false,"QuantidadeMinimaProdutos":{"Ativo":false,"Mensagem":"","QuantidadeMinima":0},"ValorMinimoPedido":{"ValorMinimo":0.0,"Mensagem":"Faltam [valor] para atingir o valor mínimo do pedido"},"CookieOnly":false}
3868
- const response = await this.axiosInstance.get(`${checkoutBase}/api/carrinho`);
3868
+ const response = await this.axiosInstance.get(`${checkoutBase}/api/carrinho`, {
3869
+ headers: {
3870
+ "cookie": document.cookie
3871
+ }
3872
+ });
3869
3873
  return response.data;
3870
3874
  }
3871
3875
  }
@@ -3874,4 +3878,4 @@ CrmBonusService._instance = null;
3874
3878
  exports.CHECKOUT_CART_WAKE = CHECKOUT_CART_WAKE;
3875
3879
  exports.CrmBonusService = CrmBonusService;
3876
3880
 
3877
- //# sourceMappingURL=crmbonus.service-9067d00d.js.map
3881
+ //# sourceMappingURL=crmbonus.service-29b20f84.js.map