crmbonus-component-wake 2.0.114-custom.1 → 2.0.115
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/cart.helper-6a0021b4.js +49 -0
- package/dist/cjs/cart.helper-6a0021b4.js.map +1 -0
- package/dist/cjs/crm-bonus-form.cjs.entry.js +1 -1
- package/dist/cjs/crm-bonus-note.cjs.entry.js +13 -11
- package/dist/cjs/crm-bonus-note.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-bonus.cjs.entry.js +40 -50
- package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-giftback-form_2.cjs.entry.js +1 -1
- package/dist/cjs/crmbonus-component-wake.cjs.js +1 -1
- package/dist/cjs/{crmbonus.service-c3953094.js → crmbonus.service-a4a07c28.js} +3 -2
- package/dist/cjs/crmbonus.service-a4a07c28.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pedido-finalizado.cjs.entry.js +13 -12
- package/dist/cjs/pedido-finalizado.cjs.entry.js.map +1 -1
- package/dist/collection/components/crm-bonus/crm-bonus.js +42 -136
- package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
- package/dist/collection/components/note/crm-bonus-note.js +13 -49
- package/dist/collection/components/note/crm-bonus-note.js.map +1 -1
- package/dist/collection/components/pedido/pedido.js +12 -68
- package/dist/collection/components/pedido/pedido.js.map +1 -1
- package/dist/collection/dto/validate.pin.bonus.js.map +1 -1
- package/dist/collection/helpers/cart.helper.js +20 -0
- package/dist/collection/helpers/cart.helper.js.map +1 -0
- package/dist/collection/objectvalues/cart.wake.js +24 -0
- package/dist/collection/objectvalues/cart.wake.js.map +1 -0
- package/dist/collection/services/crmbonus.service.js +1 -0
- package/dist/collection/services/crmbonus.service.js.map +1 -1
- package/dist/components/crm-bonus-form.js +1 -1
- package/dist/components/crm-bonus-note.js +13 -13
- package/dist/components/crm-bonus-note.js.map +1 -1
- package/dist/components/crm-bonus.js +42 -58
- package/dist/components/crm-bonus.js.map +1 -1
- package/dist/components/crm-giftback-form.js +1 -1
- package/dist/components/{p-f9c5e669.js → p-7f0cb052.js} +2 -2
- package/dist/components/{p-f9c5e669.js.map → p-7f0cb052.js.map} +1 -1
- package/dist/components/p-8179aaa5.js +47 -0
- package/dist/components/p-8179aaa5.js.map +1 -0
- package/dist/components/{p-e16ea64c.js → p-fd62879e.js} +3 -2
- package/dist/components/p-fd62879e.js.map +1 -0
- package/dist/components/pedido-finalizado.js +14 -17
- package/dist/components/pedido-finalizado.js.map +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-289a892a.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-289a892a.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/{p-b8376e7a.entry.js → p-4f47b32c.entry.js} +2 -2
- package/dist/crmbonus-component-wake/{p-57eff4fa.entry.js → p-51a4fdbf.entry.js} +2 -2
- package/dist/crmbonus-component-wake/p-8179aaa5.js +2 -0
- package/dist/crmbonus-component-wake/p-8179aaa5.js.map +1 -0
- package/dist/crmbonus-component-wake/p-a11e6510.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-a11e6510.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-e85698cd.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-e85698cd.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/{p-e16ea64c.js → p-fd62879e.js} +2 -2
- package/dist/crmbonus-component-wake/{p-e16ea64c.js.map → p-fd62879e.js.map} +1 -1
- package/dist/env.js +1 -1
- package/dist/env.js.map +1 -1
- package/dist/esm/cart.helper-dfef7b74.js +47 -0
- package/dist/esm/cart.helper-dfef7b74.js.map +1 -0
- package/dist/esm/crm-bonus-form.entry.js +1 -1
- package/dist/esm/crm-bonus-note.entry.js +13 -11
- package/dist/esm/crm-bonus-note.entry.js.map +1 -1
- package/dist/esm/crm-bonus.entry.js +40 -50
- package/dist/esm/crm-bonus.entry.js.map +1 -1
- package/dist/esm/crm-giftback-form_2.entry.js +1 -1
- package/dist/esm/crmbonus-component-wake.js +1 -1
- package/dist/esm/{crmbonus.service-fc7d9fdc.js → crmbonus.service-31fd796c.js} +3 -2
- package/dist/esm/crmbonus.service-31fd796c.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pedido-finalizado.entry.js +13 -12
- package/dist/esm/pedido-finalizado.entry.js.map +1 -1
- package/dist/types/components/crm-bonus/crm-bonus.d.ts +4 -8
- package/dist/types/components/note/crm-bonus-note.d.ts +3 -3
- package/dist/types/components/pedido/pedido.d.ts +1 -3
- package/dist/types/components.d.ts +1 -19
- package/dist/types/dto/validate.pin.bonus.d.ts +6 -0
- package/dist/types/helpers/cart.helper.d.ts +2 -0
- package/dist/types/home/darlison/Projects/Bycoders/crmbonus/crmbonus-component/.stencil/env.d.ts +1 -1
- package/dist/types/objectvalues/cart.wake.d.ts +12 -0
- package/package.json +1 -1
- package/dist/cjs/crmbonus.service-c3953094.js.map +0 -1
- package/dist/components/p-e16ea64c.js.map +0 -1
- package/dist/crmbonus-component-wake/p-27a96c29.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-27a96c29.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-3646705b.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-3646705b.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-7751b4be.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-7751b4be.entry.js.map +0 -1
- package/dist/esm/crmbonus.service-fc7d9fdc.js.map +0 -1
- /package/dist/crmbonus-component-wake/{p-b8376e7a.entry.js.map → p-4f47b32c.entry.js.map} +0 -0
- /package/dist/crmbonus-component-wake/{p-57eff4fa.entry.js.map → p-51a4fdbf.entry.js.map} +0 -0
@@ -3,31 +3,32 @@
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
5
|
const index = require('./index-d11684bd.js');
|
6
|
-
const crmbonus_service = require('./crmbonus.service-
|
6
|
+
const crmbonus_service = require('./crmbonus.service-a4a07c28.js');
|
7
|
+
const cart_helper = require('./cart.helper-6a0021b4.js');
|
7
8
|
require('./keys.storage-de7744aa.js');
|
8
9
|
|
9
10
|
const Pedido = class {
|
10
11
|
constructor(hostRef) {
|
11
12
|
index.registerInstance(this, hostRef);
|
12
|
-
this.cartId = undefined;
|
13
|
-
this.orderId = undefined;
|
14
|
-
this.metadadoString = undefined;
|
15
13
|
}
|
16
14
|
async componentWillLoad() {
|
17
|
-
|
18
|
-
|
15
|
+
await this.handleOrder();
|
16
|
+
}
|
17
|
+
async handleOrder() {
|
18
|
+
const cart = await cart_helper.getCart();
|
19
|
+
if (cart.id && cart.orderId) {
|
19
20
|
crmbonus_service.CrmBonusService.getInstance().updateOrder({
|
20
|
-
cartId:
|
21
|
-
orderId:
|
22
|
-
cartIdCrm:
|
21
|
+
cartId: cart.id,
|
22
|
+
orderId: cart.orderId,
|
23
|
+
cartIdCrm: cart.middlewareId
|
23
24
|
});
|
24
|
-
const key = `bc-products:${
|
25
|
+
const key = `bc-products:${cart.id}`;
|
25
26
|
localStorage.removeItem(key);
|
26
|
-
localStorage.removeItem(
|
27
|
+
localStorage.removeItem(cart.id);
|
27
28
|
}
|
28
29
|
}
|
29
30
|
render() {
|
30
|
-
return (index.h("div", { key: '
|
31
|
+
return (index.h("div", { key: 'b5d23baa12ed65a426ff01a351aa43559c30bc81' }));
|
31
32
|
}
|
32
33
|
};
|
33
34
|
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"pedido-finalizado.entry.cjs.js","mappings":"
|
1
|
+
{"file":"pedido-finalizado.entry.cjs.js","mappings":";;;;;;;;;MAOa,MAAM;;;;IAEf,MAAM,iBAAiB;QACnB,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;KAC3B;IAED,MAAM,WAAW;QACb,MAAM,IAAI,GAAG,MAAMA,mBAAO,EAAE,CAAC;QAE7B,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE;YACzBC,gCAAe,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC;gBACtC,MAAM,EAAE,IAAI,CAAC,EAAE;gBACf,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,SAAS,EAAE,IAAI,CAAC,YAAY;aAC/B,CAAC,CAAC;YAEH,MAAM,GAAG,GAAG,eAAe,IAAI,CAAC,EAAE,EAAE,CAAC;YACrC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC7B,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACpC;KACJ;IAED,MAAM;QACF,QACIC,mEAAW,EACd;KACJ;;;;;","names":["getCart","CrmBonusService","h"],"sources":["src/components/pedido/pedido.tsx"],"sourcesContent":["import { Component, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { getCart } from \"../../helpers/cart.helper\";\n\n@Component({\n tag: \"pedido-finalizado\"\n})\nexport class Pedido {\n\n async componentWillLoad() {\n await this.handleOrder()\n }\n\n async handleOrder() {\n const cart = await getCart();\n\n if (cart.id && cart.orderId) {\n CrmBonusService.getInstance().updateOrder({\n cartId: cart.id,\n orderId: cart.orderId,\n cartIdCrm: cart.middlewareId\n });\n\n const key = `bc-products:${cart.id}`;\n localStorage.removeItem(key);\n localStorage.removeItem(cart.id);\n }\n }\n\n render() {\n return (\n <div></div>\n )\n }\n}"],"version":3}
|
@@ -3,15 +3,12 @@ import { CrmBonusService } from "../../services/crmbonus.service";
|
|
3
3
|
import { StepFormEnum } from "../../contants";
|
4
4
|
import i18next from "../../i18n/i18n";
|
5
5
|
import { buildProductsByWake } from "../../helpers/build.payload.helper";
|
6
|
+
import { getCart } from "../../helpers/cart.helper";
|
6
7
|
export class CrmBonus {
|
7
8
|
constructor() {
|
8
9
|
this.crmBonusService = CrmBonusService.getInstance();
|
9
10
|
this.showModal = false;
|
10
|
-
this.
|
11
|
-
this.storeName = undefined;
|
12
|
-
this.productsInString = undefined;
|
13
|
-
this.cartId = undefined;
|
14
|
-
this.products = undefined;
|
11
|
+
this.cartWake = undefined;
|
15
12
|
this.customer = {
|
16
13
|
birthDate: "",
|
17
14
|
document: "",
|
@@ -29,10 +26,6 @@ export class CrmBonus {
|
|
29
26
|
}
|
30
27
|
async resetBonus() {
|
31
28
|
console.log('[START RESET BONUS]!!!!!');
|
32
|
-
// const used = localStorage.getItem("bc:used");
|
33
|
-
// if (used == "use") {
|
34
|
-
// await this.crmBonusService.cancelBonus(this.cartId, this.storeName);
|
35
|
-
// }
|
36
29
|
try {
|
37
30
|
await this.crmBonusRef.processBonus(this.buildProducts(), true);
|
38
31
|
console.log('[BONUS RESETADO]!!!!!');
|
@@ -46,11 +39,11 @@ export class CrmBonus {
|
|
46
39
|
this.loading = false;
|
47
40
|
}
|
48
41
|
}
|
49
|
-
async reprocess(
|
42
|
+
async reprocess() {
|
50
43
|
this.loading_reprocess = true;
|
51
44
|
try {
|
52
|
-
this.
|
53
|
-
|
45
|
+
this.cartWake = await getCart();
|
46
|
+
console.log('cart', this.cartWake);
|
54
47
|
await this.resetBonus();
|
55
48
|
}
|
56
49
|
catch (err) {
|
@@ -60,59 +53,59 @@ export class CrmBonus {
|
|
60
53
|
this.loading_reprocess = false;
|
61
54
|
}
|
62
55
|
}
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
}
|
56
|
+
// @Watch("productsInString")
|
57
|
+
// async watchProducts(newValue: string) {
|
58
|
+
// try {
|
59
|
+
// console.log('[update products list]');
|
60
|
+
// this.productsInString = newValue;
|
61
|
+
// await this.handleLoad();
|
62
|
+
// await this.resetBonus();
|
63
|
+
// } catch (err) {
|
64
|
+
// console.debug('[watchProducts]', err.message);
|
65
|
+
// }
|
66
|
+
// }
|
74
67
|
async componentWillLoad() {
|
75
68
|
i18next.changeLanguage(i18next.language);
|
69
|
+
await this.handleLoad();
|
76
70
|
await this.loadSession();
|
77
71
|
await this.loadConfigStore();
|
78
|
-
await this.handleLoad();
|
79
72
|
}
|
80
73
|
async loadConfigStore() {
|
81
|
-
await this.crmBonusService.getCustomization(this.
|
74
|
+
await this.crmBonusService.getCustomization(this.cartWake.store.name);
|
82
75
|
}
|
83
76
|
async handleLoad() {
|
84
77
|
try {
|
85
|
-
|
86
|
-
|
78
|
+
this.cartWake = await getCart();
|
79
|
+
console.log('cart', this.cartWake);
|
80
|
+
if (this.cartWake.user.id) {
|
81
|
+
this.customer = await this.crmBonusService.getCustomer(this.cartWake.user.id, this.cartWake.store.name);
|
87
82
|
console.log('customer', this.customer);
|
88
83
|
}
|
89
|
-
const amount = localStorage.getItem(this.
|
84
|
+
const amount = localStorage.getItem(this.cartWake.id);
|
90
85
|
if (amount) {
|
91
86
|
this.canCancel = true;
|
92
87
|
this.amountCancel = amount;
|
93
88
|
}
|
89
|
+
await this.buildAndGetProducts(this.cartWake.products);
|
94
90
|
}
|
95
91
|
catch (error) {
|
96
92
|
console.log('info customer');
|
97
93
|
}
|
98
|
-
await this.buildAndGetProducts();
|
99
94
|
}
|
100
95
|
async loadSession() {
|
101
|
-
this.
|
96
|
+
console.log('this.storeName', this.cartWake.store.name);
|
97
|
+
this.session = await this.crmBonusService.getToken(this.cartWake.store.name);
|
102
98
|
setTimeout(() => {
|
103
99
|
this.loadSession();
|
104
100
|
}, 1500000);
|
105
101
|
}
|
106
|
-
async buildAndGetProducts() {
|
107
|
-
const key = `bc-products:${this.
|
108
|
-
const
|
109
|
-
|
110
|
-
this.productsInString = JSON.stringify(cart.Produtos);
|
111
|
-
localStorage.setItem(key, this.productsInString);
|
112
|
-
const productsInCart = JSON.parse(this.productsInString);
|
102
|
+
async buildAndGetProducts(productsWake) {
|
103
|
+
const key = `bc-products:${this.cartWake.id}`;
|
104
|
+
const productsString = JSON.stringify(productsWake);
|
105
|
+
localStorage.setItem(key, productsString);
|
113
106
|
const products_in_cache = JSON.parse(localStorage.getItem(key));
|
114
107
|
const products = [];
|
115
|
-
for (const product_cart of
|
108
|
+
for (const product_cart of productsWake) {
|
116
109
|
const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId);
|
117
110
|
const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === "Formula");
|
118
111
|
if (pro) {
|
@@ -122,7 +115,7 @@ export class CrmBonus {
|
|
122
115
|
products.push(product_cart);
|
123
116
|
}
|
124
117
|
}
|
125
|
-
this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);
|
118
|
+
this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);
|
126
119
|
}
|
127
120
|
async sendPin(phone) {
|
128
121
|
var _a, _b;
|
@@ -131,7 +124,7 @@ export class CrmBonus {
|
|
131
124
|
try {
|
132
125
|
const _phone = phone.replace(/\D/g, '');
|
133
126
|
this.phone = Number(_phone);
|
134
|
-
this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.
|
127
|
+
this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
|
135
128
|
;
|
136
129
|
await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);
|
137
130
|
this.showModal = true;
|
@@ -149,8 +142,7 @@ export class CrmBonus {
|
|
149
142
|
this.message = "";
|
150
143
|
try {
|
151
144
|
this.customer.name = customerName;
|
152
|
-
this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.
|
153
|
-
;
|
145
|
+
this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);
|
154
146
|
await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);
|
155
147
|
this.showModal = true;
|
156
148
|
}
|
@@ -162,13 +154,13 @@ export class CrmBonus {
|
|
162
154
|
}
|
163
155
|
}
|
164
156
|
buildProducts() {
|
165
|
-
return buildProductsByWake(this.products);
|
157
|
+
return buildProductsByWake(this.cartWake.products);
|
166
158
|
}
|
167
159
|
handleCloseModal() {
|
168
160
|
this.showModal = false;
|
169
161
|
}
|
170
162
|
save(amount) {
|
171
|
-
localStorage.setItem(this.
|
163
|
+
localStorage.setItem(this.cartWake.id, amount.toString());
|
172
164
|
this.canCancel = true;
|
173
165
|
this.amountCancel = amount.toString();
|
174
166
|
}
|
@@ -176,9 +168,9 @@ export class CrmBonus {
|
|
176
168
|
this.message = "";
|
177
169
|
this.loading = true;
|
178
170
|
try {
|
179
|
-
await this.crmBonusService.cancel(this.
|
171
|
+
await this.crmBonusService.cancel(this.cartWake.id);
|
180
172
|
this.canCancel = false;
|
181
|
-
localStorage.removeItem(this.
|
173
|
+
localStorage.removeItem(this.cartWake.id);
|
182
174
|
}
|
183
175
|
catch (error) {
|
184
176
|
this.message = "Não consegui cancelar o bônus, tente novamente!";
|
@@ -203,7 +195,7 @@ export class CrmBonus {
|
|
203
195
|
this.showModal = true;
|
204
196
|
}
|
205
197
|
render() {
|
206
|
-
return (h("loading-container", { key: '
|
198
|
+
return (h("loading-container", { key: '67b0c86da1b59ec891a48bfcd4d7b0572c322cee', loading: this.loading_reprocess }, h("crm-giftback-form", { key: '59cddeaba1f47ea10aaa20371b33892b9b555304', 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() })));
|
207
199
|
}
|
208
200
|
static get is() { return "crm-bonus"; }
|
209
201
|
static get encapsulation() { return "scoped"; }
|
@@ -218,82 +210,10 @@ export class CrmBonus {
|
|
218
210
|
};
|
219
211
|
}
|
220
212
|
static get assetsDirs() { return ["assets"]; }
|
221
|
-
static get properties() {
|
222
|
-
return {
|
223
|
-
"userId": {
|
224
|
-
"type": "number",
|
225
|
-
"mutable": false,
|
226
|
-
"complexType": {
|
227
|
-
"original": "number",
|
228
|
-
"resolved": "number",
|
229
|
-
"references": {}
|
230
|
-
},
|
231
|
-
"required": false,
|
232
|
-
"optional": false,
|
233
|
-
"docs": {
|
234
|
-
"tags": [],
|
235
|
-
"text": ""
|
236
|
-
},
|
237
|
-
"attribute": "userid",
|
238
|
-
"reflect": false
|
239
|
-
},
|
240
|
-
"storeName": {
|
241
|
-
"type": "any",
|
242
|
-
"mutable": false,
|
243
|
-
"complexType": {
|
244
|
-
"original": "any",
|
245
|
-
"resolved": "any",
|
246
|
-
"references": {}
|
247
|
-
},
|
248
|
-
"required": false,
|
249
|
-
"optional": false,
|
250
|
-
"docs": {
|
251
|
-
"tags": [],
|
252
|
-
"text": ""
|
253
|
-
},
|
254
|
-
"attribute": "storename",
|
255
|
-
"reflect": false
|
256
|
-
},
|
257
|
-
"productsInString": {
|
258
|
-
"type": "string",
|
259
|
-
"mutable": false,
|
260
|
-
"complexType": {
|
261
|
-
"original": "string",
|
262
|
-
"resolved": "string",
|
263
|
-
"references": {}
|
264
|
-
},
|
265
|
-
"required": false,
|
266
|
-
"optional": false,
|
267
|
-
"docs": {
|
268
|
-
"tags": [],
|
269
|
-
"text": ""
|
270
|
-
},
|
271
|
-
"attribute": "products",
|
272
|
-
"reflect": false
|
273
|
-
},
|
274
|
-
"cartId": {
|
275
|
-
"type": "any",
|
276
|
-
"mutable": false,
|
277
|
-
"complexType": {
|
278
|
-
"original": "any",
|
279
|
-
"resolved": "any",
|
280
|
-
"references": {}
|
281
|
-
},
|
282
|
-
"required": false,
|
283
|
-
"optional": false,
|
284
|
-
"docs": {
|
285
|
-
"tags": [],
|
286
|
-
"text": ""
|
287
|
-
},
|
288
|
-
"attribute": "cartid",
|
289
|
-
"reflect": false
|
290
|
-
}
|
291
|
-
};
|
292
|
-
}
|
293
213
|
static get states() {
|
294
214
|
return {
|
295
215
|
"showModal": {},
|
296
|
-
"
|
216
|
+
"cartWake": {},
|
297
217
|
"customer": {},
|
298
218
|
"loading": {},
|
299
219
|
"message": {},
|
@@ -326,20 +246,12 @@ export class CrmBonus {
|
|
326
246
|
},
|
327
247
|
"reprocess": {
|
328
248
|
"complexType": {
|
329
|
-
"signature": "(
|
330
|
-
"parameters": [
|
331
|
-
"name": "products",
|
332
|
-
"type": "any[]",
|
333
|
-
"docs": ""
|
334
|
-
}],
|
249
|
+
"signature": "() => Promise<void>",
|
250
|
+
"parameters": [],
|
335
251
|
"references": {
|
336
252
|
"Promise": {
|
337
253
|
"location": "global",
|
338
254
|
"id": "global::Promise"
|
339
|
-
},
|
340
|
-
"Array": {
|
341
|
-
"location": "global",
|
342
|
-
"id": "global::Array"
|
343
255
|
}
|
344
256
|
},
|
345
257
|
"return": "Promise<void>"
|
@@ -351,11 +263,5 @@ export class CrmBonus {
|
|
351
263
|
}
|
352
264
|
};
|
353
265
|
}
|
354
|
-
static get watchers() {
|
355
|
-
return [{
|
356
|
-
"propName": "productsInString",
|
357
|
-
"methodName": "watchProducts"
|
358
|
-
}];
|
359
|
-
}
|
360
266
|
}
|
361
267
|
//# sourceMappingURL=crm-bonus.js.map
|
@@ -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,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,OAAO,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAQzE,MAAM,OAAO,QAAQ;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IA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GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,GAExC,CACgB,CACrB,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Method, Prop, State, Watch, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n // const used = localStorage.getItem(\"bc:used\");\n\n // if (used == \"use\") {\n // await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n // }\n\n try {\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async reprocess(products: Array<any>) {\n this.loading_reprocess = true\n\n try {\n this.productsInString = JSON.stringify(products);\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n @Watch(\"productsInString\")\n async watchProducts(newValue: string) {\n try {\n console.log('[update products list]');\n this.productsInString = newValue;\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n }\n }\n\n async componentWillLoad() {\n i18next.changeLanguage(i18next.language);\n\n await this.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n console.log('customer', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n await this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n\n const key = `bc-products:${this.cartId}`;\n \n const baseUrl = window.location.origin; //\"https://bycoders.fbits.store\" //window.location.origin;\n \n const cart = await this.crmBonusService.getInfoCart(baseUrl);\n\n this.productsInString = JSON.stringify(cart.Produtos)\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n const [ ajuste = { Valor:0 } ] = pro.Ajustes.filter( aj => aj.Tipo === \"Formula\" )\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor + (ajuste.Valor * -1),\n Quantidade: pro.Quantidade,\n Ajustes: pro.Ajustes\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return buildProductsByWake(this.products);\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n loadProducts={() => this.buildProducts()}\n \n />\n </loading-container>\n )\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"crm-bonus.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus/crm-bonus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAQ,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,OAAO,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AASpD,MAAM,OAAO,QAAQ;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,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;;IAGlC,KAAK,CAAC,UAAU;QACd,OAAO,CAAC,GAAG,C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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,GAExC,CACgB,CACrB,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Method, Prop, State, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\nimport { getCart } from '../../helpers/cart.helper';\nimport { CartWake } from '../../objectvalues/cart.wake';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @State() showModal: boolean = false;\n \n @State() cartWake: CartWake;\n \n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n \n try {\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async reprocess() {\n this.loading_reprocess = true\n\n try {\n\n this.cartWake = await getCart();\n\n console.log('cart', this.cartWake)\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n // @Watch(\"productsInString\")\n // async watchProducts(newValue: string) {\n // try {\n // console.log('[update products list]');\n // this.productsInString = newValue;\n // await this.handleLoad();\n\n // await this.resetBonus();\n // } catch (err) {\n // console.debug('[watchProducts]', err.message);\n // }\n // }\n\n async componentWillLoad() {\n i18next.changeLanguage(i18next.language);\n\n await this.handleLoad();\n\n await this.loadSession();\n await this.loadConfigStore()\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.cartWake.store.name);\n }\n\n async handleLoad() {\n try {\n\n this.cartWake = await getCart();\n\n console.log('cart', this.cartWake)\n\n if (this.cartWake.user.id) {\n this.customer = await this.crmBonusService.getCustomer(this.cartWake.user.id, this.cartWake.store.name);\n console.log('customer', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartWake.id);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n await this.buildAndGetProducts(this.cartWake.products);\n } catch (error) {\n console.log('info customer')\n }\n }\n\n async loadSession() {\n console.log('this.storeName', this.cartWake.store.name)\n this.session = await this.crmBonusService.getToken(this.cartWake.store.name);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts(productsWake: IProductWake[]) {\n\n const key = `bc-products:${this.cartWake.id}`;\n\n const productsString = JSON.stringify(productsWake)\n\n localStorage.setItem(key, productsString);\n\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsWake) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n const [ajuste = { Valor: 0 }] = pro.Ajustes.filter(aj => aj.Tipo === \"Formula\")\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor + (ajuste.Valor * -1),\n Quantidade: pro.Quantidade,\n Ajustes: pro.Ajustes\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.cartWake.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.cartWake.store.name);\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return buildProductsByWake(this.cartWake.products);\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartWake.id, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartWake.id);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartWake.id);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.cartWake.store.name}\n products={this.buildProducts()}\n cartId={this.cartWake.id}\n customer={this.customer}\n loadProducts={() => this.buildProducts()}\n\n />\n </loading-container>\n )\n }\n}\n"]}
|
@@ -4,10 +4,10 @@ import money from "../../assets/svg/money-dollars-svgrepo-com.svg";
|
|
4
4
|
import { getKeyReserveByCartId } from "../../utils/keys.storage";
|
5
5
|
import i18next from "../../i18n/i18n";
|
6
6
|
import { setTime } from "../../helpers/time.helper";
|
7
|
+
import { getCart } from "../../helpers/cart.helper";
|
7
8
|
export class CrmBonusNote {
|
8
9
|
constructor() {
|
9
|
-
this.
|
10
|
-
this.storename = undefined;
|
10
|
+
this.cartWake = undefined;
|
11
11
|
this.url = undefined;
|
12
12
|
this.config = undefined;
|
13
13
|
this.bonus = undefined;
|
@@ -17,8 +17,9 @@ export class CrmBonusNote {
|
|
17
17
|
this.upadateCheckToFreteAndGetUrl();
|
18
18
|
this.startTime();
|
19
19
|
}
|
20
|
-
upadateCheckToFreteAndGetUrl() {
|
21
|
-
this.
|
20
|
+
async upadateCheckToFreteAndGetUrl() {
|
21
|
+
this.cartWake = await getCart();
|
22
|
+
this.config = getInfoCustomization(this.cartWake.store.name);
|
22
23
|
const envios = document.getElementsByName('forma-envio');
|
23
24
|
envios.forEach((envio) => {
|
24
25
|
envio.checked = false;
|
@@ -26,11 +27,11 @@ export class CrmBonusNote {
|
|
26
27
|
this.url = window.location.origin;
|
27
28
|
}
|
28
29
|
handleHide() {
|
29
|
-
const amount = localStorage.getItem(this.
|
30
|
+
const amount = localStorage.getItem(this.cartWake.id);
|
30
31
|
return !!amount;
|
31
32
|
}
|
32
33
|
getAmount() {
|
33
|
-
const amount = localStorage.getItem(this.
|
34
|
+
const amount = localStorage.getItem(this.cartWake.id);
|
34
35
|
return amount ? Number(amount).toFixed(2).replace(".", ",") || "0,00" : "0,00";
|
35
36
|
}
|
36
37
|
async backCart() {
|
@@ -45,7 +46,7 @@ export class CrmBonusNote {
|
|
45
46
|
}
|
46
47
|
}
|
47
48
|
hasBonus() {
|
48
|
-
const _bonus = localStorage.getItem(getKeyReserveByCartId(this.
|
49
|
+
const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartWake.id));
|
49
50
|
const info = {
|
50
51
|
hasBonus: false,
|
51
52
|
requestBonus: false
|
@@ -64,10 +65,10 @@ export class CrmBonusNote {
|
|
64
65
|
render() {
|
65
66
|
const giftbackname = this.config.giftbackTitle || "Giftback";
|
66
67
|
const infobonus = this.hasBonus();
|
67
|
-
return (h("div", { key: '
|
68
|
-
(h("p", { key: '
|
69
|
-
(h("p", { key: '
|
70
|
-
(h("div", { key: '
|
68
|
+
return (h("div", { key: '03718ce8adc7ff0e5db68dfe7a47e504e4da501c' }, h("div", { key: '152dfe88a0f532efdf57fbf72788a7ac1ab4f94a', class: "note-container" }, h("div", { key: '4c7f76fb6086b04efbc566247f33ac6f4420e6f5', class: "note-header" }, h("p", { key: 'cc62523e813d228025a78ca494cea0d8421a5fdc', class: "note-title" }, h("img", { key: '2b0ed0424cf21da3d5844b76834041d9450a7eb8', src: money, width: 23 }), this.config.giftbackTitle), infobonus.hasBonus && (h("div", { key: '471194982ce8d9aa88a2651120519a090c54e79d' }, this.showEdit && (h("p", { key: '0121fe033d2e5ab0582d04c2c3b9d146bb16cb50', class: "back-cart", onClick: () => this.backCart() }, i18next.t("edit"))), !this.showEdit && h("countdown-timer", { key: 'fb07477025913752e56178b0f30efdf3e64ff553', initialValue: this.getTime(), downtime: () => { this.showEdit = true; } })))), infobonus.hasBonus &&
|
69
|
+
(h("p", { key: '2cbf881eed3bf44dd5ef8a3196cbee23ae8757a3', class: "note-description-2" }, i18next.t("withApplyBonus", { giftbackname: giftbackname }), " ", h("strong", { key: 'be66439d229a2d9c653b6c8326bc8439e25a0add' }, "R$ ", this.getAmount(), "."))), (infobonus.requestBonus && !infobonus.hasBonus) &&
|
70
|
+
(h("p", { key: '1305b882c7adba7d58834d8f287b0a1ae6e79841', class: "note-description-not" }, i18next.t("noBonus", { giftbackname: giftbackname }))), !infobonus.requestBonus &&
|
71
|
+
(h("div", { key: '0c14d537a581d8692e76e9400b86f6bc336126ec', class: "description" }, h("p", { key: '42560579e7f3b379df64bb1262f3cf35166e969a', class: "note-description-not" }, i18next.t("backCart")), h("crm-button", { key: '64d3ee4b62bac23186e97778e8644c65ac6e06c6', txtBtn: "VOLTAR AO CARRINHO", handleClick: () => this.backCart() }))))));
|
71
72
|
}
|
72
73
|
static get is() { return "crm-bonus-note"; }
|
73
74
|
static get originalStyleUrls() {
|
@@ -80,46 +81,9 @@ export class CrmBonusNote {
|
|
80
81
|
"$": ["crm-bonus-note.css"]
|
81
82
|
};
|
82
83
|
}
|
83
|
-
static get properties() {
|
84
|
-
return {
|
85
|
-
"cartId": {
|
86
|
-
"type": "any",
|
87
|
-
"mutable": false,
|
88
|
-
"complexType": {
|
89
|
-
"original": "any",
|
90
|
-
"resolved": "any",
|
91
|
-
"references": {}
|
92
|
-
},
|
93
|
-
"required": false,
|
94
|
-
"optional": false,
|
95
|
-
"docs": {
|
96
|
-
"tags": [],
|
97
|
-
"text": ""
|
98
|
-
},
|
99
|
-
"attribute": "cartid",
|
100
|
-
"reflect": false
|
101
|
-
},
|
102
|
-
"storename": {
|
103
|
-
"type": "any",
|
104
|
-
"mutable": false,
|
105
|
-
"complexType": {
|
106
|
-
"original": "any",
|
107
|
-
"resolved": "any",
|
108
|
-
"references": {}
|
109
|
-
},
|
110
|
-
"required": false,
|
111
|
-
"optional": false,
|
112
|
-
"docs": {
|
113
|
-
"tags": [],
|
114
|
-
"text": ""
|
115
|
-
},
|
116
|
-
"attribute": "storename",
|
117
|
-
"reflect": false
|
118
|
-
}
|
119
|
-
};
|
120
|
-
}
|
121
84
|
static get states() {
|
122
85
|
return {
|
86
|
+
"cartWake": {},
|
123
87
|
"url": {},
|
124
88
|
"config": {},
|
125
89
|
"bonus": {},
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"crm-bonus-note.js","sourceRoot":"","sources":["../../../../src/components/note/crm-bonus-note.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
1
|
+
{"version":3,"file":"crm-bonus-note.js","sourceRoot":"","sources":["../../../../src/components/note/crm-bonus-note.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAc,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAEpF,OAAO,KAAK,MAAM,gDAAgD,CAAA;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,OAAO,MAAM,iBAAiB,CAAA;AAErC,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAMpD,MAAM,OAAO,YAAY;;;;;;wBASQ,KAAK;;IAElC,iBAAiB;QACb,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACpC,IAAI,CAAC,SAAS,EAAE,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,4BAA4B;QAE9B,IAAI,CAAC,QAAQ,GAAG,MAAM,OAAO,EAAE,CAAC;QAEhC,IAAI,CAAC,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE7D,MAAM,MAAM,GAAG,QAAQ,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACzD,MAAM,CAAC,OAAO,CAAC,CAAC,KAAU,EAAE,EAAE;YAC1B,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;QAC1B,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;IACtC,CAAC;IAED,UAAU;QACN,MAAM,MAAM,GAAG,Y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I,0DAAG,KAAK,EAAC,sBAAsB,IAC1B,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC,CACrD,CACP;gBAID,CAAC,SAAS,CAAC,YAAY;oBACvB,CACI,4DAAK,KAAK,EAAC,aAAa;wBACpB,0DAAG,KAAK,EAAC,sBAAsB,IAC1B,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CACtB;wBACJ,mEAAY,MAAM,EAAC,oBAAoB,EAAC,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAI,CAC5E,CACT,CAMH,CACJ,CACT,CAAA;IACL,CAAC;;;;;;;;;;;;;;;CACJ","sourcesContent":["import { Component, Prop, State, h } from \"@stencil/core\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport money from '../../assets/svg/money-dollars-svgrepo-com.svg'\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\nimport i18next from \"../../i18n/i18n\"\nimport { IBonus } from \"../../components\";\nimport { setTime } from \"../../helpers/time.helper\";\nimport { CartWake } from \"../../objectvalues/cart.wake\";\nimport { getCart } from \"../../helpers/cart.helper\";\n\n@Component({\n tag: 'crm-bonus-note',\n styleUrl: 'crm-bonus-note.css'\n})\nexport class CrmBonusNote {\n\n @State() cartWake: CartWake;\n\n @State() url: string;\n @State() config: IInfoStore;\n\n @State() bonus: IBonus;\n\n @State() showEdit: boolean = false;\n\n componentWillLoad() {\n this.upadateCheckToFreteAndGetUrl();\n this.startTime();\n }\n\n async upadateCheckToFreteAndGetUrl() {\n\n this.cartWake = await getCart();\n\n this.config = getInfoCustomization(this.cartWake.store.name);\n\n const envios = document.getElementsByName('forma-envio');\n envios.forEach((envio: any) => {\n envio.checked = false;\n });\n\n this.url = window.location.origin;\n }\n\n handleHide() {\n const amount = localStorage.getItem(this.cartWake.id);\n return !!amount;\n }\n\n getAmount() {\n const amount = localStorage.getItem(this.cartWake.id);\n\n return amount ? Number(amount).toFixed(2).replace(\".\", \",\") || \"0,00\" : \"0,00\";\n }\n\n async backCart() {\n window.location.href = this.url;\n }\n\n\n private startTime() {\n if(document.location.pathname == '/Fechamento') {\n\n if(!localStorage.getItem(\"bc:time-allow\")) {\n localStorage.removeItem(\"bc:time\")\n }\n\n setTime();\n }\n }\n\n\n hasBonus() {\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartWake.id));\n\n const info = {\n hasBonus: false,\n requestBonus: false\n }\n\n if (_bonus) {\n this.bonus = JSON.parse(_bonus);\n info.hasBonus = this.bonus.hasBonus;\n info.requestBonus = true;\n }\n\n return info;\n }\n\n getTime() {\n const time = localStorage.getItem(\"bc:time\")\n \n return time ? Number(time) : 0;\n }\n\n render() {\n\n const giftbackname = this.config.giftbackTitle || \"Giftback\";\n\n const infobonus = this.hasBonus()\n\n return (\n <div>\n <div class=\"note-container\">\n <div class=\"note-header\">\n\n <p class=\"note-title\">\n <img src={money} width={23} />\n {this.config.giftbackTitle}\n </p>\n {\n infobonus.hasBonus && (\n <div>\n {this.showEdit && (\n <p class=\"back-cart\" onClick={() => this.backCart()}>\n {i18next.t(\"edit\")}\n </p>\n )}\n {!this.showEdit && <countdown-timer initialValue={this.getTime()} downtime={() => { this.showEdit = true }} />}\n </div>\n )\n }\n </div>\n\n {\n infobonus.hasBonus &&\n (\n <p class=\"note-description-2\">\n {i18next.t(\"withApplyBonus\", { giftbackname: giftbackname })} <strong>R$ {this.getAmount()}.</strong>\n </p>\n )\n }\n\n {\n (infobonus.requestBonus && !infobonus.hasBonus) &&\n (\n <p class=\"note-description-not\">\n {i18next.t(\"noBonus\", { giftbackname: giftbackname })}\n </p>\n )\n }\n\n {\n !infobonus.requestBonus &&\n (\n <div class=\"description\">\n <p class=\"note-description-not\">\n {i18next.t(\"backCart\")}\n </p>\n <crm-button txtBtn=\"VOLTAR AO CARRINHO\" handleClick={() => this.backCart()} />\n </div>\n )\n }\n\n {/* <a class=\"back-cart\" href={this.url}>\n Voltar ao carrinho\n </a> */}\n </div>\n </div>\n )\n }\n}"]}
|