crmbonus-component-wake 2.1.31-ngrok → 2.1.33-ngrok
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.
- package/dist/cjs/{build.payload.helper-b93f7ea5.js → build.payload.helper-cfd3173e.js} +4 -1
- package/dist/cjs/build.payload.helper-cfd3173e.js.map +1 -0
- package/dist/cjs/crm-bonus-2.cjs.entry.js +6 -257
- package/dist/cjs/crm-bonus-2.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-bonus-note.cjs.entry.js +1 -1
- package/dist/cjs/crm-bonus.cjs.entry.js +257 -6
- package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -1
- package/dist/cjs/crmbonus-component-wake.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/crm-bonus/crm-bonus.js +1 -1
- package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
- package/dist/collection/components/crm-bonus/crmbonus.js +2 -2
- package/dist/collection/components/crm-bonus/crmbonus.js.map +1 -1
- package/dist/collection/dto/validate.pin.bonus.js.map +1 -1
- package/dist/collection/helpers/build.payload.helper.js +3 -0
- package/dist/collection/helpers/build.payload.helper.js.map +1 -1
- package/dist/components/crm-bonus-2.js +10 -332
- package/dist/components/crm-bonus-2.js.map +1 -1
- package/dist/components/crm-bonus-note.js +2 -2
- package/dist/components/crm-bonus.js +332 -10
- package/dist/components/crm-bonus.js.map +1 -1
- package/dist/components/crm-giftback-form.js +1 -1
- package/dist/components/giftback-info.js +1 -1
- package/dist/components/{p-fedabc25.js → p-028f43a1.js} +2 -2
- package/dist/components/{p-fedabc25.js.map → p-028f43a1.js.map} +1 -1
- package/dist/components/{p-78fbe33d.js → p-0bb6b0e5.js} +3 -3
- package/dist/components/{p-78fbe33d.js.map → p-0bb6b0e5.js.map} +1 -1
- package/dist/components/{p-4c7e066c.js → p-b0ef2c0b.js} +4 -1
- package/dist/components/p-b0ef2c0b.js.map +1 -0
- package/dist/components/{p-0a5e4aca.js → p-c90ea2e9.js} +57 -57
- package/dist/components/p-c90ea2e9.js.map +1 -0
- package/dist/components/pedido-finalizado.js +1 -1
- package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
- package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js.map +1 -1
- package/dist/crmbonus-component-wake/{p-3e87e176.entry.js → p-22dc17d2.entry.js} +2 -2
- package/dist/crmbonus-component-wake/{p-b928333a.entry.js → p-4ed412c2.entry.js} +2 -2
- package/dist/crmbonus-component-wake/p-4ed412c2.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/{p-c54d706c.entry.js → p-7d608b81.entry.js} +2 -2
- package/dist/crmbonus-component-wake/p-7d608b81.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-b0ef2c0b.js +2 -0
- package/dist/crmbonus-component-wake/p-b0ef2c0b.js.map +1 -0
- package/dist/esm/{build.payload.helper-caf0a82b.js → build.payload.helper-699a48ca.js} +4 -1
- package/dist/esm/build.payload.helper-699a48ca.js.map +1 -0
- package/dist/esm/crm-bonus-2.entry.js +7 -258
- package/dist/esm/crm-bonus-2.entry.js.map +1 -1
- package/dist/esm/crm-bonus-note.entry.js +1 -1
- package/dist/esm/crm-bonus.entry.js +258 -7
- package/dist/esm/crm-bonus.entry.js.map +1 -1
- package/dist/esm/crmbonus-component-wake.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components.d.ts +4 -4
- package/dist/types/dto/validate.pin.bonus.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/build.payload.helper-b93f7ea5.js.map +0 -1
- package/dist/components/p-0a5e4aca.js.map +0 -1
- package/dist/components/p-4c7e066c.js.map +0 -1
- package/dist/crmbonus-component-wake/p-4c7e066c.js +0 -2
- package/dist/crmbonus-component-wake/p-4c7e066c.js.map +0 -1
- package/dist/crmbonus-component-wake/p-b928333a.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-c54d706c.entry.js.map +0 -1
- package/dist/esm/build.payload.helper-caf0a82b.js.map +0 -1
- /package/dist/crmbonus-component-wake/{p-3e87e176.entry.js.map → p-22dc17d2.entry.js.map} +0 -0
@@ -4,6 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
5
5
|
const index = require('./index-a7537457.js');
|
6
6
|
const cart_helper = require('./cart.helper-b08a12b2.js');
|
7
|
+
const i18n = require('./i18n-1ce6cb94.js');
|
8
|
+
const build_payload_helper = require('./build.payload.helper-cfd3173e.js');
|
7
9
|
|
8
10
|
const crmBonusCss = ".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;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 .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";
|
9
11
|
const CrmBonusStyle0 = crmBonusCss;
|
@@ -11,18 +13,267 @@ const CrmBonusStyle0 = crmBonusCss;
|
|
11
13
|
const CrmBonus = class {
|
12
14
|
constructor(hostRef) {
|
13
15
|
index.registerInstance(this, hostRef);
|
14
|
-
this.
|
16
|
+
this.crmBonusService = cart_helper.CrmBonusService.getInstance();
|
17
|
+
this.cart = undefined;
|
18
|
+
this.canhidden = false;
|
19
|
+
this.showModal = false;
|
15
20
|
this.cartWake = undefined;
|
21
|
+
this.customer = {
|
22
|
+
birthDate: "",
|
23
|
+
document: "",
|
24
|
+
name: "",
|
25
|
+
phone: ""
|
26
|
+
};
|
27
|
+
this.loading = false;
|
28
|
+
this.message = undefined;
|
29
|
+
this.phone = undefined;
|
30
|
+
this.canCancel = false;
|
31
|
+
this.amountCancel = undefined;
|
32
|
+
this.sent = undefined;
|
33
|
+
this.session = undefined;
|
34
|
+
this.loading_reprocess = false;
|
35
|
+
this.styles = i18n.defaultStyles;
|
36
|
+
this.reservedInfo = undefined;
|
37
|
+
}
|
38
|
+
async resetBonus() {
|
39
|
+
console.log('[START RESET BONUS]!!!!!');
|
40
|
+
try {
|
41
|
+
await this.crmBonusRef.processBonus(this.buildProducts(), true);
|
42
|
+
console.log('[BONUS RESETADO]!!!!!');
|
43
|
+
}
|
44
|
+
catch (err) {
|
45
|
+
this.loading = false;
|
46
|
+
console.log('[error ao reprocessar bonous]');
|
47
|
+
await this.crmBonusRef.setStep(i18n.StepFormEnum.STEP_PHONE);
|
48
|
+
}
|
49
|
+
finally {
|
50
|
+
this.loading = false;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
async setloading() {
|
54
|
+
this.loading_reprocess = !this.loading_reprocess;
|
55
|
+
}
|
56
|
+
async reprocess() {
|
57
|
+
console.log("[CRMBONUS] - reprocess");
|
58
|
+
this.loading_reprocess = true;
|
59
|
+
try {
|
60
|
+
const isUse = localStorage.getItem(cart_helper.USED_KEY);
|
61
|
+
if (!isUse)
|
62
|
+
return;
|
63
|
+
this.cartWake = await cart_helper.getCart();
|
64
|
+
await this.resetBonus();
|
65
|
+
}
|
66
|
+
catch (err) {
|
67
|
+
console.debug('[watchProducts]', err.message);
|
68
|
+
}
|
69
|
+
finally {
|
70
|
+
this.loading_reprocess = false;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
async componentWillLoad() {
|
74
|
+
window.addEventListener('productRemovedFromCart', async () => {
|
75
|
+
console.log('[CRMBONUS] - productRemovedFromCart');
|
76
|
+
await this.reprocess();
|
77
|
+
});
|
78
|
+
window.addEventListener('productAddedToCart', async () => {
|
79
|
+
console.log('[CRMBONUS] - productAddedToCart');
|
80
|
+
await this.reprocess();
|
81
|
+
});
|
82
|
+
document.querySelectorAll('form').forEach((el) => {
|
83
|
+
el.addEventListener("submit", () => {
|
84
|
+
console.log("[CRMBONUS] - Formulário está sendo submetido!");
|
85
|
+
// você pode marcar como "em submissão" aqui
|
86
|
+
setTimeout(async () => {
|
87
|
+
await this.reprocess();
|
88
|
+
});
|
89
|
+
});
|
90
|
+
});
|
91
|
+
await this.observerHandle();
|
92
|
+
i18n.instance.changeLanguage(i18n.instance.language);
|
93
|
+
await this.loadSession();
|
94
|
+
this.handleLoad();
|
95
|
+
await this.loadConfigStore();
|
16
96
|
}
|
17
97
|
async componentDidLoad() {
|
18
|
-
|
98
|
+
console.log('[did load]');
|
99
|
+
}
|
100
|
+
async observerHandle() {
|
101
|
+
const elements = document.getElementsByTagName('a');
|
102
|
+
//@ts-ignore
|
103
|
+
for (let el of elements) {
|
104
|
+
console.log('[el.href]', el.href);
|
105
|
+
if (el.href.includes('Produto/Delete')) {
|
106
|
+
el.addEventListener('click', async () => {
|
107
|
+
console.log('[CRMBONUS] - Produto removido do carrinho');
|
108
|
+
setTimeout(async () => {
|
109
|
+
await this.reprocess();
|
110
|
+
this.observerHandle();
|
111
|
+
}, 2000);
|
112
|
+
});
|
113
|
+
}
|
114
|
+
if (el.href.includes('Produto/Add')) {
|
115
|
+
el.addEventListener('click', async () => {
|
116
|
+
console.log('[CRMBONUS] - Produto adicionado ao carrinho');
|
117
|
+
setTimeout(async () => {
|
118
|
+
await this.reprocess();
|
119
|
+
this.observerHandle();
|
120
|
+
}, 2000);
|
121
|
+
});
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
async loadConfigStore() {
|
126
|
+
const [customization, infoBonus] = await Promise.all([
|
127
|
+
this.crmBonusService.getCustomization(this.cartWake.store.name),
|
128
|
+
cart_helper.getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name)
|
129
|
+
]);
|
130
|
+
console.log('[infoBonus]', infoBonus);
|
131
|
+
this.reservedInfo = infoBonus;
|
132
|
+
if (customization.keepStoreFrontStyle) {
|
133
|
+
console.log('[bc:usar estilo da loja]');
|
134
|
+
this.styles = null;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
async fetchCustomer(userId, storeName) {
|
138
|
+
try {
|
139
|
+
return await this.crmBonusService.getCustomer(userId, storeName);
|
140
|
+
}
|
141
|
+
catch (error) {
|
142
|
+
console.error('[fetchCustomer] Error fetching customer:', error);
|
143
|
+
return null;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
async handleLoad() {
|
147
|
+
try {
|
148
|
+
if (this.cartWake.user.id) {
|
149
|
+
this.fetchCustomer(this.cartWake.user.id, this.cartWake.store.name).then((customer) => {
|
150
|
+
console.log('[bc:loading customer]');
|
151
|
+
if (customer) {
|
152
|
+
this.customer = customer;
|
153
|
+
console.log('customer', this.customer);
|
154
|
+
}
|
155
|
+
});
|
156
|
+
}
|
157
|
+
const amount = localStorage.getItem(this.cartWake.id);
|
158
|
+
if (amount) {
|
159
|
+
this.canCancel = true;
|
160
|
+
this.amountCancel = amount;
|
161
|
+
}
|
162
|
+
await this.buildAndGetProducts(this.cartWake.products);
|
163
|
+
}
|
164
|
+
catch (error) {
|
165
|
+
console.log('info customer');
|
166
|
+
}
|
167
|
+
}
|
168
|
+
async loadSession() {
|
169
|
+
this.cartWake = this.cart ? new cart_helper.CartWake(JSON.parse(this.cart)) : await cart_helper.getCart();
|
170
|
+
console.log('[bc:carregou carrinho]');
|
171
|
+
this.session = await this.crmBonusService.getToken(this.cartWake.store.name);
|
172
|
+
console.log('[bc:carregou session]');
|
173
|
+
setTimeout(() => {
|
174
|
+
this.loadSession();
|
175
|
+
}, 1500000);
|
176
|
+
}
|
177
|
+
async buildAndGetProducts(productsWake) {
|
178
|
+
console.log();
|
179
|
+
const key = `bc-products:${this.cartWake.id}`;
|
180
|
+
const productsString = JSON.stringify(productsWake);
|
181
|
+
localStorage.setItem(key, productsString);
|
182
|
+
const products_in_cache = JSON.parse(localStorage.getItem(key));
|
183
|
+
const products = [];
|
184
|
+
for (const product_cart of productsWake) {
|
185
|
+
const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId);
|
186
|
+
//const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === "Formula")
|
187
|
+
if (pro) {
|
188
|
+
products.push(Object.assign(Object.assign({}, product_cart), { PrecoPor: pro.PrecoPor, PrecoDe: pro.PrecoDe, Quantidade: pro.Quantidade, Ajustes: pro.Ajustes }));
|
189
|
+
}
|
190
|
+
else {
|
191
|
+
products.push(product_cart);
|
192
|
+
}
|
193
|
+
}
|
194
|
+
this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);
|
195
|
+
}
|
196
|
+
async sendPin(phone) {
|
197
|
+
var _a, _b;
|
198
|
+
this.loading = true;
|
199
|
+
this.message = "";
|
200
|
+
try {
|
201
|
+
const _phone = phone.replace(/\D/g, '');
|
202
|
+
this.phone = Number(_phone);
|
203
|
+
this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
|
204
|
+
await this.crmBonusRef.setStep(i18n.StepFormEnum.STEP_PIN);
|
205
|
+
this.showModal = true;
|
206
|
+
}
|
207
|
+
catch (error) {
|
208
|
+
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;
|
209
|
+
}
|
210
|
+
finally {
|
211
|
+
this.loading = false;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
async sendPinName(customerName) {
|
215
|
+
var _a, _b;
|
216
|
+
this.loading = true;
|
217
|
+
this.message = "";
|
218
|
+
try {
|
219
|
+
this.customer.name = customerName;
|
220
|
+
this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
|
221
|
+
await this.crmBonusRef.setStep(i18n.StepFormEnum.STEP_PIN);
|
222
|
+
this.showModal = true;
|
223
|
+
}
|
224
|
+
catch (error) {
|
225
|
+
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;
|
226
|
+
}
|
227
|
+
finally {
|
228
|
+
this.loading = false;
|
229
|
+
}
|
230
|
+
}
|
231
|
+
buildProducts() {
|
232
|
+
return build_payload_helper.buildProductsByWake(this.cartWake.products);
|
233
|
+
}
|
234
|
+
handleCloseModal() {
|
235
|
+
this.showModal = false;
|
236
|
+
}
|
237
|
+
save(amount) {
|
238
|
+
localStorage.setItem(this.cartWake.id, amount.toString());
|
239
|
+
this.canCancel = true;
|
240
|
+
this.amountCancel = amount.toString();
|
241
|
+
}
|
242
|
+
async cancel() {
|
243
|
+
this.message = "";
|
244
|
+
this.loading = true;
|
245
|
+
try {
|
246
|
+
await this.crmBonusService.cancel(this.cartWake.id);
|
247
|
+
this.canCancel = false;
|
248
|
+
localStorage.removeItem(this.cartWake.id);
|
249
|
+
}
|
250
|
+
catch (error) {
|
251
|
+
this.message = "Não consegui cancelar o bônus, tente novamente!";
|
252
|
+
}
|
253
|
+
finally {
|
254
|
+
this.loading = false;
|
255
|
+
}
|
19
256
|
}
|
20
|
-
async
|
21
|
-
this.
|
257
|
+
async handleSendPin(phone) {
|
258
|
+
this.message = "";
|
259
|
+
if (!phone) {
|
260
|
+
this.message = "Informe seu telefone";
|
261
|
+
return;
|
262
|
+
}
|
263
|
+
this.customer.phone = phone;
|
264
|
+
const _phone = phone.replace(/\D/g, '');
|
265
|
+
this.phone = Number(_phone);
|
266
|
+
if (this.customer.name) {
|
267
|
+
return this.sendPin(phone);
|
268
|
+
}
|
269
|
+
await this.crmBonusRef.setStep(i18n.StepFormEnum.STEP_NAME);
|
270
|
+
this.showModal = true;
|
22
271
|
}
|
23
272
|
render() {
|
24
|
-
|
25
|
-
|
273
|
+
if (this.canhidden) {
|
274
|
+
return null;
|
275
|
+
}
|
276
|
+
return (index.h("loading-container", { loading: this.loading_reprocess }, index.h("crm-giftback-form", { customStyles: this.styles, style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.cartWake.store.name, products: this.buildProducts(), cartId: this.cartWake.id, customer: this.customer, loadProducts: () => this.buildProducts(), loadAll: () => this.handleLoad(), reservedInfo: this.reservedInfo })));
|
26
277
|
}
|
27
278
|
static get assetsDirs() { return ["assets"]; }
|
28
279
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"crm-bonus.entry.cjs.js","mappings":";;;;;;;AAAA,MAAM,WAAW,GAAG,o8BAAo8B,CAAC;AACz9B,uBAAe,WAAW;;MCUb,QAAQ;;;uBAEE,KAAK;;;IAIxB,MAAM,gBAAgB;QAClB,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;KAC5B;IAED,MAAM,YAAY;QACd,IAAI,CAAC,QAAQ,GAAG,MAAMA,mBAAO,EAAE,CAAC;KACnC;IAED,MAAM;QAEF,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QAE3C,QACIC,oEACIA,gFAAmB,OAAO,EAAE,IAAI,CAAC,OAAO,IACpCA,mFAAsB,CACN,EAEhB,IAAI,CAAC,QAAQ,KACTA,oEACK,IAAI,CAAC,QAAQ,CAAC,EAAE,CACf,CACT,CAEH,EAET;KACJ;;;;;;;","names":["getCart","h"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=shadow","src/components/crm-bonus/crmbonus.tsx"],"sourcesContent":["\r\n.container-button {\r\n /* max-width: 100%; */\r\n cursor: pointer;\r\n padding: 5px 5px 5px 14px;\r\n /* display: flex; */\r\n}\r\n\r\n/* padding: 0 15px 15px;\r\nborder: 1px solid #ddd;\r\nmargin-bottom: 20px; */\r\n\r\n.section-crm {\r\n border: 1px solid #dbd4d4;\r\n /* min-height: 50px; */\r\n text-align: -webkit-center;\r\n margin-bottom: 20px;\r\n}\r\n\r\n.section-cart-crm {\r\n margin-top: 10px;\r\n}\r\n\r\n.section-cart-crm p {\r\n padding: 0;\r\n margin: 0px 0px 0px 15px;\r\n}\r\n\r\n.button {\r\n top: 50%;\r\n background-color: #6c6c7e;\r\n color: #fff;\r\n border: none;\r\n /* border-radius: 10px; */\r\n padding: 15px;\r\n min-height: 30px;\r\n min-width: 120px;\r\n /* font-size: 20px; */\r\n cursor: pointer;\r\n margin-left: 10px;\r\n height: 70px;\r\n}\r\n\r\n.form-container {\r\n width: 97%;\r\n display: flex;\r\n justify-content: space-around;\r\n}\r\n\r\n\r\n.btn {\r\n display: inline-block;\r\n padding: 6px 12px;\r\n margin-bottom: 0;\r\n /* font-size: 14px; */\r\n font-weight: 400;\r\n line-height: 1.42857143;\r\n text-align: center;\r\n white-space: nowrap;\r\n vertical-align: middle;\r\n -ms-touch-action: manipulation;\r\n touch-action: manipulation;\r\n cursor: pointer;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n background-image: none;\r\n border: 1px solid transparent;\r\n border-radius: 0px;\r\n}\r\n\r\n.form-container .btnCrm {\r\n background: #00162e;\r\n border-color: #00162e;\r\n width: 30%;\r\n color: #fff;\r\n}\r\n\r\n.message-alert {\r\n color: #df4d4d;\r\n margin-top: 5px;\r\n}","import { Component, h, State } from \"@stencil/core\";\r\nimport { CartWake } from \"../../objectvalues/cart.wake\";\r\nimport { getCart } from \"../../helpers/cart.helper\";\r\n\r\n@Component({\r\n tag: 'crm-bonus',\r\n styleUrl: 'crm-bonus.css',\r\n assetsDirs: ['assets'],\r\n // scoped: true\r\n shadow: true\r\n})\r\nexport class CrmBonus {\r\n\r\n @State() loading = false;\r\n\r\n @State() cartWake: CartWake;\r\n\r\n async componentDidLoad() {\r\n await this.loadCheckout()\r\n }\r\n\r\n async loadCheckout() {\r\n this.cartWake = await getCart();\r\n }\r\n\r\n render() {\r\n\r\n console.log('this.cartWake', this.cartWake)\r\n\r\n return (\r\n <div>\r\n <loading-container loading={this.loading}>\r\n <h3>CARREGANDO...</h3>\r\n </loading-container>\r\n {\r\n this.cartWake && (\r\n <div>\r\n {this.cartWake.id}\r\n </div>\r\n )\r\n }\r\n </div>\r\n\r\n )\r\n }\r\n}"],"version":3}
|
1
|
+
{"file":"crm-bonus.entry.cjs.js","mappings":";;;;;;;;;AAAA,MAAM,WAAW,GAAG,o8BAAo8B,CAAC;AACz9B,uBAAe,WAAW;;MCmBb,QAAQ;;;QAEX,oBAAe,GAAoBA,2BAAe,CAAC,WAAW,EAAE,CAAC;;yBAK5C,KAAK;yBAEJ,KAAK;;wBAIJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;iCAKN,KAAK;sBAChBC,kBAAa;;;IAI/B,MAAM,UAAU;QACd,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QAExC,IAAI;YACF,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,CAAC;YAChE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;SACtC;QAAC,OAAO,GAAG,EAAE;YAEZ,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAACC,iBAAY,CAAC,UAAU,CAAC,CAAC;SACzD;gBAAS;YACR,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;SACtB;KACF;IAGD,MAAM,UAAU;QACd,IAAI,CAAC,iBAAiB,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC;KAClD;IAGD,MAAM,SAAS;QACb,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;QACrC,IAAI,CAAC,iBA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AAC,KAAK,CAAC,IAAI,EACnC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,EACxC,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE,EAChC,YAAY,EAAE,IAAI,CAAC,YAAY,GAC/B,CACgB,EACrB;KACF;;;;;;;","names":["CrmBonusService","defaultStyles","StepFormEnum","USED_KEY","getCart","i18next","getInfoBonusByCartIdAndStoreName","CartWake","buildProductsByWake","h"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=shadow","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["\r\n.container-button {\r\n /* max-width: 100%; */\r\n cursor: pointer;\r\n padding: 5px 5px 5px 14px;\r\n /* display: flex; */\r\n}\r\n\r\n/* padding: 0 15px 15px;\r\nborder: 1px solid #ddd;\r\nmargin-bottom: 20px; */\r\n\r\n.section-crm {\r\n border: 1px solid #dbd4d4;\r\n /* min-height: 50px; */\r\n text-align: -webkit-center;\r\n margin-bottom: 20px;\r\n}\r\n\r\n.section-cart-crm {\r\n margin-top: 10px;\r\n}\r\n\r\n.section-cart-crm p {\r\n padding: 0;\r\n margin: 0px 0px 0px 15px;\r\n}\r\n\r\n.button {\r\n top: 50%;\r\n background-color: #6c6c7e;\r\n color: #fff;\r\n border: none;\r\n /* border-radius: 10px; */\r\n padding: 15px;\r\n min-height: 30px;\r\n min-width: 120px;\r\n /* font-size: 20px; */\r\n cursor: pointer;\r\n margin-left: 10px;\r\n height: 70px;\r\n}\r\n\r\n.form-container {\r\n width: 97%;\r\n display: flex;\r\n justify-content: space-around;\r\n}\r\n\r\n\r\n.btn {\r\n display: inline-block;\r\n padding: 6px 12px;\r\n margin-bottom: 0;\r\n /* font-size: 14px; */\r\n font-weight: 400;\r\n line-height: 1.42857143;\r\n text-align: center;\r\n white-space: nowrap;\r\n vertical-align: middle;\r\n -ms-touch-action: manipulation;\r\n touch-action: manipulation;\r\n cursor: pointer;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n background-image: none;\r\n border: 1px solid transparent;\r\n border-radius: 0px;\r\n}\r\n\r\n.form-container .btnCrm {\r\n background: #00162e;\r\n border-color: #00162e;\r\n width: 30%;\r\n color: #fff;\r\n}\r\n\r\n.message-alert {\r\n color: #df4d4d;\r\n margin-top: 5px;\r\n}","import { Component, Method, Prop, State, h } from '@stencil/core';\r\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\r\nimport { CrmBonusService } from '../../services/crmbonus.service';\r\nimport { IPinSent } from '../../components';\r\nimport { defaultStyles, StepFormEnum } from '../../contants';\r\n\r\nimport i18next from '../../i18n/i18n'\r\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\r\nimport { getCart, getInfoBonusByCartIdAndStoreName } from '../../helpers/cart.helper';\r\nimport { CartWake } from '../../objectvalues/cart.wake';\r\nimport { USED_KEY } from '../../utils/keys.storage';\r\nimport { ReservedInfoDTO } from '../../dto/reserved-info.dto';\r\n\r\n@Component({\r\n tag: 'crm-bonus',\r\n styleUrl: 'crm-bonus.css',\r\n assetsDirs: ['assets'],\r\n // scoped: true\r\n shadow: true\r\n})\r\nexport class CrmBonus {\r\n\r\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\r\n\r\n private crmBonusRef: HTMLCrmGiftbackFormElement;\r\n\r\n @Prop() cart;\r\n @Prop() canhidden: boolean = false;\r\n\r\n @State() showModal: boolean = false;\r\n\r\n @State() cartWake: CartWake;\r\n\r\n @State() customer: ICustomer = {\r\n birthDate: \"\",\r\n document: \"\",\r\n name: \"\",\r\n phone: \"\"\r\n };\r\n\r\n @State() loading: boolean = false;\r\n @State() message: string;\r\n @State() phone: number;\r\n @State() canCancel: boolean = false;\r\n @State() amountCancel: string;\r\n @State() sent: IPinSent;\r\n\r\n @State() session: string;\r\n @State() loading_reprocess = false;\r\n @State() styles = defaultStyles;\r\n @State() reservedInfo: ReservedInfoDTO;\r\n\r\n @Method()\r\n async resetBonus() {\r\n console.log('[START RESET BONUS]!!!!!');\r\n\r\n try {\r\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\r\n console.log('[BONUS RESETADO]!!!!!');\r\n } catch (err) {\r\n\r\n this.loading = false;\r\n console.log('[error ao reprocessar bonous]');\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n @Method()\r\n async setloading() {\r\n this.loading_reprocess = !this.loading_reprocess;\r\n }\r\n\r\n @Method()\r\n async reprocess() {\r\n console.log(\"[CRMBONUS] - reprocess\")\r\n this.loading_reprocess = true\r\n\r\n try {\r\n\r\n const isUse = localStorage.getItem(USED_KEY);\r\n\r\n if (!isUse) return;\r\n\r\n this.cartWake = await getCart();\r\n await this.resetBonus();\r\n } catch (err) {\r\n console.debug('[watchProducts]', err.message);\r\n } finally {\r\n this.loading_reprocess = false\r\n }\r\n }\r\n\r\n async componentWillLoad() {\r\n\r\n window.addEventListener('productRemovedFromCart', async () => {\r\n console.log('[CRMBONUS] - productRemovedFromCart');\r\n await this.reprocess()\r\n });\r\n\r\n window.addEventListener('productAddedToCart', async () => {\r\n console.log('[CRMBONUS] - productAddedToCart');\r\n await this.reprocess();\r\n });\r\n\r\n document.querySelectorAll('form').forEach((el) => {\r\n el.addEventListener(\"submit\", () => {\r\n console.log(\"[CRMBONUS] - Formulário está sendo submetido!\");\r\n // você pode marcar como \"em submissão\" aqui\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n })\r\n });\r\n });\r\n\r\n await this.observerHandle();\r\n\r\n i18next.changeLanguage(i18next.language);\r\n\r\n await this.loadSession();\r\n\r\n this.handleLoad();\r\n await this.loadConfigStore()\r\n }\r\n\r\n async componentDidLoad() {\r\n console.log('[did load]');\r\n \r\n }\r\n\r\n private async observerHandle() {\r\n const elements = document.getElementsByTagName('a');\r\n\r\n //@ts-ignore\r\n for (let el of elements) {\r\n console.log('[el.href]', el.href);\r\n if (el.href.includes('Produto/Delete')) {\r\n el.addEventListener('click', async () => {\r\n console.log('[CRMBONUS] - Produto removido do carrinho');\r\n\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n this.observerHandle();\r\n }, 2000);\r\n\r\n });\r\n }\r\n\r\n if (el.href.includes('Produto/Add')) {\r\n el.addEventListener('click', async () => {\r\n console.log('[CRMBONUS] - Produto adicionado ao carrinho');\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n this.observerHandle();\r\n }, 2000);\r\n });\r\n }\r\n }\r\n }\r\n\r\n async loadConfigStore() {\r\n\r\n const [customization, infoBonus] = await Promise.all([\r\n this.crmBonusService.getCustomization(this.cartWake.store.name),\r\n getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name)\r\n ]);\r\n\r\n console.log('[infoBonus]', infoBonus);\r\n\r\n this.reservedInfo = infoBonus;\r\n\r\n if (customization.keepStoreFrontStyle) {\r\n console.log('[bc:usar estilo da loja]');\r\n this.styles = null;\r\n }\r\n }\r\n\r\n async fetchCustomer(userId: number, storeName: string) {\r\n try {\r\n return await this.crmBonusService.getCustomer(userId, storeName);\r\n } catch (error) {\r\n console.error('[fetchCustomer] Error fetching customer:', error);\r\n return null;\r\n }\r\n }\r\n\r\n async handleLoad() {\r\n try {\r\n if (this.cartWake.user.id) {\r\n this.fetchCustomer(this.cartWake.user.id, this.cartWake.store.name).then((customer) => {\r\n console.log('[bc:loading customer]');\r\n if (customer) {\r\n this.customer = customer;\r\n console.log('customer', this.customer);\r\n }\r\n });\r\n }\r\n\r\n const amount = localStorage.getItem(this.cartWake.id);\r\n\r\n if (amount) {\r\n this.canCancel = true;\r\n this.amountCancel = amount;\r\n }\r\n\r\n await this.buildAndGetProducts(this.cartWake.products);\r\n } catch (error) {\r\n console.log('info customer')\r\n }\r\n }\r\n\r\n async loadSession() {\r\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\r\n console.log('[bc:carregou carrinho]');\r\n\r\n this.session = await this.crmBonusService.getToken(this.cartWake.store.name);\r\n console.log('[bc:carregou session]');\r\n setTimeout(() => {\r\n this.loadSession()\r\n }, 1500000)\r\n }\r\n\r\n async buildAndGetProducts(productsWake: IProductWake[]) {\r\n console.log()\r\n\r\n const key = `bc-products:${this.cartWake.id}`;\r\n\r\n const productsString = JSON.stringify(productsWake)\r\n\r\n localStorage.setItem(key, productsString);\r\n\r\n const products_in_cache = JSON.parse(localStorage.getItem(key));\r\n\r\n const products: Array<IProductWake> = []\r\n\r\n for (const product_cart of productsWake) {\r\n\r\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\r\n\r\n //const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === \"Formula\")\r\n\r\n if (pro) {\r\n products.push({\r\n ...product_cart,\r\n PrecoPor: pro.PrecoPor,\r\n PrecoDe: pro.PrecoDe,\r\n Quantidade: pro.Quantidade,\r\n Ajustes: pro.Ajustes\r\n })\r\n } else {\r\n products.push(product_cart)\r\n }\r\n\r\n }\r\n\r\n this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\r\n\r\n }\r\n\r\n public async sendPin(phone: string) {\r\n this.loading = true;\r\n this.message = \"\";\r\n\r\n try {\r\n\r\n const _phone = phone.replace(/\\D/g, '');\r\n this.phone = Number(_phone);\r\n\r\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);;\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\r\n\r\n this.showModal = true;\r\n } catch (error) {\r\n this.message = error?.response?.data?.message\r\n } finally {\r\n this.loading = false\r\n }\r\n }\r\n\r\n public async sendPinName(customerName: string) {\r\n this.loading = true;\r\n this.message = \"\";\r\n\r\n try {\r\n this.customer.name = customerName;\r\n\r\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\r\n\r\n this.showModal = true;\r\n } catch (error) {\r\n this.message = error?.response?.data?.message\r\n } finally {\r\n this.loading = false\r\n }\r\n }\r\n\r\n buildProducts(): IProduct[] {\r\n return buildProductsByWake(this.cartWake.products);\r\n }\r\n\r\n handleCloseModal() {\r\n this.showModal = false;\r\n }\r\n\r\n save(amount: number) {\r\n localStorage.setItem(this.cartWake.id, amount.toString());\r\n this.canCancel = true;\r\n this.amountCancel = amount.toString()\r\n }\r\n\r\n async cancel() {\r\n this.message = \"\";\r\n this.loading = true;\r\n try {\r\n await this.crmBonusService.cancel(this.cartWake.id);\r\n this.canCancel = false;\r\n\r\n localStorage.removeItem(this.cartWake.id);\r\n } catch (error) {\r\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n async handleSendPin(phone: string) {\r\n this.message = \"\"\r\n if (!phone) {\r\n this.message = \"Informe seu telefone\";\r\n return;\r\n }\r\n\r\n this.customer.phone = phone;\r\n const _phone = phone.replace(/\\D/g, '');\r\n this.phone = Number(_phone);\r\n\r\n if (this.customer.name) {\r\n return this.sendPin(phone)\r\n }\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\r\n this.showModal = true;\r\n }\r\n\r\n render() {\r\n\r\n if (this.canhidden) {\r\n return null;\r\n }\r\n\r\n return (\r\n <loading-container loading={this.loading_reprocess} >\r\n <crm-giftback-form\r\n customStyles={this.styles}\r\n style={{ position: \"relative\" }}\r\n ref={ref => this.crmBonusRef = ref}\r\n storeName={this.cartWake.store.name}\r\n products={this.buildProducts()}\r\n cartId={this.cartWake.id}\r\n customer={this.customer}\r\n loadProducts={() => this.buildProducts()}\r\n loadAll={() => this.handleLoad()}\r\n reservedInfo={this.reservedInfo}\r\n />\r\n </loading-container>\r\n )\r\n }\r\n}\r\n"],"version":3}
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
19
19
|
|
20
20
|
patchBrowser().then(async (options) => {
|
21
21
|
await appGlobals.globalScripts();
|
22
|
-
return index.bootstrapLazy([["crm-bonus
|
22
|
+
return index.bootstrapLazy([["crm-bonus.cjs",[[1,"crm-bonus",{"cart":[8],"canhidden":[4],"showModal":[32],"cartWake":[32],"customer":[32],"loading":[32],"message":[32],"phone":[32],"canCancel":[32],"amountCancel":[32],"sent":[32],"session":[32],"loading_reprocess":[32],"styles":[32],"reservedInfo":[32],"resetBonus":[64],"setloading":[64],"reprocess":[64]}]]],["crm-bonus-2.cjs",[[1,"crm-bonus-2",{"loading":[32],"cartWake":[32]}]]],["crm-bonus-note.cjs",[[0,"crm-bonus-note",{"cart":[8],"cartWake":[32],"url":[32],"config":[32],"bonus":[32],"showEdit":[32],"styles":[32],"infoBonus":[32],"loading":[32],"info":[32]}]]],["app-modal.cjs",[[1,"app-modal",{"isOpen":[516,"is-open"],"modalTitle":[1,"modal-title"]}]]],["countdown-timer-v2.cjs",[[1,"countdown-timer-v2",{"downtime":[16],"reload":[4],"dates":[16],"seconds":[32],"minutes":[32]}]]],["crm-bonus-tray.cjs",[[0,"crm-bonus-tray"]]],["pedido-finalizado.cjs",[[0,"pedido-finalizado",{"cart":[8]}]]],["loading-container.cjs",[[4,"loading-container",{"loading":[4]}]]],["loading-spinner.cjs",[[1,"loading-spinner",{"size":[1],"color":[1]}]]],["countdown-timer_2.cjs",[[0,"crm-button",{"txtBtn":[1,"txt-btn"],"loading":[4],"handleClick":[16]}],[0,"countdown-timer",{"downtime":[16],"dataCriacao":[1,"data-criacao"],"minutos":[2],"segundos":[2],"tempoRestante":[32]}]]],["crm-tooltip_5.cjs",[[0,"phone-form",{"value":[1],"loading":[4],"handlerSubmit":[16],"config":[16]}],[1,"pin-form",{"validate":[16],"cancel":[16],"resend":[16],"sent":[16],"loading":[4],"phone":[1],"config":[16],"pin":[32],"isVerified":[32],"canResend":[32]}],[0,"giftback-info",{"cartId":[8,"cart-id"],"loading":[4],"bonus":[16],"reserve":[16],"cancel":[16],"config":[16],"infoBonus":[16],"storeName":[1,"store-name"],"usedValue":[32],"selectedOption":[32],"sliderPosition":[32],"sliderValuePosition":[32],"loadingTime":[32]},null,{"bonus":["changedBonus"]}],[0,"crm-tooltip",{"text":[1],"identity":[1]}],[1,"phone-input-mask",{"initialValue":[1,"initial-value"],"disabled":[4],"phone":[32],"message":[32],"getPhone":[64]}]]],["crm-giftback-form.cjs",[[0,"crm-giftback-form",{"storeName":[8,"storename"],"cartId":[8,"cart-id"],"products":[16],"customer":[16],"loadProducts":[16],"loadAll":[16],"customStyles":[8,"custom-styles"],"reservedInfo":[16],"value":[32],"loading":[32],"message":[32],"phone":[32],"pinInfo":[32],"step":[32],"bonus":[32],"sucess":[32],"error":[32],"config":[32],"hasApplyBonus":[32],"loadingAllComponent":[32],"setStep":[64],"processBonus":[64]}]]]], options);
|
23
23
|
});
|
24
24
|
|
25
25
|
exports.setNonce = index.setNonce;
|
package/dist/cjs/loader.cjs.js
CHANGED
@@ -8,7 +8,7 @@ const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
8
8
|
const defineCustomElements = async (win, options) => {
|
9
9
|
if (typeof window === 'undefined') return undefined;
|
10
10
|
await appGlobals.globalScripts();
|
11
|
-
return index.bootstrapLazy([["crm-bonus
|
11
|
+
return index.bootstrapLazy([["crm-bonus.cjs",[[1,"crm-bonus",{"cart":[8],"canhidden":[4],"showModal":[32],"cartWake":[32],"customer":[32],"loading":[32],"message":[32],"phone":[32],"canCancel":[32],"amountCancel":[32],"sent":[32],"session":[32],"loading_reprocess":[32],"styles":[32],"reservedInfo":[32],"resetBonus":[64],"setloading":[64],"reprocess":[64]}]]],["crm-bonus-2.cjs",[[1,"crm-bonus-2",{"loading":[32],"cartWake":[32]}]]],["crm-bonus-note.cjs",[[0,"crm-bonus-note",{"cart":[8],"cartWake":[32],"url":[32],"config":[32],"bonus":[32],"showEdit":[32],"styles":[32],"infoBonus":[32],"loading":[32],"info":[32]}]]],["app-modal.cjs",[[1,"app-modal",{"isOpen":[516,"is-open"],"modalTitle":[1,"modal-title"]}]]],["countdown-timer-v2.cjs",[[1,"countdown-timer-v2",{"downtime":[16],"reload":[4],"dates":[16],"seconds":[32],"minutes":[32]}]]],["crm-bonus-tray.cjs",[[0,"crm-bonus-tray"]]],["pedido-finalizado.cjs",[[0,"pedido-finalizado",{"cart":[8]}]]],["loading-container.cjs",[[4,"loading-container",{"loading":[4]}]]],["loading-spinner.cjs",[[1,"loading-spinner",{"size":[1],"color":[1]}]]],["countdown-timer_2.cjs",[[0,"crm-button",{"txtBtn":[1,"txt-btn"],"loading":[4],"handleClick":[16]}],[0,"countdown-timer",{"downtime":[16],"dataCriacao":[1,"data-criacao"],"minutos":[2],"segundos":[2],"tempoRestante":[32]}]]],["crm-tooltip_5.cjs",[[0,"phone-form",{"value":[1],"loading":[4],"handlerSubmit":[16],"config":[16]}],[1,"pin-form",{"validate":[16],"cancel":[16],"resend":[16],"sent":[16],"loading":[4],"phone":[1],"config":[16],"pin":[32],"isVerified":[32],"canResend":[32]}],[0,"giftback-info",{"cartId":[8,"cart-id"],"loading":[4],"bonus":[16],"reserve":[16],"cancel":[16],"config":[16],"infoBonus":[16],"storeName":[1,"store-name"],"usedValue":[32],"selectedOption":[32],"sliderPosition":[32],"sliderValuePosition":[32],"loadingTime":[32]},null,{"bonus":["changedBonus"]}],[0,"crm-tooltip",{"text":[1],"identity":[1]}],[1,"phone-input-mask",{"initialValue":[1,"initial-value"],"disabled":[4],"phone":[32],"message":[32],"getPhone":[64]}]]],["crm-giftback-form.cjs",[[0,"crm-giftback-form",{"storeName":[8,"storename"],"cartId":[8,"cart-id"],"products":[16],"customer":[16],"loadProducts":[16],"loadAll":[16],"customStyles":[8,"custom-styles"],"reservedInfo":[16],"value":[32],"loading":[32],"message":[32],"phone":[32],"pinInfo":[32],"step":[32],"bonus":[32],"sucess":[32],"error":[32],"config":[32],"hasApplyBonus":[32],"loadingAllComponent":[32],"setStep":[64],"processBonus":[64]}]]]], options);
|
12
12
|
};
|
13
13
|
|
14
14
|
exports.setNonce = index.setNonce;
|
@@ -271,7 +271,7 @@ export class CrmBonus {
|
|
271
271
|
}
|
272
272
|
return (h("loading-container", { loading: this.loading_reprocess }, h("crm-giftback-form", { customStyles: this.styles, style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.cartWake.store.name, products: this.buildProducts(), cartId: this.cartWake.id, customer: this.customer, loadProducts: () => this.buildProducts(), loadAll: () => this.handleLoad(), reservedInfo: this.reservedInfo })));
|
273
273
|
}
|
274
|
-
static get is() { return "crm-bonus
|
274
|
+
static get is() { return "crm-bonus"; }
|
275
275
|
static get encapsulation() { return "shadow"; }
|
276
276
|
static get originalStyleUrls() {
|
277
277
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"crm-bonus.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus/crm-bonus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,OAAO,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAUpD,MAAM,OAAO,QAAQ;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;;yBAK5C,KAAK;yBAE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OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC5B,CAAC;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,MAAM;QAEJ,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CACL,yBAAmB,OAAO,EAAE,IAAI,CAAC,iBAAiB;YAChD,yBACE,YAAY,EAAE,IAAI,CAAC,MAAM,EACzB,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAC/B,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EACnC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE,EACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,EACxC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,EAChC,YAAY,EAAE,IAAI,CAAC,YAAY,GAC/B,CACgB,CACrB,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Method, Prop, State, h } from '@stencil/core';\r\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\r\nimport { CrmBonusService } from '../../services/crmbonus.service';\r\nimport { IPinSent } from '../../components';\r\nimport { defaultStyles, StepFormEnum } from '../../contants';\r\n\r\nimport i18next from '../../i18n/i18n'\r\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\r\nimport { getCart, getInfoBonusByCartIdAndStoreName } from '../../helpers/cart.helper';\r\nimport { CartWake } from '../../objectvalues/cart.wake';\r\nimport { USED_KEY } from '../../utils/keys.storage';\r\nimport { ReservedInfoDTO } from '../../dto/reserved-info.dto';\r\n\r\n@Component({\r\n tag: 'crm-bonus-2',\r\n styleUrl: 'crm-bonus.css',\r\n assetsDirs: ['assets'],\r\n // scoped: true\r\n shadow: true\r\n})\r\nexport class CrmBonus {\r\n\r\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\r\n\r\n private crmBonusRef: HTMLCrmGiftbackFormElement;\r\n\r\n @Prop() cart;\r\n @Prop() canhidden: boolean = false;\r\n\r\n @State() showModal: boolean = false;\r\n\r\n @State() cartWake: CartWake;\r\n\r\n @State() customer: ICustomer = {\r\n birthDate: \"\",\r\n document: \"\",\r\n name: \"\",\r\n phone: \"\"\r\n };\r\n\r\n @State() loading: boolean = false;\r\n @State() message: string;\r\n @State() phone: number;\r\n @State() canCancel: boolean = false;\r\n @State() amountCancel: string;\r\n @State() sent: IPinSent;\r\n\r\n @State() session: string;\r\n @State() loading_reprocess = false;\r\n @State() styles = defaultStyles;\r\n @State() reservedInfo: ReservedInfoDTO;\r\n\r\n @Method()\r\n async resetBonus() {\r\n console.log('[START RESET BONUS]!!!!!');\r\n\r\n try {\r\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\r\n console.log('[BONUS RESETADO]!!!!!');\r\n } catch (err) {\r\n\r\n this.loading = false;\r\n console.log('[error ao reprocessar bonous]');\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n @Method()\r\n async setloading() {\r\n this.loading_reprocess = !this.loading_reprocess;\r\n }\r\n\r\n @Method()\r\n async reprocess() {\r\n console.log(\"[CRMBONUS] - reprocess\")\r\n this.loading_reprocess = true\r\n\r\n try {\r\n\r\n const isUse = localStorage.getItem(USED_KEY);\r\n\r\n if (!isUse) return;\r\n\r\n this.cartWake = await getCart();\r\n await this.resetBonus();\r\n } catch (err) {\r\n console.debug('[watchProducts]', err.message);\r\n } finally {\r\n this.loading_reprocess = false\r\n }\r\n }\r\n\r\n async componentWillLoad() {\r\n\r\n window.addEventListener('productRemovedFromCart', async () => {\r\n console.log('[CRMBONUS] - productRemovedFromCart');\r\n await this.reprocess()\r\n });\r\n\r\n window.addEventListener('productAddedToCart', async () => {\r\n console.log('[CRMBONUS] - productAddedToCart');\r\n await this.reprocess();\r\n });\r\n\r\n document.querySelectorAll('form').forEach((el) => {\r\n el.addEventListener(\"submit\", () => {\r\n console.log(\"[CRMBONUS] - Formulário está sendo submetido!\");\r\n // você pode marcar como \"em submissão\" aqui\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n })\r\n });\r\n });\r\n\r\n await this.observerHandle();\r\n\r\n i18next.changeLanguage(i18next.language);\r\n\r\n await this.loadSession();\r\n\r\n this.handleLoad();\r\n await this.loadConfigStore()\r\n }\r\n\r\n async componentDidLoad() {\r\n console.log('[did load]');\r\n \r\n }\r\n\r\n private async observerHandle() {\r\n const elements = document.getElementsByTagName('a');\r\n\r\n //@ts-ignore\r\n for (let el of elements) {\r\n console.log('[el.href]', el.href);\r\n if (el.href.includes('Produto/Delete')) {\r\n el.addEventListener('click', async () => {\r\n console.log('[CRMBONUS] - Produto removido do carrinho');\r\n\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n this.observerHandle();\r\n }, 2000);\r\n\r\n });\r\n }\r\n\r\n if (el.href.includes('Produto/Add')) {\r\n el.addEventListener('click', async () => {\r\n console.log('[CRMBONUS] - Produto adicionado ao carrinho');\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n this.observerHandle();\r\n }, 2000);\r\n });\r\n }\r\n }\r\n }\r\n\r\n async loadConfigStore() {\r\n\r\n const [customization, infoBonus] = await Promise.all([\r\n this.crmBonusService.getCustomization(this.cartWake.store.name),\r\n getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name)\r\n ]);\r\n\r\n console.log('[infoBonus]', infoBonus);\r\n\r\n this.reservedInfo = infoBonus;\r\n\r\n if (customization.keepStoreFrontStyle) {\r\n console.log('[bc:usar estilo da loja]');\r\n this.styles = null;\r\n }\r\n }\r\n\r\n async fetchCustomer(userId: number, storeName: string) {\r\n try {\r\n return await this.crmBonusService.getCustomer(userId, storeName);\r\n } catch (error) {\r\n console.error('[fetchCustomer] Error fetching customer:', error);\r\n return null;\r\n }\r\n }\r\n\r\n async handleLoad() {\r\n try {\r\n if (this.cartWake.user.id) {\r\n this.fetchCustomer(this.cartWake.user.id, this.cartWake.store.name).then((customer) => {\r\n console.log('[bc:loading customer]');\r\n if (customer) {\r\n this.customer = customer;\r\n console.log('customer', this.customer);\r\n }\r\n });\r\n }\r\n\r\n const amount = localStorage.getItem(this.cartWake.id);\r\n\r\n if (amount) {\r\n this.canCancel = true;\r\n this.amountCancel = amount;\r\n }\r\n\r\n await this.buildAndGetProducts(this.cartWake.products);\r\n } catch (error) {\r\n console.log('info customer')\r\n }\r\n }\r\n\r\n async loadSession() {\r\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\r\n console.log('[bc:carregou carrinho]');\r\n\r\n this.session = await this.crmBonusService.getToken(this.cartWake.store.name);\r\n console.log('[bc:carregou session]');\r\n setTimeout(() => {\r\n this.loadSession()\r\n }, 1500000)\r\n }\r\n\r\n async buildAndGetProducts(productsWake: IProductWake[]) {\r\n console.log()\r\n\r\n const key = `bc-products:${this.cartWake.id}`;\r\n\r\n const productsString = JSON.stringify(productsWake)\r\n\r\n localStorage.setItem(key, productsString);\r\n\r\n const products_in_cache = JSON.parse(localStorage.getItem(key));\r\n\r\n const products: Array<IProductWake> = []\r\n\r\n for (const product_cart of productsWake) {\r\n\r\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\r\n\r\n //const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === \"Formula\")\r\n\r\n if (pro) {\r\n products.push({\r\n ...product_cart,\r\n PrecoPor: pro.PrecoPor,\r\n PrecoDe: pro.PrecoDe,\r\n Quantidade: pro.Quantidade,\r\n Ajustes: pro.Ajustes\r\n })\r\n } else {\r\n products.push(product_cart)\r\n }\r\n\r\n }\r\n\r\n this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\r\n\r\n }\r\n\r\n public async sendPin(phone: string) {\r\n this.loading = true;\r\n this.message = \"\";\r\n\r\n try {\r\n\r\n const _phone = phone.replace(/\\D/g, '');\r\n this.phone = Number(_phone);\r\n\r\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);;\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\r\n\r\n this.showModal = true;\r\n } catch (error) {\r\n this.message = error?.response?.data?.message\r\n } finally {\r\n this.loading = false\r\n }\r\n }\r\n\r\n public async sendPinName(customerName: string) {\r\n this.loading = true;\r\n this.message = \"\";\r\n\r\n try {\r\n this.customer.name = customerName;\r\n\r\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\r\n\r\n this.showModal = true;\r\n } catch (error) {\r\n this.message = error?.response?.data?.message\r\n } finally {\r\n this.loading = false\r\n }\r\n }\r\n\r\n buildProducts(): IProduct[] {\r\n return buildProductsByWake(this.cartWake.products);\r\n }\r\n\r\n handleCloseModal() {\r\n this.showModal = false;\r\n }\r\n\r\n save(amount: number) {\r\n localStorage.setItem(this.cartWake.id, amount.toString());\r\n this.canCancel = true;\r\n this.amountCancel = amount.toString()\r\n }\r\n\r\n async cancel() {\r\n this.message = \"\";\r\n this.loading = true;\r\n try {\r\n await this.crmBonusService.cancel(this.cartWake.id);\r\n this.canCancel = false;\r\n\r\n localStorage.removeItem(this.cartWake.id);\r\n } catch (error) {\r\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n async handleSendPin(phone: string) {\r\n this.message = \"\"\r\n if (!phone) {\r\n this.message = \"Informe seu telefone\";\r\n return;\r\n }\r\n\r\n this.customer.phone = phone;\r\n const _phone = phone.replace(/\\D/g, '');\r\n this.phone = Number(_phone);\r\n\r\n if (this.customer.name) {\r\n return this.sendPin(phone)\r\n }\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\r\n this.showModal = true;\r\n }\r\n\r\n render() {\r\n\r\n if (this.canhidden) {\r\n return null;\r\n }\r\n\r\n return (\r\n <loading-container loading={this.loading_reprocess} >\r\n <crm-giftback-form\r\n customStyles={this.styles}\r\n style={{ position: \"relative\" }}\r\n ref={ref => this.crmBonusRef = ref}\r\n storeName={this.cartWake.store.name}\r\n products={this.buildProducts()}\r\n cartId={this.cartWake.id}\r\n customer={this.customer}\r\n loadProducts={() => this.buildProducts()}\r\n loadAll={() => this.handleLoad()}\r\n reservedInfo={this.reservedInfo}\r\n />\r\n </loading-container>\r\n )\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"crm-bonus.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus/crm-bonus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,OAAO,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,C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port { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\r\nimport { CrmBonusService } from '../../services/crmbonus.service';\r\nimport { IPinSent } from '../../components';\r\nimport { defaultStyles, StepFormEnum } from '../../contants';\r\n\r\nimport i18next from '../../i18n/i18n'\r\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\r\nimport { getCart, getInfoBonusByCartIdAndStoreName } from '../../helpers/cart.helper';\r\nimport { CartWake } from '../../objectvalues/cart.wake';\r\nimport { USED_KEY } from '../../utils/keys.storage';\r\nimport { ReservedInfoDTO } from '../../dto/reserved-info.dto';\r\n\r\n@Component({\r\n tag: 'crm-bonus',\r\n styleUrl: 'crm-bonus.css',\r\n assetsDirs: ['assets'],\r\n // scoped: true\r\n shadow: true\r\n})\r\nexport class CrmBonus {\r\n\r\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\r\n\r\n private crmBonusRef: HTMLCrmGiftbackFormElement;\r\n\r\n @Prop() cart;\r\n @Prop() canhidden: boolean = false;\r\n\r\n @State() showModal: boolean = false;\r\n\r\n @State() cartWake: CartWake;\r\n\r\n @State() customer: ICustomer = {\r\n birthDate: \"\",\r\n document: \"\",\r\n name: \"\",\r\n phone: \"\"\r\n };\r\n\r\n @State() loading: boolean = false;\r\n @State() message: string;\r\n @State() phone: number;\r\n @State() canCancel: boolean = false;\r\n @State() amountCancel: string;\r\n @State() sent: IPinSent;\r\n\r\n @State() session: string;\r\n @State() loading_reprocess = false;\r\n @State() styles = defaultStyles;\r\n @State() reservedInfo: ReservedInfoDTO;\r\n\r\n @Method()\r\n async resetBonus() {\r\n console.log('[START RESET BONUS]!!!!!');\r\n\r\n try {\r\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\r\n console.log('[BONUS RESETADO]!!!!!');\r\n } catch (err) {\r\n\r\n this.loading = false;\r\n console.log('[error ao reprocessar bonous]');\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n @Method()\r\n async setloading() {\r\n this.loading_reprocess = !this.loading_reprocess;\r\n }\r\n\r\n @Method()\r\n async reprocess() {\r\n console.log(\"[CRMBONUS] - reprocess\")\r\n this.loading_reprocess = true\r\n\r\n try {\r\n\r\n const isUse = localStorage.getItem(USED_KEY);\r\n\r\n if (!isUse) return;\r\n\r\n this.cartWake = await getCart();\r\n await this.resetBonus();\r\n } catch (err) {\r\n console.debug('[watchProducts]', err.message);\r\n } finally {\r\n this.loading_reprocess = false\r\n }\r\n }\r\n\r\n async componentWillLoad() {\r\n\r\n window.addEventListener('productRemovedFromCart', async () => {\r\n console.log('[CRMBONUS] - productRemovedFromCart');\r\n await this.reprocess()\r\n });\r\n\r\n window.addEventListener('productAddedToCart', async () => {\r\n console.log('[CRMBONUS] - productAddedToCart');\r\n await this.reprocess();\r\n });\r\n\r\n document.querySelectorAll('form').forEach((el) => {\r\n el.addEventListener(\"submit\", () => {\r\n console.log(\"[CRMBONUS] - Formulário está sendo submetido!\");\r\n // você pode marcar como \"em submissão\" aqui\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n })\r\n });\r\n });\r\n\r\n await this.observerHandle();\r\n\r\n i18next.changeLanguage(i18next.language);\r\n\r\n await this.loadSession();\r\n\r\n this.handleLoad();\r\n await this.loadConfigStore()\r\n }\r\n\r\n async componentDidLoad() {\r\n console.log('[did load]');\r\n \r\n }\r\n\r\n private async observerHandle() {\r\n const elements = document.getElementsByTagName('a');\r\n\r\n //@ts-ignore\r\n for (let el of elements) {\r\n console.log('[el.href]', el.href);\r\n if (el.href.includes('Produto/Delete')) {\r\n el.addEventListener('click', async () => {\r\n console.log('[CRMBONUS] - Produto removido do carrinho');\r\n\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n this.observerHandle();\r\n }, 2000);\r\n\r\n });\r\n }\r\n\r\n if (el.href.includes('Produto/Add')) {\r\n el.addEventListener('click', async () => {\r\n console.log('[CRMBONUS] - Produto adicionado ao carrinho');\r\n setTimeout(async () => {\r\n await this.reprocess();\r\n this.observerHandle();\r\n }, 2000);\r\n });\r\n }\r\n }\r\n }\r\n\r\n async loadConfigStore() {\r\n\r\n const [customization, infoBonus] = await Promise.all([\r\n this.crmBonusService.getCustomization(this.cartWake.store.name),\r\n getInfoBonusByCartIdAndStoreName(this.cartWake.id, this.cartWake.store.name)\r\n ]);\r\n\r\n console.log('[infoBonus]', infoBonus);\r\n\r\n this.reservedInfo = infoBonus;\r\n\r\n if (customization.keepStoreFrontStyle) {\r\n console.log('[bc:usar estilo da loja]');\r\n this.styles = null;\r\n }\r\n }\r\n\r\n async fetchCustomer(userId: number, storeName: string) {\r\n try {\r\n return await this.crmBonusService.getCustomer(userId, storeName);\r\n } catch (error) {\r\n console.error('[fetchCustomer] Error fetching customer:', error);\r\n return null;\r\n }\r\n }\r\n\r\n async handleLoad() {\r\n try {\r\n if (this.cartWake.user.id) {\r\n this.fetchCustomer(this.cartWake.user.id, this.cartWake.store.name).then((customer) => {\r\n console.log('[bc:loading customer]');\r\n if (customer) {\r\n this.customer = customer;\r\n console.log('customer', this.customer);\r\n }\r\n });\r\n }\r\n\r\n const amount = localStorage.getItem(this.cartWake.id);\r\n\r\n if (amount) {\r\n this.canCancel = true;\r\n this.amountCancel = amount;\r\n }\r\n\r\n await this.buildAndGetProducts(this.cartWake.products);\r\n } catch (error) {\r\n console.log('info customer')\r\n }\r\n }\r\n\r\n async loadSession() {\r\n this.cartWake = this.cart ? new CartWake(JSON.parse(this.cart)) : await getCart();\r\n console.log('[bc:carregou carrinho]');\r\n\r\n this.session = await this.crmBonusService.getToken(this.cartWake.store.name);\r\n console.log('[bc:carregou session]');\r\n setTimeout(() => {\r\n this.loadSession()\r\n }, 1500000)\r\n }\r\n\r\n async buildAndGetProducts(productsWake: IProductWake[]) {\r\n console.log()\r\n\r\n const key = `bc-products:${this.cartWake.id}`;\r\n\r\n const productsString = JSON.stringify(productsWake)\r\n\r\n localStorage.setItem(key, productsString);\r\n\r\n const products_in_cache = JSON.parse(localStorage.getItem(key));\r\n\r\n const products: Array<IProductWake> = []\r\n\r\n for (const product_cart of productsWake) {\r\n\r\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\r\n\r\n //const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === \"Formula\")\r\n\r\n if (pro) {\r\n products.push({\r\n ...product_cart,\r\n PrecoPor: pro.PrecoPor,\r\n PrecoDe: pro.PrecoDe,\r\n Quantidade: pro.Quantidade,\r\n Ajustes: pro.Ajustes\r\n })\r\n } else {\r\n products.push(product_cart)\r\n }\r\n\r\n }\r\n\r\n this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\r\n\r\n }\r\n\r\n public async sendPin(phone: string) {\r\n this.loading = true;\r\n this.message = \"\";\r\n\r\n try {\r\n\r\n const _phone = phone.replace(/\\D/g, '');\r\n this.phone = Number(_phone);\r\n\r\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);;\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\r\n\r\n this.showModal = true;\r\n } catch (error) {\r\n this.message = error?.response?.data?.message\r\n } finally {\r\n this.loading = false\r\n }\r\n }\r\n\r\n public async sendPinName(customerName: string) {\r\n this.loading = true;\r\n this.message = \"\";\r\n\r\n try {\r\n this.customer.name = customerName;\r\n\r\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\r\n\r\n this.showModal = true;\r\n } catch (error) {\r\n this.message = error?.response?.data?.message\r\n } finally {\r\n this.loading = false\r\n }\r\n }\r\n\r\n buildProducts(): IProduct[] {\r\n return buildProductsByWake(this.cartWake.products);\r\n }\r\n\r\n handleCloseModal() {\r\n this.showModal = false;\r\n }\r\n\r\n save(amount: number) {\r\n localStorage.setItem(this.cartWake.id, amount.toString());\r\n this.canCancel = true;\r\n this.amountCancel = amount.toString()\r\n }\r\n\r\n async cancel() {\r\n this.message = \"\";\r\n this.loading = true;\r\n try {\r\n await this.crmBonusService.cancel(this.cartWake.id);\r\n this.canCancel = false;\r\n\r\n localStorage.removeItem(this.cartWake.id);\r\n } catch (error) {\r\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\r\n } finally {\r\n this.loading = false;\r\n }\r\n }\r\n\r\n async handleSendPin(phone: string) {\r\n this.message = \"\"\r\n if (!phone) {\r\n this.message = \"Informe seu telefone\";\r\n return;\r\n }\r\n\r\n this.customer.phone = phone;\r\n const _phone = phone.replace(/\\D/g, '');\r\n this.phone = Number(_phone);\r\n\r\n if (this.customer.name) {\r\n return this.sendPin(phone)\r\n }\r\n\r\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\r\n this.showModal = true;\r\n }\r\n\r\n render() {\r\n\r\n if (this.canhidden) {\r\n return null;\r\n }\r\n\r\n return (\r\n <loading-container loading={this.loading_reprocess} >\r\n <crm-giftback-form\r\n customStyles={this.styles}\r\n style={{ position: \"relative\" }}\r\n ref={ref => this.crmBonusRef = ref}\r\n storeName={this.cartWake.store.name}\r\n products={this.buildProducts()}\r\n cartId={this.cartWake.id}\r\n customer={this.customer}\r\n loadProducts={() => this.buildProducts()}\r\n loadAll={() => this.handleLoad()}\r\n reservedInfo={this.reservedInfo}\r\n />\r\n </loading-container>\r\n )\r\n }\r\n}\r\n"]}
|
@@ -13,9 +13,9 @@ export class CrmBonus {
|
|
13
13
|
}
|
14
14
|
render() {
|
15
15
|
console.log('this.cartWake', this.cartWake);
|
16
|
-
return (h("div", { key: '
|
16
|
+
return (h("div", { key: 'cc9dc7fa4262bf6cb5df716164ee9413f9a3bc6f' }, h("loading-container", { key: '4d5ff4d93a3769e609b630cc0760043458990e64', loading: this.loading }, h("h3", { key: 'f7f60857813f42b2735cc3ee6e73523fb4018f2b' }, "CARREGANDO...")), this.cartWake && (h("div", { key: 'bb86c641b03cbf94e50560a3d0d62d022cb80499' }, this.cartWake.id))));
|
17
17
|
}
|
18
|
-
static get is() { return "crm-bonus"; }
|
18
|
+
static get is() { return "crm-bonus-2"; }
|
19
19
|
static get encapsulation() { return "shadow"; }
|
20
20
|
static get originalStyleUrls() {
|
21
21
|
return {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"crmbonus.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus/crmbonus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AASpD,MAAM,OAAO,QAAQ;;uBAEE,KAAK;;;IAIxB,KAAK,CAAC,gBAAgB;QAClB,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,YAAY;QACd,IAAI,CAAC,QAAQ,GAAG,MAAM,OAAO,EAAE,CAAC;IACpC,CAAC;IAED,MAAM;QAEF,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QAE3C,OAAO,CACH;YACI,0EAAmB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACpC,6EAAsB,CACN;YAEhB,IAAI,CAAC,QAAQ,IAAI,CACb,8DACK,IAAI,CAAC,QAAQ,CAAC,EAAE,CACf,CACT,CAEH,CAET,CAAA;IACL,CAAC;;;;;;;;;;;;;;CACJ","sourcesContent":["import { Component, h, State } from \"@stencil/core\";\r\nimport { CartWake } from \"../../objectvalues/cart.wake\";\r\nimport { getCart } from \"../../helpers/cart.helper\";\r\n\r\n@Component({\r\n tag: 'crm-bonus',\r\n styleUrl: 'crm-bonus.css',\r\n assetsDirs: ['assets'],\r\n // scoped: true\r\n shadow: true\r\n})\r\nexport class CrmBonus {\r\n\r\n @State() loading = false;\r\n\r\n @State() cartWake: CartWake;\r\n\r\n async componentDidLoad() {\r\n await this.loadCheckout()\r\n }\r\n\r\n async loadCheckout() {\r\n this.cartWake = await getCart();\r\n }\r\n\r\n render() {\r\n\r\n console.log('this.cartWake', this.cartWake)\r\n\r\n return (\r\n <div>\r\n <loading-container loading={this.loading}>\r\n <h3>CARREGANDO...</h3>\r\n </loading-container>\r\n {\r\n this.cartWake && (\r\n <div>\r\n {this.cartWake.id}\r\n </div>\r\n )\r\n }\r\n </div>\r\n\r\n )\r\n }\r\n}"]}
|
1
|
+
{"version":3,"file":"crmbonus.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus/crmbonus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AASpD,MAAM,OAAO,QAAQ;;uBAEE,KAAK;;;IAIxB,KAAK,CAAC,gBAAgB;QAClB,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;IAC7B,CAAC;IAED,KAAK,CAAC,YAAY;QACd,IAAI,CAAC,QAAQ,GAAG,MAAM,OAAO,EAAE,CAAC;IACpC,CAAC;IAED,MAAM;QAEF,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QAE3C,OAAO,CACH;YACI,0EAAmB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACpC,6EAAsB,CACN;YAEhB,IAAI,CAAC,QAAQ,IAAI,CACb,8DACK,IAAI,CAAC,QAAQ,CAAC,EAAE,CACf,CACT,CAEH,CAET,CAAA;IACL,CAAC;;;;;;;;;;;;;;CACJ","sourcesContent":["import { Component, h, State } from \"@stencil/core\";\r\nimport { CartWake } from \"../../objectvalues/cart.wake\";\r\nimport { getCart } from \"../../helpers/cart.helper\";\r\n\r\n@Component({\r\n tag: 'crm-bonus-2',\r\n styleUrl: 'crm-bonus.css',\r\n assetsDirs: ['assets'],\r\n // scoped: true\r\n shadow: true\r\n})\r\nexport class CrmBonus {\r\n\r\n @State() loading = false;\r\n\r\n @State() cartWake: CartWake;\r\n\r\n async componentDidLoad() {\r\n await this.loadCheckout()\r\n }\r\n\r\n async loadCheckout() {\r\n this.cartWake = await getCart();\r\n }\r\n\r\n render() {\r\n\r\n console.log('this.cartWake', this.cartWake)\r\n\r\n return (\r\n <div>\r\n <loading-container loading={this.loading}>\r\n <h3>CARREGANDO...</h3>\r\n </loading-container>\r\n {\r\n this.cartWake && (\r\n <div>\r\n {this.cartWake.id}\r\n </div>\r\n )\r\n }\r\n </div>\r\n\r\n )\r\n }\r\n}"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"validate.pin.bonus.js","sourceRoot":"","sources":["../../../src/dto/validate.pin.bonus.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"validate.pin.bonus.js","sourceRoot":"","sources":["../../../src/dto/validate.pin.bonus.ts"],"names":[],"mappings":"AAUA,MAAM,CAAN,IAAY,eAKX;AALD,WAAY,eAAe;IACvB,iCAAc,CAAA;IACd,uCAAoB,CAAA;IACpB,yCAAsB,CAAA;IACtB,gCAAa,CAAA;AACjB,CAAC,EALW,eAAe,KAAf,eAAe,QAK1B","sourcesContent":["export interface IProduct {\r\n productVariantId: string;\r\n sku: string;\r\n value: number;\r\n originalValue: number;\r\n quantity: number;\r\n discount: number;\r\n promotion_product: boolean;\r\n}\r\n\r\nexport enum AjustesTipoEnum {\r\n P = \"Promocao\",\r\n CC = \"ContaCorrente\",\r\n PP = \"PromocaoProduto\",\r\n F = \"Formula\"\r\n}\r\n\r\nexport interface IAjustes {\r\n Tipo: AjustesTipoEnum;\r\n Valor: number;\r\n}\r\n\r\nexport interface IUser {\r\n id: number;\r\n}\r\n\r\nexport interface IStore {\r\n name: string;\r\n}\r\n\r\nexport interface IProductWake {\r\n ProdutoVarianteId: number;\r\n SKU: string;\r\n PrecoPor: number;\r\n PrecoDe: number;\r\n Quantidade: number;\r\n Ajustes: IAjustes[];\r\n}\r\n\r\nexport interface ICustomer {\r\n birthDate: string;\r\n document: string;\r\n name: string;\r\n phone: string;\r\n}\r\n\r\nexport interface IProccesPinBonusDto {\r\n storeName: string;\r\n name: string;\r\n checkoutId: string;\r\n checkoutProducts: Array<IProduct>;\r\n storeId: string;\r\n userId: string;\r\n cellphone: number;\r\n pin: string;\r\n\r\n}\r\n\r\nexport interface IBonus {\r\n hasBonus: boolean;\r\n bonusBalance: number;\r\n totalBonus: number;\r\n minimumPurchase: number;\r\n bonusIds: string;\r\n firstValidityDate: string\r\n history: [\r\n {\r\n validityStart: string;\r\n validityEnd: string;\r\n value: number\r\n },\r\n {\r\n validityStart: string;\r\n validityEnd: string\r\n value: number\r\n }\r\n ]\r\n storeId: number;\r\n userId: number;\r\n cartId: string\r\n calculatedValue: number;\r\n totalValue: number\r\n}\r\n\r\n\r\nexport interface IReserveDTO {\r\n storeName: string;\r\n cartId: string;\r\n grossValue: number;\r\n redeemedBonus: number;\r\n ticket: string;\r\n storeId: string;\r\n userId: number;\r\n}"]}
|
@@ -7,6 +7,8 @@ export function buildProductsByWake(productsWake = []) {
|
|
7
7
|
var value = (pw.PrecoDe * pw.Quantidade);
|
8
8
|
var originalValue = (pw.PrecoDe * pw.Quantidade);
|
9
9
|
var discounts_value = (discounts * -1);
|
10
|
+
const existsPromotionProduct = pw.Ajustes.filter(adj => [AjustesTipoEnum.PP].includes(adj.Tipo));
|
11
|
+
const promotion_product = (existsPromotionProduct.length > 0);
|
10
12
|
products.push({
|
11
13
|
sku: pw.SKU,
|
12
14
|
value: value,
|
@@ -14,6 +16,7 @@ export function buildProductsByWake(productsWake = []) {
|
|
14
16
|
productVariantId: pw.ProdutoVarianteId.toString(),
|
15
17
|
quantity: pw.Quantidade,
|
16
18
|
discount: value < discounts_value ? value : discounts_value,
|
19
|
+
promotion_product
|
17
20
|
});
|
18
21
|
}
|
19
22
|
return products;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"build.payload.helper.js","sourceRoot":"","sources":["../../../src/helpers/build.payload.helper.ts"],"names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4D;AAC5D,kDAAkD;AAClD,YAAY;AACZ,QAAQ;AAER,wBAAwB;AACxB,IAAI","sourcesContent":["import { AjustesTipoEnum, IAjustes, IProduct, IProductWake } from \"../dto/validate.pin.bonus\";\r\n\r\nexport function buildProductsByWake(productsWake: Array<IProductWake> = []): Array<IProduct> {\r\n\r\n const products: Array<IProduct> = [];\r\n\r\n for ( const pw of productsWake ) {\r\n let discounts = getDiscount(pw.Ajustes)\r\n // let discounts_formula = getDiscountFormula(pw.Ajustes);\r\n\r\n var value = (pw.PrecoDe * pw.Quantidade);\r\n var originalValue = (pw.PrecoDe * pw.Quantidade);\r\n\r\n var discounts_value = (discounts * -1)\r\n\r\n const existsPromotionProduct = pw.Ajustes.filter(adj => [AjustesTipoEnum.PP].includes(adj.Tipo))\r\n\r\n const promotion_product = (existsPromotionProduct.length > 0)\r\n\r\n products.push(\r\n {\r\n sku: pw.SKU,\r\n value: value,\r\n originalValue: originalValue,\r\n productVariantId: pw.ProdutoVarianteId.toString(),\r\n quantity: pw.Quantidade,\r\n discount: value < discounts_value ? value : discounts_value,\r\n promotion_product\r\n }\r\n )\r\n }\r\n\r\n return products;\r\n}\r\n\r\nfunction getDiscount(ajustes: IAjustes[] = []) {\r\n \r\n let discounts = 0;\r\n \r\n for(const discount of ajustes) {\r\n if([AjustesTipoEnum.P, AjustesTipoEnum.CC, AjustesTipoEnum.PP].includes(discount.Tipo)) {\r\n discounts += discount.Valor;\r\n }\r\n }\r\n\r\n return discounts;\r\n}\r\n\r\n// function getDiscountFormula(ajustes: IAjustes[] = []) {\r\n \r\n// let discounts = 0;\r\n \r\n// for(const discount of ajustes) {\r\n// if([AjustesTipoEnum.F].includes(discount.Tipo)) {\r\n// discounts += (discount.Valor * -1);\r\n// }\r\n// }\r\n\r\n// return discounts;\r\n// }"]}
|