crmbonus-component-wake 1.0.43 → 1.0.45
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/app-modal_4.cjs.entry.js +4 -6
- package/dist/cjs/app-modal_4.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-bonus.cjs.entry.js +10 -5
- package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -1
- package/dist/cjs/crmbonus-component-wake.cjs.js +1 -1
- package/dist/cjs/{crmbonus.service-ad521d7d.js → crmbonus.service-d804521b.js} +52 -15
- package/dist/cjs/crmbonus.service-d804521b.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pedido-finalizado.cjs.entry.js +3 -6
- package/dist/cjs/pedido-finalizado.cjs.entry.js.map +1 -1
- package/dist/collection/components/crm-bonus/crm-bonus.js +11 -5
- package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
- package/dist/collection/components/crm-bonus-form/crm-bonus-form.js +3 -5
- package/dist/collection/components/crm-bonus-form/crm-bonus-form.js.map +1 -1
- package/dist/collection/components/pedido/pedido.js +2 -5
- package/dist/collection/components/pedido/pedido.js.map +1 -1
- package/dist/collection/services/crmbonus.service.js +50 -13
- package/dist/collection/services/crmbonus.service.js.map +1 -1
- package/dist/components/crm-bonus-form.js +1 -1
- package/dist/components/crm-bonus.js +13 -7
- package/dist/components/crm-bonus.js.map +1 -1
- package/dist/components/{p-aeaad64e.js → p-96d4b7f8.js} +52 -15
- package/dist/components/p-96d4b7f8.js.map +1 -0
- package/dist/components/{p-0ebfe0d3.js → p-c3888e1e.js} +5 -7
- package/dist/components/p-c3888e1e.js.map +1 -0
- package/dist/components/pedido-finalizado.js +3 -6
- 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-64a22e59.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-64a22e59.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-75ba6bac.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-75ba6bac.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-9686d220.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-9686d220.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-96d4b7f8.js +2 -0
- package/dist/crmbonus-component-wake/p-96d4b7f8.js.map +1 -0
- package/dist/env.js +1 -1
- package/dist/env.js.map +1 -1
- package/dist/esm/app-modal_4.entry.js +4 -6
- package/dist/esm/app-modal_4.entry.js.map +1 -1
- package/dist/esm/crm-bonus.entry.js +10 -5
- package/dist/esm/crm-bonus.entry.js.map +1 -1
- package/dist/esm/crmbonus-component-wake.js +1 -1
- package/dist/esm/{crmbonus.service-dda2d96b.js → crmbonus.service-06ce5e98.js} +52 -15
- package/dist/esm/crmbonus.service-06ce5e98.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pedido-finalizado.entry.js +3 -6
- package/dist/esm/pedido-finalizado.entry.js.map +1 -1
- package/dist/types/components/crm-bonus/crm-bonus.d.ts +2 -0
- package/dist/types/home/darlison/Projects/crmbonus/app/crmbonus-component/.stencil/env.d.ts +1 -1
- package/dist/types/services/crmbonus.service.d.ts +6 -2
- package/package.json +1 -1
- package/dist/cjs/crmbonus.service-ad521d7d.js.map +0 -1
- package/dist/components/p-0ebfe0d3.js.map +0 -1
- package/dist/components/p-aeaad64e.js.map +0 -1
- package/dist/crmbonus-component-wake/p-04db24fc.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-04db24fc.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-60249052.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-60249052.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-6de2e9c3.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-6de2e9c3.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-aeaad64e.js +0 -2
- package/dist/crmbonus-component-wake/p-aeaad64e.js.map +0 -1
- package/dist/esm/crmbonus.service-dda2d96b.js.map +0 -1
@@ -3,7 +3,7 @@ import { CrmBonusService } from "../../services/crmbonus.service";
|
|
3
3
|
import { StepFormEnum } from "../../contants";
|
4
4
|
export class CrmBonus {
|
5
5
|
constructor() {
|
6
|
-
this.crmBonusService =
|
6
|
+
this.crmBonusService = CrmBonusService.getInstance();
|
7
7
|
this.showModal = false;
|
8
8
|
this.userId = undefined;
|
9
9
|
this.storeName = undefined;
|
@@ -22,8 +22,10 @@ export class CrmBonus {
|
|
22
22
|
this.canCancel = false;
|
23
23
|
this.amountCancel = undefined;
|
24
24
|
this.sent = undefined;
|
25
|
+
this.session = undefined;
|
25
26
|
}
|
26
27
|
async componentWillLoad() {
|
28
|
+
await this.loadSession();
|
27
29
|
await this.handleLoad();
|
28
30
|
}
|
29
31
|
async handleLoad() {
|
@@ -43,6 +45,9 @@ export class CrmBonus {
|
|
43
45
|
}
|
44
46
|
this.buildAndGetProducts();
|
45
47
|
}
|
48
|
+
async loadSession() {
|
49
|
+
this.session = await this.crmBonusService.getToken(this.storeName);
|
50
|
+
}
|
46
51
|
async buildAndGetProducts() {
|
47
52
|
const key = `bc-products:${this.cartId}`;
|
48
53
|
const cache_products = localStorage.getItem(key);
|
@@ -115,7 +120,7 @@ export class CrmBonus {
|
|
115
120
|
this.message = "";
|
116
121
|
this.loading = true;
|
117
122
|
try {
|
118
|
-
await this.crmBonusService.cancel(this.cartId
|
123
|
+
await this.crmBonusService.cancel(this.cartId);
|
119
124
|
this.canCancel = false;
|
120
125
|
localStorage.removeItem(this.cartId);
|
121
126
|
}
|
@@ -142,8 +147,8 @@ export class CrmBonus {
|
|
142
147
|
this.showModal = true;
|
143
148
|
}
|
144
149
|
render() {
|
145
|
-
return (h("div", { key: '
|
146
|
-
: h("phone-input", { value: this.customer.phone, sendPin: (phone) => { this.handleSendPin(phone); }, loading: this.loading })), h("p", { key: '
|
150
|
+
return (h("div", { key: 'd21b06d2e19ac37704bea558df60f7ab08ecc868', class: "section-cart-crm" }, h("p", { key: '2e46e7eea083c5a70249f99bc7fe09129efa01a2', class: "text-left fbits-responsive-carrinho-desconto-texto" }, "Giftback"), h("div", { key: 'e0a309488b616c9b0f0875218923ee9a891b7339', class: "container-button" }, this.canCancel ? h("phone-cancel-input", { value: this.amountCancel, sendPin: () => { this.cancel(); }, loading: this.loading })
|
151
|
+
: h("phone-input", { value: this.customer.phone, sendPin: (phone) => { this.handleSendPin(phone); }, loading: this.loading })), h("p", { key: '978f0509978dc3b27f81deb712230b4f5bb91066', class: "message-alert" }, this.message), h("app-modal", { key: '91ecefdc47006236a375aecfe195b1aadb69fe19', isOpen: this.showModal, modalTitle: `Giftback`, onModalClosed: () => (this.showModal = false) }, h("crm-bonus-form", { key: '04c3aeaa2c59ae355a1ce8be64776c110d974dc4', loadingModal: this.loading, saveStore: (amount) => this.save(amount), ref: ref => this.crmBonusRef = ref, sent: this.sent, phone: this.phone, cancel: () => this.handleCloseModal(), storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer, handleCustomerName: (name) => this.sendPinName(name) }))));
|
147
152
|
}
|
148
153
|
static get is() { return "crm-bonus"; }
|
149
154
|
static get encapsulation() { return "shadow"; }
|
@@ -240,7 +245,8 @@ export class CrmBonus {
|
|
240
245
|
"phone": {},
|
241
246
|
"canCancel": {},
|
242
247
|
"amountCancel": {},
|
243
|
-
"sent": {}
|
248
|
+
"sent": {},
|
249
|
+
"session": {}
|
244
250
|
};
|
245
251
|
}
|
246
252
|
}
|
@@ -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,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,eAAe,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AC,OAAO,EAC1B,SAAS,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAChD,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,EACrC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAC5C,kBAAkB,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAC5D,CACQ,CACR,CACP,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, 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\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n shadow: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = new CrmBonusService();\n\n private crmBonusRef: HTMLCrmBonusFormElement;\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\n async componentWillLoad() {\n await this.handleLoad();\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('user', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n \n this.buildAndGetProducts();\n }\n\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n const cache_products = localStorage.getItem(key)\n\n if (!cache_products) {\n localStorage.setItem(key, this.productsInString);\n }\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n \n }\n\n this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId, this.storeName);\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 return (\n <div class=\"section-cart-crm\">\n <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n <div class=\"container-button\">\n {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n {\n this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n }\n </div>\n <p class=\"message-alert\" >{this.message}</p>\n <app-modal\n isOpen={this.showModal}\n modalTitle={`Giftback`}\n onModalClosed={() => (this.showModal = false)}\n >\n <crm-bonus-form\n loadingModal={this.loading}\n saveStore={(amount: number) => this.save(amount)}\n ref={ref => this.crmBonusRef = ref}\n sent={this.sent}\n phone={this.phone}\n cancel={() => this.handleCloseModal()}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId} customer={this.customer}\n handleCustomerName={(name: string) => this.sendPinName(name)}\n />\n </app-modal>\n </div>\n )\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"crm-bonus.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus/crm-bonus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,MAAM,OAAO,QAAQ;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;;IAMnC,KAAK,CAAC,iBAAiB;QACrB,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;QACxB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;gBACpF,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACrC,CAAC;YAED,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAEjD,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;YAC7B,CAAC;QAEH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mBAAa,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,GAAI,CAEvH;YACN,0DAAG,KAAK,EAAC,eAAe,IAAG,IAAI,CAAC,OAAO,CAAK;YAC5C,kEACE,MAAM,EAAE,IAAI,CAAC,SAAS,EACtB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;gBAE7C,uEACE,YAAY,EAAE,IAAI,CAAC,OAAO,EAC1B,SAAS,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAChD,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,EACrC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAC5C,kBAAkB,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAC5D,CACQ,CACR,CACP,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, 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\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n shadow: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmBonusFormElement;\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\n async componentWillLoad() {\n await this.loadSession()\n await this.handleLoad();\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('user', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n \n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n const cache_products = localStorage.getItem(key)\n\n if (!cache_products) {\n localStorage.setItem(key, this.productsInString);\n }\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n \n }\n\n this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n return (\n <div class=\"section-cart-crm\">\n <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n <div class=\"container-button\">\n {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n {\n this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n }\n </div>\n <p class=\"message-alert\" >{this.message}</p>\n <app-modal\n isOpen={this.showModal}\n modalTitle={`Giftback`}\n onModalClosed={() => (this.showModal = false)}\n >\n <crm-bonus-form\n loadingModal={this.loading}\n saveStore={(amount: number) => this.save(amount)}\n ref={ref => this.crmBonusRef = ref}\n sent={this.sent}\n phone={this.phone}\n cancel={() => this.handleCloseModal()}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId} customer={this.customer}\n handleCustomerName={(name: string) => this.sendPinName(name)}\n />\n </app-modal>\n </div>\n )\n }\n}\n"]}
|
@@ -3,7 +3,7 @@ import { CrmBonusService } from "../../services/crmbonus.service";
|
|
3
3
|
import { StepFormEnum } from "../../contants";
|
4
4
|
export class CrmBonusForm {
|
5
5
|
constructor() {
|
6
|
-
this.crmBonusService =
|
6
|
+
this.crmBonusService = CrmBonusService.getInstance();
|
7
7
|
this.storeName = undefined;
|
8
8
|
this.cartId = undefined;
|
9
9
|
this.products = undefined;
|
@@ -43,8 +43,7 @@ export class CrmBonusForm {
|
|
43
43
|
storeName: this.storeName
|
44
44
|
};
|
45
45
|
try {
|
46
|
-
this.bonus = await this.crmBonusService.validatePinBonus(payload
|
47
|
-
console.log('[this.bonus]', this.bonus);
|
46
|
+
this.bonus = await this.crmBonusService.validatePinBonus(payload);
|
48
47
|
this.step = StepFormEnum.STEP_RESERVE;
|
49
48
|
}
|
50
49
|
catch (error) {
|
@@ -53,7 +52,6 @@ export class CrmBonusForm {
|
|
53
52
|
finally {
|
54
53
|
this.loading = false;
|
55
54
|
}
|
56
|
-
console.log('payload', payload);
|
57
55
|
}
|
58
56
|
async reserveApply(amount) {
|
59
57
|
this.loading = true;
|
@@ -86,7 +84,7 @@ export class CrmBonusForm {
|
|
86
84
|
this.cancel();
|
87
85
|
}
|
88
86
|
render() {
|
89
|
-
return (h(Host, { key: '
|
87
|
+
return (h(Host, { key: '6e71114a1e7b254f5f3a1fa907c96bb2c2f36171' }, this.step == StepFormEnum.STEP_NAME && h("name-input", { key: 'd44a3757015d8af2062f98d2cc0271dd2d9e79af', loading: this.loadingModal, value: this.customer.name, applyName: (name) => this.handleCustomerName(name) }), this.step === StepFormEnum.STEP_PIN && h("giftback-pin", { key: '74e74078485e3f75d053f54300acb5e99c84533a', cancel: () => this.handleCancel(), sent: this.sent, validate: (data) => this.validateBonus(data), loading: this.loading }), this.step === StepFormEnum.STEP_RESERVE && h("giftback-progress", { key: '2b9c3cd91e20af1efca4590b6f94e694b2f4c03f', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === StepFormEnum.STEP_APPLY && h("giftback-finish", { key: 'f66d8c5da16a1a48a1b1be8b48a61a62676fa753' }), h("p", { key: 'c68f26529c21ce047819449f0414538f5e9771f8', class: "message-error" }, this.message)));
|
90
88
|
}
|
91
89
|
static get is() { return "crm-bonus-form"; }
|
92
90
|
static get encapsulation() { return "shadow"; }
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"crm-bonus-form.js","sourceRoot":"","sources":["../../../../src/components/crm-bonus-form/crm-bonus-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,MAAM,OAAO,YAAY;;QAEb,oBAAe,GAAoB,
|
1
|
+
{"version":3,"file":"crm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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import { Component, Host, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent';\n\n@Component({\n tag: 'crm-bonus-form',\n styleUrl: 'crm-bonus-form.css',\n shadow: true\n})\nexport class CrmBonusForm {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n @Prop({ attribute: 'storename' }) storeName;\n @Prop() cartId;\n @Prop() products: Array<IProduct>;\n @Prop() customer: ICustomer = {\n phone: \"\",\n birthDate: \"\",\n document: \"\",\n name: \"\"\n };\n @Prop() sent: IPinSent;\n @Prop() stepNext: StepFormEnum;\n @Prop() phone: number;\n @Prop() loadingModal: boolean;\n\n @Prop() saveStore: (amount: number) => void;\n\n @Prop() cancel: () => void;\n\n @Prop() handleCustomerName: (name: string) => void;\n\n @State() loading: boolean = false;\n\n @State() step: number = StepFormEnum.STEP_NAME;\n\n @State() message: string;\n\n @State() bonus: IBonus;\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n public async validateBonus(pin: string) {\n this.loading = true;\n this.message = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.sent.storeId.toString(),\n userId: this.sent.userId.toString(),\n checkoutId: this.cartId,\n checkoutProducts: this.products,\n name: null,\n storeName: this.storeName\n }\n\n try {\n this.bonus = await this.crmBonusService.validatePinBonus(payload);\n\n this.step = StepFormEnum.STEP_RESERVE;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false;\n }\n }\n\n public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n\n this.step = StepFormEnum.STEP_APPLY;\n\n this.saveStore(amount);\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n } finally {\n this.loading = false;\n }\n }\n\n public async reserve(amount: number) {\n await this.crmBonusService.reserve({\n redeemedBonus: amount,\n cartId: this.cartId,\n ticket: this.cartId,\n grossValue: Number(this.bonus.totalValue),\n storeName: this.storeName,\n storeId: this.bonus.storeId.toString(),\n userId: this.bonus.userId\n });\n }\n\n public handleCancel() {\n this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n render() {\n return (\n <Host>\n {/* {this.step === StepFormEnum.STEP_PHONE && <phone-input value={this.customer.phone} sendPin={(phone) => this.sendPin(phone)} loading={this.loading} />} */}\n \n {this.step == StepFormEnum.STEP_NAME && <name-input loading={this.loadingModal} value={this.customer.name} applyName={(name) => this.handleCustomerName(name)} />}\n {this.step === StepFormEnum.STEP_PIN && <giftback-pin cancel={() => this.handleCancel()} sent={this.sent} validate={(data) => this.validateBonus(data)} loading={this.loading} />}\n\n {this.step === StepFormEnum.STEP_RESERVE && <giftback-progress loading={this.loading} cancel={() => this.handleCancel()} bonus={this.bonus} reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)} />}\n {this.step === StepFormEnum.STEP_APPLY && <giftback-finish />}\n <p class=\"message-error\">{this.message}</p>\n </Host>\n )\n }\n}"]}
|
@@ -9,11 +9,8 @@ export class Pedido {
|
|
9
9
|
async componentWillLoad() {
|
10
10
|
console.log('this.metadadoString', this.metadadoString);
|
11
11
|
const metadado = this.metadadoString ? JSON.parse(this.metadadoString) : { id: null };
|
12
|
-
console.log('this.cartId', this.cartId);
|
13
|
-
console.log('this.orderid', this.orderId);
|
14
|
-
console.log('metadadoid', metadado);
|
15
12
|
if (this.cartId && this.orderId) {
|
16
|
-
|
13
|
+
CrmBonusService.getInstance().updateOrder({
|
17
14
|
cartId: this.cartId,
|
18
15
|
orderId: this.orderId,
|
19
16
|
cartIdCrm: metadado.id
|
@@ -24,7 +21,7 @@ export class Pedido {
|
|
24
21
|
}
|
25
22
|
}
|
26
23
|
render() {
|
27
|
-
return (h("div", { key: '
|
24
|
+
return (h("div", { key: '139ce085fc0fa628516214796a16d9efbb34d6fc' }));
|
28
25
|
}
|
29
26
|
static get is() { return "pedido-finalizado"; }
|
30
27
|
static get properties() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pedido.js","sourceRoot":"","sources":["../../../../src/components/pedido/pedido.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAKlE,MAAM,OAAO,MAAM;;;;;;IAMf,KAAK,CAAC,iBAAiB;QACnB,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;
|
1
|
+
{"version":3,"file":"pedido.js","sourceRoot":"","sources":["../../../../src/components/pedido/pedido.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAKlE,MAAM,OAAO,MAAM;;;;;;IAMf,KAAK,CAAC,iBAAiB;QACnB,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;QAGtF,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC9B,eAAe,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC;gBACtC,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,OAAO,EAAG,IAAI,CAAC,OAAO;gBACtB,SAAS,EAAE,QAAQ,CAAC,EAAE;aACzB,CAAC,CAAC;YAEH,MAAM,GAAG,GAAG,eAAe,IAAI,CAAC,MAAM,EAAE,CAAC;YACzC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC7B,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;IACL,CAAC;IAED,MAAM;QACF,OAAO,CACH,6DAAW,CACd,CAAA;IACL,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACJ","sourcesContent":["import { Component, Prop, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\n\n@Component({\n tag: \"pedido-finalizado\"\n})\nexport class Pedido {\n\n @Prop({ attribute: \"cartid\" }) cartId: string;\n @Prop({ attribute: \"orderid\" }) orderId: number;\n @Prop({ attribute: \"metadado\" }) metadadoString: string;\n\n async componentWillLoad() {\n console.log('this.metadadoString', this.metadadoString)\n const metadado = this.metadadoString ? JSON.parse(this.metadadoString) : { id: null };\n\n\n if (this.cartId && this.orderId) {\n CrmBonusService.getInstance().updateOrder({\n cartId: this.cartId,\n orderId: this.orderId,\n cartIdCrm: metadado.id\n });\n\n const key = `bc-products:${this.cartId}`;\n localStorage.removeItem(key);\n localStorage.removeItem(this.cartId);\n }\n }\n\n render() {\n return (\n <div></div>\n )\n }\n}"]}
|
@@ -10,39 +10,76 @@ export class CrmBonusService {
|
|
10
10
|
},
|
11
11
|
});
|
12
12
|
}
|
13
|
+
static getInstance() {
|
14
|
+
if (this._instance) {
|
15
|
+
return this._instance;
|
16
|
+
}
|
17
|
+
this._instance = new CrmBonusService();
|
18
|
+
return this._instance;
|
19
|
+
}
|
13
20
|
async getCustomer(userId, store) {
|
14
|
-
|
15
|
-
|
16
|
-
|
21
|
+
var _a, _b;
|
22
|
+
const headers = {
|
23
|
+
'Content-Type': 'application/json',
|
24
|
+
'Authorization': `Bearer ${this.token}`
|
25
|
+
};
|
26
|
+
const response = await this.axiosInstance.get(`/store/${store}/customer/${userId}`, { headers: headers });
|
27
|
+
this.token = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.token;
|
28
|
+
return (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.customer;
|
17
29
|
}
|
18
30
|
async updateOrder(updateOrderDTO) {
|
19
|
-
const
|
31
|
+
const headers = {
|
32
|
+
'Content-Type': 'application/json',
|
33
|
+
'Authorization': `Bearer ${this.token}`
|
34
|
+
};
|
35
|
+
await this.axiosInstance.patch(`/checkouts/${updateOrderDTO.cartId}/updateOrder`, {
|
20
36
|
orderId: updateOrderDTO.orderId,
|
21
37
|
externalId: updateOrderDTO.cartIdCrm
|
22
|
-
}, { headers:
|
23
|
-
console.log('response', response.data);
|
38
|
+
}, { headers: headers });
|
24
39
|
}
|
25
40
|
async sendPin(phone, name, store) {
|
26
|
-
const
|
41
|
+
const headers = {
|
42
|
+
'Content-Type': 'application/json',
|
43
|
+
'Authorization': `Bearer ${this.token}`
|
44
|
+
};
|
45
|
+
const response = await this.axiosInstance.post("/crmbonus/send-pin", { cellphone: phone, name: name, storeName: store }, { headers: headers });
|
27
46
|
return {
|
28
47
|
storeId: response.data.storeId,
|
29
48
|
userId: response.data.userId
|
30
49
|
};
|
31
50
|
}
|
32
|
-
async validatePinBonus(payload
|
33
|
-
|
34
|
-
|
51
|
+
async validatePinBonus(payload) {
|
52
|
+
const headers = {
|
53
|
+
'Content-Type': 'application/json',
|
54
|
+
'Authorization': `Bearer ${this.token}`
|
55
|
+
};
|
56
|
+
const response = await this.axiosInstance.post("/crmbonus/process-pin-bonus", payload, { headers });
|
35
57
|
return response.data;
|
36
58
|
}
|
37
59
|
async reserve(payload) {
|
38
|
-
const
|
60
|
+
const headers = {
|
61
|
+
'Content-Type': 'application/json',
|
62
|
+
'Authorization': `Bearer ${this.token}`
|
63
|
+
};
|
64
|
+
const response = await this.axiosInstance.post("/crmbonus/redeem-bonus", payload, { headers });
|
39
65
|
return response.data;
|
40
66
|
}
|
41
|
-
async cancel(cartId
|
67
|
+
async cancel(cartId) {
|
68
|
+
const headers = {
|
69
|
+
'Content-Type': 'application/json',
|
70
|
+
'Authorization': `Bearer ${this.token}`
|
71
|
+
};
|
42
72
|
const response = await this.axiosInstance.post("/crmbonus/cancel-apply-bonus", {
|
43
73
|
ticket: cartId
|
44
|
-
}, { headers
|
74
|
+
}, { headers });
|
45
75
|
return response.data;
|
46
76
|
}
|
77
|
+
async getToken(store) {
|
78
|
+
var _a, _b;
|
79
|
+
const response = await this.axiosInstance.post("/wake/requestToken", { storeName: store });
|
80
|
+
this.token = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.token;
|
81
|
+
return (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.token;
|
82
|
+
}
|
47
83
|
}
|
84
|
+
CrmBonusService._instance = null;
|
48
85
|
//# sourceMappingURL=crmbonus.service.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"crmbonus.service.js","sourceRoot":"","sources":["../../../src/services/crmbonus.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAK7C,MAAM,OAAO,eAAe;
|
1
|
+
{"version":3,"file":"crmbonus.service.js","sourceRoot":"","sources":["../../../src/services/crmbonus.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,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AAO,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/F,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc;QAEvB,MAAM,OAAO,GAAG;YACZ,cAAc,EAAE,kBAAkB;YAClC,eAAe,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE;SAC1C,CAAA;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,8BAA8B,EAAE;YAC3E,MAAM,EAAE,MAAM;SACjB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAChB,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAa;;QACxB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAA;QAC1F,IAAI,CAAC,KAAK,GAAG,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,KAAK,CAAC;QAEnC,OAAO,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,0CAAE,KAAK,CAAC;IACjC,CAAC;;AA5Gc,yBAAS,GAAoB,IAAI,CAAC","sourcesContent":["import axios, { AxiosInstance } from 'axios';\nimport { CRM_BONUS_API_URL } from '../../env'\nimport { IPinSent } from '../dto/pin.sent';\nimport { IBonus, IProccesPinBonusDto, IReserveDTO } from '../dto/validate.pin.bonus';\nimport { UpdateOrderDTO } from '../dto/update.order.dto';\n\nexport class CrmBonusService {\n private axiosInstance: AxiosInstance;\n private token: string;\n\n private static _instance: CrmBonusService = null;\n\n constructor() {\n this.axiosInstance = axios.create({\n baseURL: CRM_BONUS_API_URL,\n headers: {\n 'Content-Type': 'application/json',\n 'accept': 'application/json',\n },\n });\n }\n\n public static getInstance(): CrmBonusService {\n if (this._instance) {\n return this._instance;\n }\n\n this._instance = new CrmBonusService()\n\n return this._instance;\n }\n\n async getCustomer(userId: number, store: string) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.get(`/store/${store}/customer/${userId}`, { headers: headers })\n\n this.token = response?.data?.token\n\n return response?.data?.customer\n }\n\n async updateOrder(updateOrderDTO: UpdateOrderDTO) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n await this.axiosInstance.patch(`/checkouts/${updateOrderDTO.cartId}/updateOrder`,\n {\n orderId: updateOrderDTO.orderId,\n externalId: updateOrderDTO.cartIdCrm\n }, { headers: headers })\n\n\n }\n\n async sendPin(phone: number, name: string, store: string): Promise<IPinSent> {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n\n const response = await this.axiosInstance.post(\"/crmbonus/send-pin\", { cellphone: phone, name: name, storeName: store }, { headers: headers });\n return {\n storeId: response.data.storeId,\n userId: response.data.userId\n }\n }\n\n async validatePinBonus(payload: IProccesPinBonusDto): Promise<IBonus> {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.post(\"/crmbonus/process-pin-bonus\", payload, { headers })\n\n return response.data;\n }\n\n async reserve(payload: IReserveDTO) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.post(\"/crmbonus/redeem-bonus\", payload, { headers });\n return response.data;\n }\n\n async cancel(cartId: string) {\n\n const headers = {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.token}`\n }\n\n const response = await this.axiosInstance.post(\"/crmbonus/cancel-apply-bonus\", {\n ticket: cartId\n }, { headers });\n return response.data;\n }\n\n async getToken(store: string): Promise<string> {\n const response = await this.axiosInstance.post(\"/wake/requestToken\", { storeName: store })\n this.token = response?.data?.token;\n\n return response?.data?.token;\n }\n}"]}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { p as proxyCustomElement, H, h } from './p-faf7103e.js';
|
2
|
-
import { C as CrmBonusService } from './p-
|
3
|
-
import { d as defineCustomElement$a, S as StepFormEnum } from './p-
|
2
|
+
import { C as CrmBonusService } from './p-96d4b7f8.js';
|
3
|
+
import { d as defineCustomElement$a, S as StepFormEnum } from './p-c3888e1e.js';
|
4
4
|
import { d as defineCustomElement$b } from './p-1dbb0f43.js';
|
5
5
|
import { d as defineCustomElement$9 } from './p-530006e6.js';
|
6
6
|
import { d as defineCustomElement$8 } from './p-0e99f907.js';
|
@@ -19,7 +19,7 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
|
|
19
19
|
super();
|
20
20
|
this.__registerHost();
|
21
21
|
this.__attachShadow();
|
22
|
-
this.crmBonusService =
|
22
|
+
this.crmBonusService = CrmBonusService.getInstance();
|
23
23
|
this.showModal = false;
|
24
24
|
this.userId = undefined;
|
25
25
|
this.storeName = undefined;
|
@@ -38,8 +38,10 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
|
|
38
38
|
this.canCancel = false;
|
39
39
|
this.amountCancel = undefined;
|
40
40
|
this.sent = undefined;
|
41
|
+
this.session = undefined;
|
41
42
|
}
|
42
43
|
async componentWillLoad() {
|
44
|
+
await this.loadSession();
|
43
45
|
await this.handleLoad();
|
44
46
|
}
|
45
47
|
async handleLoad() {
|
@@ -59,6 +61,9 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
|
|
59
61
|
}
|
60
62
|
this.buildAndGetProducts();
|
61
63
|
}
|
64
|
+
async loadSession() {
|
65
|
+
this.session = await this.crmBonusService.getToken(this.storeName);
|
66
|
+
}
|
62
67
|
async buildAndGetProducts() {
|
63
68
|
const key = `bc-products:${this.cartId}`;
|
64
69
|
const cache_products = localStorage.getItem(key);
|
@@ -129,7 +134,7 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
|
|
129
134
|
this.message = "";
|
130
135
|
this.loading = true;
|
131
136
|
try {
|
132
|
-
await this.crmBonusService.cancel(this.cartId
|
137
|
+
await this.crmBonusService.cancel(this.cartId);
|
133
138
|
this.canCancel = false;
|
134
139
|
localStorage.removeItem(this.cartId);
|
135
140
|
}
|
@@ -156,8 +161,8 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
|
|
156
161
|
this.showModal = true;
|
157
162
|
}
|
158
163
|
render() {
|
159
|
-
return (h("div", { key: '
|
160
|
-
: h("phone-input", { value: this.customer.phone, sendPin: (phone) => { this.handleSendPin(phone); }, loading: this.loading })), h("p", { key: '
|
164
|
+
return (h("div", { key: 'd21b06d2e19ac37704bea558df60f7ab08ecc868', class: "section-cart-crm" }, h("p", { key: '2e46e7eea083c5a70249f99bc7fe09129efa01a2', class: "text-left fbits-responsive-carrinho-desconto-texto" }, "Giftback"), h("div", { key: 'e0a309488b616c9b0f0875218923ee9a891b7339', class: "container-button" }, this.canCancel ? h("phone-cancel-input", { value: this.amountCancel, sendPin: () => { this.cancel(); }, loading: this.loading })
|
165
|
+
: h("phone-input", { value: this.customer.phone, sendPin: (phone) => { this.handleSendPin(phone); }, loading: this.loading })), h("p", { key: '978f0509978dc3b27f81deb712230b4f5bb91066', class: "message-alert" }, this.message), h("app-modal", { key: '91ecefdc47006236a375aecfe195b1aadb69fe19', isOpen: this.showModal, modalTitle: `Giftback`, onModalClosed: () => (this.showModal = false) }, h("crm-bonus-form", { key: '04c3aeaa2c59ae355a1ce8be64776c110d974dc4', loadingModal: this.loading, saveStore: (amount) => this.save(amount), ref: ref => this.crmBonusRef = ref, sent: this.sent, phone: this.phone, cancel: () => this.handleCloseModal(), storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer, handleCustomerName: (name) => this.sendPinName(name) }))));
|
161
166
|
}
|
162
167
|
static get assetsDirs() { return ["assets"]; }
|
163
168
|
static get style() { return CrmBonusStyle0; }
|
@@ -174,7 +179,8 @@ const CrmBonus$1 = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
|
|
174
179
|
"phone": [32],
|
175
180
|
"canCancel": [32],
|
176
181
|
"amountCancel": [32],
|
177
|
-
"sent": [32]
|
182
|
+
"sent": [32],
|
183
|
+
"session": [32]
|
178
184
|
}]);
|
179
185
|
function defineCustomElement$1() {
|
180
186
|
if (typeof customElements === "undefined") {
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"crm-bonus.js","mappings":";;;;;;;;;;;;;AAAA,MAAM,WAAW,GAAG,y/BAAy/B,CAAC;AAC9gC,uBAAe,WAAW;;MCWbA,UAAQ;;;;;QAEX,oBAAe,GAAoB,IAAI,eAAe,EAAE,CAAC;yBAInC,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;IAKnC,MAAM,iBAAiB;QACrB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;KACzB;IAED,MAAM,UAAU;QACd,IAAI;YACF,IAAI,IAAI,CAAC,MAAM,EAAE;gBACf,IAAI,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;gBACpF,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;aACpC;YAED,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAEjD,IAAI,MAAM,EAAE;gBACV,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;gBACtB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;aAC5B;SAEF;QAAC,OAAO,KAAK,E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,GAAG,EAClC,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,MAAM,IAAI,CAAC,gBAAgB,EAAE,EACrC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAC5C,kBAAkB,EAAE,CAAC,IAAY,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAC5D,CACQ,CACR,EACP;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CrmBonus"],"sources":["src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=shadow","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["/* :host {\n display: block;\n} */\n\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, 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\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n shadow: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = new CrmBonusService();\n\n private crmBonusRef: HTMLCrmBonusFormElement;\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\n async componentWillLoad() {\n await this.handleLoad();\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('user', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n \n this.buildAndGetProducts();\n }\n\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n const cache_products = localStorage.getItem(key)\n\n if (!cache_products) {\n localStorage.setItem(key, this.productsInString);\n }\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n \n }\n\n this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId, this.storeName);\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 return (\n <div class=\"section-cart-crm\">\n <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n <div class=\"container-button\">\n {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n {\n this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n }\n </div>\n <p class=\"message-alert\" >{this.message}</p>\n <app-modal\n isOpen={this.showModal}\n modalTitle={`Giftback`}\n onModalClosed={() => (this.showModal = false)}\n >\n <crm-bonus-form\n loadingModal={this.loading}\n saveStore={(amount: number) => this.save(amount)}\n ref={ref => this.crmBonusRef = ref}\n sent={this.sent}\n phone={this.phone}\n cancel={() => this.handleCloseModal()}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId} customer={this.customer}\n handleCustomerName={(name: string) => this.sendPinName(name)}\n />\n </app-modal>\n </div>\n )\n }\n}\n"],"version":3}
|
1
|
+
{"file":"crm-bonus.js","mappings":";;;;;;;;;;;;;AAAA,MAAM,WAAW,GAAG,y/BAAy/B,CAAC;AAC9gC,uBAAe,WAAW;;MCWbA,UAAQ;;;;;QAEX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;yBAI3C,KAAK;;;;;;wBAOJ;YAC7B,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,EAAE;YACZ,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;SACV;uBAE2B,KAAK;;;yBAGH,KAAK;;;;;IAM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onus.css?tag=crm-bonus&encapsulation=shadow","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["/* :host {\n display: block;\n} */\n\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, 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\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n shadow: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmBonusFormElement;\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\n async componentWillLoad() {\n await this.loadSession()\n await this.handleLoad();\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('user', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n \n this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n }\n\n async buildAndGetProducts() {\n const key = `bc-products:${this.cartId}`;\n const cache_products = localStorage.getItem(key)\n\n if (!cache_products) {\n localStorage.setItem(key, this.productsInString);\n }\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor\n })\n } else {\n products.push(product_cart)\n }\n \n }\n\n this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return this.products.map(product => ({ sku: product.SKU, value: (product.PrecoPor * product.Quantidade), productVariantId: product.ProdutoVarianteId.toString(), quantity: product.Quantidade }))\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n return (\n <div class=\"section-cart-crm\">\n <p class=\"text-left fbits-responsive-carrinho-desconto-texto\">Giftback</p>\n <div class=\"container-button\">\n {/* <img src={logo} onClick={() => (this.showModal = true)} /> */}\n {\n this.canCancel ? <phone-cancel-input value={this.amountCancel} sendPin={() => { this.cancel() }} loading={this.loading} />\n : <phone-input value={this.customer.phone} sendPin={(phone) => { this.handleSendPin(phone) }} loading={this.loading} />\n }\n </div>\n <p class=\"message-alert\" >{this.message}</p>\n <app-modal\n isOpen={this.showModal}\n modalTitle={`Giftback`}\n onModalClosed={() => (this.showModal = false)}\n >\n <crm-bonus-form\n loadingModal={this.loading}\n saveStore={(amount: number) => this.save(amount)}\n ref={ref => this.crmBonusRef = ref}\n sent={this.sent}\n phone={this.phone}\n cancel={() => this.handleCloseModal()}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId} customer={this.customer}\n handleCustomerName={(name: string) => this.sendPinName(name)}\n />\n </app-modal>\n </div>\n )\n }\n}\n"],"version":3}
|
@@ -3749,7 +3749,7 @@ axios.default = axios;
|
|
3749
3749
|
// this module should only have a default export
|
3750
3750
|
const axios$1 = axios;
|
3751
3751
|
|
3752
|
-
const CRM_BONUS_API_URL = "https://crmbonus-wake-hub-staging-5daedbc4e22b.herokuapp.com/api"
|
3752
|
+
const CRM_BONUS_API_URL = "https://wake-middleware.crmbonus.com/api"; // "https://crmbonus-wake-hub-staging-5daedbc4e22b.herokuapp.com/api" //"https://crmbonus-service-staging-d15ba5377115.herokuapp.com"; //"https://typically-workable-perch.ngrok-free.app"; // "http://localhost:3500";
|
3753
3753
|
|
3754
3754
|
class CrmBonusService {
|
3755
3755
|
constructor() {
|
@@ -3761,42 +3761,79 @@ class CrmBonusService {
|
|
3761
3761
|
},
|
3762
3762
|
});
|
3763
3763
|
}
|
3764
|
+
static getInstance() {
|
3765
|
+
if (this._instance) {
|
3766
|
+
return this._instance;
|
3767
|
+
}
|
3768
|
+
this._instance = new CrmBonusService();
|
3769
|
+
return this._instance;
|
3770
|
+
}
|
3764
3771
|
async getCustomer(userId, store) {
|
3765
|
-
|
3766
|
-
|
3767
|
-
|
3772
|
+
var _a, _b;
|
3773
|
+
const headers = {
|
3774
|
+
'Content-Type': 'application/json',
|
3775
|
+
'Authorization': `Bearer ${this.token}`
|
3776
|
+
};
|
3777
|
+
const response = await this.axiosInstance.get(`/store/${store}/customer/${userId}`, { headers: headers });
|
3778
|
+
this.token = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.token;
|
3779
|
+
return (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.customer;
|
3768
3780
|
}
|
3769
3781
|
async updateOrder(updateOrderDTO) {
|
3770
|
-
const
|
3782
|
+
const headers = {
|
3783
|
+
'Content-Type': 'application/json',
|
3784
|
+
'Authorization': `Bearer ${this.token}`
|
3785
|
+
};
|
3786
|
+
await this.axiosInstance.patch(`/checkouts/${updateOrderDTO.cartId}/updateOrder`, {
|
3771
3787
|
orderId: updateOrderDTO.orderId,
|
3772
3788
|
externalId: updateOrderDTO.cartIdCrm
|
3773
|
-
}, { headers:
|
3774
|
-
console.log('response', response.data);
|
3789
|
+
}, { headers: headers });
|
3775
3790
|
}
|
3776
3791
|
async sendPin(phone, name, store) {
|
3777
|
-
const
|
3792
|
+
const headers = {
|
3793
|
+
'Content-Type': 'application/json',
|
3794
|
+
'Authorization': `Bearer ${this.token}`
|
3795
|
+
};
|
3796
|
+
const response = await this.axiosInstance.post("/crmbonus/send-pin", { cellphone: phone, name: name, storeName: store }, { headers: headers });
|
3778
3797
|
return {
|
3779
3798
|
storeId: response.data.storeId,
|
3780
3799
|
userId: response.data.userId
|
3781
3800
|
};
|
3782
3801
|
}
|
3783
|
-
async validatePinBonus(payload
|
3784
|
-
|
3785
|
-
|
3802
|
+
async validatePinBonus(payload) {
|
3803
|
+
const headers = {
|
3804
|
+
'Content-Type': 'application/json',
|
3805
|
+
'Authorization': `Bearer ${this.token}`
|
3806
|
+
};
|
3807
|
+
const response = await this.axiosInstance.post("/crmbonus/process-pin-bonus", payload, { headers });
|
3786
3808
|
return response.data;
|
3787
3809
|
}
|
3788
3810
|
async reserve(payload) {
|
3789
|
-
const
|
3811
|
+
const headers = {
|
3812
|
+
'Content-Type': 'application/json',
|
3813
|
+
'Authorization': `Bearer ${this.token}`
|
3814
|
+
};
|
3815
|
+
const response = await this.axiosInstance.post("/crmbonus/redeem-bonus", payload, { headers });
|
3790
3816
|
return response.data;
|
3791
3817
|
}
|
3792
|
-
async cancel(cartId
|
3818
|
+
async cancel(cartId) {
|
3819
|
+
const headers = {
|
3820
|
+
'Content-Type': 'application/json',
|
3821
|
+
'Authorization': `Bearer ${this.token}`
|
3822
|
+
};
|
3793
3823
|
const response = await this.axiosInstance.post("/crmbonus/cancel-apply-bonus", {
|
3794
3824
|
ticket: cartId
|
3795
|
-
}, { headers
|
3825
|
+
}, { headers });
|
3796
3826
|
return response.data;
|
3797
3827
|
}
|
3828
|
+
async getToken(store) {
|
3829
|
+
var _a, _b;
|
3830
|
+
const response = await this.axiosInstance.post("/wake/requestToken", { storeName: store });
|
3831
|
+
this.token = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.token;
|
3832
|
+
return (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.token;
|
3833
|
+
}
|
3798
3834
|
}
|
3835
|
+
CrmBonusService._instance = null;
|
3799
3836
|
|
3800
3837
|
export { CrmBonusService as C };
|
3801
3838
|
|
3802
|
-
//# sourceMappingURL=p-
|
3839
|
+
//# sourceMappingURL=p-96d4b7f8.js.map
|