crmbonus-component-wake 0.0.14 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +7 -0
  2. package/dist/cjs/app-globals-3a1e7e63.js.map +1 -0
  3. package/dist/cjs/app-modal_2.cjs.entry.js +127 -0
  4. package/dist/cjs/app-modal_2.cjs.entry.js.map +1 -0
  5. package/dist/cjs/crm-bonus.cjs.entry.js +46 -0
  6. package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -0
  7. package/dist/cjs/crmbonus-component-wake.cjs.js +27 -0
  8. package/dist/cjs/crmbonus-component-wake.cjs.js.map +1 -0
  9. package/dist/cjs/crmbonus.service-a626c034.js +3795 -0
  10. package/dist/cjs/crmbonus.service-a626c034.js.map +1 -0
  11. package/dist/cjs/giftback-finish_5.cjs.entry.js +153 -0
  12. package/dist/cjs/giftback-finish_5.cjs.entry.js.map +1 -0
  13. package/dist/cjs/index-52d8a075.js +1248 -0
  14. package/dist/cjs/index-52d8a075.js.map +1 -0
  15. package/dist/cjs/index.cjs.js +11 -0
  16. package/dist/cjs/index.cjs.js.map +1 -0
  17. package/dist/cjs/loader.cjs.js +17 -0
  18. package/dist/cjs/loader.cjs.js.map +1 -0
  19. package/dist/cjs/loading-spinner.cjs.entry.js +24 -0
  20. package/dist/cjs/loading-spinner.cjs.entry.js.map +1 -0
  21. package/dist/cjs/pedido-finalizado.cjs.entry.js +28 -0
  22. package/dist/cjs/pedido-finalizado.cjs.entry.js.map +1 -0
  23. package/dist/collection/collection-manifest.json +21 -0
  24. package/dist/collection/components/crm-bonus/assets/logo.svg +18 -0
  25. package/dist/collection/components/crm-bonus/assets/success-svgrepo-com.svg +8 -0
  26. package/dist/collection/components/crm-bonus/assets/svg/logo.svg +18 -0
  27. package/dist/collection/components/crm-bonus/assets/svg/success-svgrepo-com.svg +8 -0
  28. package/dist/collection/components/crm-bonus/crm-bonus.css +12 -0
  29. package/dist/collection/components/crm-bonus/crm-bonus.js +123 -0
  30. package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -0
  31. package/dist/collection/components/crm-bonus-form/crm-bonus-form.css +32 -0
  32. package/dist/collection/components/crm-bonus-form/crm-bonus-form.js +194 -0
  33. package/dist/collection/components/crm-bonus-form/crm-bonus-form.js.map +1 -0
  34. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-finish/giftback-finish.css +10 -0
  35. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-finish/giftback-finish.js +20 -0
  36. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-finish/giftback-finish.js.map +1 -0
  37. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-pin/giftback-pin.css +54 -0
  38. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-pin/giftback-pin.js +111 -0
  39. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-pin/giftback-pin.js.map +1 -0
  40. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-progress/giftback-progress.css +95 -0
  41. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-progress/giftback-progress.js +111 -0
  42. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-progress/giftback-progress.js.map +1 -0
  43. package/dist/collection/components/crm-bonus-form/subcomponents/phone/phone.input.js +75 -0
  44. package/dist/collection/components/crm-bonus-form/subcomponents/phone/phone.input.js.map +1 -0
  45. package/dist/collection/components/loading-spinner/loading-spinner.css +17 -0
  46. package/dist/collection/components/loading-spinner/loading-spinner.js +63 -0
  47. package/dist/collection/components/loading-spinner/loading-spinner.js.map +1 -0
  48. package/dist/collection/components/modal/app-modal.css +45 -0
  49. package/dist/collection/components/modal/app-modal.js +83 -0
  50. package/dist/collection/components/modal/app-modal.js.map +1 -0
  51. package/dist/collection/components/pedido/pedido.js +58 -0
  52. package/dist/collection/components/pedido/pedido.js.map +1 -0
  53. package/dist/collection/components/phone/phone-input-mask.css +47 -0
  54. package/dist/collection/components/phone/phone-input-mask.js +90 -0
  55. package/dist/collection/components/phone/phone-input-mask.js.map +1 -0
  56. package/dist/collection/contants/index.js +8 -0
  57. package/dist/collection/contants/index.js.map +1 -0
  58. package/dist/collection/contants/mocks.js +28 -0
  59. package/dist/collection/contants/mocks.js.map +1 -0
  60. package/dist/collection/dto/pin.sent.js +2 -0
  61. package/dist/collection/dto/pin.sent.js.map +1 -0
  62. package/dist/collection/dto/validate.pin.bonus.js +2 -0
  63. package/dist/collection/dto/validate.pin.bonus.js.map +1 -0
  64. package/dist/collection/index.js +11 -0
  65. package/dist/collection/index.js.map +1 -0
  66. package/dist/collection/services/crmbonus.service.js +39 -0
  67. package/dist/collection/services/crmbonus.service.js.map +1 -0
  68. package/dist/collection/utils/utils.js +4 -0
  69. package/dist/collection/utils/utils.js.map +1 -0
  70. package/dist/components/app-modal.js +8 -0
  71. package/dist/components/app-modal.js.map +1 -0
  72. package/dist/components/crm-bonus-form.js +8 -0
  73. package/dist/components/crm-bonus-form.js.map +1 -0
  74. package/dist/components/crm-bonus.js +117 -0
  75. package/dist/components/crm-bonus.js.map +1 -0
  76. package/dist/components/giftback-finish.d.ts +11 -0
  77. package/dist/components/giftback-finish.js +8 -0
  78. package/dist/components/giftback-finish.js.map +1 -0
  79. package/dist/components/giftback-pin.js +8 -0
  80. package/dist/components/giftback-pin.js.map +1 -0
  81. package/dist/components/giftback-progress.js +8 -0
  82. package/dist/components/giftback-progress.js.map +1 -0
  83. package/dist/components/index.js +9 -0
  84. package/dist/components/index.js.map +1 -0
  85. package/dist/components/loading-spinner.js +8 -0
  86. package/dist/components/loading-spinner.js.map +1 -0
  87. package/dist/components/p-17ee9996.js +52 -0
  88. package/dist/components/p-17ee9996.js.map +1 -0
  89. package/dist/{crmbonus-component-wake/phone-input-mask.entry.js → components/p-2dbfb2c7.js} +34 -9
  90. package/dist/components/p-2dbfb2c7.js.map +1 -0
  91. package/dist/components/p-563ea4c5.js +166 -0
  92. package/dist/components/p-563ea4c5.js.map +1 -0
  93. package/dist/{crmbonus-component-wake/crmbonus.service-134e7b0c.js → components/p-629fcb5b.js} +99 -169
  94. package/dist/components/p-629fcb5b.js.map +1 -0
  95. package/dist/components/p-7294e43f.js +36 -0
  96. package/dist/components/p-7294e43f.js.map +1 -0
  97. package/dist/components/p-78529eea.js +39 -0
  98. package/dist/components/p-78529eea.js.map +1 -0
  99. package/dist/components/p-8e0ed8dd.js +43 -0
  100. package/dist/components/p-8e0ed8dd.js.map +1 -0
  101. package/dist/{crmbonus-component-wake/giftback-pin.entry.js → components/p-a1781d03.js} +38 -9
  102. package/dist/components/p-a1781d03.js.map +1 -0
  103. package/dist/components/p-a88bc337.js +67 -0
  104. package/dist/components/p-a88bc337.js.map +1 -0
  105. package/dist/components/p-faf7103e.js +1064 -0
  106. package/dist/components/p-faf7103e.js.map +1 -0
  107. package/dist/components/pedido-finalizado.js +45 -0
  108. package/dist/components/pedido-finalizado.js.map +1 -0
  109. package/dist/components/phone-input-mask.js +8 -0
  110. package/dist/components/phone-input-mask.js.map +1 -0
  111. package/dist/components/phone-input.js +8 -0
  112. package/dist/components/phone-input.js.map +1 -0
  113. package/dist/crmbonus-component-wake/assets/success-svgrepo-com.svg +8 -0
  114. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -48
  115. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js.map +1 -1
  116. package/dist/crmbonus-component-wake/index.esm.js +1 -16
  117. package/dist/crmbonus-component-wake/index.esm.js.map +1 -1
  118. package/dist/crmbonus-component-wake/p-54e51298.entry.js +2 -0
  119. package/dist/crmbonus-component-wake/p-54e51298.entry.js.map +1 -0
  120. package/dist/crmbonus-component-wake/p-629fcb5b.js +2 -0
  121. package/dist/crmbonus-component-wake/p-629fcb5b.js.map +1 -0
  122. package/dist/crmbonus-component-wake/p-6b075110.entry.js +2 -0
  123. package/dist/crmbonus-component-wake/p-6b075110.entry.js.map +1 -0
  124. package/dist/crmbonus-component-wake/p-72510682.js +3 -0
  125. package/dist/crmbonus-component-wake/p-72510682.js.map +1 -0
  126. package/dist/crmbonus-component-wake/p-82f64f70.entry.js +2 -0
  127. package/dist/crmbonus-component-wake/p-82f64f70.entry.js.map +1 -0
  128. package/dist/crmbonus-component-wake/p-bf4b486e.entry.js +2 -0
  129. package/dist/crmbonus-component-wake/p-bf4b486e.entry.js.map +1 -0
  130. package/dist/crmbonus-component-wake/p-e1255160.js +2 -0
  131. package/dist/crmbonus-component-wake/p-e1255160.js.map +1 -0
  132. package/dist/crmbonus-component-wake/p-f0d68c31.entry.js +2 -0
  133. package/dist/crmbonus-component-wake/p-f0d68c31.entry.js.map +1 -0
  134. package/dist/env.js +5 -0
  135. package/dist/env.js.map +1 -0
  136. package/dist/esm/app-modal_2.entry.js +122 -0
  137. package/dist/esm/app-modal_2.entry.js.map +1 -0
  138. package/dist/{crmbonus-component-wake → esm}/crm-bonus.entry.js +17 -8
  139. package/dist/esm/crm-bonus.entry.js.map +1 -0
  140. package/dist/esm/crmbonus-component-wake.js +22 -0
  141. package/dist/esm/crmbonus-component-wake.js.map +1 -0
  142. package/dist/esm/crmbonus.service-83f67708.js +3793 -0
  143. package/dist/esm/crmbonus.service-83f67708.js.map +1 -0
  144. package/dist/esm/giftback-finish_5.entry.js +145 -0
  145. package/dist/esm/giftback-finish_5.entry.js.map +1 -0
  146. package/dist/esm/index-9f7bde48.js +1220 -0
  147. package/dist/esm/index-9f7bde48.js.map +1 -0
  148. package/dist/esm/index.js +7 -0
  149. package/dist/esm/index.js.map +1 -0
  150. package/dist/esm/loader.js +13 -0
  151. package/dist/esm/loader.js.map +1 -0
  152. package/dist/{crmbonus-component-wake → esm}/loading-spinner.entry.js +4 -3
  153. package/dist/esm/loading-spinner.entry.js.map +1 -0
  154. package/dist/esm/pedido-finalizado.entry.js +24 -0
  155. package/dist/esm/pedido-finalizado.entry.js.map +1 -0
  156. package/dist/index.cjs.js +1 -0
  157. package/dist/index.js +1 -0
  158. package/dist/types/components/crm-bonus/crm-bonus.d.ts +7 -4
  159. package/dist/types/components/crm-bonus-form/crm-bonus-form.d.ts +2 -1
  160. package/dist/types/components/crm-bonus-form/subcomponents/giftback-finish/giftback-finish.d.ts +3 -0
  161. package/dist/types/components/crm-bonus-form/subcomponents/phone/phone.input.d.ts +1 -0
  162. package/dist/types/components/pedido/pedido.d.ts +2 -0
  163. package/dist/types/components/phone/phone-input-mask.d.ts +2 -0
  164. package/dist/types/components.d.ts +27 -4
  165. package/dist/types/contants/index.d.ts +2 -1
  166. package/dist/types/dto/validate.pin.bonus.d.ts +10 -2
  167. package/dist/types/home/darlison/Projects/crmbonus/{crmbonus-component-wake → app/crmbonus-component}/.stencil/env.d.ts +1 -1
  168. package/dist/types/services/crmbonus.service.d.ts +2 -1
  169. package/loader/cdn.js +1 -0
  170. package/loader/index.cjs.js +1 -0
  171. package/loader/index.d.ts +24 -0
  172. package/loader/index.es2017.js +1 -0
  173. package/loader/index.js +2 -0
  174. package/loader/package.json +11 -0
  175. package/package.json +1 -1
  176. package/dist/crmbonus-component-wake/app-modal.entry.js +0 -23
  177. package/dist/crmbonus-component-wake/app-modal.entry.js.map +0 -1
  178. package/dist/crmbonus-component-wake/crm-bonus-form.entry.js +0 -94
  179. package/dist/crmbonus-component-wake/crm-bonus-form.entry.js.map +0 -1
  180. package/dist/crmbonus-component-wake/crm-bonus.entry.js.map +0 -1
  181. package/dist/crmbonus-component-wake/crmbonus.service-134e7b0c.js.map +0 -1
  182. package/dist/crmbonus-component-wake/giftback-pin.entry.js.map +0 -1
  183. package/dist/crmbonus-component-wake/giftback-progress.entry.js +0 -39
  184. package/dist/crmbonus-component-wake/giftback-progress.entry.js.map +0 -1
  185. package/dist/crmbonus-component-wake/index-b9a7a992.js +0 -3039
  186. package/dist/crmbonus-component-wake/index-b9a7a992.js.map +0 -1
  187. package/dist/crmbonus-component-wake/loading-spinner.entry.js.map +0 -1
  188. package/dist/crmbonus-component-wake/pedido-finalizado.entry.js +0 -18
  189. package/dist/crmbonus-component-wake/pedido-finalizado.entry.js.map +0 -1
  190. package/dist/crmbonus-component-wake/phone-input-mask.entry.js.map +0 -1
  191. package/dist/crmbonus-component-wake/phone-input.entry.js +0 -20
  192. package/dist/crmbonus-component-wake/phone-input.entry.js.map +0 -1
  193. package/dist/crmbonus-component-wake/shadow-css-7ad5caf8.js +0 -334
  194. package/dist/crmbonus-component-wake/shadow-css-7ad5caf8.js.map +0 -1
  195. /package/dist/{crmbonus-component-wake → esm}/app-globals-0f993ce5.js +0 -0
  196. /package/dist/{crmbonus-component-wake → esm}/app-globals-0f993ce5.js.map +0 -0
@@ -0,0 +1,166 @@
1
+ import { p as proxyCustomElement, H, h, d as Host } from './p-faf7103e.js';
2
+ import { C as CrmBonusService } from './p-629fcb5b.js';
3
+ import { d as defineCustomElement$6 } from './p-7294e43f.js';
4
+ import { d as defineCustomElement$5 } from './p-a1781d03.js';
5
+ import { d as defineCustomElement$4 } from './p-a88bc337.js';
6
+ import { d as defineCustomElement$3 } from './p-78529eea.js';
7
+ import { d as defineCustomElement$2 } from './p-17ee9996.js';
8
+ import { d as defineCustomElement$1 } from './p-2dbfb2c7.js';
9
+
10
+ var StepFormEnum;
11
+ (function (StepFormEnum) {
12
+ StepFormEnum[StepFormEnum["STEP_PHONE"] = 1] = "STEP_PHONE";
13
+ StepFormEnum[StepFormEnum["STEP_PIN"] = 2] = "STEP_PIN";
14
+ StepFormEnum[StepFormEnum["STEP_RESERVE"] = 3] = "STEP_RESERVE";
15
+ StepFormEnum[StepFormEnum["STEP_APPLY"] = 4] = "STEP_APPLY";
16
+ })(StepFormEnum || (StepFormEnum = {}));
17
+
18
+ const crmBonusFormCss = ".form-container{width:100%;display:flex;justify-content:center;justify-content:space-around}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;border-radius:10px;padding:15px;min-height:30px;min-width:120px;font-size:20px;cursor:pointer}.disabled{opacity:0.6;cursor:not-allowed}.message-error{color:#d11111;font-weight:bold;font-family:Arial;font-size:small;margin-left:16px}";
19
+ const CrmBonusFormStyle0 = crmBonusFormCss;
20
+
21
+ const CrmBonusForm = /*@__PURE__*/ proxyCustomElement(class CrmBonusForm extends H {
22
+ constructor() {
23
+ super();
24
+ this.__registerHost();
25
+ this.__attachShadow();
26
+ this.crmBonusService = new CrmBonusService();
27
+ this.storeName = undefined;
28
+ this.cartId = undefined;
29
+ this.products = undefined;
30
+ this.customer = {
31
+ phone: "",
32
+ birthDate: "",
33
+ document: "",
34
+ name: ""
35
+ };
36
+ this.loading = false;
37
+ this.step = StepFormEnum.STEP_PHONE;
38
+ this.sent = undefined;
39
+ this.message = undefined;
40
+ this.phone = undefined;
41
+ this.bonus = undefined;
42
+ }
43
+ async sendPin(phone) {
44
+ var _a, _b;
45
+ this.loading = true;
46
+ this.message = "";
47
+ try {
48
+ const _phone = phone.replace(/\D/g, '');
49
+ this.phone = Number(_phone);
50
+ const sent = await this.crmBonusService.sendPin(this.phone, this.storeName);
51
+ this.sent = sent;
52
+ this.step = StepFormEnum.STEP_PIN;
53
+ }
54
+ catch (error) {
55
+ 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;
56
+ }
57
+ finally {
58
+ this.loading = false;
59
+ }
60
+ }
61
+ async validateBonus(pin) {
62
+ var _a, _b;
63
+ this.loading = true;
64
+ const payload = {
65
+ pin: pin,
66
+ cellphone: this.phone.toString(),
67
+ loja_id: this.sent.storeId,
68
+ user_id: this.sent.userId,
69
+ cartId: this.cartId,
70
+ products: this.products
71
+ };
72
+ try {
73
+ this.bonus = await this.crmBonusService.validatePinBonus(payload, this.storeName);
74
+ console.log('[this.bonus]', this.bonus);
75
+ this.step = StepFormEnum.STEP_RESERVE;
76
+ }
77
+ catch (error) {
78
+ 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;
79
+ }
80
+ finally {
81
+ this.loading = false;
82
+ }
83
+ console.log('payload', payload);
84
+ }
85
+ async reserve(amount) {
86
+ this.loading = true;
87
+ this.message = "";
88
+ try {
89
+ await this.crmBonusService.reserve({
90
+ redeemed_bonus: amount,
91
+ cart_id: this.cartId,
92
+ ticket: this.cartId,
93
+ gross_value: this.bonus.totalValue,
94
+ }, this.storeName);
95
+ }
96
+ catch (error) {
97
+ this.message = "ocorreu um error ao solicitar a aplicação do bonus! tente novamente";
98
+ }
99
+ finally {
100
+ this.loading = false;
101
+ }
102
+ }
103
+ render() {
104
+ return (h(Host, { key: '5a1b20b7243430f94b179ade85728592c077fa2e' }, this.step === StepFormEnum.STEP_PHONE && h("phone-input", { key: '9d0a8683efee3c35307c96899320696c30b3f411', value: this.customer.phone, sendPin: (phone) => this.sendPin(phone), loading: this.loading }), this.step === StepFormEnum.STEP_PIN && h("giftback-pin", { key: '6a4212e62ddd6c550eb43e414fa1b87365b0724e', sent: this.sent, validate: (data) => this.validateBonus(data), loading: this.loading }), this.step === StepFormEnum.STEP_RESERVE && h("giftback-progress", { key: '94bd68421255cc6a0c269466b9e8c664f8c771be', bonus: this.bonus, reserve: (amountRedeemed) => this.reserve(amountRedeemed) }), this.step === StepFormEnum.STEP_APPLY && h("giftback-finish", { key: 'd354369a81be61afd3c9b4133b07e624de5534c1' }), h("p", { key: 'bb80d97f27a67fdcea667fcaad6f5a300e3e8491', class: "message-error" }, this.message)));
105
+ }
106
+ static get style() { return CrmBonusFormStyle0; }
107
+ }, [1, "crm-bonus-form", {
108
+ "storeName": [8, "storename"],
109
+ "cartId": [8, "cart-id"],
110
+ "products": [16],
111
+ "customer": [16],
112
+ "loading": [32],
113
+ "step": [32],
114
+ "sent": [32],
115
+ "message": [32],
116
+ "phone": [32],
117
+ "bonus": [32]
118
+ }]);
119
+ function defineCustomElement() {
120
+ if (typeof customElements === "undefined") {
121
+ return;
122
+ }
123
+ const components = ["crm-bonus-form", "giftback-finish", "giftback-pin", "giftback-progress", "loading-spinner", "phone-input", "phone-input-mask"];
124
+ components.forEach(tagName => { switch (tagName) {
125
+ case "crm-bonus-form":
126
+ if (!customElements.get(tagName)) {
127
+ customElements.define(tagName, CrmBonusForm);
128
+ }
129
+ break;
130
+ case "giftback-finish":
131
+ if (!customElements.get(tagName)) {
132
+ defineCustomElement$6();
133
+ }
134
+ break;
135
+ case "giftback-pin":
136
+ if (!customElements.get(tagName)) {
137
+ defineCustomElement$5();
138
+ }
139
+ break;
140
+ case "giftback-progress":
141
+ if (!customElements.get(tagName)) {
142
+ defineCustomElement$4();
143
+ }
144
+ break;
145
+ case "loading-spinner":
146
+ if (!customElements.get(tagName)) {
147
+ defineCustomElement$3();
148
+ }
149
+ break;
150
+ case "phone-input":
151
+ if (!customElements.get(tagName)) {
152
+ defineCustomElement$2();
153
+ }
154
+ break;
155
+ case "phone-input-mask":
156
+ if (!customElements.get(tagName)) {
157
+ defineCustomElement$1();
158
+ }
159
+ break;
160
+ } });
161
+ }
162
+ defineCustomElement();
163
+
164
+ export { CrmBonusForm as C, defineCustomElement as d };
165
+
166
+ //# sourceMappingURL=p-563ea4c5.js.map
@@ -0,0 +1 @@
1
+ {"file":"p-563ea4c5.js","mappings":";;;;;;;;;AAAA,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,2DAAc,CAAA;IACd,uDAAY,CAAA;IACZ,+DAAgB,CAAA;IAChB,2DAAc,CAAA;AAClB,CAAC,EALW,YAAY,KAAZ,YAAY;;ACAxB,MAAM,eAAe,GAAG,sYAAsY,CAAC;AAC/Z,2BAAe,eAAe;;MCUjB,YAAY;;;;;QAEb,oBAAe,GAAoB,IAAI,eAAe,EAAE,CAAC;;;;wBAKnC;YAC1B,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;SACX;uBAE2B,KAAK;oBAET,YAAY,CAAC,UAAU;;;;;;IAUxC,MAAM,OAAO,CAAC,KAAa;;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAElB,IAAI;YACA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CAAC,YAAY,IAAI,0EAAmB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,cAAsB,KAAK,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,GAAI,EACtJ,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,UAAU,IAAI,yEAAmB,EAC7D,0DAAG,KAAK,EAAC,eAAe,IAAE,IAAI,CAAC,OAAO,CAAK,CACxC,EACV;KACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/contants/index.ts","src/components/crm-bonus-form/crm-bonus-form.css?tag=crm-bonus-form&encapsulation=shadow","src/components/crm-bonus-form/crm-bonus-form.tsx"],"sourcesContent":["export enum StepFormEnum {\n STEP_PHONE = 1,\n STEP_PIN = 2,\n STEP_RESERVE = 3,\n STEP_APPLY = 4\n}",".form-container {\n width: 100%;\n display: flex;\n justify-content: center;\n justify-content: space-around;\n}\n\n.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}\n\n.disabled {\n opacity: 0.6;\n cursor: not-allowed;\n}\n\n.message-error {\n color: #d11111;\n font-weight: bold;\n font-family: Arial;\n font-size: small;\n margin-left: 16px;\n}","import { Component, Host, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { IPinSent } from \"../../components\";\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { StepFormEnum } from \"../../contants\";\n\n@Component({\n tag: 'crm-bonus-form',\n styleUrl: 'crm-bonus-form.css',\n shadow: true\n})\nexport class CrmBonusForm {\n\n private crmBonusService: CrmBonusService = new CrmBonusService();\n\n @Prop({ attribute: 'storename' }) storeName;\n @Prop() cartId;\n @Prop() products: Array<IProduct>;\n @Prop() customer: ICustomer = {\n phone: \"\",\n birthDate: \"\",\n document: \"\",\n name: \"\"\n };\n\n @State() loading: boolean = false;\n\n @State() step: number = StepFormEnum.STEP_PHONE;\n\n @State() sent: IPinSent;\n\n @State() message: string;\n\n @State() phone: number;\n\n @State() bonus: IBonus;\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n const sent = await this.crmBonusService.sendPin(this.phone, this.storeName);\n this.sent = sent;\n this.step = StepFormEnum.STEP_PIN;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async validateBonus(pin: string) {\n this.loading = true;\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n loja_id: this.sent.storeId,\n user_id: this.sent.userId,\n cartId: this.cartId,\n products: this.products\n }\n\n try {\n this.bonus = await this.crmBonusService.validatePinBonus(payload, this.storeName);\n\n console.log('[this.bonus]', this.bonus);\n this.step = StepFormEnum.STEP_RESERVE;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false;\n }\n console.log('payload', payload)\n }\n\n public async reserve(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.crmBonusService.reserve({\n redeemed_bonus: amount,\n cart_id: this.cartId,\n ticket: this.cartId,\n gross_value: this.bonus.totalValue,\n }, this.storeName);\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n } finally {\n this.loading = false;\n }\n }\n\n render() {\n return (\n <Host>\n {this.step === StepFormEnum.STEP_PHONE && <phone-input value={this.customer.phone} sendPin={(phone) => this.sendPin(phone)} loading={this.loading} />}\n {this.step === StepFormEnum.STEP_PIN && <giftback-pin sent={this.sent} validate={(data) => this.validateBonus(data)} loading={this.loading} />}\n\n {this.step === StepFormEnum.STEP_RESERVE && <giftback-progress bonus={this.bonus} reserve={(amountRedeemed: number) => this.reserve(amountRedeemed)} />}\n {this.step === StepFormEnum.STEP_APPLY && <giftback-finish />}\n <p class=\"message-error\">{this.message}</p>\n </Host>\n )\n }\n}"],"version":3}