crmbonus-component-wake 2.0.101 → 2.0.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/app-modal.cjs.entry.js +1 -1
- package/dist/cjs/countdown-timer_2.cjs.entry.js +63 -0
- package/dist/cjs/countdown-timer_2.cjs.entry.js.map +1 -0
- package/dist/cjs/crm-bonus-note.cjs.entry.js +5 -5
- package/dist/cjs/crm-bonus-note.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-bonus.cjs.entry.js +1 -1
- package/dist/cjs/crm-bonus.cjs.entry.js.map +1 -1
- package/dist/cjs/crm-giftback-form_2.cjs.entry.js +3 -3
- package/dist/cjs/crm-giftback-form_2.cjs.entry.js.map +1 -1
- package/dist/cjs/{countdown-timer_5.cjs.entry.js → crm-tooltip_4.cjs.entry.js} +12 -33
- package/dist/cjs/crm-tooltip_4.cjs.entry.js.map +1 -0
- package/dist/cjs/crmbonus-component-wake.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/loading-spinner.cjs.entry.js +1 -1
- package/dist/cjs/pedido-finalizado.cjs.entry.js +1 -1
- package/dist/cjs/phone-input-mask.cjs.entry.js +1 -1
- package/dist/collection/components/countdown-timer/countdown-timer.js +35 -5
- package/dist/collection/components/countdown-timer/countdown-timer.js.map +1 -1
- package/dist/collection/components/crm-bonus/crm-bonus.js +1 -1
- package/dist/collection/components/crm-bonus/crm-bonus.js.map +1 -1
- package/dist/collection/components/giftback-form/giftback-form.js +2 -2
- package/dist/collection/components/giftback-form/giftback-form.js.map +1 -1
- package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.js +29 -3
- package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.js.map +1 -1
- package/dist/collection/components/giftback-form/subcomponents/phone-form/phone-form.js +1 -1
- package/dist/collection/components/giftback-form/subcomponents/pin-form/pin-form.js +1 -1
- package/dist/collection/components/giftback-form/subcomponents/pin-form/pin-form.js.map +1 -1
- package/dist/collection/components/loading-container/loading-container.js +1 -1
- package/dist/collection/components/loading-spinner/loading-spinner.js +1 -1
- package/dist/collection/components/modal/app-modal.js +1 -1
- package/dist/collection/components/note/crm-bonus-note.js +7 -6
- package/dist/collection/components/note/crm-bonus-note.js.map +1 -1
- package/dist/collection/components/pedido/pedido.js +1 -1
- package/dist/collection/components/phone/phone-input-mask.js +1 -1
- package/dist/collection/components/tooltip/tooltip.js +1 -1
- package/dist/components/app-modal.js +1 -1
- package/dist/components/countdown-timer.js +1 -1
- package/dist/components/crm-bonus-form.js +4 -4
- package/dist/components/crm-bonus-note.js +16 -9
- package/dist/components/crm-bonus-note.js.map +1 -1
- package/dist/components/crm-bonus.js +11 -11
- package/dist/components/crm-bonus.js.map +1 -1
- package/dist/components/crm-button.js +1 -1
- package/dist/components/crm-giftback-form.js +1 -1
- package/dist/components/crm-tooltip.js +1 -1
- package/dist/components/giftback-info.js +1 -1
- package/dist/components/giftback-pin.js +1 -1
- package/dist/components/giftback-progress.js +1 -1
- package/dist/components/loading-container.js +1 -1
- package/dist/components/loading-spinner.js +1 -1
- package/dist/components/name-input.js +1 -1
- package/dist/components/{p-ffa42f74.js → p-11085d9b.js} +2 -2
- package/dist/components/{p-ffa42f74.js.map → p-11085d9b.js.map} +1 -1
- package/dist/components/{p-0949411f.js → p-246a3e9d.js} +2 -2
- package/dist/components/{p-0949411f.js.map → p-246a3e9d.js.map} +1 -1
- package/dist/components/{p-504f8ce0.js → p-28c89b99.js} +11 -11
- package/dist/components/p-28c89b99.js.map +1 -0
- package/dist/components/{p-2f30297f.js → p-47f9da55.js} +2 -2
- package/dist/components/{p-2f30297f.js.map → p-47f9da55.js.map} +1 -1
- package/dist/components/{p-53259f8a.js → p-58b97429.js} +2 -2
- package/dist/components/{p-53259f8a.js.map → p-58b97429.js.map} +1 -1
- package/dist/components/{p-86564a17.js → p-6186ddcc.js} +2 -2
- package/dist/components/{p-86564a17.js.map → p-6186ddcc.js.map} +1 -1
- package/dist/components/{p-69799798.js → p-6c546e48.js} +5 -5
- package/dist/components/{p-69799798.js.map → p-6c546e48.js.map} +1 -1
- package/dist/components/{p-a6fefb58.js → p-6fcc9cd7.js} +18 -6
- package/dist/components/p-6fcc9cd7.js.map +1 -0
- package/dist/components/{p-078fe899.js → p-761e6cd2.js} +19 -6
- package/dist/components/p-761e6cd2.js.map +1 -0
- package/dist/components/{p-735f01da.js → p-78cca8a2.js} +5 -5
- package/dist/components/p-78cca8a2.js.map +1 -0
- package/dist/components/{p-d1a21f41.js → p-7c744cca.js} +2 -2
- package/dist/components/{p-d1a21f41.js.map → p-7c744cca.js.map} +1 -1
- package/dist/components/{p-f1fb885c.js → p-cc1ea33f.js} +2 -2
- package/dist/components/{p-f1fb885c.js.map → p-cc1ea33f.js.map} +1 -1
- package/dist/components/{p-169fe768.js → p-fe9c3966.js} +2 -2
- package/dist/components/{p-169fe768.js.map → p-fe9c3966.js.map} +1 -1
- package/dist/components/pedido-finalizado.js +1 -1
- package/dist/components/phone-cancel-input.js +2 -2
- package/dist/components/phone-form.js +1 -1
- package/dist/components/phone-input-mask.js +1 -1
- package/dist/components/phone-input.js +2 -2
- package/dist/components/pin-form.js +1 -1
- package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
- package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js.map +1 -1
- package/dist/crmbonus-component-wake/{p-380bbd28.entry.js → p-21464f24.entry.js} +2 -2
- package/dist/crmbonus-component-wake/{p-380bbd28.entry.js.map → p-21464f24.entry.js.map} +1 -1
- package/dist/crmbonus-component-wake/{p-e8113d86.entry.js → p-4ac17815.entry.js} +2 -2
- package/dist/crmbonus-component-wake/p-4ac17815.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/p-59e714cc.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-59e714cc.entry.js.map +1 -0
- package/dist/crmbonus-component-wake/{p-9cd20349.entry.js → p-620ec1a3.entry.js} +2 -2
- package/dist/crmbonus-component-wake/{p-24ef780a.entry.js → p-86d3daa2.entry.js} +2 -2
- package/dist/crmbonus-component-wake/{p-24ef780a.entry.js.map → p-86d3daa2.entry.js.map} +1 -1
- package/dist/crmbonus-component-wake/{p-5e62b863.entry.js → p-885fc30e.entry.js} +2 -2
- package/dist/crmbonus-component-wake/{p-10f6923a.entry.js → p-b873347f.entry.js} +2 -2
- package/dist/crmbonus-component-wake/{p-53c1694c.entry.js → p-be3ddacc.entry.js} +2 -2
- package/dist/crmbonus-component-wake/p-faff2cf2.entry.js +2 -0
- package/dist/crmbonus-component-wake/p-faff2cf2.entry.js.map +1 -0
- package/dist/esm/app-modal.entry.js +1 -1
- package/dist/esm/countdown-timer_2.entry.js +58 -0
- package/dist/esm/countdown-timer_2.entry.js.map +1 -0
- package/dist/esm/crm-bonus-note.entry.js +5 -5
- package/dist/esm/crm-bonus-note.entry.js.map +1 -1
- package/dist/esm/crm-bonus.entry.js +1 -1
- package/dist/esm/crm-bonus.entry.js.map +1 -1
- package/dist/esm/crm-giftback-form_2.entry.js +3 -3
- package/dist/esm/crm-giftback-form_2.entry.js.map +1 -1
- package/dist/esm/{countdown-timer_5.entry.js → crm-tooltip_4.entry.js} +13 -33
- package/dist/esm/crm-tooltip_4.entry.js.map +1 -0
- package/dist/esm/crmbonus-component-wake.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/loading-spinner.entry.js +1 -1
- package/dist/esm/pedido-finalizado.entry.js +1 -1
- package/dist/esm/phone-input-mask.entry.js +1 -1
- package/dist/types/components/countdown-timer/countdown-timer.d.ts +3 -1
- package/dist/types/components/giftback-form/subcomponents/giftback-info/giftback-info.d.ts +2 -0
- package/dist/types/components/note/crm-bonus-note.d.ts +1 -0
- package/dist/types/components.d.ts +4 -0
- package/package.json +1 -1
- package/dist/cjs/countdown-timer_5.cjs.entry.js.map +0 -1
- package/dist/cjs/crm-button.cjs.entry.js +0 -25
- package/dist/cjs/crm-button.cjs.entry.js.map +0 -1
- package/dist/components/p-078fe899.js.map +0 -1
- package/dist/components/p-504f8ce0.js.map +0 -1
- package/dist/components/p-735f01da.js.map +0 -1
- package/dist/components/p-a6fefb58.js.map +0 -1
- package/dist/crmbonus-component-wake/p-3ccbcc11.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-3ccbcc11.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-c2ff5149.entry.js +0 -2
- package/dist/crmbonus-component-wake/p-c2ff5149.entry.js.map +0 -1
- package/dist/crmbonus-component-wake/p-e8113d86.entry.js.map +0 -1
- package/dist/esm/countdown-timer_5.entry.js.map +0 -1
- package/dist/esm/crm-button.entry.js +0 -21
- package/dist/esm/crm-button.entry.js.map +0 -1
- /package/dist/crmbonus-component-wake/{p-9cd20349.entry.js.map → p-620ec1a3.entry.js.map} +0 -0
- /package/dist/crmbonus-component-wake/{p-5e62b863.entry.js.map → p-885fc30e.entry.js.map} +0 -0
- /package/dist/crmbonus-component-wake/{p-10f6923a.entry.js.map → p-b873347f.entry.js.map} +0 -0
- /package/dist/crmbonus-component-wake/{p-53c1694c.entry.js.map → p-be3ddacc.entry.js.map} +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AjustesTipoEnum","buildProductsByWake","productsWake","products","pw","discounts","getDiscount","Ajustes","push","sku","SKU","value","PrecoPor","Quantidade","productVariantId","ProdutoVarianteId","toString","quantity","discount","ajustes","Tipo","P","Valor","crmBonusCss","CrmBonusStyle0","CrmBonus","this","crmBonusService","CrmBonusService","getInstance","birthDate","document","name","phone","resetBonus","console","log","crmBonusRef","processBonus","buildProducts","err","loading","setStep","StepFormEnum","STEP_PHONE","reprocess","loading_reprocess","productsInString","JSON","stringify","handleLoad","debug","message","watchProducts","newValue","componentWillLoad","i18next","changeLanguage","language","loadSession","loadConfigStore","getCustomization","storeName","userId","customer","getCustomer","amount","localStorage","getItem","cartId","canCancel","amountCancel","error","buildAndGetProducts","session","getToken","setTimeout","key","cart","getInfoCart","Produtos","setItem","productsInCart","parse","products_in_cache","product_cart","pro","filter","p","ajuste","aj","Object","assign","sendPin","_phone","replace","Number","sent","STEP_PIN","showModal","_b","_a","response","data","sendPinName","customerName","handleCloseModal","save","cancel","removeItem","handleSendPin","STEP_NAME","render","h","style","position","ref","loadProducts"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["export interface IProduct {\n productVariantId: string;\n sku: string;\n value: number;\n quantity: number;\n discount: number;\n}\n\nexport enum AjustesTipoEnum {\n P = \"Promocao\" \n}\n\nexport interface IAjustes {\n Tipo: AjustesTipoEnum;\n Valor: number;\n}\n\nexport interface IProductWake {\n ProdutoVarianteId: number;\n SKU: string;\n PrecoPor: number;\n Quantidade: number;\n Ajustes: IAjustes[];\n}\n\nexport interface ICustomer {\n birthDate: string;\n document: string;\n name: string;\n phone: string;\n}\n\nexport interface IProccesPinBonusDto {\n storeName: string;\n name: string;\n checkoutId: string;\n checkoutProducts: Array<IProduct>;\n storeId: string;\n userId: string;\n cellphone: number;\n pin: string;\n\n}\n\nexport interface IBonus {\n hasBonus: boolean;\n bonusBalance: number;\n totalBonus: number;\n minimumPurchase: number;\n bonusIds: string;\n firstValidityDate: string\n history: [\n {\n validityStart: string;\n validityEnd: string;\n value: number\n },\n {\n validityStart: string;\n validityEnd: string\n value: number\n }\n ]\n storeId: number;\n userId: number;\n cartId: string\n calculatedValue: number;\n totalValue: number\n}\n\n\nexport interface IReserveDTO {\n storeName: string;\n cartId: string;\n grossValue: number;\n redeemedBonus: number;\n ticket: string;\n storeId: string;\n userId: number;\n}","import { AjustesTipoEnum, IAjustes, IProduct, IProductWake } from \"../dto/validate.pin.bonus\";\n\nexport function buildProductsByWake(productsWake: Array<IProductWake> = []): Array<IProduct> {\n\n const products: Array<IProduct> = [];\n\n for ( const pw of productsWake ) {\n let discounts = getDiscount(pw.Ajustes)\n\n products.push(\n {\n sku: pw.SKU,\n value: (pw.PrecoPor * pw.Quantidade),\n productVariantId: pw.ProdutoVarianteId.toString(),\n quantity: pw.Quantidade,\n discount: (discounts * -1)\n }\n )\n }\n\n return products;\n}\n\nfunction getDiscount(ajustes: IAjustes[] = []) {\n \n let discounts = 0;\n \n for(const discount of ajustes) {\n if(discount.Tipo === AjustesTipoEnum.P) {\n discounts += discount.Valor;\n }\n }\n\n return discounts;\n}","\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, Method, Prop, State, Watch, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n // const used = localStorage.getItem(\"bc:used\");\n\n // if (used == \"use\") {\n // await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n // }\n\n try {\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async reprocess(products: Array<any>) {\n this.loading_reprocess = true\n\n console.log('[reprocess]');\n try {\n console.log('[update products list]');\n this.productsInString = JSON.stringify(products);\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n @Watch(\"productsInString\")\n async watchProducts(newValue: string) {\n try {\n console.log('[update products list]');\n this.productsInString = newValue;\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n }\n }\n\n async componentWillLoad() {\n i18next.changeLanguage(i18next.language);\n\n await this.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n console.log('customer', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n await this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n \n const key = `bc-products:${this.cartId}`;\n\n const cart = await this.crmBonusService.getInfoCart();\n\n this.productsInString = JSON.stringify(cart.Produtos)\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n const [ ajuste = { Valor:0 } ] = pro.Ajustes.filter( aj => aj.Tipo === \"Formula\" )\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor + (ajuste.Valor * -1),\n Quantidade: pro.Quantidade,\n Ajustes: pro.Ajustes\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return buildProductsByWake(this.products);\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n loadProducts={() => this.buildProducts()}\n \n />\n </loading-container>\n )\n }\n}\n"],"mappings":"+KAQA,IAAYA,GAAZ,SAAYA,GACRA,EAAA,eACH,EAFD,CAAYA,MAAe,K,SCNXC,EAAoBC,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CAAKzC,GACHC,aAAac,QAAQvD,KAAK2C,OAAQH,EAAOlD,YACzCU,KAAK4C,UAAY,KACjB5C,KAAK6C,aAAeL,EAAOlD,U,CAG7B,YAAM4F,GACJlF,KAAK0B,QAAU,GACf1B,KAAKe,QAAU,KACf,UACQf,KAAKC,gBAAgBiF,OAAOlF,KAAK2C,QACvC3C,KAAK4C,UAAY,MAEjBH,aAAa0C,WAAWnF,KAAK2C,O,CAC7B,MAAOG,GACP9C,KAAK0B,QAAU,iD,SAEf1B,KAAKe,QAAU,K,EAInB,mBAAMqE,CAAc7E,GAClBP,KAAK0B,QAAU,GACf,IAAKnB,EAAO,CACVP,KAAK0B,QAAU,uBACf,M,CAGF1B,KAAKsC,SAAS/B,MAAQA,EACtB,MAAM6D,EAAS7D,EAAM8D,QAAQ,MAAO,IACpCrE,KAAKO,MAAQ+D,OAAOF,GAEpB,GAAIpE,KAAKsC,SAAShC,KAAM,CACtB,OAAON,KAAKmE,QAAQ5D,E,OAGhBP,KAAKW,YAAYK,QAAQC,EAAaoE,WAC5CrF,KAAKyE,UAAY,I,CAGnB,MAAAa,GAEE,OACEC,EAAA,qBAAApC,IAAA,2CAAmBpC,QAASf,KAAKoB,mBAC/BmE,EAAA,qBAAApC,IAAA,2CACEqC,MAAO,CAAEC,SAAU,YACnBC,IAAKA,GAAO1F,KAAKW,YAAc+E,EAC/BtD,UAAWpC,KAAKoC,UAChB3D,SAAUuB,KAAKa,gBACf8B,OAAQ3C,KAAK2C,OACbL,SAAUtC,KAAKsC,SACfqD,aAAc,IAAM3F,KAAKa,kB","ignoreList":[]}
|
1
|
+
{"version":3,"names":["AjustesTipoEnum","buildProductsByWake","productsWake","products","pw","discounts","getDiscount","Ajustes","push","sku","SKU","value","PrecoPor","Quantidade","productVariantId","ProdutoVarianteId","toString","quantity","discount","ajustes","Tipo","P","Valor","crmBonusCss","CrmBonusStyle0","CrmBonus","this","crmBonusService","CrmBonusService","getInstance","birthDate","document","name","phone","resetBonus","console","log","crmBonusRef","processBonus","buildProducts","err","loading","setStep","StepFormEnum","STEP_PHONE","reprocess","loading_reprocess","productsInString","JSON","stringify","handleLoad","debug","message","watchProducts","newValue","componentWillLoad","i18next","changeLanguage","language","loadSession","loadConfigStore","getCustomization","storeName","userId","customer","getCustomer","amount","localStorage","getItem","cartId","canCancel","amountCancel","error","buildAndGetProducts","session","getToken","setTimeout","key","cart","getInfoCart","Produtos","setItem","productsInCart","parse","products_in_cache","product_cart","pro","filter","p","ajuste","aj","Object","assign","sendPin","_phone","replace","Number","sent","STEP_PIN","showModal","_b","_a","response","data","sendPinName","customerName","handleCloseModal","save","cancel","removeItem","handleSendPin","STEP_NAME","render","h","style","position","ref","loadProducts"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["export interface IProduct {\n productVariantId: string;\n sku: string;\n value: number;\n quantity: number;\n discount: number;\n}\n\nexport enum AjustesTipoEnum {\n P = \"Promocao\" \n}\n\nexport interface IAjustes {\n Tipo: AjustesTipoEnum;\n Valor: number;\n}\n\nexport interface IProductWake {\n ProdutoVarianteId: number;\n SKU: string;\n PrecoPor: number;\n Quantidade: number;\n Ajustes: IAjustes[];\n}\n\nexport interface ICustomer {\n birthDate: string;\n document: string;\n name: string;\n phone: string;\n}\n\nexport interface IProccesPinBonusDto {\n storeName: string;\n name: string;\n checkoutId: string;\n checkoutProducts: Array<IProduct>;\n storeId: string;\n userId: string;\n cellphone: number;\n pin: string;\n\n}\n\nexport interface IBonus {\n hasBonus: boolean;\n bonusBalance: number;\n totalBonus: number;\n minimumPurchase: number;\n bonusIds: string;\n firstValidityDate: string\n history: [\n {\n validityStart: string;\n validityEnd: string;\n value: number\n },\n {\n validityStart: string;\n validityEnd: string\n value: number\n }\n ]\n storeId: number;\n userId: number;\n cartId: string\n calculatedValue: number;\n totalValue: number\n}\n\n\nexport interface IReserveDTO {\n storeName: string;\n cartId: string;\n grossValue: number;\n redeemedBonus: number;\n ticket: string;\n storeId: string;\n userId: number;\n}","import { AjustesTipoEnum, IAjustes, IProduct, IProductWake } from \"../dto/validate.pin.bonus\";\n\nexport function buildProductsByWake(productsWake: Array<IProductWake> = []): Array<IProduct> {\n\n const products: Array<IProduct> = [];\n\n for ( const pw of productsWake ) {\n let discounts = getDiscount(pw.Ajustes)\n\n products.push(\n {\n sku: pw.SKU,\n value: (pw.PrecoPor * pw.Quantidade),\n productVariantId: pw.ProdutoVarianteId.toString(),\n quantity: pw.Quantidade,\n discount: (discounts * -1)\n }\n )\n }\n\n return products;\n}\n\nfunction getDiscount(ajustes: IAjustes[] = []) {\n \n let discounts = 0;\n \n for(const discount of ajustes) {\n if(discount.Tipo === AjustesTipoEnum.P) {\n discounts += discount.Valor;\n }\n }\n\n return discounts;\n}","\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, Method, Prop, State, Watch, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n // const used = localStorage.getItem(\"bc:used\");\n\n // if (used == \"use\") {\n // await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n // }\n\n try {\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async reprocess(products: Array<any>) {\n this.loading_reprocess = true\n\n console.log('[reprocess]');\n try {\n console.log('[update products list]');\n this.productsInString = JSON.stringify(products);\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n @Watch(\"productsInString\")\n async watchProducts(newValue: string) {\n try {\n console.log('[update products list]');\n this.productsInString = newValue;\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n }\n }\n\n async componentWillLoad() {\n i18next.changeLanguage(i18next.language);\n\n await this.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n console.log('customer', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n await this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n \n const key = `bc-products:${this.cartId}`;\n\n const cart = await this.crmBonusService.getInfoCart();\n\n this.productsInString = JSON.stringify(cart.Produtos)\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n const [ ajuste = { Valor:0 } ] = pro.Ajustes.filter( aj => aj.Tipo === \"Formula\" )\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor + (ajuste.Valor * -1),\n Quantidade: pro.Quantidade,\n Ajustes: pro.Ajustes\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return buildProductsByWake(this.products);\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n loadProducts={() => this.buildProducts()}\n \n />\n </loading-container>\n )\n }\n}\n"],"mappings":"+KAQA,IAAYA,GAAZ,SAAYA,GACRA,EAAA,eACH,EAFD,CAAYA,MAAe,K,SCNXC,EAAoBC,EAAoC,IAEpE,MAAMC,EAA4B,GAElC,IAAM,MAAMC,KAAMF,EAAe,CAC7B,IAAIG,EAAYC,EAAYF,EAAGG,SAE/BJ,EAASK,KACL,CACIC,IAAKL,EAAGM,IACRC,MAAQP,EAAGQ,SAAWR,EAAGS,WACzBC,iBAAkBV,EAAGW,kBAAkBC,WACvCC,SAAUb,EAAGS,WACbK,SAAWb,GAAa,G,CAKpC,OAAOF,CACX,CAEA,SAASG,EAAYa,EAAsB,IAEvC,IAAId,EAAY,EAEhB,IAAI,MAAMa,KAAYC,EAAS,CAC3B,GAAGD,EAASE,OAASpB,EAAgBqB,EAAG,CACpChB,GAAaa,EAASI,K,EAI9B,OAAOjB,CACX,CClCA,MAAMkB,EAAc,woCACpB,MAAAC,EAAeD,E,MCcFE,EAAQ,M,yBAEXC,KAAAC,gBAAmCC,EAAgBC,c,eAI7B,M,2IAOC,CAC7BC,UAAW,GACXC,SAAU,GACVC,KAAM,GACNC,MAAO,I,aAGmB,M,2DAGE,M,8FAKD,K,CAG7B,gBAAMC,GACJC,QAAQC,IAAI,4BAOZ,UACQV,KAAKW,YAAYC,aAAaZ,KAAKa,gBAAiB,MAC1DJ,QAAQC,IAAI,wB,CACZ,MAAOI,GAEPd,KAAKe,QAAU,MACfN,QAAQC,IAAI,uCACNV,KAAKW,YAAYK,QAAQC,EAAaC,W,SAE5ClB,KAAKe,QAAU,K,EAKnB,eAAMI,CAAU1C,GACduB,KAAKoB,kBAAoB,KAEzBX,QAAQC,IAAI,eACZ,IACED,QAAQC,IAAI,0BACZ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AAM3F,KAAKa,kB","ignoreList":[]}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{r as e,c as d,h as a}from"./p-3d6152b1.js";const o=".modal-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:none;justify-content:center;align-items:center;z-index:1000}.modal-backdrop.visible{display:flex}.modal{background:white;border-radius:8px;padding:1rem;max-width:500px;width:90%;box-shadow:0 2px 10px rgba(0, 0, 0, 0.3)}.modal-header{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #ddd;margin-bottom:1rem}.close-button{background:none;border:none;font-size:1.5rem;cursor:pointer}.modal-body{}";const s=o;const t=class{constructor(a){e(this,a);this.modalClosed=d(this,"modalClosed",7);this.isOpen=false;this.modalTitle=undefined}closeModal(){this.modalClosed.emit()}render(){return a("div",{key:"
|
2
|
-
//# sourceMappingURL=p-
|
1
|
+
import{r as e,c as d,h as a}from"./p-3d6152b1.js";const o=".modal-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0, 0, 0, 0.5);display:none;justify-content:center;align-items:center;z-index:1000}.modal-backdrop.visible{display:flex}.modal{background:white;border-radius:8px;padding:1rem;max-width:500px;width:90%;box-shadow:0 2px 10px rgba(0, 0, 0, 0.3)}.modal-header{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid #ddd;margin-bottom:1rem}.close-button{background:none;border:none;font-size:1.5rem;cursor:pointer}.modal-body{}";const s=o;const t=class{constructor(a){e(this,a);this.modalClosed=d(this,"modalClosed",7);this.isOpen=false;this.modalTitle=undefined}closeModal(){this.modalClosed.emit()}render(){return a("div",{key:"3f44609d2835224eea0668475f6851eab807cfce",class:`modal-backdrop ${this.isOpen?"visible":""}`},a("div",{key:"c7998d2ab6ce04ce722a52712267b0493495cb29",class:"modal"},a("div",{key:"dcc7438d690866d20972f04c6c9ad39f4f2e84da",class:"modal-header"},a("h3",{key:"0257c585eeec3daf72b7b371b557ae699891dba9"},this.modalTitle),a("button",{key:"e0b4f89907a4da774c021bcc3797f5b2fb1f0c0e",class:"close-button",onClick:()=>this.closeModal()},"×")),a("div",{key:"e9efd84c1fd89da8b9df15970b71beae66ea6fb8",class:"modal-body"},a("slot",{key:"6e3371866a4a2adf86a04e30e7a1ed843e7492fb"}))))}};t.style=s;export{t as app_modal};
|
2
|
+
//# sourceMappingURL=p-885fc30e.entry.js.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{r as t,h as s}from"./p-3d6152b1.js";import{C as i}from"./p-c44e2f02.js";import"./p-f9aeffc1.js";const o=class{constructor(s){t(this,s);this.cartId=undefined;this.orderId=undefined;this.metadadoString=undefined}async componentWillLoad(){const t=this.metadadoString?JSON.parse(this.metadadoString):{id:null};if(this.cartId&&this.orderId){i.getInstance().updateOrder({cartId:this.cartId,orderId:this.orderId,cartIdCrm:t.id});const s=`bc-products:${this.cartId}`;localStorage.removeItem(s);localStorage.removeItem(this.cartId)}}render(){return s("div",{key:"
|
2
|
-
//# sourceMappingURL=p-
|
1
|
+
import{r as t,h as s}from"./p-3d6152b1.js";import{C as i}from"./p-c44e2f02.js";import"./p-f9aeffc1.js";const o=class{constructor(s){t(this,s);this.cartId=undefined;this.orderId=undefined;this.metadadoString=undefined}async componentWillLoad(){const t=this.metadadoString?JSON.parse(this.metadadoString):{id:null};if(this.cartId&&this.orderId){i.getInstance().updateOrder({cartId:this.cartId,orderId:this.orderId,cartIdCrm:t.id});const s=`bc-products:${this.cartId}`;localStorage.removeItem(s);localStorage.removeItem(this.cartId)}}render(){return s("div",{key:"6796f6e91c7e0ca6ea1d6c6bb4dc8297c531988b"})}};export{o as pedido_finalizado};
|
2
|
+
//# sourceMappingURL=p-b873347f.entry.js.map
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import{r,h as s}from"./p-3d6152b1.js";const t=".spinner{display:inline-block;border:4px solid transparent;border-radius:50%;border-top-color:var(--color, #0078d7);animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";const n=t;const e=class{constructor(s){r(this,s);this.size="50px";this.color="#0078d7"}render(){return s("div",{key:"
|
2
|
-
//# sourceMappingURL=p-
|
1
|
+
import{r,h as s}from"./p-3d6152b1.js";const t=".spinner{display:inline-block;border:4px solid transparent;border-radius:50%;border-top-color:var(--color, #0078d7);animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";const n=t;const e=class{constructor(s){r(this,s);this.size="50px";this.color="#0078d7"}render(){return s("div",{key:"148b1ced74314541178bf725d205e8271b682335",class:"spinner",style:{width:this.size,height:this.size,borderColor:`${this.color} transparent transparent transparent`}})}};e.style=n;export{e as loading_spinner};
|
2
|
+
//# sourceMappingURL=p-be3ddacc.entry.js.map
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import{r as t,h as e}from"./p-3d6152b1.js";const n=class{constructor(e){t(this,e);this.downtime=undefined;this.initialValue=120;this.seconds=30}componentWillLoad(){const t=localStorage.getItem("bc:time");this.seconds=t?Number(t):this.initialValue;this.intervalId=setInterval((()=>{if(this.seconds>0){this.seconds--;localStorage.setItem("bc:time",this.seconds.toString())}else{clearInterval(this.intervalId);this.downtime();localStorage.removeItem("bc:time")}}),1e3)}disconnectedCallback(){clearInterval(this.intervalId)}padLeft(){const t=this.seconds/60;const e=this.seconds%60;if(t<1)return`${e}s`;return`${parseInt(t.toString())}m ${e}s`}render(){return e("label",{key:"51f3be00f4abb6f20fcb9f029d50bbcffc69c111"},this.padLeft())}};const i="input,button{margin:0;padding:10px;}.crm-contaner-button{height:auto;width:auto}.crm-button{height:48px;width:100%;border:1px solid #000;padding:14px 20px;background-color:#000;color:#fff;font-size:14px;line-height:20px;font-weight:500;cursor:pointer}";const s=i;const o=class{constructor(e){t(this,e);this.txtBtn=undefined;this.loading=undefined;this.handleClick=undefined}render(){return e("div",{key:"848df9f754a114343163eae85d34a2acb6b04863",class:"crm-contaner-button"},e("button",{key:"517b761b39ced2615dd04fc42d5aaa98a7d749f6",class:"crm-button",onClick:()=>this.handleClick()},!this.loading?this.txtBtn:e("loading-spinner",{size:"15px",color:"#fff"})))}};o.style=s;export{n as countdown_timer,o as crm_button};
|
2
|
+
//# sourceMappingURL=p-faff2cf2.entry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["CountdownTimer","componentWillLoad","initial","localStorage","getItem","this","seconds","Number","initialValue","intervalId","setInterval","setItem","toString","clearInterval","downtime","removeItem","disconnectedCallback","padLeft","minutes","parseInt","render","h","key","crmButtonCss","CrmButtonStyle0","Button","class","onClick","handleClick","loading","txtBtn","size","color"],"sources":["src/components/countdown-timer/countdown-timer.tsx","src/components/button/crm-button.css?tag=crm-button","src/components/button/index.tsx"],"sourcesContent":["import { Component, h, Prop, State } from '@stencil/core';\n\n@Component({\n tag: 'countdown-timer',\n shadow: true,\n})\nexport class CountdownTimer {\n\n @Prop() downtime: () => void;\n @Prop() initialValue: number = 120;\n\n @State() seconds: number = 30;\n\n private intervalId: NodeJS.Timer;\n\n componentWillLoad() {\n const initial = localStorage.getItem(\"bc:time\");\n\n this.seconds = initial ? Number(initial) : this.initialValue;\n \n this.intervalId = setInterval(() => {\n if (this.seconds > 0) {\n this.seconds--;\n\n localStorage.setItem(\"bc:time\", this.seconds.toString());\n } else {\n clearInterval(this.intervalId);\n\n this.downtime();\n\n localStorage.removeItem(\"bc:time\");\n }\n }, 1000); // Intervalo de 1 segundo\n }\n\n disconnectedCallback() {\n clearInterval(this.intervalId);\n }\n\n padLeft() {\n const minutes = this.seconds / 60; \n const seconds = this.seconds % 60;\n\n if(minutes < 1) return `${seconds}s`\n \n return `${parseInt(minutes.toString())}m ${seconds}s`\n }\n\n render() {\n return (\n <label>{this.padLeft()}</label>\n );\n }\n}\n","input, button {\n margin: 0;\n padding: 10px; /* Ajuste o valor conforme necessário */\n}\n\n.crm-contaner-button {\n height: auto;\n width: auto;\n}\n\n.crm-button {\n height: 48px;\n width: 100%;\n border: 1px solid #000;\n padding: 14px 20px;\n background-color: #000;\n color: #fff;\n font-size: 14px;\n line-height: 20px;\n font-weight: 500;\n cursor: pointer;\n}","import { Component, Prop, h } from \"@stencil/core\";\n\n@Component({\n tag: 'crm-button',\n styleUrl: 'crm-button.css'\n})\nexport class Button {\n\n @Prop() txtBtn: string;\n @Prop() loading: boolean;\n\n @Prop() handleClick: () => void;\n\n render() {\n return (\n <div class=\"crm-contaner-button\">\n <button class=\"crm-button\" onClick={() => this.handleClick()}>\n {\n !this.loading ? this.txtBtn : <loading-spinner size=\"15px\" color=\"#fff\" />\n }\n </button>\n </div>\n )\n }\n}"],"mappings":"iDAMaA,EAAc,M,mEAGQ,I,aAEJ,E,CAI3B,iBAAAC,GACI,MAAMC,EAAUC,aAAaC,QAAQ,WAErCC,KAAKC,QAAWJ,EAAUK,OAAOL,GAAWG,KAAKG,aAEjDH,KAAKI,WAAaC,aAAY,KAC1B,GAAIL,KAAKC,QAAU,EAAG,CAClBD,KAAKC,UAELH,aAAaQ,QAAQ,UAAWN,KAAKC,QAAQM,W,KAC1C,CACHC,cAAcR,KAAKI,YAEnBJ,KAAKS,WAELX,aAAaY,WAAW,U,IAE7B,I,CAGP,oBAAAC,GACIH,cAAcR,KAAKI,W,CAGvB,OAAAQ,GACI,MAAMC,EAAUb,KAAKC,QAAU,GAC/B,MAAMA,EAAUD,KAAKC,QAAU,GAE/B,GAAGY,EAAU,EAAG,MAAO,GAAGZ,KAE1B,MAAO,GAAGa,SAASD,EAAQN,gBAAgBN,I,CAG/C,MAAAc,GACI,OACIC,EAAA,SAAAC,IAAA,4CAAQjB,KAAKY,U,GClDzB,MAAMM,EAAe,8PACrB,MAAAC,EAAeD,E,MCKFE,EAAM,M,iGAOf,MAAAL,GACI,OACIC,EAAA,OAAAC,IAAA,2CAAKI,MAAM,uBACPL,EAAA,UAAAC,IAAA,2CAAQI,MAAM,aAAaC,QAAS,IAAMtB,KAAKuB,gBAEtCvB,KAAKwB,QAAUxB,KAAKyB,OAAST,EAAA,mBAAiBU,KAAK,OAAOC,MAAM,U","ignoreList":[]}
|
@@ -14,7 +14,7 @@ const AppModal = class {
|
|
14
14
|
this.modalClosed.emit();
|
15
15
|
}
|
16
16
|
render() {
|
17
|
-
return (h("div", { key: '
|
17
|
+
return (h("div", { key: '3f44609d2835224eea0668475f6851eab807cfce', class: `modal-backdrop ${this.isOpen ? 'visible' : ''}` }, h("div", { key: 'c7998d2ab6ce04ce722a52712267b0493495cb29', class: "modal" }, h("div", { key: 'dcc7438d690866d20972f04c6c9ad39f4f2e84da', class: "modal-header" }, h("h3", { key: '0257c585eeec3daf72b7b371b557ae699891dba9' }, this.modalTitle), h("button", { key: 'e0b4f89907a4da774c021bcc3797f5b2fb1f0c0e', class: "close-button", onClick: () => this.closeModal() }, "\u00D7")), h("div", { key: 'e9efd84c1fd89da8b9df15970b71beae66ea6fb8', class: "modal-body" }, h("slot", { key: '6e3371866a4a2adf86a04e30e7a1ed843e7492fb' })))));
|
18
18
|
}
|
19
19
|
};
|
20
20
|
AppModal.style = AppModalStyle0;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { r as registerInstance, h } from './index-e8724c8f.js';
|
2
|
+
|
3
|
+
const CountdownTimer = class {
|
4
|
+
constructor(hostRef) {
|
5
|
+
registerInstance(this, hostRef);
|
6
|
+
this.downtime = undefined;
|
7
|
+
this.initialValue = 120;
|
8
|
+
this.seconds = 30;
|
9
|
+
}
|
10
|
+
componentWillLoad() {
|
11
|
+
const initial = localStorage.getItem("bc:time");
|
12
|
+
this.seconds = initial ? Number(initial) : this.initialValue;
|
13
|
+
this.intervalId = setInterval(() => {
|
14
|
+
if (this.seconds > 0) {
|
15
|
+
this.seconds--;
|
16
|
+
localStorage.setItem("bc:time", this.seconds.toString());
|
17
|
+
}
|
18
|
+
else {
|
19
|
+
clearInterval(this.intervalId);
|
20
|
+
this.downtime();
|
21
|
+
localStorage.removeItem("bc:time");
|
22
|
+
}
|
23
|
+
}, 1000); // Intervalo de 1 segundo
|
24
|
+
}
|
25
|
+
disconnectedCallback() {
|
26
|
+
clearInterval(this.intervalId);
|
27
|
+
}
|
28
|
+
padLeft() {
|
29
|
+
const minutes = this.seconds / 60;
|
30
|
+
const seconds = this.seconds % 60;
|
31
|
+
if (minutes < 1)
|
32
|
+
return `${seconds}s`;
|
33
|
+
return `${parseInt(minutes.toString())}m ${seconds}s`;
|
34
|
+
}
|
35
|
+
render() {
|
36
|
+
return (h("label", { key: '51f3be00f4abb6f20fcb9f029d50bbcffc69c111' }, this.padLeft()));
|
37
|
+
}
|
38
|
+
};
|
39
|
+
|
40
|
+
const crmButtonCss = "input,button{margin:0;padding:10px;}.crm-contaner-button{height:auto;width:auto}.crm-button{height:48px;width:100%;border:1px solid #000;padding:14px 20px;background-color:#000;color:#fff;font-size:14px;line-height:20px;font-weight:500;cursor:pointer}";
|
41
|
+
const CrmButtonStyle0 = crmButtonCss;
|
42
|
+
|
43
|
+
const Button = class {
|
44
|
+
constructor(hostRef) {
|
45
|
+
registerInstance(this, hostRef);
|
46
|
+
this.txtBtn = undefined;
|
47
|
+
this.loading = undefined;
|
48
|
+
this.handleClick = undefined;
|
49
|
+
}
|
50
|
+
render() {
|
51
|
+
return (h("div", { key: '848df9f754a114343163eae85d34a2acb6b04863', class: "crm-contaner-button" }, h("button", { key: '517b761b39ced2615dd04fc42d5aaa98a7d749f6', class: "crm-button", onClick: () => this.handleClick() }, !this.loading ? this.txtBtn : h("loading-spinner", { size: "15px", color: "#fff" }))));
|
52
|
+
}
|
53
|
+
};
|
54
|
+
Button.style = CrmButtonStyle0;
|
55
|
+
|
56
|
+
export { CountdownTimer as countdown_timer, Button as crm_button };
|
57
|
+
|
58
|
+
//# sourceMappingURL=countdown-timer_2.entry.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"file":"countdown-timer.crm-button.entry.js","mappings":";;MAMa,cAAc;;;;4BAGQ,GAAG;uBAEP,EAAE;;IAI7B,iBAAiB;QACb,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,S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,uBAAiB,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,MAAM,GAAG,CAEzE,CACP,EACT;KACJ;;;;;;","names":[],"sources":["src/components/countdown-timer/countdown-timer.tsx","src/components/button/crm-button.css?tag=crm-button","src/components/button/index.tsx"],"sourcesContent":["import { Component, h, Prop, State } from '@stencil/core';\n\n@Component({\n tag: 'countdown-timer',\n shadow: true,\n})\nexport class CountdownTimer {\n\n @Prop() downtime: () => void;\n @Prop() initialValue: number = 120;\n\n @State() seconds: number = 30;\n\n private intervalId: NodeJS.Timer;\n\n componentWillLoad() {\n const initial = localStorage.getItem(\"bc:time\");\n\n this.seconds = initial ? Number(initial) : this.initialValue;\n \n this.intervalId = setInterval(() => {\n if (this.seconds > 0) {\n this.seconds--;\n\n localStorage.setItem(\"bc:time\", this.seconds.toString());\n } else {\n clearInterval(this.intervalId);\n\n this.downtime();\n\n localStorage.removeItem(\"bc:time\");\n }\n }, 1000); // Intervalo de 1 segundo\n }\n\n disconnectedCallback() {\n clearInterval(this.intervalId);\n }\n\n padLeft() {\n const minutes = this.seconds / 60; \n const seconds = this.seconds % 60;\n\n if(minutes < 1) return `${seconds}s`\n \n return `${parseInt(minutes.toString())}m ${seconds}s`\n }\n\n render() {\n return (\n <label>{this.padLeft()}</label>\n );\n }\n}\n","input, button {\n margin: 0;\n padding: 10px; /* Ajuste o valor conforme necessário */\n}\n\n.crm-contaner-button {\n height: auto;\n width: auto;\n}\n\n.crm-button {\n height: 48px;\n width: 100%;\n border: 1px solid #000;\n padding: 14px 20px;\n background-color: #000;\n color: #fff;\n font-size: 14px;\n line-height: 20px;\n font-weight: 500;\n cursor: pointer;\n}","import { Component, Prop, h } from \"@stencil/core\";\n\n@Component({\n tag: 'crm-button',\n styleUrl: 'crm-button.css'\n})\nexport class Button {\n\n @Prop() txtBtn: string;\n @Prop() loading: boolean;\n\n @Prop() handleClick: () => void;\n\n render() {\n return (\n <div class=\"crm-contaner-button\">\n <button class=\"crm-button\" onClick={() => this.handleClick()}>\n {\n !this.loading ? this.txtBtn : <loading-spinner size=\"15px\" color=\"#fff\" />\n }\n </button>\n </div>\n )\n }\n}"],"version":3}
|
@@ -16,6 +16,7 @@ const CrmBonusNote = class {
|
|
16
16
|
this.url = undefined;
|
17
17
|
this.config = undefined;
|
18
18
|
this.bonus = undefined;
|
19
|
+
this.showEdit = false;
|
19
20
|
}
|
20
21
|
componentWillLoad() {
|
21
22
|
this.upadateCheckToFreteAndGetUrl();
|
@@ -49,7 +50,6 @@ const CrmBonusNote = class {
|
|
49
50
|
};
|
50
51
|
if (_bonus) {
|
51
52
|
this.bonus = JSON.parse(_bonus);
|
52
|
-
console.log("bonus", this.bonus);
|
53
53
|
info.hasBonus = this.bonus.hasBonus;
|
54
54
|
info.requestBonus = true;
|
55
55
|
}
|
@@ -58,10 +58,10 @@ const CrmBonusNote = class {
|
|
58
58
|
render() {
|
59
59
|
const giftbackname = this.config.giftbackTitle || "Giftback";
|
60
60
|
const infobonus = this.hasBonus();
|
61
|
-
return (h("div", { key: '
|
62
|
-
(h("p", { key: '
|
63
|
-
(h("p", { key: '
|
64
|
-
(h("div", { key: '
|
61
|
+
return (h("div", { key: 'e918536bb1517ee22a4572ce74988306dbe31f01' }, h("div", { key: '958b56abdbe364f70377cd7476ffd893f80630cb', class: "note-container" }, h("div", { key: 'e79c47ec7000d74af61f794d583faef06d65e812', class: "note-header" }, h("p", { key: 'd15eba4e26c6091729f0b5d41bfd702d2fdb6f04', class: "note-title" }, h("img", { key: 'de5ab8deca48cea53f30923ba9cbc5f1bec90d44', src: moneyDollarsSvgrepoComSvg, width: 23 }), this.config.giftbackTitle), infobonus.hasBonus && (h("div", { key: 'a14dee6357f4f39de1019b9cf0b8886430342bb2' }, this.showEdit && (h("p", { key: '3f86785606b8fa9571283f2ef93011673194ce90', class: "back-cart", onClick: () => this.backCart() }, instance.t("edit"))), !this.showEdit && h("countdown-timer", { key: '9d808c66eb2d9f6d443f1a5ecf88733ce22a2445', initialValue: 60, downtime: () => { this.showEdit = true; } })))), infobonus.hasBonus &&
|
62
|
+
(h("p", { key: 'eaca502ac377289c1592fa2316c9c474e464d69d', class: "note-description-2" }, instance.t("withApplyBonus", { giftbackname: giftbackname }), " ", h("strong", { key: '298bcd621c6ce2a952853dd4d6ec205b183a1e9c' }, "R$ ", this.getAmount(), "."))), (infobonus.requestBonus && !infobonus.hasBonus) &&
|
63
|
+
(h("p", { key: '20326607c5c74cc97dfb6fcb81e9e85ade2ae474', class: "note-description-not" }, instance.t("noBonus", { giftbackname: giftbackname }))), !infobonus.requestBonus &&
|
64
|
+
(h("div", { key: 'faaefcec481ec5ca21bac021003f13f3f5f6cf54', class: "description" }, h("p", { key: 'a95c95602fdb8e4734d783b6af1d2918adbb5aff', class: "note-description-not" }, instance.t("backCart")), h("crm-button", { key: '95a8bac95b5eb843005990e7fb01318d99efaaee', txtBtn: "VOLTAR AO CARRINHO", handleClick: () => this.backCart() }))))));
|
65
65
|
}
|
66
66
|
};
|
67
67
|
CrmBonusNote.style = CrmBonusNoteStyle0;
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"crm-bonus-note.entry.js","mappings":";;;;;AAAA,MAAM,yBAAyB,GAAG,4gCAA4gC;;ACA9iC,MAAM,eAAe,GAAG,i3CAAi3C,CAAC;AAC14C,2BAAe,eAAe;;MCWjB,YAAY
|
1
|
+
{"file":"crm-bonus-note.entry.js","mappings":";;;;;AAAA,MAAM,yBAAyB,GAAG,4gCAA4gC;;ACA9iC,MAAM,eAAe,GAAG,i3CAAi3C,CAAC;AAC14C,2BAAe,eAAe;;MCWjB,YAAY;;;;;;;;wBAUQ,KAAK;;IAElC,iBAAiB;QACb,IAAI,CAAC,4BAA4B,EAAE,CAAA;KACtC;IAED,4BAA4B;QAExB,IAAI,CAAC,MAAM,GAAG,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,QAAQ,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACzD,MAA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ars-svgrepo-com.svg","src/components/note/crm-bonus-note.css?tag=crm-bonus-note","src/components/note/crm-bonus-note.tsx"],"sourcesContent":["<?xml version=\"1.0\" encoding=\"utf-8\"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->\n<svg width=\"800px\" height=\"800px\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"#000000\" stroke-width=\"2\"/>\n<path d=\"M15 9.94728C14.5 9.3 13.8 8.5 12 8.5C10.2 8.5 9 9.51393 9 9.94728C9 10.3806 9.06786 10.9277 10 11.5C10.7522 11.9618 12.6684 12.0439 13.5 12.5C14.679 13.1467 14.8497 13.8202 14.8497 14.0522C14.8497 14.6837 13.4175 15.4852 12 15.5C10.536 15.5153 9.5 14.7 9 14.0522\" stroke=\"#000000\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path d=\"M12 7V17\" stroke=\"#000000\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>",".note-container {\n border: 1px solid #dddddd;\n padding: 0 15px 15px;\n margin: 0 0 26px 0px;\n display: flex;\n flex-direction: column;\n gap: 13px;\n\n\n & .description {\n display: flex;\n flex-direction: column;\n gap: 13px;\n }\n}\n\n.note-container hr {\n border: 1px solid #CCC;\n}\n\n.note-container .back-cart {\n display: flex;\n text-align: center;\n}\n\n.note-header {\n display: flex;\n align-items: baseline;\n justify-content: space-between;\n}\n\n.note-title {\n font-weight: 700;\n text-align: left;\n display: flex;\n gap: 6px;\n align-items: center;\n margin-top: 11px;\n color: #000;\n}\n\n.note-description {\n font-family: Arial;\n color: #6d6d5f;\n padding: 0;\n margin: 0 auto;\n}\n\n.back-cart {\n font-size: .9em;\n color: #27272A;\n text-decoration: none;\n cursor: pointer;\n margin-top: 11px;\n}\n\n.note-description-2 {\n color: var(--crm-scheme-fg-main-inverse, #262626);\n font-family: Roboto;\n font-size: var(--crm-font-size-body-lg, 16px);\n font-style: normal;\n font-weight: var(--crm-font-weight-body-bold, 400);\n line-height: var(--crm-line-height-body-md, 20px);\n letter-spacing: var(--crm-letter-spacing-title-md, 0px);\n margin-top: 11px;\n color: #000;\n}\n\n.note-description-not {\n font-size: 16px;\n}","import { Component, Prop, State, h } from \"@stencil/core\";\nimport { IInfoStore, getInfoCustomization } from \"../../helpers/info.config.helper\";\n\nimport money from '../../assets/svg/money-dollars-svgrepo-com.svg'\nimport { getKeyReserveByCartId } from \"../../utils/keys.storage\";\nimport i18next from \"../../i18n/i18n\"\nimport { IBonus } from \"../../components\";\n\n@Component({\n tag: 'crm-bonus-note',\n styleUrl: 'crm-bonus-note.css'\n})\nexport class CrmBonusNote {\n\n @Prop({ attribute: 'cartid' }) cartId;\n @Prop({ attribute: \"storename\" }) storename;\n\n @State() url: string;\n @State() config: IInfoStore;\n\n @State() bonus: IBonus;\n\n @State() showEdit: boolean = false;\n\n componentWillLoad() {\n this.upadateCheckToFreteAndGetUrl()\n }\n\n upadateCheckToFreteAndGetUrl() {\n\n this.config = getInfoCustomization(this.storename);\n const envios = document.getElementsByName('forma-envio');\n envios.forEach((envio: any) => {\n envio.checked = false;\n });\n\n this.url = window.location.origin;\n }\n\n handleHide() {\n const amount = localStorage.getItem(this.cartId);\n return !!amount;\n }\n\n getAmount() {\n const amount = localStorage.getItem(this.cartId);\n\n return amount ? Number(amount).toFixed(2).replace(\".\", \",\") || \"0,00\" : \"0,00\";\n }\n\n async backCart() {\n // await CrmBonusService.getInstance().cancelBonus(this.cartId, this.storename);\n window.location.href = this.url;\n\n // localStorage.removeItem(getKeyReserveByCartId(this.cartId));\n }\n\n\n hasBonus() {\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n const info = {\n hasBonus: false,\n requestBonus: false\n }\n\n if (_bonus) {\n this.bonus = JSON.parse(_bonus);\n info.hasBonus = this.bonus.hasBonus;\n info.requestBonus = true;\n }\n\n return info;\n }\n\n render() {\n\n const giftbackname = this.config.giftbackTitle || \"Giftback\";\n\n const infobonus = this.hasBonus()\n\n return (\n <div>\n <div class=\"note-container\">\n <div class=\"note-header\">\n\n <p class=\"note-title\">\n <img src={money} width={23} />\n {this.config.giftbackTitle}\n </p>\n {\n infobonus.hasBonus && (\n <div>\n {this.showEdit && (\n <p class=\"back-cart\" onClick={() => this.backCart()}>\n {i18next.t(\"edit\")}\n </p>\n )}\n {!this.showEdit && <countdown-timer initialValue={60} downtime={() => { this.showEdit = true }} />}\n </div>\n )\n }\n </div>\n\n {\n infobonus.hasBonus &&\n (\n <p class=\"note-description-2\">\n {i18next.t(\"withApplyBonus\", { giftbackname: giftbackname })} <strong>R$ {this.getAmount()}.</strong>\n </p>\n )\n }\n\n {\n (infobonus.requestBonus && !infobonus.hasBonus) &&\n (\n <p class=\"note-description-not\">\n {i18next.t(\"noBonus\", { giftbackname: giftbackname })}\n </p>\n )\n }\n\n {\n !infobonus.requestBonus &&\n (\n <div class=\"description\">\n <p class=\"note-description-not\">\n {i18next.t(\"backCart\")}\n </p>\n <crm-button txtBtn=\"VOLTAR AO CARRINHO\" handleClick={() => this.backCart()} />\n </div>\n )\n }\n\n {/* <a class=\"back-cart\" href={this.url}>\n Voltar ao carrinho\n </a> */}\n </div>\n </div>\n )\n }\n}"],"version":3}
|
@@ -236,7 +236,7 @@ const CrmBonus = class {
|
|
236
236
|
this.showModal = true;
|
237
237
|
}
|
238
238
|
render() {
|
239
|
-
return (h("loading-container", { key: '
|
239
|
+
return (h("loading-container", { key: 'c45bd74fb77951cdc177040ece9475e4378669b4', loading: this.loading_reprocess }, h("crm-giftback-form", { key: 'b8e13fcb5e2c149a53d2c3bc2b1bbf3f69c34070', style: { position: "relative" }, ref: ref => this.crmBonusRef = ref, storeName: this.storeName, products: this.buildProducts(), cartId: this.cartId, customer: this.customer, loadProducts: () => this.buildProducts() })));
|
240
240
|
}
|
241
241
|
static get assetsDirs() { return ["assets"]; }
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C;YACtC,OAAO;SACR;QAED,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;SAC3B;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;KACvB;IAED,MAAM;QAEJ,QACE,0EAAmB,OAAO,EAAE,IAAI,CAAC,iBAAiB,IAChD,0EACE,KAAK,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAC/B,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAClC,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,GAExC,CACgB,EACrB;KACF;;;;;;;;;;","names":["i18next"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["export interface IProduct {\n productVariantId: string;\n sku: string;\n value: number;\n quantity: number;\n discount: number;\n}\n\nexport enum AjustesTipoEnum {\n P = \"Promocao\" \n}\n\nexport interface IAjustes {\n Tipo: AjustesTipoEnum;\n Valor: number;\n}\n\nexport interface IProductWake {\n ProdutoVarianteId: number;\n SKU: string;\n PrecoPor: number;\n Quantidade: number;\n Ajustes: IAjustes[];\n}\n\nexport interface ICustomer {\n birthDate: string;\n document: string;\n name: string;\n phone: string;\n}\n\nexport interface IProccesPinBonusDto {\n storeName: string;\n name: string;\n checkoutId: string;\n checkoutProducts: Array<IProduct>;\n storeId: string;\n userId: string;\n cellphone: number;\n pin: string;\n\n}\n\nexport interface IBonus {\n hasBonus: boolean;\n bonusBalance: number;\n totalBonus: number;\n minimumPurchase: number;\n bonusIds: string;\n firstValidityDate: string\n history: [\n {\n validityStart: string;\n validityEnd: string;\n value: number\n },\n {\n validityStart: string;\n validityEnd: string\n value: number\n }\n ]\n storeId: number;\n userId: number;\n cartId: string\n calculatedValue: number;\n totalValue: number\n}\n\n\nexport interface IReserveDTO {\n storeName: string;\n cartId: string;\n grossValue: number;\n redeemedBonus: number;\n ticket: string;\n storeId: string;\n userId: number;\n}","import { AjustesTipoEnum, IAjustes, IProduct, IProductWake } from \"../dto/validate.pin.bonus\";\n\nexport function buildProductsByWake(productsWake: Array<IProductWake> = []): Array<IProduct> {\n\n const products: Array<IProduct> = [];\n\n for ( const pw of productsWake ) {\n let discounts = getDiscount(pw.Ajustes)\n\n products.push(\n {\n sku: pw.SKU,\n value: (pw.PrecoPor * pw.Quantidade),\n productVariantId: pw.ProdutoVarianteId.toString(),\n quantity: pw.Quantidade,\n discount: (discounts * -1)\n }\n )\n }\n\n return products;\n}\n\nfunction getDiscount(ajustes: IAjustes[] = []) {\n \n let discounts = 0;\n \n for(const discount of ajustes) {\n if(discount.Tipo === AjustesTipoEnum.P) {\n discounts += discount.Valor;\n }\n }\n\n return discounts;\n}","\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, Method, Prop, State, Watch, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n // const used = localStorage.getItem(\"bc:used\");\n\n // if (used == \"use\") {\n // await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n // }\n\n try {\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async reprocess(products: Array<any>) {\n this.loading_reprocess = true\n\n console.log('[reprocess]');\n try {\n console.log('[update products list]');\n this.productsInString = JSON.stringify(products);\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n @Watch(\"productsInString\")\n async watchProducts(newValue: string) {\n try {\n console.log('[update products list]');\n this.productsInString = newValue;\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n }\n }\n\n async componentWillLoad() {\n i18next.changeLanguage(i18next.language);\n\n await this.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n console.log('customer', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n await this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n \n const key = `bc-products:${this.cartId}`;\n\n const cart = await this.crmBonusService.getInfoCart();\n\n this.productsInString = JSON.stringify(cart.Produtos)\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n const [ ajuste = { Valor:0 } ] = pro.Ajustes.filter( aj => aj.Tipo === \"Formula\" )\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor + (ajuste.Valor * -1),\n Quantidade: pro.Quantidade,\n Ajustes: pro.Ajustes\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return buildProductsByWake(this.products);\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n loadProducts={() => this.buildProducts()}\n \n />\n </loading-container>\n )\n }\n}\n"],"version":3}
|
1
|
+
{"file":"crm-bonus.entry.js","mappings":";;;;;;AAQA,IAAY,eAEX;AAFD,WAAY,eAAe;IACvB,iCAAc,CAAA;AAClB,CAAC,EAFW,eAAe,KAAf,eAAe;;SCNX,mBAAmB,CAAC,eAAoC,EAAE;IAEtE,MAAM,QAAQ,GAAoB,EAAE,CAAC;IAErC,KAAM,MAAM,EAAE,IAAI,YAAY,EAAG;QAC7B,IAAI,SAAS,GAAG,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC,CAAA;QAEvC,QAAQ,CAAC,IAAI,CACT;YACI,GAAG,EAAE,EAAE,CAAC,GAAG;YACX,KAAK,GAAG,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC;YACpC,gBAAgB,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,EAAE;YACjD,QAAQ,EAAE,EAAE,CAAC,UAAU;YACvB,QAAQ,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC;SAC7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EAAE,IAAI,CAAC,SAAS,EACzB,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,EAC9B,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,YAAY,EAAE,MAAM,IAAI,CAAC,aAAa,EAAE,GAExC,CACgB,EACrB;KACF;;;;;;;;;;","names":["i18next"],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts","src/components/crm-bonus/crm-bonus.css?tag=crm-bonus&encapsulation=scoped","src/components/crm-bonus/crm-bonus.tsx"],"sourcesContent":["export interface IProduct {\n productVariantId: string;\n sku: string;\n value: number;\n quantity: number;\n discount: number;\n}\n\nexport enum AjustesTipoEnum {\n P = \"Promocao\" \n}\n\nexport interface IAjustes {\n Tipo: AjustesTipoEnum;\n Valor: number;\n}\n\nexport interface IProductWake {\n ProdutoVarianteId: number;\n SKU: string;\n PrecoPor: number;\n Quantidade: number;\n Ajustes: IAjustes[];\n}\n\nexport interface ICustomer {\n birthDate: string;\n document: string;\n name: string;\n phone: string;\n}\n\nexport interface IProccesPinBonusDto {\n storeName: string;\n name: string;\n checkoutId: string;\n checkoutProducts: Array<IProduct>;\n storeId: string;\n userId: string;\n cellphone: number;\n pin: string;\n\n}\n\nexport interface IBonus {\n hasBonus: boolean;\n bonusBalance: number;\n totalBonus: number;\n minimumPurchase: number;\n bonusIds: string;\n firstValidityDate: string\n history: [\n {\n validityStart: string;\n validityEnd: string;\n value: number\n },\n {\n validityStart: string;\n validityEnd: string\n value: number\n }\n ]\n storeId: number;\n userId: number;\n cartId: string\n calculatedValue: number;\n totalValue: number\n}\n\n\nexport interface IReserveDTO {\n storeName: string;\n cartId: string;\n grossValue: number;\n redeemedBonus: number;\n ticket: string;\n storeId: string;\n userId: number;\n}","import { AjustesTipoEnum, IAjustes, IProduct, IProductWake } from \"../dto/validate.pin.bonus\";\n\nexport function buildProductsByWake(productsWake: Array<IProductWake> = []): Array<IProduct> {\n\n const products: Array<IProduct> = [];\n\n for ( const pw of productsWake ) {\n let discounts = getDiscount(pw.Ajustes)\n\n products.push(\n {\n sku: pw.SKU,\n value: (pw.PrecoPor * pw.Quantidade),\n productVariantId: pw.ProdutoVarianteId.toString(),\n quantity: pw.Quantidade,\n discount: (discounts * -1)\n }\n )\n }\n\n return products;\n}\n\nfunction getDiscount(ajustes: IAjustes[] = []) {\n \n let discounts = 0;\n \n for(const discount of ajustes) {\n if(discount.Tipo === AjustesTipoEnum.P) {\n discounts += discount.Valor;\n }\n }\n\n return discounts;\n}","\n.container-button {\n /* max-width: 100%; */\n cursor: pointer;\n padding: 5px 5px 5px 14px;\n /* display: flex; */\n}\n\n/* padding: 0 15px 15px;\nborder: 1px solid #ddd;\nmargin-bottom: 20px; */\n\n.section-crm {\n border: 1px solid #dbd4d4;\n /* min-height: 50px; */\n text-align: -webkit-center;\n margin-bottom: 20px;\n}\n\n.section-cart-crm {\n margin-top: 10px;\n}\n\n.section-cart-crm p {\n padding: 0;\n margin: 0px 0px 0px 15px;\n}\n\n.button {\n top: 50%;\n background-color: #6c6c7e;\n color: #fff;\n border: none;\n /* border-radius: 10px; */\n padding: 15px;\n min-height: 30px;\n min-width: 120px;\n font-size: 20px;\n cursor: pointer;\n margin-left: 10px;\n height: 70px;\n}\n\n.form-container {\n width: 97%;\n display: flex;\n justify-content: space-around;\n}\n\n\n.btn {\n display: inline-block;\n padding: 6px 12px;\n margin-bottom: 0;\n font-size: 14px;\n font-weight: 400;\n line-height: 1.42857143;\n text-align: center;\n white-space: nowrap;\n vertical-align: middle;\n -ms-touch-action: manipulation;\n touch-action: manipulation;\n cursor: pointer;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n background-image: none;\n border: 1px solid transparent;\n border-radius: 0px;\n}\n\n.form-container .btnCrm {\n background: #00162e;\n border-color: #00162e;\n width: 30%;\n color: #fff;\n}\n\n.message-alert {\n font-family: sans-serif;\n color: #df4d4d;\n margin-top: 5px;\n}","import { Component, Method, Prop, State, Watch, h } from '@stencil/core';\nimport { IProduct, IProductWake, ICustomer } from '../../dto/validate.pin.bonus';\nimport { CrmBonusService } from '../../services/crmbonus.service';\nimport { IPinSent } from '../../components';\nimport { StepFormEnum } from '../../contants';\n\nimport i18next from '../../i18n/i18n'\nimport { buildProductsByWake } from '../../helpers/build.payload.helper';\n\n@Component({\n tag: 'crm-bonus',\n styleUrl: 'crm-bonus.css',\n scoped: true,\n assetsDirs: ['assets']\n})\nexport class CrmBonus {\n\n private crmBonusService: CrmBonusService = CrmBonusService.getInstance();\n\n private crmBonusRef: HTMLCrmGiftbackFormElement;\n\n @State() showModal: boolean = false;\n @Prop({ attribute: 'userid' }) userId: number;\n @Prop({ attribute: 'storename' }) storeName;\n @Prop({ attribute: 'products' }) productsInString: string;\n @Prop({ attribute: 'cartid' }) cartId;\n\n @State() products: Array<IProductWake>;\n @State() customer: ICustomer = {\n birthDate: \"\",\n document: \"\",\n name: \"\",\n phone: \"\"\n };\n\n @State() loading: boolean = false;\n @State() message: string;\n @State() phone: number;\n @State() canCancel: boolean = false;\n @State() amountCancel: string;\n @State() sent: IPinSent;\n\n @State() session: string;\n @State() loading_reprocess = false;\n\n @Method()\n async resetBonus() {\n console.log('[START RESET BONUS]!!!!!');\n // const used = localStorage.getItem(\"bc:used\");\n\n // if (used == \"use\") {\n // await this.crmBonusService.cancelBonus(this.cartId, this.storeName);\n // }\n\n try {\n await this.crmBonusRef.processBonus(this.buildProducts(), true);\n console.log('[BONUS RESETADO]!!!!!');\n } catch (err) {\n\n this.loading = false;\n console.log('[error ao reprocessar bonous]');\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PHONE);\n } finally {\n this.loading = false;\n }\n }\n\n @Method()\n async reprocess(products: Array<any>) {\n this.loading_reprocess = true\n\n console.log('[reprocess]');\n try {\n console.log('[update products list]');\n this.productsInString = JSON.stringify(products);\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n } finally {\n this.loading_reprocess = false\n }\n }\n\n @Watch(\"productsInString\")\n async watchProducts(newValue: string) {\n try {\n console.log('[update products list]');\n this.productsInString = newValue;\n await this.handleLoad();\n\n await this.resetBonus();\n } catch (err) {\n console.debug('[watchProducts]', err.message);\n }\n }\n\n async componentWillLoad() {\n i18next.changeLanguage(i18next.language);\n\n await this.loadSession();\n await this.loadConfigStore()\n await this.handleLoad();\n }\n\n async loadConfigStore() {\n await this.crmBonusService.getCustomization(this.storeName);\n }\n\n async handleLoad() {\n try {\n if (this.userId) {\n this.customer = await this.crmBonusService.getCustomer(this.userId, this.storeName);\n console.log('customer', this.customer);\n }\n\n const amount = localStorage.getItem(this.cartId);\n\n if (amount) {\n this.canCancel = true;\n this.amountCancel = amount;\n }\n\n } catch (error) {\n console.log('info customer')\n }\n\n await this.buildAndGetProducts();\n }\n\n\n async loadSession() {\n this.session = await this.crmBonusService.getToken(this.storeName);\n\n setTimeout(() => {\n this.loadSession()\n }, 1500000)\n\n }\n\n async buildAndGetProducts() {\n \n const key = `bc-products:${this.cartId}`;\n\n const cart = await this.crmBonusService.getInfoCart();\n\n this.productsInString = JSON.stringify(cart.Produtos)\n\n localStorage.setItem(key, this.productsInString);\n\n const productsInCart = JSON.parse(this.productsInString);\n const products_in_cache = JSON.parse(localStorage.getItem(key));\n\n const products: Array<IProductWake> = []\n\n for (const product_cart of productsInCart) {\n\n const [pro] = products_in_cache.filter(p => p.ProdutoVarianteId == product_cart.ProdutoVarianteId)\n\n const [ ajuste = { Valor:0 } ] = pro.Ajustes.filter( aj => aj.Tipo === \"Formula\" )\n\n if (pro) {\n products.push({\n ...product_cart,\n PrecoPor: pro.PrecoPor + (ajuste.Valor * -1),\n Quantidade: pro.Quantidade,\n Ajustes: pro.Ajustes\n })\n } else {\n products.push(product_cart)\n }\n\n }\n\n this.products = products; //cache_products ? JSON.parse(cache_products) : JSON.parse(this.productsInString);\n\n }\n\n public async sendPin(phone: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n public async sendPinName(customerName: string) {\n this.loading = true;\n this.message = \"\";\n\n try {\n this.customer.name = customerName;\n\n this.sent = await this.crmBonusService.sendPin(this.phone, this.customer.name, this.storeName);;\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_PIN);\n\n this.showModal = true;\n } catch (error) {\n this.message = error?.response?.data?.message\n } finally {\n this.loading = false\n }\n }\n\n buildProducts(): IProduct[] {\n return buildProductsByWake(this.products);\n }\n\n handleCloseModal() {\n this.showModal = false;\n }\n\n save(amount: number) {\n localStorage.setItem(this.cartId, amount.toString());\n this.canCancel = true;\n this.amountCancel = amount.toString()\n }\n\n async cancel() {\n this.message = \"\";\n this.loading = true;\n try {\n await this.crmBonusService.cancel(this.cartId);\n this.canCancel = false;\n\n localStorage.removeItem(this.cartId);\n } catch (error) {\n this.message = \"Não consegui cancelar o bônus, tente novamente!\"\n } finally {\n this.loading = false;\n }\n }\n\n async handleSendPin(phone: string) {\n this.message = \"\"\n if (!phone) {\n this.message = \"Informe seu telefone\";\n return;\n }\n\n this.customer.phone = phone;\n const _phone = phone.replace(/\\D/g, '');\n this.phone = Number(_phone);\n\n if (this.customer.name) {\n return this.sendPin(phone)\n }\n\n await this.crmBonusRef.setStep(StepFormEnum.STEP_NAME);\n this.showModal = true;\n }\n\n render() {\n\n return (\n <loading-container loading={this.loading_reprocess} >\n <crm-giftback-form\n style={{ position: \"relative\" }}\n ref={ref => this.crmBonusRef = ref}\n storeName={this.storeName}\n products={this.buildProducts()}\n cartId={this.cartId}\n customer={this.customer}\n loadProducts={() => this.buildProducts()}\n \n />\n </loading-container>\n )\n }\n}\n"],"version":3}
|
@@ -223,8 +223,8 @@ const CrmBonus = class {
|
|
223
223
|
return (h("div", { key: '8856b0021380c06a1b6d0fe377d0836de0308e40', class: "crm-container-form fbits-responsive-carrinho-desconto" }, h("label", { key: 'ef51aa9f64f7438ae887f5af0688df3c216d810c', class: "crm-title" }, this.config.giftbackTitle), this.step === StepFormEnum.STEP_PHONE &&
|
224
224
|
h("phone-form", { key: '12cd253b89c74738fe27a3ef0a2a46ce50b4f71d', value: this.customer.phone, config: this.config, loading: this.loading, handlerSubmit: (phone) => this.handleSendPin(phone) }), this.step === StepFormEnum.STEP_PIN &&
|
225
225
|
h("pin-form", { key: 'fb7c11d2d94e0035be7615d342cd6e9bf04924e4', 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: '5c8071135ce7f287cb6203f78d0c05988eee3d13', class: "crm-message-info" }, this.sucess), this.error && h("p", { key: 'e0516266cfa7886049a4d751595318ceaf0131f7', class: "crm-message-error" }, this.error)), this.step === StepFormEnum.STEP_RESERVE &&
|
226
|
-
h("giftback-info", { key: '
|
227
|
-
(h("div", { key: '
|
226
|
+
h("giftback-info", { key: 'b36f43a03dd113bc743c985b4327762647aea00c', config: this.config, loading: this.loading, cancel: () => this.handleCancel(), bonus: this.bonus, reserve: () => this.processBonus() }), this.step === StepFormEnum.STEP_NO_BONUS &&
|
227
|
+
(h("div", { key: 'cfeacde74e0b598e2ab93a86af5dc6838ef040cb', class: "container-message" }, instance.t("noGiftback", { storename: this.config.giftbackTitle })))));
|
228
228
|
}
|
229
229
|
};
|
230
230
|
CrmBonus.style = CrmGiftbackFormStyle0;
|
@@ -238,7 +238,7 @@ const LoadingContainer = class {
|
|
238
238
|
this.loading = true;
|
239
239
|
}
|
240
240
|
render() {
|
241
|
-
return (h("div", { key: '
|
241
|
+
return (h("div", { key: '06a7a57acb07c91ca75d00dd42ca568ac708a3ef', class: "relative-xy" }, this.loading && (h("div", { key: '6eee6954ce47b3a60cc9d3f599aa826c30e522db', class: "loading-container" }, h("div", { key: '8747ac17ca30704d18739ccd1cf7d31fbbb05419', class: "loading-spinner" }))), h("slot", { key: '32ffc7a17474372cf35fe7812fa4f193d00aa224' })));
|
242
242
|
}
|
243
243
|
};
|
244
244
|
LoadingContainer.style = LoadingContainerStyle0;
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"crm-giftback-form.loading-container.entry.js","mappings":";;;;;;;AAAA,MAAM,eAAe,GAAG,i+BAAi+B,CAAC;AAC1/B,8BAAe,eAAe;;MCajB,QAAQ;;;;QAGX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;;;;;;;uBAS7C,KAAK;;;;oBAIH,YAAY,CAAC,YAAY;;sBAG7B,EAAE;qBACH,EAAE;;6BAGF,KAAK;;IAI9B,MAAM,OAAO,CAAC,IAAkB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACjB;IAGD,MAAM,YAAY,CAAC,WAAuB,EAAE,EAAE,aAAa,GAAG,KAAK;QACjE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QAEjB,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;QAC/B,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;SAC1B;QAED,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAExE,IAAI,MAAM,EAAE;YAEV,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,EAAE,KAAK,CAAC,MAAM;aACrB,CAAA;YAED,MAAM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,QAAO,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAC9D,CACP,CAGC,EACP;KACF;;;;ACzUH,MAAM,mBAAmB,GAAG,8bAA8b,CAAC;AAC3d,+BAAe,mBAAmB;;MCKrB,gBAAgB;;;uBAEE,IAAI;;IAE/B,MAAM;QACF,QACI,4DAAK,KAAK,EAAC,aAAa,IAEhB,IAAI,CAAC,OAAO,KACR,4DAAK,KAAK,EAAC,mBAAmB,IAC1B,4DAAK,KAAK,EAAC,iBAAiB,GAEtB,CAEJ,CACT,EAEL,8DAAa,CACX,EACT;KACJ;;;;;;","names":["i18next"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx","src/components/loading-container/loading-container.css?tag=loading-container","src/components/loading-container/loading-container.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 font-weight: 100;\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 { USED_KEY, 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 @Prop() loadProducts: () => void;\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_RESERVE;\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(products: IProduct[] = [], hasNewProduct = false) {\n this.sucess = \"\";\n\n console.log('processBonus', [])\n if (hasNewProduct) {\n this.products = products;\n }\n\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\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 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 const phoneAgain = this.getPhoneNumberAgain();\n\n if (phoneAgain) {\n this.step = StepFormEnum.STEP_PHONE;\n return\n }\n\n await this.processBonus();\n\n }\n\n getPhoneNumberAgain() {\n const consulta_bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (!consulta_bonus) return true;\n\n const bonus = JSON.parse(consulta_bonus);\n\n return !bonus.hasBonus;\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 const pinInfoCache = localStorage.getItem(`bc:${this.phone}`);\n\n if (!pinInfoCache) {\n this.pinInfo = await this.crmBonusService.sendPin(_phone, this.customer?.name, this.storeName);\n }\n\n if (pinInfoCache) {\n\n const bonus = JSON.parse(pinInfoCache);\n\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 } else {\n this.step = StepFormEnum.STEP_PIN;\n }\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 this.loadProducts();\n\n const used_or_no = localStorage.getItem(USED_KEY);\n\n if (used_or_no == \"dontUse\") {\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.convertStringToNumber(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.userId.toString(),\n checkoutId: this.cartId,\n checkoutProducts: this.products,\n name: this.customer?.name,\n storeName: this.storeName\n }\n\n try {\n this.bonus = await this.crmBonusService.validatePinBonus(payload);\n\n if (!this.bonus.hasBonus) {\n\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\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 localStorage.setItem(`bc:${this.phone}`, JSON.stringify(this.bonus));\n\n localStorage.setItem(USED_KEY, \"use\");\n localStorage.setItem(this.cartId, this.bonus.bonusBalance.toString());\n\n this.step = StepFormEnum.STEP_RESERVE;\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\n localStorage.setItem(USED_KEY, \"dontUse\");\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\n {/* <loading-container /> */}\n\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={() => this.processBonus()}\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}","/* Estilo para centralizar o container do loading */\n.loading-container {\n position: absolute;\n /* Fixa o loading na tela */\n top: 0;\n left: 0;\n width: 100%;\n /* Tamanho total da tela */\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n /* Fundo semitransparente */\n display: flex;\n /* Centraliza o conteúdo */\n justify-content: center;\n align-items: center;\n z-index: 1000;\n /* Coloca o loading acima de outros elementos */\n}\n\n/* Estilo do spinner (círculo giratório) */\n.loading-spinner {\n width: 50px;\n height: 50px;\n border: 5px solid rgba(255, 255, 255, 0.3);\n /* Borda semitransparente */\n border-top: 5px solid white;\n /* Borda que será animada */\n border-radius: 50%;\n /* Faz o círculo */\n animation: spin 1s linear infinite;\n /* Gira continuamente */\n}\n\n/* Keyframes para a animação de rotação */\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.relative-xy {\n position: relative;\n}","import { Component, Prop, h } from \"@stencil/core\";\n\n@Component({\n tag: 'loading-container',\n styleUrl: 'loading-container.css'\n})\nexport class LoadingContainer {\n\n @Prop() loading: boolean = true;\n\n render() {\n return (\n <div class=\"relative-xy\">\n {\n this.loading && (\n <div class=\"loading-container\">\n <div class=\"loading-spinner\">\n\n </div>\n \n </div>\n )\n }\n <slot></slot>\n </div>\n )\n }\n}"],"version":3}
|
1
|
+
{"file":"crm-giftback-form.loading-container.entry.js","mappings":";;;;;;;AAAA,MAAM,eAAe,GAAG,i+BAAi+B,CAAC;AAC1/B,8BAAe,eAAe;;MCajB,QAAQ;;;;QAGX,oBAAe,GAAoB,eAAe,CAAC,WAAW,EAAE,CAAC;;;;;;;uBAS7C,KAAK;;;;oBAIH,YAAY,CAAC,YAAY;;sBAG7B,EAAE;qBACH,EAAE;;6BAGF,KAAK;;IAI9B,MAAM,OAAO,CAAC,IAAkB;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;KACjB;IAGD,MAAM,YAAY,CAAC,WAAuB,EAAE,EAAE,aAAa,GAAG,KAAK;QACjE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QAEjB,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;QAC/B,IAAI,aAAa,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;SAC1B;QAED,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAExE,IAAI,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,IAAI,KAAK,YAAY,CAAC,YAAY;YACvC,sEACE,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,MAAM,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,EACjC,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,MAAM,IAAI,CAAC,YAAY,EAAE,GAClC,EAIF,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;;;;AC1UH,MAAM,mBAAmB,GAAG,8bAA8b,CAAC;AAC3d,+BAAe,mBAAmB;;MCKrB,gBAAgB;;;uBAEE,IAAI;;IAE/B,MAAM;QACF,QACI,4DAAK,KAAK,EAAC,aAAa,IAEhB,IAAI,CAAC,OAAO,KACR,4DAAK,KAAK,EAAC,mBAAmB,IAC1B,4DAAK,KAAK,EAAC,iBAAiB,GAEtB,CAEJ,CACT,EAEL,8DAAa,CACX,EACT;KACJ;;;;;;","names":["i18next"],"sources":["src/components/giftback-form/giftback-form.css?tag=crm-giftback-form","src/components/giftback-form/giftback-form.tsx","src/components/loading-container/loading-container.css?tag=loading-container","src/components/loading-container/loading-container.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 font-weight: 100;\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 { USED_KEY, 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 @Prop() loadProducts: () => void;\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_RESERVE;\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(products: IProduct[] = [], hasNewProduct = false) {\n this.sucess = \"\";\n\n console.log('processBonus', [])\n if (hasNewProduct) {\n this.products = products;\n }\n\n const _bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\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 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 const phoneAgain = this.getPhoneNumberAgain();\n\n if (phoneAgain) {\n this.step = StepFormEnum.STEP_PHONE;\n return\n }\n\n await this.processBonus();\n\n }\n\n getPhoneNumberAgain() {\n const consulta_bonus = localStorage.getItem(getKeyReserveByCartId(this.cartId));\n\n if (!consulta_bonus) return true;\n\n const bonus = JSON.parse(consulta_bonus);\n\n return !bonus.hasBonus;\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 const pinInfoCache = localStorage.getItem(`bc:${this.phone}`);\n\n if (!pinInfoCache) {\n this.pinInfo = await this.crmBonusService.sendPin(_phone, this.customer?.name, this.storeName);\n }\n\n if (pinInfoCache) {\n\n const bonus = JSON.parse(pinInfoCache);\n\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 } else {\n this.step = StepFormEnum.STEP_PIN;\n }\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 this.loadProducts();\n\n const used_or_no = localStorage.getItem(USED_KEY);\n\n if (used_or_no == \"dontUse\") {\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.convertStringToNumber(),\n storeId: this.pinInfo.storeId.toString(),\n userId: this.pinInfo.userId.toString(),\n checkoutId: this.cartId,\n checkoutProducts: this.products,\n name: this.customer?.name,\n storeName: this.storeName\n }\n\n try {\n this.bonus = await this.crmBonusService.validatePinBonus(payload);\n\n if (!this.bonus.hasBonus) {\n\n localStorage.setItem(getKeyReserveByCartId(this.cartId), JSON.stringify({ ...this.bonus, phone: this.phone }));\n\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 localStorage.setItem(`bc:${this.phone}`, JSON.stringify(this.bonus));\n\n localStorage.setItem(USED_KEY, \"use\");\n localStorage.setItem(this.cartId, this.bonus.bonusBalance.toString());\n\n this.step = StepFormEnum.STEP_RESERVE;\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\n localStorage.setItem(USED_KEY, \"dontUse\");\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\n {/* <loading-container /> */}\n\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 config={this.config}\n loading={this.loading}\n cancel={() => this.handleCancel()}\n bonus={this.bonus}\n reserve={() => this.processBonus()}\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}","/* Estilo para centralizar o container do loading */\n.loading-container {\n position: absolute;\n /* Fixa o loading na tela */\n top: 0;\n left: 0;\n width: 100%;\n /* Tamanho total da tela */\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n /* Fundo semitransparente */\n display: flex;\n /* Centraliza o conteúdo */\n justify-content: center;\n align-items: center;\n z-index: 1000;\n /* Coloca o loading acima de outros elementos */\n}\n\n/* Estilo do spinner (círculo giratório) */\n.loading-spinner {\n width: 50px;\n height: 50px;\n border: 5px solid rgba(255, 255, 255, 0.3);\n /* Borda semitransparente */\n border-top: 5px solid white;\n /* Borda que será animada */\n border-radius: 50%;\n /* Faz o círculo */\n animation: spin 1s linear infinite;\n /* Gira continuamente */\n}\n\n/* Keyframes para a animação de rotação */\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n\n 100% {\n transform: rotate(360deg);\n }\n}\n\n.relative-xy {\n position: relative;\n}","import { Component, Prop, h } from \"@stencil/core\";\n\n@Component({\n tag: 'loading-container',\n styleUrl: 'loading-container.css'\n})\nexport class LoadingContainer {\n\n @Prop() loading: boolean = true;\n\n render() {\n return (\n <div class=\"relative-xy\">\n {\n this.loading && (\n <div class=\"loading-container\">\n <div class=\"loading-spinner\">\n\n </div>\n \n </div>\n )\n }\n <slot></slot>\n </div>\n )\n }\n}"],"version":3}
|