crmbonus-component-wake 2.0.78 → 2.0.81

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 (107) hide show
  1. package/dist/cjs/countdown-timer_4.cjs.entry.js +7 -5
  2. package/dist/cjs/countdown-timer_4.cjs.entry.js.map +1 -1
  3. package/dist/cjs/crm-bonus-form.cjs.entry.js +2 -1
  4. package/dist/cjs/crm-bonus-form.cjs.entry.js.map +1 -1
  5. package/dist/cjs/crm-bonus-note.cjs.entry.js +3 -2
  6. package/dist/cjs/crm-bonus-note.cjs.entry.js.map +1 -1
  7. package/dist/cjs/crm-bonus.cjs.entry.js +36 -36
  8. package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -1
  9. package/dist/cjs/crm-giftback-form_2.cjs.entry.js +35 -18
  10. package/dist/cjs/crm-giftback-form_2.cjs.entry.js.map +1 -1
  11. package/dist/cjs/crmbonus-component-wake.cjs.js +1 -1
  12. package/dist/cjs/{crmbonus.service-ebe0b3c6.js → crmbonus.service-b2b18a51.js} +7 -14
  13. package/dist/cjs/crmbonus.service-b2b18a51.js.map +1 -0
  14. package/dist/cjs/keys.storage-de7744aa.js +17 -0
  15. package/dist/cjs/keys.storage-de7744aa.js.map +1 -0
  16. package/dist/cjs/loader.cjs.js +1 -1
  17. package/dist/cjs/pedido-finalizado.cjs.entry.js +2 -1
  18. package/dist/cjs/pedido-finalizado.cjs.entry.js.map +1 -1
  19. package/dist/collection/components/crm-bonus/crm-bonus.js +6 -35
  20. package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
  21. package/dist/collection/components/giftback-form/giftback-form.js +62 -18
  22. package/dist/collection/components/giftback-form/giftback-form.js.map +1 -1
  23. package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.css +15 -5
  24. package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.js +6 -4
  25. package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.js.map +1 -1
  26. package/dist/collection/dto/validate.pin.bonus.js +4 -1
  27. package/dist/collection/dto/validate.pin.bonus.js.map +1 -1
  28. package/dist/collection/helpers/build.payload.helper.js +25 -0
  29. package/dist/collection/helpers/build.payload.helper.js.map +1 -0
  30. package/dist/collection/services/crmbonus.service.js +2 -2
  31. package/dist/collection/services/crmbonus.service.js.map +1 -1
  32. package/dist/collection/utils/keys.storage.js +1 -0
  33. package/dist/collection/utils/keys.storage.js.map +1 -1
  34. package/dist/components/crm-bonus-form.js +1 -1
  35. package/dist/components/crm-bonus-note.js +2 -1
  36. package/dist/components/crm-bonus-note.js.map +1 -1
  37. package/dist/components/crm-bonus.js +37 -38
  38. package/dist/components/crm-bonus.js.map +1 -1
  39. package/dist/components/crm-giftback-form.js +1 -1
  40. package/dist/components/giftback-info.js +1 -1
  41. package/dist/components/{p-998b6c7d.js → p-090c085f.js} +8 -6
  42. package/dist/components/p-090c085f.js.map +1 -0
  43. package/dist/components/{p-9ceca803.js → p-1b08fd54.js} +36 -18
  44. package/dist/components/p-1b08fd54.js.map +1 -0
  45. package/dist/components/{p-a7ddcab4.js → p-641b4efd.js} +5 -11
  46. package/dist/components/p-641b4efd.js.map +1 -0
  47. package/dist/components/p-89c5ef5a.js +12 -0
  48. package/dist/components/p-89c5ef5a.js.map +1 -0
  49. package/dist/components/pedido-finalizado.js +1 -1
  50. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
  51. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js.map +1 -1
  52. package/dist/crmbonus-component-wake/p-10598ee8.entry.js +2 -0
  53. package/dist/crmbonus-component-wake/p-10598ee8.entry.js.map +1 -0
  54. package/dist/crmbonus-component-wake/p-641b4efd.js +2 -0
  55. package/dist/crmbonus-component-wake/p-641b4efd.js.map +1 -0
  56. package/dist/crmbonus-component-wake/p-7989ccb3.entry.js +2 -0
  57. package/dist/crmbonus-component-wake/{p-b7925fc7.entry.js.map → p-7989ccb3.entry.js.map} +1 -1
  58. package/dist/crmbonus-component-wake/p-7fbf47fc.entry.js +2 -0
  59. package/dist/crmbonus-component-wake/p-7fbf47fc.entry.js.map +1 -0
  60. package/dist/crmbonus-component-wake/p-89c5ef5a.js +2 -0
  61. package/dist/crmbonus-component-wake/p-89c5ef5a.js.map +1 -0
  62. package/dist/crmbonus-component-wake/p-b524a53e.entry.js +2 -0
  63. package/dist/crmbonus-component-wake/{p-304d3f89.entry.js.map → p-b524a53e.entry.js.map} +1 -1
  64. package/dist/crmbonus-component-wake/p-dc3e1c29.entry.js +2 -0
  65. package/dist/crmbonus-component-wake/{p-282b201b.entry.js.map → p-dc3e1c29.entry.js.map} +1 -1
  66. package/dist/crmbonus-component-wake/p-f801e9c0.entry.js +2 -0
  67. package/dist/crmbonus-component-wake/p-f801e9c0.entry.js.map +1 -0
  68. package/dist/esm/countdown-timer_4.entry.js +7 -5
  69. package/dist/esm/countdown-timer_4.entry.js.map +1 -1
  70. package/dist/esm/crm-bonus-form.entry.js +2 -1
  71. package/dist/esm/crm-bonus-form.entry.js.map +1 -1
  72. package/dist/esm/crm-bonus-note.entry.js +2 -1
  73. package/dist/esm/crm-bonus-note.entry.js.map +1 -1
  74. package/dist/esm/crm-bonus.entry.js +36 -36
  75. package/dist/esm/crm-bonus.entry.js.map +1 -1
  76. package/dist/esm/crm-giftback-form_2.entry.js +33 -16
  77. package/dist/esm/crm-giftback-form_2.entry.js.map +1 -1
  78. package/dist/esm/crmbonus-component-wake.js +1 -1
  79. package/dist/esm/{crmbonus.service-84f1cc25.js → crmbonus.service-a21cf811.js} +5 -11
  80. package/dist/esm/crmbonus.service-a21cf811.js.map +1 -0
  81. package/dist/esm/keys.storage-9e276481.js +12 -0
  82. package/dist/esm/keys.storage-9e276481.js.map +1 -0
  83. package/dist/esm/loader.js +1 -1
  84. package/dist/esm/pedido-finalizado.entry.js +2 -1
  85. package/dist/esm/pedido-finalizado.entry.js.map +1 -1
  86. package/dist/types/components/giftback-form/giftback-form.d.ts +2 -1
  87. package/dist/types/components.d.ts +3 -1
  88. package/dist/types/dto/validate.pin.bonus.d.ts +9 -0
  89. package/dist/types/helpers/build.payload.helper.d.ts +2 -0
  90. package/dist/types/utils/keys.storage.d.ts +1 -0
  91. package/package.json +1 -1
  92. package/dist/cjs/crmbonus.service-ebe0b3c6.js.map +0 -1
  93. package/dist/components/p-998b6c7d.js.map +0 -1
  94. package/dist/components/p-9ceca803.js.map +0 -1
  95. package/dist/components/p-a7ddcab4.js.map +0 -1
  96. package/dist/crmbonus-component-wake/p-282b201b.entry.js +0 -2
  97. package/dist/crmbonus-component-wake/p-304d3f89.entry.js +0 -2
  98. package/dist/crmbonus-component-wake/p-a7ddcab4.js +0 -2
  99. package/dist/crmbonus-component-wake/p-a7ddcab4.js.map +0 -1
  100. package/dist/crmbonus-component-wake/p-b7925fc7.entry.js +0 -2
  101. package/dist/crmbonus-component-wake/p-cd95574b.entry.js +0 -2
  102. package/dist/crmbonus-component-wake/p-cd95574b.entry.js.map +0 -1
  103. package/dist/crmbonus-component-wake/p-d4ecfd2b.entry.js +0 -2
  104. package/dist/crmbonus-component-wake/p-d4ecfd2b.entry.js.map +0 -1
  105. package/dist/crmbonus-component-wake/p-d8e5a526.entry.js +0 -2
  106. package/dist/crmbonus-component-wake/p-d8e5a526.entry.js.map +0 -1
  107. package/dist/esm/crmbonus.service-84f1cc25.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import axios from "axios";
2
2
  import { CRM_BONUS_API_URL } from "../../env";
3
- import { BYCODERS_KEY, getKeyConfigByStoreName } from "../utils/keys.storage";
3
+ import { BYCODERS_KEY, USED_KEY, getKeyConfigByStoreName } from "../utils/keys.storage";
4
4
  export class CrmBonusService {
5
5
  constructor() {
6
6
  this.axiosInstance = axios.create({
@@ -104,7 +104,7 @@ export class CrmBonusService {
104
104
  storeName: storeName
105
105
  }, { headers: headers });
106
106
  localStorage.setItem(cartId, "0");
107
- localStorage.removeItem("bc:used");
107
+ localStorage.removeItem(USED_KEY);
108
108
  }
109
109
  }
110
110
  CrmBonusService._instance = null;
@@ -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;AAI7C,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAE9E,MAAM,OAAO,eAAe;IAMxB;QACI,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;YAC9B,OAAO,EAAE,iBAAiB;YAC1B,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;gBAClC,QAAQ,EAAE,kBAAkB;aAC/B;SACJ,CAAC,CAAC;IACP,CAAC;IAEM,MAAM,CAAC,WAAW;QACrB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC,SAAS,CAAC;QAC1B,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,IAAI,eAAe,EAAE,CAAA;QAEtC,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,KAAa;;QAE3C,MAAM,OAAO,GAAG;YACZ,cAAc,EAAE,kBAAkB;YAClC,eAAe,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE;SAC1C,CAAA;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,UAAU,KAAK,aAAa,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;QAEzG,IAAI,CAAC,KAAK,GAAG,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,KAAK,CAAA;QAElC,OAAO,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,QAAQ,CAAA;IACnC,CAAC;IAED,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AM,OAAO,GAAG;YACZ,cAAc,EAAE,kBAAkB;YAClC,eAAe,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE;SAC1C,CAAA;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,WAAW,SAAS,iBAAiB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAElG,YAAY,CAAC,OAAO,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAA;IAC3F,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,MAAc,EAAE,SAAiB;QAC/C,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAEjD,MAAM,OAAO,GAAG;YACZ,cAAc,EAAE,kBAAkB;YAClC,eAAe,EAAE,UAAU,KAAK,EAAE;SACrC,CAAA;QAED,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,wBAAwB,EAClD;YACI,MAAM;YACN,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,SAAS;SACvB,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;QAE5B,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAElC,YAAY,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IACtC,CAAC;;AA/Ic,yBAAS,GAAoB,IAAI,CAAC","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';\nimport { BYCODERS_KEY, getKeyConfigByStoreName } from '../utils/keys.storage';\n\nexport class CrmBonusService {\n private axiosInstance: AxiosInstance;\n private token: string;\n\n private static _instance: CrmBonusService = null;\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 public static getInstance(): CrmBonusService {\n if (this._instance) {\n return this._instance;\n }\n\n this._instance = new CrmBonusService()\n\n return this._instance;\n }\n\n async getCustomer(userId: number, store: string) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.get(`/store/${store}/customer/${userId}`, { headers: headers })\n\n this.token = response?.data?.token\n\n return response?.data?.customer\n }\n\n async updateOrder(updateOrderDTO: UpdateOrderDTO) {\n\n const token = localStorage.getItem(\"@BYCODERS_KEY\");\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${token}`\n }\n\n await this.axiosInstance.patch(`/checkouts/${updateOrderDTO.cartId}/updateOrder`,\n {\n orderId: updateOrderDTO.orderId,\n externalId: updateOrderDTO.cartIdCrm\n }, { headers: headers })\n\n localStorage.removeItem(\"@BYCODERS_KEY\");\n }\n\n async sendPin(phone: number, name: string, store: string): Promise<IPinSent> {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n\n const response = await this.axiosInstance.post(\"/crmbonus/send-pin\", { cellphone: phone, name: name, storeName: store }, { headers: headers });\n return {\n storeId: response.data.storeId,\n userId: response.data.userId\n }\n }\n\n async validatePinBonus(payload: IProccesPinBonusDto): Promise<IBonus> {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.post(\"/crmbonus/process-pin-bonus\", payload, { headers })\n\n return response.data;\n }\n\n async reserve(payload: IReserveDTO) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n const response = await this.axiosInstance.post(\"/crmbonus/redeem-bonus\", payload, { headers });\n return response.data;\n }\n\n async cancel(cartId: string) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.post(\"/crmbonus/cancel-apply-bonus\", {\n ticket: cartId\n }, { headers });\n return response.data;\n }\n\n async getToken(store: string): Promise<string> {\n const response = await this.axiosInstance.post(\"/wake/requestToken\", { storeName: store })\n this.token = response?.data?.token;\n\n localStorage.setItem(BYCODERS_KEY, this.token);\n\n return response?.data?.token;\n }\n\n async getCustomization(storeName: string) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.get(`/stores/${storeName}/customizations`, { headers });\n\n localStorage.setItem(getKeyConfigByStoreName(storeName), JSON.stringify(response.data))\n }\n\n async cancelBonus(cartId: string, storeName: string) {\n const token = localStorage.getItem(BYCODERS_KEY);\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${token}`\n }\n\n await this.axiosInstance.post(`/crmbonus/cancel-bonus`,\n {\n cartId,\n usedBonus: true,\n storeName: storeName\n }, { headers: headers })\n\n localStorage.setItem(cartId, \"0\");\n \n localStorage.removeItem(\"bc:used\")\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;AAI7C,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAExF,MAAM,OAAO,eAAe;IAMxB;QACI,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;YAC9B,OAAO,EAAE,iBAAiB;YAC1B,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;gBAClC,QAAQ,EAAE,kBAAkB;aAC/B;SACJ,CAAC,CAAC;IACP,CAAC;IAEM,MAAM,CAAC,WAAW;QACrB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YAC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C,CAAA;QAED,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,wBAAwB,EAClD;YACI,MAAM;YACN,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,SAAS;SACvB,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;QAE5B,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAElC,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IACrC,CAAC;;AA/Ic,yBAAS,GAAoB,IAAI,CAAC","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';\nimport { BYCODERS_KEY, USED_KEY, getKeyConfigByStoreName } from '../utils/keys.storage';\n\nexport class CrmBonusService {\n private axiosInstance: AxiosInstance;\n private token: string;\n\n private static _instance: CrmBonusService = null;\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 public static getInstance(): CrmBonusService {\n if (this._instance) {\n return this._instance;\n }\n\n this._instance = new CrmBonusService()\n\n return this._instance;\n }\n\n async getCustomer(userId: number, store: string) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.get(`/store/${store}/customer/${userId}`, { headers: headers })\n\n this.token = response?.data?.token\n\n return response?.data?.customer\n }\n\n async updateOrder(updateOrderDTO: UpdateOrderDTO) {\n\n const token = localStorage.getItem(\"@BYCODERS_KEY\");\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${token}`\n }\n\n await this.axiosInstance.patch(`/checkouts/${updateOrderDTO.cartId}/updateOrder`,\n {\n orderId: updateOrderDTO.orderId,\n externalId: updateOrderDTO.cartIdCrm\n }, { headers: headers })\n\n localStorage.removeItem(\"@BYCODERS_KEY\");\n }\n\n async sendPin(phone: number, name: string, store: string): Promise<IPinSent> {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n\n const response = await this.axiosInstance.post(\"/crmbonus/send-pin\", { cellphone: phone, name: name, storeName: store }, { headers: headers });\n return {\n storeId: response.data.storeId,\n userId: response.data.userId\n }\n }\n\n async validatePinBonus(payload: IProccesPinBonusDto): Promise<IBonus> {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.post(\"/crmbonus/process-pin-bonus\", payload, { headers })\n\n return response.data;\n }\n\n async reserve(payload: IReserveDTO) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n const response = await this.axiosInstance.post(\"/crmbonus/redeem-bonus\", payload, { headers });\n return response.data;\n }\n\n async cancel(cartId: string) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.post(\"/crmbonus/cancel-apply-bonus\", {\n ticket: cartId\n }, { headers });\n return response.data;\n }\n\n async getToken(store: string): Promise<string> {\n const response = await this.axiosInstance.post(\"/wake/requestToken\", { storeName: store })\n this.token = response?.data?.token;\n\n localStorage.setItem(BYCODERS_KEY, this.token);\n\n return response?.data?.token;\n }\n\n async getCustomization(storeName: string) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.get(`/stores/${storeName}/customizations`, { headers });\n\n localStorage.setItem(getKeyConfigByStoreName(storeName), JSON.stringify(response.data))\n }\n\n async cancelBonus(cartId: string, storeName: string) {\n const token = localStorage.getItem(BYCODERS_KEY);\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${token}`\n }\n\n await this.axiosInstance.post(`/crmbonus/cancel-bonus`,\n {\n cartId,\n usedBonus: true,\n storeName: storeName\n }, { headers: headers })\n\n localStorage.setItem(cartId, \"0\");\n\n localStorage.removeItem(USED_KEY)\n }\n}"]}
@@ -2,6 +2,7 @@ export const getKeyReserveByCartId = (cartId) => {
2
2
  return `bc:reserve${cartId}`;
3
3
  };
4
4
  export const BYCODERS_KEY = "@BYCODERS_KEY";
5
+ export const USED_KEY = "bc:used";
5
6
  export const getKeyConfigByStoreName = (storeName) => {
6
7
  return `bc:${storeName}`;
7
8
  };
@@ -1 +1 @@
1
- {"version":3,"file":"keys.storage.js","sourceRoot":"","sources":["../../../src/utils/keys.storage.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,EAAE;IACpD,OAAO,aAAa,MAAM,EAAE,CAAA;AAChC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;AAE5C,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,SAAiB,EAAE,EAAE;IACzD,OAAO,MAAM,SAAS,EAAE,CAAA;AAC5B,CAAC,CAAA","sourcesContent":["export const getKeyReserveByCartId = (cartId: string) => {\n return `bc:reserve${cartId}`\n}\n\nexport const BYCODERS_KEY = \"@BYCODERS_KEY\";\n\nexport const getKeyConfigByStoreName = (storeName: string) => {\n return `bc:${storeName}`\n}"]}
1
+ {"version":3,"file":"keys.storage.js","sourceRoot":"","sources":["../../../src/utils/keys.storage.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAc,EAAE,EAAE;IACpD,OAAO,aAAa,MAAM,EAAE,CAAA;AAChC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;AAC5C,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAC;AAGlC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,SAAiB,EAAE,EAAE;IACzD,OAAO,MAAM,SAAS,EAAE,CAAA;AAC5B,CAAC,CAAA","sourcesContent":["export const getKeyReserveByCartId = (cartId: string) => {\n return `bc:reserve${cartId}`\n}\n\nexport const BYCODERS_KEY = \"@BYCODERS_KEY\";\nexport const USED_KEY = \"bc:used\";\n\n\nexport const getKeyConfigByStoreName = (storeName: string) => {\n return `bc:${storeName}`\n}"]}
@@ -1,5 +1,5 @@
1
1
  import { p as proxyCustomElement, H, h, d as Host } from './p-959f4cc8.js';
2
- import { C as CrmBonusService } from './p-a7ddcab4.js';
2
+ import { C as CrmBonusService } from './p-641b4efd.js';
3
3
  import { S as StepFormEnum } from './p-a561251a.js';
4
4
  import { d as defineCustomElement$6 } from './p-fbcbb1aa.js';
5
5
  import { d as defineCustomElement$5 } from './p-6592ce84.js';
@@ -1,6 +1,7 @@
1
1
  import { p as proxyCustomElement, H, h } from './p-959f4cc8.js';
2
2
  import { g as getInfoCustomization } from './p-75ba7b9a.js';
3
- import { C as CrmBonusService, g as getKeyReserveByCartId } from './p-a7ddcab4.js';
3
+ import { C as CrmBonusService } from './p-641b4efd.js';
4
+ import { a as getKeyReserveByCartId } from './p-89c5ef5a.js';
4
5
 
5
6
  const moneyDollarsSvgrepoComSvg = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IS0tIFVwbG9hZGVkIHRvOiBTVkcgUmVwbywgd3d3LnN2Z3JlcG8uY29tLCBHZW5lcmF0b3I6IFNWRyBSZXBvIE1peGVyIFRvb2xzIC0tPg0KPHN2ZyB3aWR0aD0iODAwcHgiIGhlaWdodD0iODAwcHgiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxjaXJjbGUgY3g9IjEyIiBjeT0iMTIiIHI9IjEwIiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIvPg0KP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aAAa,IAAI,UAAU,2BAAsB,wEAAY,IAAI,CAAC,SAAS,EAAE,CAAU,CACpG,CACP,EAID,CAAC,IAAI,CAAC,UAAU,EAAE;aAEd,0DAAG,KAAK,EAAC,sBAAsB,yBACnB,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,UAAU,sCAC/C,CACP,CAMH,CACJ,EACT;KACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CrmBonusNote","money"],"sources":["src/assets/svg/money-dollars-svgrepo-com.svg","src/components/note/crm-bonus-note.css?tag=crm-bonus-note","src/components/note/crm-bonus-note.tsx"],"sourcesContent":["<?xml version=\"1.0\" encoding=\"utf-8\"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->\r\n<svg width=\"800px\" height=\"800px\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"#000000\" stroke-width=\"2\"/>\r\n<path d=\"M15 9.94728C14.5 9.3 13.8 8.5 12 8.5C10.2 8.5 9 9.51393 9 9.94728C9 10.3806 9.06786 10.9277 10 11.5C10.7522 11.9618 12.6684 12.0439 13.5 12.5C14.679 13.1467 14.8497 13.8202 14.8497 14.0522C14.8497 14.6837 13.4175 15.4852 12 15.5C10.536 15.5153 9.5 14.7 9 14.0522\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\r\n<path d=\"M12 7V17\" stroke=\"#000000\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\r\n</svg>",".note-container {\n border: 1px solid #dddddd;\n padding: 0 15px 15px;\n margin: 0 0 26px 0px;\n}\n\n.note-container hr {\n border: 1px solid #CCC;\n}\n\n.note-container .back-cart {\n display: flex;\n text-align: center;\n}\n\n.note-header {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n}\n\n.note-title {\n font-weight: 700;\n text-align: left;\n display: flex;\n gap: 6px;\n align-items: center;\n margin-top: 11px;\n color: #000;\n}\n\n.note-description {\n font-family: Arial;\n color: #6d6d5f;\n padding: 0;\n margin: 0 auto;\n}\n\n.back-cart {\n font-size: .9em;\n color: #27272A;\n text-decoration: none;\n cursor: pointer;\n margin-top: 11px;\n}\n\n.note-description-2 {\n color: var(--crm-scheme-fg-main-inverse, #262626);\n font-family: Roboto;\n font-size: var(--crm-font-size-body-lg, 16px);\n font-style: normal;\n font-weight: var(--crm-font-weight-body-bold, 400);\n line-height: var(--crm-line-height-body-md, 20px);\n letter-spacing: var(--crm-letter-spacing-title-md, 0px);\n margin-top: 11px;\n color: #000;\n}\n\n.note-description-not {\n font-size: 16px;\n}","import { Component, Prop, State, h } from \"@stencil/core\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport money from '../../assets/svg/money-dollars-svgrepo-com.svg'\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-bonus-note',\n styleUrl: 'crm-bonus-note.css'\n})\nexport class CrmBonusNote {\n\n @Prop({ attribute: 'cartid' }) cartId;\n @Prop({ attribute: \"storename\" }) storename;\n\n @State() url: string;\n @State() config: IInfoStore;\n\n componentWillLoad() {\n this.upadateCheckToFreteAndGetUrl()\n }\n\n upadateCheckToFreteAndGetUrl() {\n\n this.config = getInfoCustomization(this.storename);\n const envios = document.getElementsByName('forma-envio');\n envios.forEach((envio: any) => {\n envio.checked = false;\n });\n\n this.url = window.location.origin;\n }\n\n handleHide() {\n const amount = localStorage.getItem(this.cartId);\n return !!amount;\n }\n\n getAmount() {\n const amount = localStorage.getItem(this.cartId);\n\n console.log('amount', amount)\n\n return Number(amount).toFixed(2).replace(\".\", \",\") || \"0,00\"\n }\n\n async handleCancel() {\n await CrmBonusService.getInstance().cancelBonus(this.cartId, this.storename);\n window.location.href = this.url;\n\n localStorage.removeItem(getKeyReserveByCartId(this.cartId));\n }\n\n render() {\n\n return (\n <div>\n <div class=\"note-container\">\n <div class=\"note-header\">\n\n <p class=\"note-title\">\n <img src={money} width={23} />\n {this.config.giftbackTitle}\n </p>\n {\n this.handleHide() && (\n <p class=\"back-cart\" onClick={() => this.handleCancel()}>\n Editar\n </p>\n )\n }\n </div>\n\n <hr />\n {\n this.handleHide() &&\n (\n <p class=\"note-description-2\">\n {this.config.giftbackTitle || \"Giftback\"} aplicado ao pedido: <strong>R$ {this.getAmount()}</strong>\n </p>\n )\n }\n\n {\n !this.handleHide() &&\n (\n <p class=\"note-description-not\">\n Não há {this.config.giftbackTitle || \"Giftback\"} disponível para essa compra\n </p>\n )\n }\n\n {/* <a class=\"back-cart\" href={this.url}>\n Voltar ao carrinho\n </a> */}\n </div>\n </div>\n )\n }\n}"],"version":3}
1
+ {"file":"crm-bonus-note.js","mappings":";;;;;AAAA,MAAM,yBAAyB,GAAG,ghCAAghC;;ACAljC,MAAM,eAAe,GAAG,y4BAAy4B,CAAC;AACl6B,2BAAe,eAAe;;MCUjBA,cAAY;;;;;;;;;IAQrB,iBAAiB;QACb,IAAI,CAAC,4BAA4B,EAAE,CAAA;KACtC;IAED,4BAA4B;QAExB,IAAI,CAAC,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,QAAQ,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACzD,MAAM,CAAC,OAAO,CAAC,CAAC,KAAU;YACtB,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;SACzB,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;KACrC;IAED,UAAU;QACN,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjD,OAAO,CAAC,CAAC,MAAM,CAAC;KACnB;IAED,SAAS;QACL,MAAM,MAAM,GAAG,YAAY,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;;;;;;;;;;;;;;","names":["CrmBonusNote","money"],"sources":["src/assets/svg/money-dollars-svgrepo-com.svg","src/components/note/crm-bonus-note.css?tag=crm-bonus-note","src/components/note/crm-bonus-note.tsx"],"sourcesContent":["<?xml version=\"1.0\" encoding=\"utf-8\"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->\r\n<svg width=\"800px\" height=\"800px\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\r\n<circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"#000000\" stroke-width=\"2\"/>\r\n<path d=\"M15 9.94728C14.5 9.3 13.8 8.5 12 8.5C10.2 8.5 9 9.51393 9 9.94728C9 10.3806 9.06786 10.9277 10 11.5C10.7522 11.9618 12.6684 12.0439 13.5 12.5C14.679 13.1467 14.8497 13.8202 14.8497 14.0522C14.8497 14.6837 13.4175 15.4852 12 15.5C10.536 15.5153 9.5 14.7 9 14.0522\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\r\n<path d=\"M12 7V17\" stroke=\"#000000\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\r\n</svg>",".note-container {\n border: 1px solid #dddddd;\n padding: 0 15px 15px;\n margin: 0 0 26px 0px;\n}\n\n.note-container hr {\n border: 1px solid #CCC;\n}\n\n.note-container .back-cart {\n display: flex;\n text-align: center;\n}\n\n.note-header {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n}\n\n.note-title {\n font-weight: 700;\n text-align: left;\n display: flex;\n gap: 6px;\n align-items: center;\n margin-top: 11px;\n color: #000;\n}\n\n.note-description {\n font-family: Arial;\n color: #6d6d5f;\n padding: 0;\n margin: 0 auto;\n}\n\n.back-cart {\n font-size: .9em;\n color: #27272A;\n text-decoration: none;\n cursor: pointer;\n margin-top: 11px;\n}\n\n.note-description-2 {\n color: var(--crm-scheme-fg-main-inverse, #262626);\n font-family: Roboto;\n font-size: var(--crm-font-size-body-lg, 16px);\n font-style: normal;\n font-weight: var(--crm-font-weight-body-bold, 400);\n line-height: var(--crm-line-height-body-md, 20px);\n letter-spacing: var(--crm-letter-spacing-title-md, 0px);\n margin-top: 11px;\n color: #000;\n}\n\n.note-description-not {\n font-size: 16px;\n}","import { Component, Prop, State, h } from \"@stencil/core\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport money from '../../assets/svg/money-dollars-svgrepo-com.svg'\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-bonus-note',\n styleUrl: 'crm-bonus-note.css'\n})\nexport class CrmBonusNote {\n\n @Prop({ attribute: 'cartid' }) cartId;\n @Prop({ attribute: \"storename\" }) storename;\n\n @State() url: string;\n @State() config: IInfoStore;\n\n componentWillLoad() {\n this.upadateCheckToFreteAndGetUrl()\n }\n\n upadateCheckToFreteAndGetUrl() {\n\n this.config = getInfoCustomization(this.storename);\n const envios = document.getElementsByName('forma-envio');\n envios.forEach((envio: any) => {\n envio.checked = false;\n });\n\n this.url = window.location.origin;\n }\n\n handleHide() {\n const amount = localStorage.getItem(this.cartId);\n return !!amount;\n }\n\n getAmount() {\n const amount = localStorage.getItem(this.cartId);\n\n console.log('amount', amount)\n\n return Number(amount).toFixed(2).replace(\".\", \",\") || \"0,00\"\n }\n\n async handleCancel() {\n await CrmBonusService.getInstance().cancelBonus(this.cartId, this.storename);\n window.location.href = this.url;\n\n localStorage.removeItem(getKeyReserveByCartId(this.cartId));\n }\n\n render() {\n\n return (\n <div>\n <div class=\"note-container\">\n <div class=\"note-header\">\n\n <p class=\"note-title\">\n <img src={money} width={23} />\n {this.config.giftbackTitle}\n </p>\n {\n this.handleHide() && (\n <p class=\"back-cart\" onClick={() => this.handleCancel()}>\n Editar\n </p>\n )\n }\n </div>\n\n <hr />\n {\n this.handleHide() &&\n (\n <p class=\"note-description-2\">\n {this.config.giftbackTitle || \"Giftback\"} aplicado ao pedido: <strong>R$ {this.getAmount()}</strong>\n </p>\n )\n }\n\n {\n !this.handleHide() &&\n (\n <p class=\"note-description-not\">\n Não há {this.config.giftbackTitle || \"Giftback\"} disponível para essa compra\n </p>\n )\n }\n\n {/* <a class=\"back-cart\" href={this.url}>\n Voltar ao carrinho\n </a> */}\n </div>\n </div>\n )\n }\n}"],"version":3}
@@ -1,17 +1,46 @@
1
1
  import { p as proxyCustomElement, H, h } from './p-959f4cc8.js';
2
- import { C as CrmBonusService } from './p-a7ddcab4.js';
2
+ import { C as CrmBonusService } from './p-641b4efd.js';
3
3
  import { S as StepFormEnum } from './p-a561251a.js';
4
4
  import { i as instance } from './p-fb505488.js';
5
5
  import { d as defineCustomElement$a } from './p-0ef696a9.js';
6
6
  import { d as defineCustomElement$9 } from './p-29622725.js';
7
- import { d as defineCustomElement$8 } from './p-9ceca803.js';
8
- import { d as defineCustomElement$7 } from './p-998b6c7d.js';
7
+ import { d as defineCustomElement$8 } from './p-1b08fd54.js';
8
+ import { d as defineCustomElement$7 } from './p-090c085f.js';
9
9
  import { d as defineCustomElement$6 } from './p-c7fc1cb6.js';
10
10
  import { d as defineCustomElement$5 } from './p-f1639e26.js';
11
11
  import { d as defineCustomElement$4 } from './p-ca3d612c.js';
12
12
  import { d as defineCustomElement$3 } from './p-0a29a684.js';
13
13
  import { d as defineCustomElement$2 } from './p-56757e8d.js';
14
14
 
15
+ var AjustesTipoEnum;
16
+ (function (AjustesTipoEnum) {
17
+ AjustesTipoEnum["P"] = "Promocao";
18
+ })(AjustesTipoEnum || (AjustesTipoEnum = {}));
19
+
20
+ function buildProductsByWake(productsWake = []) {
21
+ const products = [];
22
+ for (const pw of productsWake) {
23
+ let discounts = getDiscount(pw.Ajustes);
24
+ products.push({
25
+ sku: pw.SKU,
26
+ value: (pw.PrecoPor * pw.Quantidade),
27
+ productVariantId: pw.ProdutoVarianteId.toString(),
28
+ quantity: pw.Quantidade,
29
+ discount: (discounts * -1)
30
+ });
31
+ }
32
+ return products;
33
+ }
34
+ function getDiscount(ajustes = []) {
35
+ let discounts = 0;
36
+ for (const discount of ajustes) {
37
+ if (discount.Tipo === AjustesTipoEnum.P) {
38
+ discounts += discount.Valor;
39
+ }
40
+ }
41
+ return discounts;
42
+ }
43
+
15
44
  const crmBonusCss = ".container-button.sc-crm-bonus{cursor:pointer;padding:5px 5px 5px 14px}.section-crm.sc-crm-bonus{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm.sc-crm-bonus{margin-top:10px}.section-cart-crm.sc-crm-bonus p.sc-crm-bonus{padding:0;margin:0px 0px 0px 15px}.button.sc-crm-bonus{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;font-size:20px;cursor:pointer;margin-left:10px;height:70px}.form-container.sc-crm-bonus{width:97%;display:flex;justify-content:space-around}.btn.sc-crm-bonus{display:inline-block;padding:6px 12px;margin-bottom:0;font-size:14px;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container.sc-crm-bonus .btnCrm.sc-crm-bonus{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert.sc-crm-bonus{font-family:sans-serif;color:#df4d4d;margin-top:5px}";
16
45
  const CrmBonusStyle0 = crmBonusCss;
17
46
 
@@ -48,7 +77,7 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
48
77
  await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
49
78
  }
50
79
  try {
51
- await this.crmBonusRef.processBonus();
80
+ await this.crmBonusRef.processBonus(this.buildProducts(), true);
52
81
  console.log('[BONUS RESETADO]!!!!!');
53
82
  }
54
83
  catch (err) {
@@ -100,7 +129,7 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
100
129
  try {
101
130
  if (this.userId) {
102
131
  this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);
103
- // this.phone = Number(this.customer.phone)
132
+ console.log('customer', this.customer);
104
133
  }
105
134
  const amount = localStorage.getItem(this.cartId);
106
135
  if (amount) {
@@ -128,7 +157,7 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
128
157
  for (const product_cart of productsInCart) {
129
158
  const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId);
130
159
  if (pro) {
131
- products.push(Object.assign(Object.assign({}, product_cart), { PrecoPor: pro.PrecoPor, Quantidade: pro.Quantidade }));
160
+ products.push(Object.assign(Object.assign({}, product_cart), { PrecoPor: pro.PrecoPor, Quantidade: pro.Quantidade, Ajustes: pro.Ajustes }));
132
161
  }
133
162
  else {
134
163
  products.push(product_cart);
@@ -172,7 +201,7 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
172
201
  }
173
202
  }
174
203
  buildProducts() {
175
- return this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }));
204
+ return buildProductsByWake(this.products);
176
205
  }
177
206
  handleCloseModal() {
178
207
  this.showModal = false;
@@ -213,37 +242,7 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
213
242
  this.showModal = true;
214
243
  }
215
244
  render() {
216
- return (h("loading-container", { key: 'e9aa66730c6e9e536bb5dcd216f93cafb81a1868', loading: this.loading_reprocess }, h("crm-giftback-form", { key: '0778a680cf8cb0ecbd36955dc89dc80ad82f85ab', style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer }))
217
- // <div class="section-cart-crm">
218
- // <p class="text-left fbits-responsive-carrinho-desconto-texto">Giftback</p>
219
- // <div class="container-button">
220
- // {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}
221
- // {
222
- // this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />
223
- // : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />
224
- // }
225
- // </div>
226
- // <p class="message-alert" >{this.message}</p>
227
- // <app-modal
228
- // isOpen={this.showModal}
229
- // modalTitle={`Giftback`}
230
- // onModalClosed={() => (this.showModal = false)}
231
- // >
232
- // <crm-bonus-form
233
- // loadingModal={this.loading}
234
- // saveStore={(amount: number) => this.save(amount)}
235
- // ref={ref => this.crmBonusRef = ref}
236
- // sent={this.sent}
237
- // phone={this.phone}
238
- // cancel={() => this.handleCloseModal()}
239
- // storeName={this.storeName}
240
- // products={this.buildProducts()}
241
- // cartId={this.cartId} customer={this.customer}
242
- // handleCustomerName={(name: string) => this.sendPinName(name)}
243
- // />
244
- // </app-modal>
245
- // </div>
246
- );
245
+ return (h("loading-container", { key: '498f7bfb3f6ab94723c2c33013082be2b0136906', loading: this.loading_reprocess }, h("crm-giftback-form", { key: '0c1f8afd3c777f085add4663f590758432d240c9', style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer, loadProducts: () => this.buildProducts() })));
247
246
  }
248
247
  static get assetsDirs() { return ["assets"]; }
249
248
  static get watchers() { return {
@@ -1 +1 @@
1
- {"file":"crm-bonus.js","mappings":";;;;;;;;;;;;;;AAAA,MAAM,WAAW,GAAG,uoCAAuoC,CAAC;AAC5pC,uBAAe,WAAW;;MCabA,UAAQ;;;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,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AK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;SAC3B;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;KACvB;IAED,MAAM;QAEJ,QAEI,0EAAmB,OAAO,EAAE,IAAI,CAAC,iBAAiB,IAChD,0EACE,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAC/B,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,GACvB,CACgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BvB;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CrmBonus","i18next"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, Method, Prop, State, Watch, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n const used = localStorage.getItem(\"bc:used\");\n\n if (used == \"use\") {\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n }\n\n try {\n await this.crmBonusRef.processBonus();\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async reprocess(products: Array<any>) {\n this.loading_reprocess = true\n \n console.log('[reprocess]');\n try {\n console.log('[update products list]');\n this.productsInString = JSON.stringify(products);\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n @Watch(\"productsInString\")\n async watchProducts(newValue: string) {\n try {\n console.log('[update products list]');\n this.productsInString = newValue;\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n }\n }\n\n async componentWillLoad() {\n i18next.changeLanguage(i18next.language);\n\n await this.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n // this.phone = Number(this.customer.phone)\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor,\n Quantidade: pro.Quantidade\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n />\n </loading-container>\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":";;;;;;;;;;;;;;AAQA,IAAY,eAEX;AAFD,WAAY,eAAe;IACvB,iCAAc,CAAA;AAClB,CAAC,EAFW,eAAe,KAAf,eAAe;;SCNX,mBAAmB,CAA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AAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;KACvB;IAED,MAAM;QAEJ,QACE,0EAAmB,OAAO,EAAE,IAAI,CAAC,iBAAiB,IAChD,0EACE,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAC/B,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,GAExC,CACgB,EACrB;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CrmBonus","i18next"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["export interface IProduct {\n productVariantId: string;\n sku: string;\n value: number;\n quantity: number;\n discount: number;\n}\n\nexport enum AjustesTipoEnum {\n P = \"Promocao\" \n}\n\nexport interface IAjustes {\n Tipo: AjustesTipoEnum;\n Valor: number;\n}\n\nexport interface 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: 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}","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, Watch, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n const used = localStorage.getItem(\"bc:used\");\n\n if (used == \"use\") {\n await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n }\n\n try {\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async reprocess(products: Array<any>) {\n this.loading_reprocess = true\n\n console.log('[reprocess]');\n try {\n console.log('[update products list]');\n this.productsInString = JSON.stringify(products);\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n @Watch(\"productsInString\")\n async watchProducts(newValue: string) {\n try {\n console.log('[update products list]');\n this.productsInString = newValue;\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n }\n }\n\n async componentWillLoad() {\n i18next.changeLanguage(i18next.language);\n\n await this.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n console.log('customer', 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 loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor,\n Quantidade: pro.Quantidade,\n Ajustes: pro.Ajustes\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 buildProductsByWake(this.products);\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n loadProducts={() => this.buildProducts()}\n \n />\n </loading-container>\n )\n }\n}\n"],"version":3}
@@ -1,4 +1,4 @@
1
- import { C as CrmBonus, d as defineCustomElement$1 } from './p-9ceca803.js';
1
+ import { C as CrmBonus, d as defineCustomElement$1 } from './p-1b08fd54.js';
2
2
 
3
3
  const CrmGiftbackForm = CrmBonus;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,4 +1,4 @@
1
- import { G as GiftbackInfo$1, d as defineCustomElement$1 } from './p-998b6c7d.js';
1
+ import { G as GiftbackInfo$1, d as defineCustomElement$1 } from './p-090c085f.js';
2
2
 
3
3
  const GiftbackInfo = GiftbackInfo$1;
4
4
  const defineCustomElement = defineCustomElement$1;
@@ -1,7 +1,8 @@
1
1
  import { p as proxyCustomElement, H, h } from './p-959f4cc8.js';
2
2
  import { i as instance } from './p-fb505488.js';
3
+ import { U as USED_KEY } from './p-89c5ef5a.js';
3
4
 
4
- const giftbackInfoCss = ":host{--text-color:#6D6D5F}.giftback-container{display:flex;flex-direction:column;gap:14px}h3{font-size:1.2rem;margin-bottom:8px;color:#333}.container-description p{font-size:14px;font-weight:400}p{font-size:12px;color:#000}.value-display h2{color:#6D6D5F;font-size:1.6rem;margin:16px 0}input[type='range']{width:100%;margin:12px 0;-webkit-appearance:none;background:#ddd;height:4px;border-radius:4px;outline:none;padding:3px}input[type='range']::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--text-color);border-radius:50%;cursor:pointer}.options{margin:0px 0;display:flex;gap:10px;flex-direction:column}.options label{display:block;margin:0px 0;font-size:0.9rem;color:#333}.options input[type='radio']{margin-right:8px;height:16px;width:16px}.options input[type='radio']{appearance:none;-webkit-appearance:none;margin-right:8px;width:16px;height:16px;border:2px solid #ddd;border-radius:50%;background-color:#fff;cursor:pointer;transition:all 0.3s;padding:0px}.options input[type='radio']:checked{border-color:#000;background-color:#FAFAFA;border:4px solid #000}.info-box{background-color:#f9f9f9;border:1px solid #e0e0e0;border-radius:4px;padding:8px;font-size:14px;color:#262626;line-height:20px}.info-icon{font-size:0.9rem;cursor:pointer;color:#888}h3{font-size:1.2rem;margin-bottom:8px;color:#333}.slider-wrapper{position:relative;margin:21px 0px 0px 0px}.slider{width:100%;-webkit-appearance:none;background:#ddd;height:4px;border-radius:2px;outline:none}.slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--text-color);border-radius:50%;cursor:pointer}.slider-value{position:absolute;top:-30px;font-size:16px;font-weight:700;color:var(--text-color);transform:translateX(-50%);white-space:nowrap;margin-left:23px}";
5
+ const giftbackInfoCss = ":host{--text-color:#6D6D5F}.giftback-container{display:flex;flex-direction:column;gap:14px}h3{font-size:1.2rem;margin-bottom:8px;color:#333}.container-description p{font-size:14px;font-weight:400}p{font-size:12px;color:#000}.value-display h2{color:#6D6D5F;font-size:1.6rem;margin:16px 0}input[type='range']{width:100%;margin:12px 0;-webkit-appearance:none;background:#ddd;height:4px;border-radius:4px;outline:none;padding:3px 0px 3px 3px}input[type=\"range\"]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:20px;height:20px;background:rgb(109, 109, 95);border-radius:50%;cursor:pointer}.options{margin:0px 0;display:flex;gap:10px;flex-direction:column}.options label{display:block;margin:0px 0;font-size:0.9rem;color:#333}.options input[type='radio']{margin-right:8px;height:16px;width:16px}.options input[type='radio']{appearance:none;-webkit-appearance:none;margin-right:8px;width:16px;height:16px;border:2px solid #ddd;border-radius:50%;background-color:#fff;cursor:pointer;transition:all 0.3s;padding:0px}.options input[type='radio']:checked{border-color:#000;background-color:#FAFAFA;border:4px solid #000}.info-box{background-color:#f9f9f9;border:1px solid #e0e0e0;border-radius:4px;padding:8px;font-size:14px;color:#262626;line-height:20px}.info-icon{font-size:0.9rem;cursor:pointer;color:#888}h3{font-size:1.2rem;margin-bottom:8px;color:#333}.slider-wrapper{position:relative;margin:21px 0px 0px 0px}.slider{width:100%;-webkit-appearance:none;background:#ddd;height:4px;border-radius:2px;outline:none}.slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;background:var(--text-color);border-radius:50%;cursor:pointer}.slider-value{position:absolute;top:-30px;font-size:16px;font-weight:700;color:var(--text-color);transform:translateX(-50%);white-space:nowrap;}";
5
6
  const GiftbackInfoStyle0 = giftbackInfoCss;
6
7
 
7
8
  const GiftbackInfo = /*@__PURE__*/ proxyCustomElement(class GiftbackInfo extends H {
@@ -50,7 +51,7 @@ const GiftbackInfo = /*@__PURE__*/ proxyCustomElement(class GiftbackInfo extends
50
51
  }
51
52
  async handleOptionChange(option) {
52
53
  this.selectedOption = option;
53
- localStorage.setItem("bc:used", option);
54
+ localStorage.setItem(USED_KEY, option);
54
55
  switch (this.selectedOption) {
55
56
  case 'use':
56
57
  await this.reserve(this.usedValue);
@@ -63,11 +64,12 @@ const GiftbackInfo = /*@__PURE__*/ proxyCustomElement(class GiftbackInfo extends
63
64
  render() {
64
65
  const remainingGiftback = this.bonus.minimumPurchase - this.bonus.totalValue;
65
66
  const translateDescription = instance.t("giftDescription", { amount: `${this.bonus.totalBonus.toFixed(2).replace(".", ",")}`, custom_name: "Giftback" });
66
- return (h("div", { key: '403c0ce7c75392fa39c5be350332485a40d355ff', class: "giftback-container" }, h("div", { key: '32082671a78c5fad47437b0f90c3b81bc554a35a', class: "container-description" }, h("p", { key: 'c092e55242b9c614cab88a0d4e668c65892c6cb5', innerHTML: translateDescription })), h("div", { key: '5ce149e7cff2c917150889466b6594e384dbc696', class: "slider-wrapper" }, h("div", { key: '597399d607a8df8346dda9ff3fa0173e1d37e08a', class: "slider-value", style: {
67
+ return (h("div", { key: 'aefc2c17a4513a5a61a80de824f81abe256f68d3', class: "giftback-container" }, h("div", { key: 'ad7e9a109314a97c76a110a0da6d0b42aa8c525f', class: "container-description" }, h("p", { key: '83d6030d9e8d84e7b47e1bf4cad1273a9cb8960e', innerHTML: translateDescription })), h("div", { key: 'c305b50bffb44e32a368e49b1fd08e7a09e4dcb8', class: "slider-wrapper" }, h("div", { key: 'b253997e071ef51093e65c62ed82f5707dd43c41', class: "slider-value", style: {
67
68
  left: `calc(${this.sliderPosition}% - 20px)`, // Ajuste para centralizar o texto
68
- } }, "R$ ", this.usedValue.toFixed(2).replace(".", ",")), h("input", { key: 'a177c7138e257733cbb291ecc3fc26a3345221dd', disabled: true, type: "range", min: "0", max: this.bonus.totalBonus, value: this.usedValue, class: "slider", step: "0.01", onInput: (event) => this.handleSliderChange(event), style: {
69
+ "margin-left": this.usedValue < 10 ? "26px" : "0px"
70
+ } }, "R$ ", this.usedValue.toFixed(2).replace(".", ",")), h("input", { key: 'dfc15ff88b37ca93823590ff7804b477a3b3e3c3', disabled: true, type: "range", min: "0", max: this.bonus.totalBonus, value: this.usedValue, class: "slider", step: "0.01", onInput: (event) => this.handleSliderChange(event), style: {
69
71
  background: `linear-gradient(to right, #6D6D5F ${this.sliderPosition}%, #ddd ${this.sliderPosition}%)`,
70
- } })), h("p", { key: '26c57cea71436eab62765cb1a5aa453312ccf3d5' }, "Adicione ", h("strong", { key: '1fe4522625c78a9b6b79c3ca240c74f97bd0b6b7' }, "R$ ", remainingGiftback < 0 ? "0,00" : remainingGiftback.toFixed(2).replace(".", ",")), " ao carrinho para atingir o valor m\u00E1ximo!"), h("div", { key: 'f90088664a4f701de71a745dc372f7ec4140d51b', class: "options" }, h("label", { key: '55459ad240e943c967ec230cf4c19da71b78d616' }, h("input", { key: 'fe173b7b58a880bbb8f53fba049558031d215ea5', type: "radio", name: "giftbackOption", value: "use", checked: this.selectedOption === 'use', onChange: () => this.handleOptionChange('use') }), "Usar o meu Giftback"), h("label", { key: '89e28ac39113490be0920642a2821bae57ae502c' }, h("input", { key: 'b02f53533b93309e2abad203106e4934ed21d17d', type: "radio", name: "giftbackOption", value: "dontUse", checked: this.selectedOption === 'dontUse', onChange: () => this.handleOptionChange('dontUse') }), "N\u00E3o usar o meu Giftback")), h("div", { key: 'edcc7dc3b9ea02a9bd3d072d62cbe592ebaa85be', class: "info-box" }, "O Giftback ser\u00E1 aplicado na pr\u00F3xima etapa.")));
72
+ } })), h("p", { key: 'b519527612036202658ab23b042e9525d52a6f3b' }, "Adicione ", h("strong", { key: '50e7e3cf3709f109998458e12f9ae9282e9e8f98' }, "R$ ", remainingGiftback < 0 ? "0,00" : remainingGiftback.toFixed(2).replace(".", ",")), " ao carrinho para atingir o valor m\u00E1ximo!"), h("div", { key: '16bb02d466c45c7810180266f67db07d40766489', class: "options" }, h("label", { key: '20621d8e7601a902880f6ad7fe861182bdc78460' }, h("input", { key: '54f6d3c1f5faac3a32fc5c76369e40380395a5e3', type: "radio", name: "giftbackOption", value: "use", checked: this.selectedOption === 'use', onChange: () => this.handleOptionChange('use') }), "Usar o meu Giftback"), h("label", { key: 'c1f6addc20dbda629409bd364ba94f50ac3d1c09' }, h("input", { key: '40b221fac93b2c3ea388990778a5e5f958e34ea8', type: "radio", name: "giftbackOption", value: "dontUse", checked: this.selectedOption === 'dontUse', onChange: () => this.handleOptionChange('dontUse') }), "N\u00E3o usar o meu Giftback")), h("div", { key: '94ca150f2f88fb49bf0e8b6d0216135fe036c8e9', class: "info-box" }, "O Giftback ser\u00E1 aplicado na pr\u00F3xima etapa.")));
71
73
  }
72
74
  static get watchers() { return {
73
75
  "bonus": ["changedBonus"]
@@ -101,4 +103,4 @@ defineCustomElement();
101
103
 
102
104
  export { GiftbackInfo as G, defineCustomElement as d };
103
105
 
104
- //# sourceMappingURL=p-998b6c7d.js.map
106
+ //# sourceMappingURL=p-090c085f.js.map
@@ -0,0 +1 @@
1
+ {"file":"p-090c085f.js","mappings":";;;;AAAA,MAAM,eAAe,GAAG,uyDAAuyD,CAAC;AACh0D,2BAAe,eAAe;;MCSjB,YAAY;;;;yBACQ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AAK,KAAK,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAClD,KAAK,EAAE;gBACH,UAAU,EAAE,qCAAqC,IAAI,CAAC,cAAc,WAAW,IAAI,CAAC,cAAc,IAAI;aACzG,GACH,CACA,EACN,yEACa,wEAAY,iBAAiB,GAAG,CAAC,GAAG,MAAM,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAU,mDAE9G,EACJ,4DAAK,KAAK,EAAC,SAAS,IAChB,gEACI,8DACI,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,gBAAgB,EACrB,KAAK,EAAC,KAAK,EACX,OAAO,EAAE,IAAI,CAAC,cAAc,KAAK,KAAK,EACtC,QAAQ,EAAE,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAChD,wBAEE,EACR,gEACI,8DACI,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,gBAAgB,EACrB,KAAK,EAAC,SAAS,EACf,OAAO,EAAE,IAAI,CAAC,cAAc,KAAK,SAAS,EAC1C,QAAQ,EAAE,MAAM,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,GACpD,iCAEE,CACN,EACN,4DAAK,KAAK,EAAC,UAAU,2DAEf,CACJ,EACR;KACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["i18next"],"sources":["src/components/giftback-form/subcomponents/giftback-info/giftback-info.css?tag=giftback-info","src/components/giftback-form/subcomponents/giftback-info/giftback-info.tsx"],"sourcesContent":[":host {\n --text-color: #6D6D5F\n}\n\n.giftback-container {\n display: flex;\n flex-direction: column;\n gap: 14px;\n}\n\nh3 {\n font-size: 1.2rem;\n margin-bottom: 8px;\n color: #333;\n}\n\n.container-description p {\n font-size: 14px;\n font-weight: 400;\n}\n\n\np {\n font-size: 12px;\n color: #000;\n}\n\n.value-display h2 {\n color: #6D6D5F;\n /* Verde para o valor atual */\n font-size: 1.6rem;\n margin: 16px 0;\n}\n\ninput[type='range'] {\n width: 100%;\n margin: 12px 0;\n -webkit-appearance: none;\n background: #ddd;\n height: 4px;\n border-radius: 4px;\n outline: none;\n padding: 3px 0px 3px 3px;\n}\n\n/* input[type='range']::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 16px;\n height: 16px;\n background: var(--text-color);\n border-radius: 50%;\n cursor: pointer;\n} */\n\ninput[type=\"range\"]::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 20px;\n height: 20px;\n background: rgb(109, 109, 95);\n /* Cor do botão */\n border-radius: 50%;\n cursor: pointer;\n}\n\n.options {\n margin: 0px 0;\n display: flex;\n gap: 10px;\n flex-direction: column;\n}\n\n.options label {\n display: block;\n margin: 0px 0;\n font-size: 0.9rem;\n color: #333;\n}\n\n.options input[type='radio'] {\n margin-right: 8px;\n height: 16px;\n width: 16px;\n}\n\n.options input[type='radio'] {\n appearance: none;\n -webkit-appearance: none;\n margin-right: 8px;\n width: 16px;\n height: 16px;\n border: 2px solid #ddd;\n border-radius: 50%;\n background-color: #fff;\n cursor: pointer;\n transition: all 0.3s;\n padding: 0px;\n}\n\n.options input[type='radio']:checked {\n border-color: #000;\n background-color: #FAFAFA;\n border: 4px solid #000;\n}\n\n.info-box {\n background-color: #f9f9f9;\n border: 1px solid #e0e0e0;\n border-radius: 4px;\n padding: 8px;\n font-size: 14px;\n color: #262626;\n line-height: 20px;\n}\n\n.info-icon {\n font-size: 0.9rem;\n cursor: pointer;\n color: #888;\n}\n\nh3 {\n font-size: 1.2rem;\n margin-bottom: 8px;\n color: #333;\n}\n\n.slider-wrapper {\n position: relative;\n margin: 21px 0px 0px 0px;\n}\n\n.slider {\n width: 100%;\n -webkit-appearance: none;\n background: #ddd;\n height: 4px;\n border-radius: 2px;\n outline: none;\n}\n\n.slider::-webkit-slider-thumb {\n -webkit-appearance: none;\n appearance: none;\n width: 16px;\n height: 16px;\n background: var(--text-color);\n /* Azul para o slider */\n border-radius: 50%;\n cursor: pointer;\n}\n\n.slider-value {\n position: absolute;\n top: -30px;\n /* Posição acima do slider */\n font-size: 16px;\n font-weight: 700;\n color: var(--text-color);\n /* Verde para o texto */\n transform: translateX(-50%);\n white-space: nowrap;\n /* margin-left: 23px; */\n}","import { Component, Prop, State, Watch, h } from \"@stencil/core\";\nimport { IBonus } from \"../../../../dto/validate.pin.bonus\";\n\nimport i18next from '../../../../i18n/i18n'\nimport { USED_KEY } from \"../../../../utils/keys.storage\";\n\n@Component({\n tag: 'giftback-info',\n styleUrls: ['giftback-info.css']\n})\nexport class GiftbackInfo {\n @State() usedValue: number = 0;\n @State() selectedOption: string = 'none';\n\n @Prop() loading: boolean = false;\n @Prop() bonus: Partial<IBonus> = {\n totalBonus: 0,\n cartId: \"\",\n minimumPurchase: 0,\n bonusBalance: 0,\n calculatedValue: 0,\n firstValidityDate: \"\",\n totalValue: 0\n };\n @Prop() reserve: (amountRedeemed: number) => void;\n @Prop() cancel: () => void;\n\n @State() sliderPosition: number = 50;\n\n @Watch(\"bonus\") \n changedBonus() {\n this.updateBonus()\n }\n\n private updateBonus() {\n this.usedValue = parseFloat(this.bonus.bonusBalance.toString());\n this.buildPositionSlider(0, this.bonus.totalBonus);\n }\n\n componentWillLoad() {\n this.updateBonus();\n this.selectedOption = localStorage.getItem(\"bc:used\");\n }\n\n handleSliderChange(event: Event) {\n const input = event.target as HTMLInputElement;\n this.usedValue = parseFloat(input.value);\n\n // Calculando a posição do texto com base no valor do slider\n // const percentage = ((this.usedValue - parseInt(input.min)) / (parseInt(input.max) - parseInt(input.min))) * 100;\n // this.sliderPosition = percentage;\n\n this.buildPositionSlider(parseFloat(input.min), parseFloat(input.max))\n }\n\n\n private buildPositionSlider(min:number, max: number) {\n // Calculando a posição do texto com base no valor do slider\n const percentage = ((this.usedValue - min) / (max - min)) * 100;\n this.sliderPosition = percentage;\n }\n\n async handleOptionChange(option: string) {\n this.selectedOption = option;\n localStorage.setItem(USED_KEY, option)\n switch (this.selectedOption) {\n case 'use':\n await this.reserve(this.usedValue)\n break;\n case 'dontUse':\n await this.cancel()\n break;\n default:\n }\n }\n render() {\n const remainingGiftback = this.bonus.minimumPurchase - this.bonus.totalValue;\n\n const translateDescription = i18next.t(\"giftDescription\", { amount: `${this.bonus.totalBonus.toFixed(2).replace(\".\", \",\")}`, custom_name: \"Giftback\" })\n\n return (\n\n <div class=\"giftback-container\">\n <div class=\"container-description\">\n <p innerHTML={translateDescription}></p>\n </div>\n <div class=\"slider-wrapper\">\n <div\n class=\"slider-value\"\n style={{\n left: `calc(${this.sliderPosition}% - 20px)`, // Ajuste para centralizar o texto\n \"margin-left\": this.usedValue < 10 ? \"26px\" : \"0px\"\n }}\n >\n R$ {this.usedValue.toFixed(2).replace(\".\", \",\")}\n </div>\n <input\n disabled\n type=\"range\"\n min=\"0\"\n max={this.bonus.totalBonus}\n value={this.usedValue}\n class=\"slider\"\n step=\"0.01\"\n onInput={(event) => this.handleSliderChange(event)}\n style={{\n background: `linear-gradient(to right, #6D6D5F ${this.sliderPosition}%, #ddd ${this.sliderPosition}%)`,\n }}\n />\n </div>\n <p>\n Adicione <strong>R$ {remainingGiftback < 0 ? \"0,00\" : remainingGiftback.toFixed(2).replace(\".\", \",\")}</strong> ao carrinho para atingir o valor\n máximo!\n </p>\n <div class=\"options\">\n <label>\n <input\n type=\"radio\"\n name=\"giftbackOption\"\n value=\"use\"\n checked={this.selectedOption === 'use'}\n onChange={() => this.handleOptionChange('use')}\n />\n Usar o meu Giftback\n </label>\n <label>\n <input\n type=\"radio\"\n name=\"giftbackOption\"\n value=\"dontUse\"\n checked={this.selectedOption === 'dontUse'}\n onChange={() => this.handleOptionChange('dontUse')}\n />\n Não usar o meu Giftback\n </label>\n </div>\n <div class=\"info-box\">\n O Giftback será aplicado na próxima etapa.\n </div>\n </div>\n );\n }\n}"],"version":3}
@@ -1,11 +1,12 @@
1
1
  import { p as proxyCustomElement, H, h } from './p-959f4cc8.js';
2
- import { C as CrmBonusService, g as getKeyReserveByCartId } from './p-a7ddcab4.js';
2
+ import { C as CrmBonusService } from './p-641b4efd.js';
3
3
  import { S as StepFormEnum } from './p-a561251a.js';
4
4
  import { g as getInfoCustomization } from './p-75ba7b9a.js';
5
5
  import { i as instance } from './p-fb505488.js';
6
+ import { a as getKeyReserveByCartId, U as USED_KEY } from './p-89c5ef5a.js';
6
7
  import { d as defineCustomElement$7 } from './p-0ef696a9.js';
7
8
  import { d as defineCustomElement$6 } from './p-29622725.js';
8
- import { d as defineCustomElement$5 } from './p-998b6c7d.js';
9
+ import { d as defineCustomElement$5 } from './p-090c085f.js';
9
10
  import { d as defineCustomElement$4 } from './p-f1639e26.js';
10
11
  import { d as defineCustomElement$3 } from './p-ca3d612c.js';
11
12
  import { d as defineCustomElement$2 } from './p-0a29a684.js';
@@ -24,6 +25,7 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
24
25
  this.cartId = undefined;
25
26
  this.products = undefined;
26
27
  this.customer = undefined;
28
+ this.loadProducts = undefined;
27
29
  this.value = undefined;
28
30
  this.loading = false;
29
31
  this.message = undefined;
@@ -39,8 +41,12 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
39
41
  async setStep(step) {
40
42
  this.step = step;
41
43
  }
42
- async processBonus() {
44
+ async processBonus(products = [], hasNewProduct = false) {
43
45
  this.sucess = "";
46
+ console.log('processBonus', []);
47
+ if (hasNewProduct) {
48
+ this.products = products;
49
+ }
44
50
  const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
45
51
  if (_bonus) {
46
52
  const bonus = JSON.parse(_bonus);
@@ -70,6 +76,7 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
70
76
  await this.handleApply();
71
77
  }
72
78
  async handleApply() {
79
+ console.log('processBonus');
73
80
  await this.processBonus();
74
81
  // const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
75
82
  // if (bonus) {
@@ -82,18 +89,24 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
82
89
  return Number(_phone);
83
90
  }
84
91
  async sendPin() {
85
- var _a, _b;
92
+ var _a, _b, _c;
86
93
  this.loading = true;
87
94
  this.message = "";
88
95
  this.sucess = "";
89
96
  this.error = "";
90
97
  try {
91
98
  const _phone = this.convertStringToNumber();
92
- this.pinInfo = await this.crmBonusService.sendPin(_phone, "", this.storeName);
93
- this.step = StepFormEnum.STEP_PIN;
99
+ this.pinInfo = await this.crmBonusService.sendPin(_phone, (_a = this.customer) === null || _a === void 0 ? void 0 : _a.name, this.storeName);
100
+ if (localStorage.getItem(`bc:${this.phone}`)) {
101
+ await this.validateBonus("2018");
102
+ this.step = StepFormEnum.STEP_RESERVE;
103
+ }
104
+ else {
105
+ this.step = StepFormEnum.STEP_PIN;
106
+ }
94
107
  }
95
108
  catch (error) {
96
- this.message = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message;
109
+ this.message = (_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message;
97
110
  }
98
111
  finally {
99
112
  this.loading = false;
@@ -105,8 +118,10 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
105
118
  this.step = StepFormEnum.STEP_PHONE;
106
119
  }
107
120
  async validateBonus(pin) {
108
- var _a, _b;
109
- if (this.sucess) {
121
+ var _a, _b, _c;
122
+ this.loadProducts();
123
+ const used_or_no = localStorage.getItem(USED_KEY);
124
+ if (used_or_no == "use") {
110
125
  this.step = StepFormEnum.STEP_RESERVE;
111
126
  return;
112
127
  }
@@ -120,7 +135,7 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
120
135
  userId: this.pinInfo.userId.toString(),
121
136
  checkoutId: this.cartId,
122
137
  checkoutProducts: this.products,
123
- name: null,
138
+ name: (_a = this.customer) === null || _a === void 0 ? void 0 : _a.name,
124
139
  storeName: this.storeName
125
140
  };
126
141
  try {
@@ -132,9 +147,11 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
132
147
  }
133
148
  this.sucess = "Código validado com sucesso!";
134
149
  localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify(Object.assign(Object.assign({}, this.bonus), { phone: this.phone })));
150
+ localStorage.setItem(`bc:${this.phone}`, "validate");
151
+ this.step = StepFormEnum.STEP_RESERVE;
135
152
  }
136
153
  catch (error) {
137
- const _error = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message;
154
+ const _error = (_c = (_b = error === null || error === void 0 ? void 0 : error.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message;
138
155
  if (_error.includes("Pin")) {
139
156
  this.error = "Código inválido!";
140
157
  }
@@ -155,7 +172,7 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
155
172
  this.message = "";
156
173
  this.loading = true;
157
174
  try {
158
- await this.crmBonusService.cancel(this.cartId);
175
+ await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
159
176
  // localStorage.removeItem(this.cartId);
160
177
  this.save(0);
161
178
  }
@@ -197,11 +214,11 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
197
214
  });
198
215
  }
199
216
  render() {
200
- return (h("div", { key: '2a225520b20b78fba60b11f6bcbff044750bf6d1', class: "crm-container-form fbits-responsive-carrinho-desconto" }, h("label", { key: '19a5f06a826500ca4cde52d9ea3da9e0a8125408', class: "crm-title" }, this.config.giftbackTitle), this.step === StepFormEnum.STEP_PHONE &&
201
- h("phone-form", { key: '15055be6adb4a01300d03ecc29f6c49963d7f642', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === StepFormEnum.STEP_PIN &&
202
- h("pin-form", { key: '10629be7ff271ce8a65f7268b1f7700f5dab8b25', config: this.config, phone: this.phone, cancel: () => this.changePhone(), resend: () => this.sendPin(), validate: (data) => this.validateBonus(data), loading: this.loading }, this.sucess && h("p", { key: 'ac9c9db89ef6f1357f26b26c2d0b179056f5affd', class: "crm-message-info" }, this.sucess), this.error && h("p", { key: 'd04c70cdbba00d72a7b4d8b089cfff961b4e9ecc', class: "crm-message-error" }, this.error)), this.step === StepFormEnum.STEP_RESERVE &&
203
- h("giftback-info", { key: '72dfd0ce0dd7fab15d41d32023d8b1190472af3f', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === StepFormEnum.STEP_NO_BONUS &&
204
- (h("div", { key: 'd25638b12aebf6fd34064092da6f47e19e54bf9d', class: "container-message" }, instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
217
+ return (h("div", { key: 'b3ee46442ab6dfc062792ba9304153735ea5c221', class: "crm-container-form fbits-responsive-carrinho-desconto" }, h("label", { key: '763cc526640bce84ece0b2389b2fb7e99519eab8', class: "crm-title" }, this.config.giftbackTitle), this.step === StepFormEnum.STEP_PHONE &&
218
+ h("phone-form", { key: '1696446b829fd16c006353ad3689c25f51ec6c90', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === StepFormEnum.STEP_PIN &&
219
+ h("pin-form", { key: '0af5348ebf7ad7980b3f3f8364cd442e41ad9fe8', config: this.config, phone: this.phone, cancel: () => this.changePhone(), resend: () => this.sendPin(), validate: (data) => this.validateBonus(data), loading: this.loading }, this.sucess && h("p", { key: 'b11bfde8822d9acf404313f0a8d079189b35a40b', class: "crm-message-info" }, this.sucess), this.error && h("p", { key: 'f848df71f4604122b87a59cb59b96e85d4a89057', class: "crm-message-error" }, this.error)), this.step === StepFormEnum.STEP_RESERVE &&
220
+ h("giftback-info", { key: '66480f6f9c5e93162ed2152192d8db76c01f459f', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === StepFormEnum.STEP_NO_BONUS &&
221
+ (h("div", { key: '054f6a2b7d1bf73daa96d46665f4b840ae85ca64', class: "container-message" }, instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
205
222
  }
206
223
  static get style() { return CrmGiftbackFormStyle0; }
207
224
  }, [0, "crm-giftback-form", {
@@ -209,6 +226,7 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
209
226
  "cartId": [8, "cart-id"],
210
227
  "products": [16],
211
228
  "customer": [16],
229
+ "loadProducts": [16],
212
230
  "value": [32],
213
231
  "loading": [32],
214
232
  "message": [32],
@@ -275,4 +293,4 @@ defineCustomElement();
275
293
 
276
294
  export { CrmBonus as C, defineCustomElement as d };
277
295
 
278
- //# sourceMappingURL=p-9ceca803.js.map
296
+ //# sourceMappingURL=p-1b08fd54.js.map