crmbonus-component-wake 2.0.73 → 2.0.74
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/crm-giftback-form.cjs.entry.js +16 -13
- package/dist/cjs/crm-giftback-form.cjs.entry.js.map +1 -1
- package/dist/collection/components/giftback-form/giftback-form.js +16 -13
- package/dist/collection/components/giftback-form/giftback-form.js.map +1 -1
- package/dist/components/crm-bonus.js +1 -1
- package/dist/components/crm-giftback-form.js +1 -1
- package/dist/components/{p-5a26c163.js → p-984bc7d0.js} +17 -14
- package/dist/components/p-984bc7d0.js.map +1 -0
- package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
- package/dist/crmbonus-component-wake/p-feadb94b.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-feadb94b.entry.js.map +1 -0
- package/dist/esm/crm-giftback-form.entry.js +16 -13
- package/dist/esm/crm-giftback-form.entry.js.map +1 -1
- package/dist/types/components/giftback-form/giftback-form.d.ts +2 -2
- package/package.json +1 -1
- package/dist/components/p-5a26c163.js.map +0 -1
- package/dist/crmbonus-component-wake/p-c04d7aac.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-c04d7aac.entry.js.map +0 -1
@@ -40,12 +40,14 @@ const CrmBonus = class {
|
|
40
40
|
const _bonus = localStorage.getItem(crmbonus_service.getKeyReserveByCartId(this.cartId));
|
41
41
|
if (_bonus) {
|
42
42
|
const bonus = JSON.parse(_bonus);
|
43
|
+
this.bonus = bonus;
|
43
44
|
this.phone = bonus.phone;
|
44
45
|
this.pinInfo = {
|
45
46
|
storeId: bonus.storeId,
|
46
47
|
userId: bonus.userId
|
47
48
|
};
|
48
49
|
await this.validateBonus("2018");
|
50
|
+
this.step = index$1.StepFormEnum.STEP_RESERVE;
|
49
51
|
}
|
50
52
|
}
|
51
53
|
async handleSendPin(phone) {
|
@@ -57,18 +59,19 @@ const CrmBonus = class {
|
|
57
59
|
this.phone = phone;
|
58
60
|
this.sendPin();
|
59
61
|
}
|
60
|
-
componentWillLoad() {
|
62
|
+
async componentWillLoad() {
|
61
63
|
this.sucess = "";
|
62
64
|
this.error = "";
|
63
65
|
this.config = info_config_helper.getInfoCustomization(this.storeName);
|
64
|
-
this.handleApply();
|
66
|
+
await this.handleApply();
|
65
67
|
}
|
66
|
-
handleApply() {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
async handleApply() {
|
69
|
+
await this.processBonus();
|
70
|
+
// const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
|
71
|
+
// if (bonus) {
|
72
|
+
// this.bonus = JSON.parse(bonus);
|
73
|
+
// this.step = StepFormEnum.STEP_RESERVE;
|
74
|
+
// }
|
72
75
|
}
|
73
76
|
convertStringToNumber() {
|
74
77
|
const _phone = this.phone.replace(/\D/g, '');
|
@@ -190,11 +193,11 @@ const CrmBonus = class {
|
|
190
193
|
});
|
191
194
|
}
|
192
195
|
render() {
|
193
|
-
return (index.h("div", { key: '
|
194
|
-
index.h("phone-form", { key: '
|
195
|
-
index.h("pin-form", { key: '
|
196
|
-
index.h("giftback-info", { key: '
|
197
|
-
(index.h("div", { key: '
|
196
|
+
return (index.h("div", { key: 'bcdcaf47c056325591abc1aca2af8b139b687905', class: "crm-container-form fbits-responsive-carrinho-desconto" }, index.h("label", { key: 'e5a07f16ec6209c01abcfbd43628c510ba87bbc7', class: "crm-title" }, this.config.giftbackTitle), this.step === index$1.StepFormEnum.STEP_PHONE &&
|
197
|
+
index.h("phone-form", { key: '9c928594efaee7f7ebd503b2144eec1ba9c1e8a5', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === index$1.StepFormEnum.STEP_PIN &&
|
198
|
+
index.h("pin-form", { key: 'd1280fb5e3b71b004b641af35fc4a1f8df85ced8', config: this.config, phone: this.phone, cancel: () => this.changePhone(), resend: () => this.sendPin(), validate: (data) => this.validateBonus(data), loading: this.loading }, this.sucess && index.h("p", { key: 'eab06087abbac2ce8fada74cd9313ef87ea63ab9', class: "crm-message-info" }, this.sucess), this.error && index.h("p", { key: '822b7d1058e8e9dfcdc3a2351984aeed3e8fca6c', class: "crm-message-error" }, this.error)), this.step === index$1.StepFormEnum.STEP_RESERVE &&
|
199
|
+
index.h("giftback-info", { key: 'e45d28b56f8a8e831050b8afc4075ccbf3bb10b3', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === index$1.StepFormEnum.STEP_NO_BONUS &&
|
200
|
+
(index.h("div", { key: 'bed09587cfcd07465345dbca12ef15657c641680', class: "container-message" }, i18n.instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
|
198
201
|
}
|
199
202
|
};
|
200
203
|
CrmBonus.style = CrmGiftbackFormStyle0;
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"crm-giftback-form.entry.cjs.js","mappings":";;;;;;;;;;AAAA,MAAM,eAAe,GAAG,i9BAAi9B,CAAC;AAC1+B,8BAAe,eAAe;;MCajB,QAAQ;;;;QAGX,oBAAe,GAAoBA,gCAAe,CAAC,WAAW,EAAE,CAAC;;;;;;uBAQ7C,KAAK;;;;oBAIHC,oBAAY,CAAC,UAAU;;sBAG3B,EAAE;qBACH,EAAE;;6BAGF,KAAK;;IAI9B,MAAM,OAAO,CAAC,IAAkB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACjB;IAGD,MAAM,YAAY;QAChB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAACC,sCAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAGxE,IAAG,MAAM,EAAE;YAET,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YAEhC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YACzB,IAAI,CAA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AC3BC,aAAO,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAC9D,CACP,CAGC,EACP;KACF;;;;;;","names":["CrmBonusService","StepFormEnum","getKeyReserveByCartId","getInfoCustomization","h","i18next"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n font-family: Roboto;\n font-size: var(--crmfont-sizebodymd);\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n font-size: 14px;\n color: var(--crm-btn);\n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n font-size: 16px;\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n font-size: 12px;\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n font-size: 12px;\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\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\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_PHONE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus() {\n this.sucess = \"\";\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n\n if(_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\")\n }\n \n \n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin()\n }\n\n componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n this.handleApply()\n\n }\n\n handleApply() {\n const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (bonus) {\n this.bonus = JSON.parse(bonus);\n this.step = StepFormEnum.STEP_RESERVE;\n }\n\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber()\n\n this.pinInfo = await this.crmBonusService.sendPin(_phone, \"\", this.storeName);\n\n this.step = StepFormEnum.STEP_PIN;\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n if (this.sucess) {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.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 if (!this.bonus.hasBonus) {\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n // localStorage.removeItem(this.cartId);\n this.save(0)\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 public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\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 render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)}\n />\n }\n\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}"],"version":3}
|
1
|
+
{"file":"crm-giftback-form.entry.cjs.js","mappings":";;;;;;;;;;AAAA,MAAM,eAAe,GAAG,i9BAAi9B,CAAC;AAC1+B,8BAAe,e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AC,kBAAkB,IAAE,IAAI,CAAC,MAAM,CAAK,EAC5D,IAAI,CAAC,KAAK,IAAIA,gEAAG,KAAK,EAAC,mBAAmB,IAAE,IAAI,CAAC,KAAK,CAAK,CAEnD,EAIX,IAAI,CAAC,IAAI,KAAKH,oBAAY,CAAC,YAAY;YACvCG,4EACE,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,EACjC,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,CAAC,cAAsB,KAAK,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,GACtE,EAKF,IAAI,CAAC,IAAI,KAAKH,oBAAY,CAAC,aAAa;aAEtCG,kEAAK,KAAK,EAAC,mBAAmB,IAC3BC,aAAO,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAC9D,CACP,CAGC,EACP;KACF;;;;;;","names":["CrmBonusService","StepFormEnum","getKeyReserveByCartId","getInfoCustomization","h","i18next"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n font-family: Roboto;\n font-size: var(--crmfont-sizebodymd);\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n font-size: 14px;\n color: var(--crm-btn);\n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n font-size: 16px;\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n font-size: 12px;\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n font-size: 12px;\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\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\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_PHONE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus() {\n this.sucess = \"\";\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n\n if(_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.bonus = bonus;\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n this.step = StepFormEnum.STEP_RESERVE;\n \n }\n \n \n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin()\n }\n\n async componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n await this.handleApply()\n\n }\n\n async handleApply() {\n await this.processBonus();\n \n // const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n // if (bonus) {\n // this.bonus = JSON.parse(bonus);\n // this.step = StepFormEnum.STEP_RESERVE; \n // }\n\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber()\n\n this.pinInfo = await this.crmBonusService.sendPin(_phone, \"\", this.storeName);\n\n this.step = StepFormEnum.STEP_PIN;\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n if (this.sucess) {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.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 if (!this.bonus.hasBonus) {\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n // localStorage.removeItem(this.cartId);\n this.save(0)\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 public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\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 render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)}\n />\n }\n\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}"],"version":3}
|
@@ -32,12 +32,14 @@ export class CrmBonus {
|
|
32
32
|
const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
|
33
33
|
if (_bonus) {
|
34
34
|
const bonus = JSON.parse(_bonus);
|
35
|
+
this.bonus = bonus;
|
35
36
|
this.phone = bonus.phone;
|
36
37
|
this.pinInfo = {
|
37
38
|
storeId: bonus.storeId,
|
38
39
|
userId: bonus.userId
|
39
40
|
};
|
40
41
|
await this.validateBonus("2018");
|
42
|
+
this.step = StepFormEnum.STEP_RESERVE;
|
41
43
|
}
|
42
44
|
}
|
43
45
|
async handleSendPin(phone) {
|
@@ -49,18 +51,19 @@ export class CrmBonus {
|
|
49
51
|
this.phone = phone;
|
50
52
|
this.sendPin();
|
51
53
|
}
|
52
|
-
componentWillLoad() {
|
54
|
+
async componentWillLoad() {
|
53
55
|
this.sucess = "";
|
54
56
|
this.error = "";
|
55
57
|
this.config = getInfoCustomization(this.storeName);
|
56
|
-
this.handleApply();
|
58
|
+
await this.handleApply();
|
57
59
|
}
|
58
|
-
handleApply() {
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
async handleApply() {
|
61
|
+
await this.processBonus();
|
62
|
+
// const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
|
63
|
+
// if (bonus) {
|
64
|
+
// this.bonus = JSON.parse(bonus);
|
65
|
+
// this.step = StepFormEnum.STEP_RESERVE;
|
66
|
+
// }
|
64
67
|
}
|
65
68
|
convertStringToNumber() {
|
66
69
|
const _phone = this.phone.replace(/\D/g, '');
|
@@ -182,11 +185,11 @@ export class CrmBonus {
|
|
182
185
|
});
|
183
186
|
}
|
184
187
|
render() {
|
185
|
-
return (h("div", { key: '
|
186
|
-
h("phone-form", { key: '
|
187
|
-
h("pin-form", { key: '
|
188
|
-
h("giftback-info", { key: '
|
189
|
-
(h("div", { key: '
|
188
|
+
return (h("div", { key: 'bcdcaf47c056325591abc1aca2af8b139b687905', class: "crm-container-form fbits-responsive-carrinho-desconto" }, h("label", { key: 'e5a07f16ec6209c01abcfbd43628c510ba87bbc7', class: "crm-title" }, this.config.giftbackTitle), this.step === StepFormEnum.STEP_PHONE &&
|
189
|
+
h("phone-form", { key: '9c928594efaee7f7ebd503b2144eec1ba9c1e8a5', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === StepFormEnum.STEP_PIN &&
|
190
|
+
h("pin-form", { key: 'd1280fb5e3b71b004b641af35fc4a1f8df85ced8', config: this.config, phone: this.phone, cancel: () => this.changePhone(), resend: () => this.sendPin(), validate: (data) => this.validateBonus(data), loading: this.loading }, this.sucess && h("p", { key: 'eab06087abbac2ce8fada74cd9313ef87ea63ab9', class: "crm-message-info" }, this.sucess), this.error && h("p", { key: '822b7d1058e8e9dfcdc3a2351984aeed3e8fca6c', class: "crm-message-error" }, this.error)), this.step === StepFormEnum.STEP_RESERVE &&
|
191
|
+
h("giftback-info", { key: 'e45d28b56f8a8e831050b8afc4075ccbf3bb10b3', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === StepFormEnum.STEP_NO_BONUS &&
|
192
|
+
(h("div", { key: 'bed09587cfcd07465345dbca12ef15657c641680', class: "container-message" }, i18next.t("noGiftback", { storename: this.config.giftbackTitle })))));
|
190
193
|
}
|
191
194
|
static get is() { return "crm-giftback-form"; }
|
192
195
|
static get originalStyleUrls() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"giftback-form.js","sourceRoot":"","sources":["../../../../src/components/giftback-form/giftback-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAc,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAEpF,OAAO,OAAO,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAMjE,MAAM,OAAO,QAAQ;;QACnB,gDAAgD;QAExC,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;;;;;;uBAQ7C,KAAK;;;;oBAIH,YAAY,CAAC,UAAU;;sBAG3B,EAAE;qBACH,EAAE;;6BAGF,KAAK;;IAI9B,KAAK,CAAC,OAAO,CAAC,IAAkB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAGD,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAGxE,IAAG,MAAM,EAAE,CAAC;YAEV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YAEhC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YACzB,IAAI,CAAC,OAAO,GAAG;gBACb,OAAO,EAAE,KAAK,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,CAEnD;YAIX,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,YAAY;gBACvC,sEACE,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,EACjC,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,CAAC,cAAsB,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,GACtE;YAKF,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,aAAa;gBACxC,CACE,4DAAK,KAAK,EAAC,mBAAmB,IAC3B,OAAO,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAC9D,CACP,CAGC,CACP,CAAA;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\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\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_PHONE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus() {\n this.sucess = \"\";\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n\n if(_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\")\n }\n \n \n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin()\n }\n\n componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n this.handleApply()\n\n }\n\n handleApply() {\n const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (bonus) {\n this.bonus = JSON.parse(bonus);\n this.step = StepFormEnum.STEP_RESERVE;\n }\n\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber()\n\n this.pinInfo = await this.crmBonusService.sendPin(_phone, \"\", this.storeName);\n\n this.step = StepFormEnum.STEP_PIN;\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n if (this.sucess) {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.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 if (!this.bonus.hasBonus) {\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n // localStorage.removeItem(this.cartId);\n this.save(0)\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 public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\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 render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)}\n />\n }\n\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}"]}
|
1
|
+
{"version":3,"file":"giftback-form.js","sourceRoot":"","sources":["../../../../src/components/giftback-form/giftback-form.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAc,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAEpF,OAAO,OAAO,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAMjE,MAAM,OAAO,QAAQ;;QACnB,gDAAgD;QAExC,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE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;CACF","sourcesContent":["import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\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\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_PHONE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus() {\n this.sucess = \"\";\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n\n if(_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.bonus = bonus;\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n this.step = StepFormEnum.STEP_RESERVE;\n \n }\n \n \n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin()\n }\n\n async componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n await this.handleApply()\n\n }\n\n async handleApply() {\n await this.processBonus();\n \n // const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n // if (bonus) {\n // this.bonus = JSON.parse(bonus);\n // this.step = StepFormEnum.STEP_RESERVE; \n // }\n\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber()\n\n this.pinInfo = await this.crmBonusService.sendPin(_phone, \"\", this.storeName);\n\n this.step = StepFormEnum.STEP_PIN;\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n if (this.sucess) {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.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 if (!this.bonus.hasBonus) {\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n // localStorage.removeItem(this.cartId);\n this.save(0)\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 public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\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 render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)}\n />\n }\n\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}"]}
|
@@ -4,7 +4,7 @@ import { S as StepFormEnum } from './p-a561251a.js';
|
|
4
4
|
import { i as instance } from './p-fb505488.js';
|
5
5
|
import { d as defineCustomElement$9 } from './p-8bc69d9b.js';
|
6
6
|
import { d as defineCustomElement$8 } from './p-2db8985c.js';
|
7
|
-
import { d as defineCustomElement$7 } from './p-
|
7
|
+
import { d as defineCustomElement$7 } from './p-984bc7d0.js';
|
8
8
|
import { d as defineCustomElement$6 } from './p-d4cfdf80.js';
|
9
9
|
import { d as defineCustomElement$5 } from './p-bfe98629.js';
|
10
10
|
import { d as defineCustomElement$4 } from './p-e957883c.js';
|
@@ -44,12 +44,14 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
|
|
44
44
|
const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
|
45
45
|
if (_bonus) {
|
46
46
|
const bonus = JSON.parse(_bonus);
|
47
|
+
this.bonus = bonus;
|
47
48
|
this.phone = bonus.phone;
|
48
49
|
this.pinInfo = {
|
49
50
|
storeId: bonus.storeId,
|
50
51
|
userId: bonus.userId
|
51
52
|
};
|
52
53
|
await this.validateBonus("2018");
|
54
|
+
this.step = StepFormEnum.STEP_RESERVE;
|
53
55
|
}
|
54
56
|
}
|
55
57
|
async handleSendPin(phone) {
|
@@ -61,18 +63,19 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
|
|
61
63
|
this.phone = phone;
|
62
64
|
this.sendPin();
|
63
65
|
}
|
64
|
-
componentWillLoad() {
|
66
|
+
async componentWillLoad() {
|
65
67
|
this.sucess = "";
|
66
68
|
this.error = "";
|
67
69
|
this.config = getInfoCustomization(this.storeName);
|
68
|
-
this.handleApply();
|
70
|
+
await this.handleApply();
|
69
71
|
}
|
70
|
-
handleApply() {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
async handleApply() {
|
73
|
+
await this.processBonus();
|
74
|
+
// const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
|
75
|
+
// if (bonus) {
|
76
|
+
// this.bonus = JSON.parse(bonus);
|
77
|
+
// this.step = StepFormEnum.STEP_RESERVE;
|
78
|
+
// }
|
76
79
|
}
|
77
80
|
convertStringToNumber() {
|
78
81
|
const _phone = this.phone.replace(/\D/g, '');
|
@@ -194,11 +197,11 @@ const CrmBonus = /*@__PURE__*/ proxyCustomElement(class CrmBonus extends H {
|
|
194
197
|
});
|
195
198
|
}
|
196
199
|
render() {
|
197
|
-
return (h("div", { key: '
|
198
|
-
h("phone-form", { key: '
|
199
|
-
h("pin-form", { key: '
|
200
|
-
h("giftback-info", { key: '
|
201
|
-
(h("div", { key: '
|
200
|
+
return (h("div", { key: 'bcdcaf47c056325591abc1aca2af8b139b687905', class: "crm-container-form fbits-responsive-carrinho-desconto" }, h("label", { key: 'e5a07f16ec6209c01abcfbd43628c510ba87bbc7', class: "crm-title" }, this.config.giftbackTitle), this.step === StepFormEnum.STEP_PHONE &&
|
201
|
+
h("phone-form", { key: '9c928594efaee7f7ebd503b2144eec1ba9c1e8a5', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === StepFormEnum.STEP_PIN &&
|
202
|
+
h("pin-form", { key: 'd1280fb5e3b71b004b641af35fc4a1f8df85ced8', config: this.config, phone: this.phone, cancel: () => this.changePhone(), resend: () => this.sendPin(), validate: (data) => this.validateBonus(data), loading: this.loading }, this.sucess && h("p", { key: 'eab06087abbac2ce8fada74cd9313ef87ea63ab9', class: "crm-message-info" }, this.sucess), this.error && h("p", { key: '822b7d1058e8e9dfcdc3a2351984aeed3e8fca6c', class: "crm-message-error" }, this.error)), this.step === StepFormEnum.STEP_RESERVE &&
|
203
|
+
h("giftback-info", { key: 'e45d28b56f8a8e831050b8afc4075ccbf3bb10b3', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === StepFormEnum.STEP_NO_BONUS &&
|
204
|
+
(h("div", { key: 'bed09587cfcd07465345dbca12ef15657c641680', class: "container-message" }, instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
|
202
205
|
}
|
203
206
|
static get style() { return CrmGiftbackFormStyle0; }
|
204
207
|
}, [0, "crm-giftback-form", {
|
@@ -272,4 +275,4 @@ defineCustomElement();
|
|
272
275
|
|
273
276
|
export { CrmBonus as C, defineCustomElement as d };
|
274
277
|
|
275
|
-
//# sourceMappingURL=p-
|
278
|
+
//# sourceMappingURL=p-984bc7d0.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"file":"p-984bc7d0.js","mappings":";;;;;;;;;;;;;AAAA,MAAM,eAAe,GAAG,i9BAAi9B,CAAC;AAC1+B,8BAAe,eAAe;;MCajB,QAAQ;;;;;QAGX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;;;;;;uBAQ7C,KAAK;;;;oBAIH,YAAY,CAAC,UAAU;;sBAG3B,EAAE;qBACH,EAAE;;6BAGF,KAAK;;IAI9B,MAAM,OAAO,CAAC,IAAkB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACjB;IAGD,MAAM,YAAY;QAChB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAGxE,IAAG,MAAM,EAAE;YAET,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YAEhC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YAEnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YACzB,IAAI,CAAC,OAAO,GAAG;gBACb,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,MAAM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":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n font-family: Roboto;\n font-size: var(--crmfont-sizebodymd);\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n font-size: 14px;\n color: var(--crm-btn);\n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n font-size: 16px;\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n font-size: 12px;\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n font-size: 12px;\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\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\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_PHONE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus() {\n this.sucess = \"\";\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n\n if(_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.bonus = bonus;\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n this.step = StepFormEnum.STEP_RESERVE;\n \n }\n \n \n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin()\n }\n\n async componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n await this.handleApply()\n\n }\n\n async handleApply() {\n await this.processBonus();\n \n // const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n // if (bonus) {\n // this.bonus = JSON.parse(bonus);\n // this.step = StepFormEnum.STEP_RESERVE; \n // }\n\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber()\n\n this.pinInfo = await this.crmBonusService.sendPin(_phone, \"\", this.storeName);\n\n this.step = StepFormEnum.STEP_PIN;\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n if (this.sucess) {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.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 if (!this.bonus.hasBonus) {\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n // localStorage.removeItem(this.cartId);\n this.save(0)\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 public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\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 render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)}\n />\n }\n\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}"],"version":3}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{p as e,b as n}from"./p-45c0296c.js";export{s as setNonce}from"./p-45c0296c.js";import{g as a}from"./p-e1255160.js";var o=()=>{const n=import.meta.url;const a={};if(n!==""){a.resourcesUrl=new URL(".",n).href}return e(a)};o().then((async e=>{await a();return n([["p-49b323ef",[[2,"crm-bonus",{userId:[2,"userid"],storeName:[8,"storename"],productsInString:[1,"products"],cartId:[8,"cartid"],showModal:[32],products:[32],customer:[32],loading:[32],message:[32],phone:[32],canCancel:[32],amountCancel:[32],sent:[32],session:[32],resetBonus:[64]},null,{productsInString:["watchProducts"]}]]],["p-c121f6fc",[[1,"crm-bonus-form",{storeName:[8,"storename"],cartId:[8,"cart-id"],products:[16],customer:[16],sent:[16],stepNext:[2,"step-next"],phone:[2],loadingModal:[4,"loading-modal"],saveStore:[16],cancel:[16],handleCustomerName:[16],loading:[32],step:[32],message:[32],bonus:[32],setStep:[64]}]]],["p-d95bd37f",[[0,"phone-cancel-input",{sendPin:[16],loading:[4],value:[1]}]]],["p-450423b5",[[0,"phone-input",{sendPin:[16],loading:[4],value:[1]}]]],["p-a950d747",[[1,"app-modal",{isOpen:[516,"is-open"],modalTitle:[1,"modal-title"]}]]],["p-a465c900",[[0,"crm-bonus-note",{cartId:[8,"cartid"],storename:[8],url:[32],config:[32]}]]],["p-64441d8f",[[0,"pedido-finalizado",{cartId:[1,"cartid"],orderId:[2,"orderid"],metadadoString:[1,"metadado"]}]]],["p-0152eebc",[[0,"crm-button",{txtBtn:[1,"txt-btn"],loading:[4],handleClick:[16]}]]],["p-b7103956",[[1,"phone-input-mask",{initialValue:[1,"initial-value"],disabled:[4],phone:[32],message:[32],getPhone:[64]}]]],["p-da97c793",[[1,"loading-spinner",{size:[1],color:[1]}]]],["p-0160f5f5",[[0,"phone-form",{value:[1],loading:[4],handlerSubmit:[16],config:[16]}],[1,"pin-form",{validate:[16],cancel:[16],resend:[16],sent:[16],loading:[4],phone:[1],config:[16],pin:[32],isVerified:[32],canResend:[32]}],[0,"giftback-info",{loading:[4],bonus:[16],reserve:[16],cancel:[16],usedValue:[32],selectedOption:[32],sliderPosition:[32]},null,{bonus:["changedBonus"]}],[1,"countdown-timer",{downtime:[16],counter:[32]}]]],["p-
|
1
|
+
import{p as e,b as n}from"./p-45c0296c.js";export{s as setNonce}from"./p-45c0296c.js";import{g as a}from"./p-e1255160.js";var o=()=>{const n=import.meta.url;const a={};if(n!==""){a.resourcesUrl=new URL(".",n).href}return e(a)};o().then((async e=>{await a();return n([["p-49b323ef",[[2,"crm-bonus",{userId:[2,"userid"],storeName:[8,"storename"],productsInString:[1,"products"],cartId:[8,"cartid"],showModal:[32],products:[32],customer:[32],loading:[32],message:[32],phone:[32],canCancel:[32],amountCancel:[32],sent:[32],session:[32],resetBonus:[64]},null,{productsInString:["watchProducts"]}]]],["p-c121f6fc",[[1,"crm-bonus-form",{storeName:[8,"storename"],cartId:[8,"cart-id"],products:[16],customer:[16],sent:[16],stepNext:[2,"step-next"],phone:[2],loadingModal:[4,"loading-modal"],saveStore:[16],cancel:[16],handleCustomerName:[16],loading:[32],step:[32],message:[32],bonus:[32],setStep:[64]}]]],["p-d95bd37f",[[0,"phone-cancel-input",{sendPin:[16],loading:[4],value:[1]}]]],["p-450423b5",[[0,"phone-input",{sendPin:[16],loading:[4],value:[1]}]]],["p-a950d747",[[1,"app-modal",{isOpen:[516,"is-open"],modalTitle:[1,"modal-title"]}]]],["p-a465c900",[[0,"crm-bonus-note",{cartId:[8,"cartid"],storename:[8],url:[32],config:[32]}]]],["p-64441d8f",[[0,"pedido-finalizado",{cartId:[1,"cartid"],orderId:[2,"orderid"],metadadoString:[1,"metadado"]}]]],["p-0152eebc",[[0,"crm-button",{txtBtn:[1,"txt-btn"],loading:[4],handleClick:[16]}]]],["p-b7103956",[[1,"phone-input-mask",{initialValue:[1,"initial-value"],disabled:[4],phone:[32],message:[32],getPhone:[64]}]]],["p-da97c793",[[1,"loading-spinner",{size:[1],color:[1]}]]],["p-0160f5f5",[[0,"phone-form",{value:[1],loading:[4],handlerSubmit:[16],config:[16]}],[1,"pin-form",{validate:[16],cancel:[16],resend:[16],sent:[16],loading:[4],phone:[1],config:[16],pin:[32],isVerified:[32],canResend:[32]}],[0,"giftback-info",{loading:[4],bonus:[16],reserve:[16],cancel:[16],usedValue:[32],selectedOption:[32],sliderPosition:[32]},null,{bonus:["changedBonus"]}],[1,"countdown-timer",{downtime:[16],counter:[32]}]]],["p-feadb94b",[[0,"crm-giftback-form",{storeName:[8,"storename"],cartId:[8,"cart-id"],products:[16],customer:[16],value:[32],loading:[32],message:[32],phone:[32],pinInfo:[32],step:[32],bonus:[32],sucess:[32],error:[32],config:[32],hasApplyBonus:[32],setStep:[64],processBonus:[64]}]]],["p-5d209c28",[[1,"giftback-pin",{sent:[16],validate:[16],cancel:[16],loading:[4],pin:[32],isVerified:[32]}],[1,"giftback-progress",{loading:[4],bonus:[16],reserve:[16],cancel:[16],usedValue:[32]}],[0,"name-input",{value:[1],loading:[4],applyName:[16],cancel:[16],newValue:[32],message:[32]}],[1,"giftback-finish"]]]],e)}));
|
2
2
|
//# sourceMappingURL=crmbonus-component-wake.esm.js.map
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{r as t,h as i}from"./p-45c0296c.js";import{C as s,g as e}from"./p-a7ddcab4.js";import{S as o}from"./p-a561251a.js";import{g as a}from"./p-75ba7b9a.js";import{i as n}from"./p-fb505488.js";const h="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-family:Roboto;font-size:var(--crmfont-sizebodymd);font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:14px;color:var(--crm-btn)}.crm-title{font-weight:700;line-height:20px;color:#262626;font-size:16px}.crm-message-info{color:#619013;font-weight:500;font-size:12px}.crm-message-error{color:#E11D48;font-weight:500;font-size:12px}";const c=h;const r=class{constructor(i){t(this,i);this.crmBonusService=s.getInstance();this.storeName=undefined;this.cartId=undefined;this.products=undefined;this.customer=undefined;this.value=undefined;this.loading=false;this.message=undefined;this.phone=undefined;this.pinInfo=undefined;this.step=o.STEP_PHONE;this.bonus=undefined;this.sucess="";this.error="";this.config=undefined;this.hasApplyBonus=false}async setStep(t){this.step=t}async processBonus(){this.sucess="";const t=localStorage.getItem(e(this.cartId));if(t){const i=JSON.parse(t);this.bonus=i;this.phone=i.phone;this.pinInfo={storeId:i.storeId,userId:i.userId};await this.validateBonus("2018");this.step=o.STEP_RESERVE}}async handleSendPin(t){this.message="";if(!t){this.message="Informe seu telefone";return}this.phone=t;this.sendPin()}async componentWillLoad(){this.sucess="";this.error="";this.config=a(this.storeName);await this.handleApply()}async handleApply(){await this.processBonus()}convertStringToNumber(){const t=this.phone.replace(/\D/g,"");return Number(t)}async sendPin(){var t,i;this.loading=true;this.message="";this.sucess="";this.error="";try{const t=this.convertStringToNumber();this.pinInfo=await this.crmBonusService.sendPin(t,"",this.storeName);this.step=o.STEP_PIN}catch(s){this.message=(i=(t=s===null||s===void 0?void 0:s.response)===null||t===void 0?void 0:t.data)===null||i===void 0?void 0:i.message}finally{this.loading=false}}changePhone(){this.sucess="";this.error="";this.step=o.STEP_PHONE}async validateBonus(t){var i,s;if(this.sucess){this.step=o.STEP_RESERVE;return}this.loading=true;this.sucess="";this.error="";const a={pin:t,cellphone:this.phone.toString(),storeId:this.pinInfo.storeId.toString(),userId:this.pinInfo.userId.toString(),checkoutId:this.cartId,checkoutProducts:this.products,name:null,storeName:this.storeName};try{this.bonus=await this.crmBonusService.validatePinBonus(a);if(!this.bonus.hasBonus){this.loading=false;this.step=o.STEP_NO_BONUS;return}this.sucess="Código validado com sucesso!";localStorage.setItem(e(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})))}catch(t){const e=(s=(i=t===null||t===void 0?void 0:t.response)===null||i===void 0?void 0:i.data)===null||s===void 0?void 0:s.message;if(e.includes("Pin")){this.error="Código inválido!"}else{this.error=e;this.step=o.STEP_NO_BONUS}}finally{this.loading=false}}handleCancel(){this.cancel()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartId);this.save(0)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async reserveApply(t){this.loading=true;this.message="";try{await this.reserve(t);this.save(t)}catch(t){this.message="ocorreu um error ao solicitar a aplicação do bonus! tente novamente";this.step=o.STEP_NO_BONUS;localStorage.removeItem(this.cartId)}finally{this.loading=false}}save(t){localStorage.setItem(this.cartId,t.toString())}async reserve(t){await this.crmBonusService.reserve({redeemedBonus:t,cartId:this.cartId,ticket:this.cartId,grossValue:Number(this.bonus.totalValue),storeName:this.storeName,storeId:this.bonus.storeId.toString(),userId:this.bonus.userId})}render(){return i("div",{key:"bcdcaf47c056325591abc1aca2af8b139b687905",class:"crm-container-form fbits-responsive-carrinho-desconto"},i("label",{key:"e5a07f16ec6209c01abcfbd43628c510ba87bbc7",class:"crm-title"},this.config.giftbackTitle),this.step===o.STEP_PHONE&&i("phone-form",{key:"9c928594efaee7f7ebd503b2144eec1ba9c1e8a5",value:this.customer.phone,config:this.config,loading:this.loading,handlerSubmit:t=>this.handleSendPin(t)}),this.step===o.STEP_PIN&&i("pin-form",{key:"d1280fb5e3b71b004b641af35fc4a1f8df85ced8",config:this.config,phone:this.phone,cancel:()=>this.changePhone(),resend:()=>this.sendPin(),validate:t=>this.validateBonus(t),loading:this.loading},this.sucess&&i("p",{key:"eab06087abbac2ce8fada74cd9313ef87ea63ab9",class:"crm-message-info"},this.sucess),this.error&&i("p",{key:"822b7d1058e8e9dfcdc3a2351984aeed3e8fca6c",class:"crm-message-error"},this.error)),this.step===o.STEP_RESERVE&&i("giftback-info",{key:"e45d28b56f8a8e831050b8afc4075ccbf3bb10b3",loading:this.loading,cancel:()=>this.handleCancel(),bonus:this.bonus,reserve:t=>this.reserveApply(t)}),this.step===o.STEP_NO_BONUS&&i("div",{key:"bed09587cfcd07465345dbca12ef15657c641680",class:"container-message"},n.t("noGiftback",{storename:this.config.giftbackTitle})))}};r.style=c;export{r as crm_giftback_form};
|
2
|
+
//# sourceMappingURL=p-feadb94b.entry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["giftbackFormCss","CrmGiftbackFormStyle0","CrmBonus","this","crmBonusService","CrmBonusService","getInstance","StepFormEnum","STEP_PHONE","setStep","step","processBonus","sucess","_bonus","localStorage","getItem","getKeyReserveByCartId","cartId","bonus","JSON","parse","phone","pinInfo","storeId","userId","validateBonus","STEP_RESERVE","handleSendPin","message","sendPin","componentWillLoad","error","config","getInfoCustomization","storeName","handleApply","convertStringToNumber","_phone","replace","Number","loading","STEP_PIN","_b","_a","response","data","changePhone","pin","payload","cellphone","toString","checkoutId","checkoutProducts","products","name","validatePinBonus","hasBonus","STEP_NO_BONUS","setItem","stringify","Object","assign","_error","includes","handleCancel","cancel","save","reserveApply","amount","reserve","removeItem","redeemedBonus","ticket","grossValue","totalValue","render","h","key","class","giftbackTitle","value","customer","handlerSubmit","resend","validate","amountRedeemed","i18next","t","storename"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n font-family: Roboto;\n font-size: var(--crmfont-sizebodymd);\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n font-size: 14px;\n color: var(--crm-btn);\n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n font-size: 16px;\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n font-size: 12px;\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n font-size: 12px;\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\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\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_PHONE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus() {\n this.sucess = \"\";\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n\n if(_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.bonus = bonus;\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n this.step = StepFormEnum.STEP_RESERVE;\n \n }\n \n \n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin()\n }\n\n async componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n await this.handleApply()\n\n }\n\n async handleApply() {\n await this.processBonus();\n \n // const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n // if (bonus) {\n // this.bonus = JSON.parse(bonus);\n // this.step = StepFormEnum.STEP_RESERVE; \n // }\n\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber()\n\n this.pinInfo = await this.crmBonusService.sendPin(_phone, \"\", this.storeName);\n\n this.step = StepFormEnum.STEP_PIN;\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n if (this.sucess) {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.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 if (!this.bonus.hasBonus) {\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n // localStorage.removeItem(this.cartId);\n this.save(0)\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 public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\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 render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)}\n />\n }\n\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}"],"mappings":"kMAAA,MAAMA,EAAkB,k9BACxB,MAAAC,EAAeD,E,MCaFE,EAAQ,M,yBAGXC,KAAAC,gBAAmCC,EAAgBC,c,iIAQ/B,M,6EAIEC,EAAaC,W,iCAGjB,G,WACD,G,yCAGA,K,CAIzB,aAAMC,CAAQC,GACZP,KAAKO,KAAOA,C,CAId,kBAAMC,GACJR,KAAKS,OAAS,GACd,MAAMC,EAASC,aAAaC,QAAQC,EAAsBb,KAAKc,SAG/D,GAAGJ,EAAQ,CAET,MAAMK,EAAQC,KAAKC,MAAMP,GAEzBV,KAAKe,MAAQA,EAEbf,KAAKkB,MAAQH,EAAMG,MACnBlB,KAAKmB,QAAU,CACbC,QAASL,EAAMK,QACfC,OAAQN,EAAMM,cAGVrB,KAAKsB,cAAc,QACzBtB,KAAKO,KAAOH,EAAamB,Y,EAO7B,mBAAMC,CAAcN,GAElBlB,KAAKyB,QAAU,GACf,IAAKP,EAAO,CACVlB,KAAKyB,QAAU,uBACf,M,CAGFzB,KAAKkB,MAAQA,EAEblB,KAAK0B,S,CAGP,uBAAMC,GACJ3B,KAAKS,OAAS,GACdT,KAAK4B,MAAQ,GACb5B,KAAK6B,OAASC,EAAqB9B,KAAK+B,iBAElC/B,KAAKgC,a,CAIb,iBAAMA,S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OACEC,EAAA,OAAAC,IAAA,2CAAKC,MAAM,yDACTF,EAAA,SAAAC,IAAA,2CAAOC,MAAM,aAAa3E,KAAK6B,OAAO+C,eAErC5E,KAAKO,OAASH,EAAaC,YAC1BoE,EAAA,cAAAC,IAAA,2CACEG,MAAO7E,KAAK8E,SAAS5D,MACrBW,OAAQ7B,KAAK6B,OACbQ,QAASrC,KAAKqC,QACd0C,cAAgB7D,GAAUlB,KAAKwB,cAAcN,KAG/ClB,KAAKO,OAASH,EAAakC,UAC3BmC,EAAA,YAAAC,IAAA,2CACE7C,OAAQ7B,KAAK6B,OACbX,MAAOlB,KAAKkB,MACZ4C,OAAQ,IAAM9D,KAAK2C,cACnBqC,OAAQ,IAAMhF,KAAK0B,UACnBuD,SAAWvC,GAAS1C,KAAKsB,cAAcoB,GACvCL,QAASrC,KAAKqC,SAEbrC,KAAKS,QAAUgE,EAAA,KAAAC,IAAA,2CAAGC,MAAM,oBAAoB3E,KAAKS,QACjDT,KAAK4B,OAAS6C,EAAA,KAAAC,IAAA,2CAAGC,MAAM,qBAAqB3E,KAAK4B,QAMpD5B,KAAKO,OAASH,EAAamB,cAC3BkD,EAAA,iBAAAC,IAAA,2CACErC,QAASrC,KAAKqC,QACdyB,OAAQ,IAAM9D,KAAK6D,eACnB9C,MAAOf,KAAKe,MACZmD,QAAUgB,GAA2BlF,KAAKgE,aAAakB,KAMzDlF,KAAKO,OAASH,EAAakD,eAEzBmB,EAAA,OAAAC,IAAA,2CAAKC,MAAM,qBACRQ,EAAQC,EAAE,aAAc,CAAEC,UAAWrF,KAAK6B,OAAO+C,iB","ignoreList":[]}
|
@@ -36,12 +36,14 @@ const CrmBonus = class {
|
|
36
36
|
const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
|
37
37
|
if (_bonus) {
|
38
38
|
const bonus = JSON.parse(_bonus);
|
39
|
+
this.bonus = bonus;
|
39
40
|
this.phone = bonus.phone;
|
40
41
|
this.pinInfo = {
|
41
42
|
storeId: bonus.storeId,
|
42
43
|
userId: bonus.userId
|
43
44
|
};
|
44
45
|
await this.validateBonus("2018");
|
46
|
+
this.step = StepFormEnum.STEP_RESERVE;
|
45
47
|
}
|
46
48
|
}
|
47
49
|
async handleSendPin(phone) {
|
@@ -53,18 +55,19 @@ const CrmBonus = class {
|
|
53
55
|
this.phone = phone;
|
54
56
|
this.sendPin();
|
55
57
|
}
|
56
|
-
componentWillLoad() {
|
58
|
+
async componentWillLoad() {
|
57
59
|
this.sucess = "";
|
58
60
|
this.error = "";
|
59
61
|
this.config = getInfoCustomization(this.storeName);
|
60
|
-
this.handleApply();
|
62
|
+
await this.handleApply();
|
61
63
|
}
|
62
|
-
handleApply() {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
async handleApply() {
|
65
|
+
await this.processBonus();
|
66
|
+
// const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));
|
67
|
+
// if (bonus) {
|
68
|
+
// this.bonus = JSON.parse(bonus);
|
69
|
+
// this.step = StepFormEnum.STEP_RESERVE;
|
70
|
+
// }
|
68
71
|
}
|
69
72
|
convertStringToNumber() {
|
70
73
|
const _phone = this.phone.replace(/\D/g, '');
|
@@ -186,11 +189,11 @@ const CrmBonus = class {
|
|
186
189
|
});
|
187
190
|
}
|
188
191
|
render() {
|
189
|
-
return (h("div", { key: '
|
190
|
-
h("phone-form", { key: '
|
191
|
-
h("pin-form", { key: '
|
192
|
-
h("giftback-info", { key: '
|
193
|
-
(h("div", { key: '
|
192
|
+
return (h("div", { key: 'bcdcaf47c056325591abc1aca2af8b139b687905', class: "crm-container-form fbits-responsive-carrinho-desconto" }, h("label", { key: 'e5a07f16ec6209c01abcfbd43628c510ba87bbc7', class: "crm-title" }, this.config.giftbackTitle), this.step === StepFormEnum.STEP_PHONE &&
|
193
|
+
h("phone-form", { key: '9c928594efaee7f7ebd503b2144eec1ba9c1e8a5', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === StepFormEnum.STEP_PIN &&
|
194
|
+
h("pin-form", { key: 'd1280fb5e3b71b004b641af35fc4a1f8df85ced8', config: this.config, phone: this.phone, cancel: () => this.changePhone(), resend: () => this.sendPin(), validate: (data) => this.validateBonus(data), loading: this.loading }, this.sucess && h("p", { key: 'eab06087abbac2ce8fada74cd9313ef87ea63ab9', class: "crm-message-info" }, this.sucess), this.error && h("p", { key: '822b7d1058e8e9dfcdc3a2351984aeed3e8fca6c', class: "crm-message-error" }, this.error)), this.step === StepFormEnum.STEP_RESERVE &&
|
195
|
+
h("giftback-info", { key: 'e45d28b56f8a8e831050b8afc4075ccbf3bb10b3', loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: (amountRedeemed) => this.reserveApply(amountRedeemed) }), this.step === StepFormEnum.STEP_NO_BONUS &&
|
196
|
+
(h("div", { key: 'bed09587cfcd07465345dbca12ef15657c641680', class: "container-message" }, instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
|
194
197
|
}
|
195
198
|
};
|
196
199
|
CrmBonus.style = CrmGiftbackFormStyle0;
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"crm-giftback-form.entry.js","mappings":";;;;;;AAAA,MAAM,eAAe,GAAG,i9BAAi9B,CAAC;AAC1+B,8BAAe,eAAe;;MCajB,QAAQ;;;;QAGX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;;;;;;uBAQ7C,KAAK;;;;oBAIH,YAAY,CAAC,UAAU;;sBAG3B,EAAE;qBACH,EAAE;;6BAGF,KAAK;;IAI9B,MAAM,OAAO,CAAC,IAAkB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACjB;IAGD,MAAM,YAAY;QAChB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAGxE,IAAG,MAAM,EA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cAAc,CAAC,GACtE,EAKF,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,aAAa;aAEtC,4DAAK,KAAK,EAAC,mBAAmB,IAC3BA,QAAO,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAC9D,CACP,CAGC,EACP;KACF;;;;;;","names":["i18next"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n font-family: Roboto;\n font-size: var(--crmfont-sizebodymd);\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n font-size: 14px;\n color: var(--crm-btn);\n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n font-size: 16px;\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n font-size: 12px;\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n font-size: 12px;\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\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\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_PHONE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus() {\n this.sucess = \"\";\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n\n if(_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\")\n }\n \n \n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin()\n }\n\n componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n this.handleApply()\n\n }\n\n handleApply() {\n const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (bonus) {\n this.bonus = JSON.parse(bonus);\n this.step = StepFormEnum.STEP_RESERVE;\n }\n\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber()\n\n this.pinInfo = await this.crmBonusService.sendPin(_phone, \"\", this.storeName);\n\n this.step = StepFormEnum.STEP_PIN;\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n if (this.sucess) {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.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 if (!this.bonus.hasBonus) {\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n // localStorage.removeItem(this.cartId);\n this.save(0)\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 public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\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 render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)}\n />\n }\n\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}"],"version":3}
|
1
|
+
{"file":"crm-giftback-form.entry.js","mappings":";;;;;;AAAA,MAAM,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AG,KAAK,EAAC,kBAAkB,IAAE,IAAI,CAAC,MAAM,CAAK,EAC5D,IAAI,CAAC,KAAK,IAAI,0DAAG,KAAK,EAAC,mBAAmB,IAAE,IAAI,CAAC,KAAK,CAAK,CAEnD,EAIX,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,YAAY;YACvC,sEACE,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,EACjC,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,CAAC,cAAsB,KAAK,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,GACtE,EAKF,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,aAAa;aAEtC,4DAAK,KAAK,EAAC,mBAAmB,IAC3BA,QAAO,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAC9D,CACP,CAGC,EACP;KACF;;;;;;","names":["i18next"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n font-family: Roboto;\n font-size: var(--crmfont-sizebodymd);\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n font-size: 14px;\n color: var(--crm-btn);\n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n font-size: 16px;\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n font-size: 12px;\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n font-size: 12px;\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\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\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_PHONE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus() {\n this.sucess = \"\";\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n\n if(_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.bonus = bonus;\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\");\n this.step = StepFormEnum.STEP_RESERVE;\n \n }\n \n \n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin()\n }\n\n async componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n await this.handleApply()\n\n }\n\n async handleApply() {\n await this.processBonus();\n \n // const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n // if (bonus) {\n // this.bonus = JSON.parse(bonus);\n // this.step = StepFormEnum.STEP_RESERVE; \n // }\n\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber()\n\n this.pinInfo = await this.crmBonusService.sendPin(_phone, \"\", this.storeName);\n\n this.step = StepFormEnum.STEP_PIN;\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n if (this.sucess) {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.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 if (!this.bonus.hasBonus) {\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n // localStorage.removeItem(this.cartId);\n this.save(0)\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 public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\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 render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)}\n />\n }\n\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}"],"version":3}
|
@@ -22,8 +22,8 @@ export declare class CrmBonus {
|
|
22
22
|
setStep(step: StepFormEnum): Promise<void>;
|
23
23
|
processBonus(): Promise<void>;
|
24
24
|
handleSendPin(phone: string): Promise<void>;
|
25
|
-
componentWillLoad(): void
|
26
|
-
handleApply(): void
|
25
|
+
componentWillLoad(): Promise<void>;
|
26
|
+
handleApply(): Promise<void>;
|
27
27
|
private convertStringToNumber;
|
28
28
|
sendPin(): Promise<void>;
|
29
29
|
changePhone(): void;
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
{"file":"p-5a26c163.js","mappings":";;;;;;;;;;;;;AAAA,MAAM,eAAe,GAAG,i9BAAi9B,CAAC;AAC1+B,8BAAe,eAAe;;MCajB,QAAQ;;;;;QAGX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;;;;;;uBAQ7C,KAAK;;;;oBAIH,YAAY,CAAC,UAAU;;sBAG3B,EAAE;qBACH,EAAE;;6BAGF,KAAK;;IAI9B,MAAM,OAAO,CAAC,IAAkB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACjB;IAGD,MAAM,YAAY;QAChB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,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E,CAAC,cAAsB,KAAK,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,GACtE,EAKF,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,aAAa;aAEtC,4DAAK,KAAK,EAAC,mBAAmB,IAC3BA,QAAO,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAC9D,CACP,CAGC,EACP;KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["i18next"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n font-family: Roboto;\n font-size: var(--crmfont-sizebodymd);\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n font-size: 14px;\n color: var(--crm-btn);\n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n font-size: 16px;\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n font-size: 12px;\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n font-size: 12px;\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\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\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_PHONE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus() {\n this.sucess = \"\";\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n\n if(_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\")\n }\n \n \n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin()\n }\n\n componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n this.handleApply()\n\n }\n\n handleApply() {\n const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (bonus) {\n this.bonus = JSON.parse(bonus);\n this.step = StepFormEnum.STEP_RESERVE;\n }\n\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber()\n\n this.pinInfo = await this.crmBonusService.sendPin(_phone, \"\", this.storeName);\n\n this.step = StepFormEnum.STEP_PIN;\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n if (this.sucess) {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.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 if (!this.bonus.hasBonus) {\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n // localStorage.removeItem(this.cartId);\n this.save(0)\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 public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\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 render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)}\n />\n }\n\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}"],"version":3}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import{r as t,h as i}from"./p-45c0296c.js";import{C as s,g as e}from"./p-a7ddcab4.js";import{S as o}from"./p-a561251a.js";import{g as n}from"./p-75ba7b9a.js";import{i as h}from"./p-fb505488.js";const a="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-family:Roboto;font-size:var(--crmfont-sizebodymd);font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:14px;color:var(--crm-btn)}.crm-title{font-weight:700;line-height:20px;color:#262626;font-size:16px}.crm-message-info{color:#619013;font-weight:500;font-size:12px}.crm-message-error{color:#E11D48;font-weight:500;font-size:12px}";const r=a;const c=class{constructor(i){t(this,i);this.crmBonusService=s.getInstance();this.storeName=undefined;this.cartId=undefined;this.products=undefined;this.customer=undefined;this.value=undefined;this.loading=false;this.message=undefined;this.phone=undefined;this.pinInfo=undefined;this.step=o.STEP_PHONE;this.bonus=undefined;this.sucess="";this.error="";this.config=undefined;this.hasApplyBonus=false}async setStep(t){this.step=t}async processBonus(){this.sucess="";const t=localStorage.getItem(e(this.cartId));if(t){const i=JSON.parse(t);this.phone=i.phone;this.pinInfo={storeId:i.storeId,userId:i.userId};await this.validateBonus("2018")}}async handleSendPin(t){this.message="";if(!t){this.message="Informe seu telefone";return}this.phone=t;this.sendPin()}componentWillLoad(){this.sucess="";this.error="";this.config=n(this.storeName);this.handleApply()}handleApply(){const t=localStorage.getItem(e(this.cartId));if(t){this.bonus=JSON.parse(t);this.step=o.STEP_RESERVE}}convertStringToNumber(){const t=this.phone.replace(/\D/g,"");return Number(t)}async sendPin(){var t,i;this.loading=true;this.message="";this.sucess="";this.error="";try{const t=this.convertStringToNumber();this.pinInfo=await this.crmBonusService.sendPin(t,"",this.storeName);this.step=o.STEP_PIN}catch(s){this.message=(i=(t=s===null||s===void 0?void 0:s.response)===null||t===void 0?void 0:t.data)===null||i===void 0?void 0:i.message}finally{this.loading=false}}changePhone(){this.sucess="";this.error="";this.step=o.STEP_PHONE}async validateBonus(t){var i,s;if(this.sucess){this.step=o.STEP_RESERVE;return}this.loading=true;this.sucess="";this.error="";const n={pin:t,cellphone:this.phone.toString(),storeId:this.pinInfo.storeId.toString(),userId:this.pinInfo.userId.toString(),checkoutId:this.cartId,checkoutProducts:this.products,name:null,storeName:this.storeName};try{this.bonus=await this.crmBonusService.validatePinBonus(n);if(!this.bonus.hasBonus){this.loading=false;this.step=o.STEP_NO_BONUS;return}this.sucess="Código validado com sucesso!";localStorage.setItem(e(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})))}catch(t){const e=(s=(i=t===null||t===void 0?void 0:t.response)===null||i===void 0?void 0:i.data)===null||s===void 0?void 0:s.message;if(e.includes("Pin")){this.error="Código inválido!"}else{this.error=e;this.step=o.STEP_NO_BONUS}}finally{this.loading=false}}handleCancel(){this.cancel()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartId);this.save(0)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async reserveApply(t){this.loading=true;this.message="";try{await this.reserve(t);this.save(t)}catch(t){this.message="ocorreu um error ao solicitar a aplicação do bonus! tente novamente";this.step=o.STEP_NO_BONUS;localStorage.removeItem(this.cartId)}finally{this.loading=false}}save(t){localStorage.setItem(this.cartId,t.toString())}async reserve(t){await this.crmBonusService.reserve({redeemedBonus:t,cartId:this.cartId,ticket:this.cartId,grossValue:Number(this.bonus.totalValue),storeName:this.storeName,storeId:this.bonus.storeId.toString(),userId:this.bonus.userId})}render(){return i("div",{key:"50cb7f1d168127e5ef15ee728c5ab376c6b56eae",class:"crm-container-form fbits-responsive-carrinho-desconto"},i("label",{key:"ea97bf9b616826be4b861bdad61f5ff362a7eac4",class:"crm-title"},this.config.giftbackTitle),this.step===o.STEP_PHONE&&i("phone-form",{key:"25094c38c8d70305d55f10131ea2e84258faf627",value:this.customer.phone,config:this.config,loading:this.loading,handlerSubmit:t=>this.handleSendPin(t)}),this.step===o.STEP_PIN&&i("pin-form",{key:"1abbf4b064920586102eb983e44b937de5d71092",config:this.config,phone:this.phone,cancel:()=>this.changePhone(),resend:()=>this.sendPin(),validate:t=>this.validateBonus(t),loading:this.loading},this.sucess&&i("p",{key:"6643e540d05642bdabc7a004b2165f8c401848e4",class:"crm-message-info"},this.sucess),this.error&&i("p",{key:"e38dd84f1eda48a8936753b185b56bfd5147e89f",class:"crm-message-error"},this.error)),this.step===o.STEP_RESERVE&&i("giftback-info",{key:"084007d5a1e9d16f3d30fd742278c62c4c013ce6",loading:this.loading,cancel:()=>this.handleCancel(),bonus:this.bonus,reserve:t=>this.reserveApply(t)}),this.step===o.STEP_NO_BONUS&&i("div",{key:"8d214593cd77985b2e2ccedd75c0feb29a73cf44",class:"container-message"},h.t("noGiftback",{storename:this.config.giftbackTitle})))}};c.style=r;export{c as crm_giftback_form};
|
2
|
-
//# sourceMappingURL=p-c04d7aac.entry.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["giftbackFormCss","CrmGiftbackFormStyle0","CrmBonus","this","crmBonusService","CrmBonusService","getInstance","StepFormEnum","STEP_PHONE","setStep","step","processBonus","sucess","_bonus","localStorage","getItem","getKeyReserveByCartId","cartId","bonus","JSON","parse","phone","pinInfo","storeId","userId","validateBonus","handleSendPin","message","sendPin","componentWillLoad","error","config","getInfoCustomization","storeName","handleApply","STEP_RESERVE","convertStringToNumber","_phone","replace","Number","loading","STEP_PIN","_b","_a","response","data","changePhone","pin","payload","cellphone","toString","checkoutId","checkoutProducts","products","name","validatePinBonus","hasBonus","STEP_NO_BONUS","setItem","stringify","Object","assign","_error","includes","handleCancel","cancel","save","reserveApply","amount","reserve","removeItem","redeemedBonus","ticket","grossValue","totalValue","render","h","key","class","giftbackTitle","value","customer","handlerSubmit","resend","validate","amountRedeemed","i18next","t","storename"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx"],"sourcesContent":["* {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n}\n\n:host {\n --crmfont-sizebodymd: 14px;\n --crmline-heightbodymd: 20px;\n --crmletter-spacingtitle-md: 0px\n}\n\n.container-message {\n font-family: Roboto;\n font-size: var(--crmfont-sizebodymd);\n font-weight: 400;\n line-height: var(--crmline-heightbodymd);\n letter-spacing: var(--crmletter-spacingtitle-md);\n text-align: left;\n text-underline-position: from-font;\n text-decoration-skip-ink: none;\n}\n\n.crm-container-form {\n display: flex;\n flex-direction: column;\n justify-content: space-around;\n height: auto;\n padding: 20px 24px 20px 24px;\n border: 1px solid #CCCC;\n writing-mode: horizontal-tb;\n gap: 16px;\n border-top: 1px solid #ccc !important;\n border-bottom: 1px solid #ccc !important;\n}\n\n/* .fbits-responsive-carrinho-desconto {\n overflow: hidden;\n border: 1px solid #ccc;\n border-top: 0;\n border-bottom: 0;\n} */\n\n.crm-phone-form {\n display: flex;\n flex-direction: column;\n height: 100%;\n /* justify-content: space-around; */\n gap: 16px;\n}\n\n.crm-subtitle {\n font-size: 14px;\n color: var(--crm-btn);\n}\n\n.crm-title {\n font-weight: 700;\n line-height: 20px;\n color: #262626;\n font-size: 16px;\n}\n\n.crm-message-info {\n color: #619013;\n font-weight: 500;\n font-size: 12px;\n}\n\n.crm-message-error {\n color: #E11D48;\n font-weight: 500;\n font-size: 12px;\n}","import { Component, Method, Prop, State, h } from \"@stencil/core\";\nimport { CrmBonusService } from \"../../services/crmbonus.service\";\nimport { StepFormEnum } from \"../../contants\";\nimport { IPinSent } from '../../dto/pin.sent'\nimport { IBonus, ICustomer, IProccesPinBonusDto, IProduct } from \"../../dto/validate.pin.bonus\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport i18next from \"../../i18n/i18n\"\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\n\n@Component({\n tag: 'crm-giftback-form',\n styleUrl: 'giftback-form.css'\n})\nexport class CrmBonus {\n // private phoneInputMask: HTMLPhoneFormElement;\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\n @State() value: string;\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: string;\n @State() pinInfo: IPinSent;\n @State() step: StepFormEnum = StepFormEnum.STEP_PHONE;\n @State() bonus: IBonus;\n\n @State() sucess: string = \"\";\n @State() error: string = \"\";\n @State() config: IInfoStore;\n\n @State() hasApplyBonus = false;\n\n\n @Method()\n async setStep(step: StepFormEnum) {\n this.step = step\n }\n\n @Method()\n async processBonus() {\n this.sucess = \"\";\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n\n if(_bonus) {\n\n const bonus = JSON.parse(_bonus)\n\n this.phone = bonus.phone;\n this.pinInfo = {\n storeId: bonus.storeId,\n userId: bonus.userId\n }\n\n await this.validateBonus(\"2018\")\n }\n \n \n }\n\n async handleSendPin(phone: string) {\n\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.phone = phone;\n\n this.sendPin()\n }\n\n componentWillLoad() {\n this.sucess = \"\";\n this.error = \"\"\n this.config = getInfoCustomization(this.storeName);\n\n this.handleApply()\n\n }\n\n handleApply() {\n const bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (bonus) {\n this.bonus = JSON.parse(bonus);\n this.step = StepFormEnum.STEP_RESERVE;\n }\n\n }\n\n private convertStringToNumber(): number {\n const _phone = this.phone.replace(/\\D/g, '');\n return Number(_phone);\n }\n\n public async sendPin() {\n this.loading = true;\n this.message = \"\";\n this.sucess = \"\";\n this.error = \"\"\n\n try {\n\n const _phone = this.convertStringToNumber()\n\n this.pinInfo = await this.crmBonusService.sendPin(_phone, \"\", this.storeName);\n\n this.step = StepFormEnum.STEP_PIN;\n\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n changePhone() {\n this.sucess = \"\";\n this.error = \"\"\n this.step = StepFormEnum.STEP_PHONE;\n }\n\n public async validateBonus(pin: string) {\n\n if (this.sucess) {\n this.step = StepFormEnum.STEP_RESERVE;\n return\n }\n\n this.loading = true;\n this.sucess = \"\";\n this.error = \"\";\n const payload: IProccesPinBonusDto = {\n pin: pin,\n cellphone: this.phone.toString(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.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 if (!this.bonus.hasBonus) {\n this.loading = false;\n this.step = StepFormEnum.STEP_NO_BONUS;\n return\n }\n\n this.sucess = \"Código validado com sucesso!\";\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\n } catch (error) {\n const _error: string = error?.response?.data?.message;\n\n if (_error.includes(\"Pin\")) {\n this.error = \"Código inválido!\"\n } else {\n this.error = _error;\n this.step = StepFormEnum.STEP_NO_BONUS;\n }\n\n\n } finally {\n this.loading = false;\n }\n }\n\n public handleCancel() {\n // this.step = StepFormEnum.STEP_PHONE;\n this.cancel()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n // localStorage.removeItem(this.cartId);\n this.save(0)\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 public async reserveApply(amount: number) {\n this.loading = true;\n this.message = \"\";\n try {\n await this.reserve(amount);\n this.save(amount);\n\n } catch (error) {\n this.message = \"ocorreu um error ao solicitar a aplicação do bonus! tente novamente\"\n\n this.step = StepFormEnum.STEP_NO_BONUS;\n localStorage.removeItem(this.cartId);\n } finally {\n this.loading = false;\n }\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n }\n\n public async reserve(amount: number) {\n\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 render() {\n return (\n <div class=\"crm-container-form fbits-responsive-carrinho-desconto\" >\n <label class=\"crm-title\">{this.config.giftbackTitle}</label>\n\n {this.step === StepFormEnum.STEP_PHONE &&\n <phone-form\n value={this.customer.phone}\n config={this.config}\n loading={this.loading}\n handlerSubmit={(phone) => this.handleSendPin(phone)}\n />}\n {\n this.step === StepFormEnum.STEP_PIN &&\n <pin-form\n config={this.config}\n phone={this.phone}\n cancel={() => this.changePhone()}\n resend={() => this.sendPin()}\n validate={(data) => this.validateBonus(data)}\n loading={this.loading}\n >\n {this.sucess && <p class=\"crm-message-info\">{this.sucess}</p>}\n {this.error && <p class=\"crm-message-error\">{this.error}</p>}\n\n </pin-form>\n }\n\n {\n this.step === StepFormEnum.STEP_RESERVE &&\n <giftback-info\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={(amountRedeemed: number) => this.reserveApply(amountRedeemed)}\n />\n }\n\n\n {\n this.step === StepFormEnum.STEP_NO_BONUS &&\n (\n <div class=\"container-message\">\n {i18next.t(\"noGiftback\", { storename: this.config.giftbackTitle })}\n </div>\n )\n\n }\n </div>\n )\n }\n}"],"mappings":"kMAAA,MAAMA,EAAkB,k9BACxB,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