crmbonus-component-wake 2.1.32-ngrok → 2.1.34

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.
Files changed (66) hide show
  1. package/dist/cjs/{build.payload.helper-b93f7ea5.js → build.payload.helper-cfd3173e.js} +4 -1
  2. package/dist/cjs/build.payload.helper-cfd3173e.js.map +1 -0
  3. package/dist/cjs/{cart.helper-b08a12b2.js → cart.helper-701ea6b2.js} +4 -2
  4. package/dist/cjs/cart.helper-701ea6b2.js.map +1 -0
  5. package/dist/cjs/crm-bonus-2.cjs.entry.js +1 -1
  6. package/dist/cjs/crm-bonus-note.cjs.entry.js +2 -2
  7. package/dist/cjs/crm-bonus.cjs.entry.js +2 -2
  8. package/dist/cjs/crm-giftback-form.cjs.entry.js +1 -1
  9. package/dist/cjs/crm-tooltip_5.cjs.entry.js +1 -1
  10. package/dist/cjs/pedido-finalizado.cjs.entry.js +1 -1
  11. package/dist/collection/dto/validate.pin.bonus.js.map +1 -1
  12. package/dist/collection/helpers/build.payload.helper.js +3 -0
  13. package/dist/collection/helpers/build.payload.helper.js.map +1 -1
  14. package/dist/components/crm-bonus-2.js +1 -1
  15. package/dist/components/crm-bonus-note.js +2 -2
  16. package/dist/components/crm-bonus.js +4 -4
  17. package/dist/components/crm-giftback-form.js +1 -1
  18. package/dist/components/giftback-info.js +1 -1
  19. package/dist/components/{p-c90ea2e9.js → p-417b4f7f.js} +4 -2
  20. package/dist/{esm/cart.helper-7101c047.js.map → components/p-417b4f7f.js.map} +1 -1
  21. package/dist/components/{p-028f43a1.js → p-488a119c.js} +2 -2
  22. package/dist/components/{p-028f43a1.js.map → p-488a119c.js.map} +1 -1
  23. package/dist/components/{p-4c7e066c.js → p-b0ef2c0b.js} +4 -1
  24. package/dist/components/p-b0ef2c0b.js.map +1 -0
  25. package/dist/components/{p-0bb6b0e5.js → p-e2a6a4cf.js} +3 -3
  26. package/dist/components/{p-0bb6b0e5.js.map → p-e2a6a4cf.js.map} +1 -1
  27. package/dist/components/pedido-finalizado.js +1 -1
  28. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +1 -1
  29. package/dist/crmbonus-component-wake/{p-9b7bd1e1.entry.js → p-17b97fd2.entry.js} +2 -2
  30. package/dist/crmbonus-component-wake/{p-3e87e176.entry.js → p-3a4d7622.entry.js} +2 -2
  31. package/dist/crmbonus-component-wake/{p-558202ef.entry.js → p-59033825.entry.js} +2 -2
  32. package/dist/crmbonus-component-wake/{p-4ed412c2.entry.js → p-87cb8341.entry.js} +2 -2
  33. package/dist/crmbonus-component-wake/p-b0ef2c0b.js +2 -0
  34. package/dist/crmbonus-component-wake/p-b0ef2c0b.js.map +1 -0
  35. package/dist/crmbonus-component-wake/{p-c74567c6.js → p-b5da6ce1.js} +2 -2
  36. package/dist/crmbonus-component-wake/{p-c74567c6.js.map → p-b5da6ce1.js.map} +1 -1
  37. package/dist/crmbonus-component-wake/{p-f37f3f3f.entry.js → p-e992d997.entry.js} +2 -2
  38. package/dist/crmbonus-component-wake/{p-a0d73d77.entry.js → p-eace8d0e.entry.js} +2 -2
  39. package/dist/env.js +3 -1
  40. package/dist/env.js.map +1 -1
  41. package/dist/esm/{build.payload.helper-caf0a82b.js → build.payload.helper-699a48ca.js} +4 -1
  42. package/dist/esm/build.payload.helper-699a48ca.js.map +1 -0
  43. package/dist/esm/{cart.helper-7101c047.js → cart.helper-4f1913ce.js} +4 -2
  44. package/dist/esm/cart.helper-4f1913ce.js.map +1 -0
  45. package/dist/esm/crm-bonus-2.entry.js +1 -1
  46. package/dist/esm/crm-bonus-note.entry.js +2 -2
  47. package/dist/esm/crm-bonus.entry.js +2 -2
  48. package/dist/esm/crm-giftback-form.entry.js +1 -1
  49. package/dist/esm/crm-tooltip_5.entry.js +1 -1
  50. package/dist/esm/pedido-finalizado.entry.js +1 -1
  51. package/dist/types/Users/Darlison/Projects/Bycoders/crmbonus/crmbonus-component/.stencil/env.d.ts +1 -1
  52. package/dist/types/dto/validate.pin.bonus.d.ts +1 -0
  53. package/package.json +1 -1
  54. package/dist/cjs/build.payload.helper-b93f7ea5.js.map +0 -1
  55. package/dist/cjs/cart.helper-b08a12b2.js.map +0 -1
  56. package/dist/components/p-4c7e066c.js.map +0 -1
  57. package/dist/components/p-c90ea2e9.js.map +0 -1
  58. package/dist/crmbonus-component-wake/p-4c7e066c.js +0 -2
  59. package/dist/crmbonus-component-wake/p-4c7e066c.js.map +0 -1
  60. package/dist/esm/build.payload.helper-caf0a82b.js.map +0 -1
  61. /package/dist/crmbonus-component-wake/{p-9b7bd1e1.entry.js.map → p-17b97fd2.entry.js.map} +0 -0
  62. /package/dist/crmbonus-component-wake/{p-3e87e176.entry.js.map → p-3a4d7622.entry.js.map} +0 -0
  63. /package/dist/crmbonus-component-wake/{p-558202ef.entry.js.map → p-59033825.entry.js.map} +0 -0
  64. /package/dist/crmbonus-component-wake/{p-4ed412c2.entry.js.map → p-87cb8341.entry.js.map} +0 -0
  65. /package/dist/crmbonus-component-wake/{p-f37f3f3f.entry.js.map → p-e992d997.entry.js.map} +0 -0
  66. /package/dist/crmbonus-component-wake/{p-a0d73d77.entry.js.map → p-eace8d0e.entry.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{r as t,h as i}from"./p-8c362346.js";import{a as s,c as e,U as o,p as a}from"./p-c74567c6.js";import{S as n,i as h}from"./p-702d5a6f.js";import{g as c}from"./p-1b441909.js";const r="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";const l=r;const d=class{constructor(i){t(this,i);this.crmBonusService=s.getInstance();this.storeName=undefined;this.cartId=undefined;this.products=undefined;this.customer=undefined;this.loadProducts=undefined;this.loadAll=undefined;this.customStyles=undefined;this.reservedInfo=undefined;this.value=undefined;this.loading=false;this.message=undefined;this.phone=undefined;this.pinInfo=undefined;this.step=n.STEP_RESERVE;this.bonus=undefined;this.sucess="";this.error="";this.config=undefined;this.hasApplyBonus=false;this.loadingAllComponent=false}async setStep(t){this.step=t}async processBonus(t=[],i=false){await this.loadProducts();this.sucess="";console.log("processBonus",[]);if(i){this.products=t}const s=localStorage.getItem(e(this.cartId));if(s){const t=JSON.parse(s);this.bonus=t;this.phone=t.phone;this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018")}}async handleSendPin(t){await this.loadAll();this.message="";if(!t){this.message="Informe seu telefone";return}this.phone=t;this.sendPin()}async componentWillLoad(){this.sucess="";this.error="";this.config=c(this.storeName);const t=this.getPhoneNumberAgain();if(t){this.step=n.STEP_PHONE;return}await this.processBonus()}getPhoneNumberAgain(){const t=localStorage.getItem(e(this.cartId));if(!t)return true;const i=JSON.parse(t);return!i.hasBonus}convertStringToNumber(){var t;const i=(t=this.phone)===null||t===void 0?void 0:t.replace(/\D/g,"");return Number(i)}async sendPin(){var t,i,s;this.loading=true;this.message="";this.sucess="";this.error="";try{const i=this.convertStringToNumber();const s=localStorage.getItem(`bc:${this.phone}`);if(!s){this.pinInfo=await this.crmBonusService.sendPin(i,(t=this.customer)===null||t===void 0?void 0:t.name,this.storeName)}if(s){const t=JSON.parse(s);this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018")}else{this.step=n.STEP_PIN}}catch(t){this.message=(s=(i=t===null||t===void 0?void 0:t.response)===null||i===void 0?void 0:i.data)===null||s===void 0?void 0:s.message}finally{this.loading=false}}changePhone(){this.sucess="";this.error="";this.step=n.STEP_PHONE}async validateBonus(t){var i,s,a,h,c,r,l,d,f,u,m,p;this.loadingAllComponent=true;await this.loadProducts();const g=localStorage.getItem(o);if(g=="dontUse"){this.step=n.STEP_RESERVE;return}this.loading=true;this.sucess="";this.error="";const v=((i=this.pinInfo)===null||i===void 0?void 0:i.storeId)||((a=(s=this.reservedInfo)===null||s===void 0?void 0:s.metadata)===null||a===void 0?void 0:a.storeId);const b=((h=this.pinInfo)===null||h===void 0?void 0:h.userId)||((r=(c=this.reservedInfo)===null||c===void 0?void 0:c.metadata)===null||r===void 0?void 0:r.userId);const y=(d=(l=this.reservedInfo)===null||l===void 0?void 0:l.metadata)===null||d===void 0?void 0:d.cellphone;const S={pin:t,cellphone:y||this.convertStringToNumber(),storeId:v.toString(),userId:b.toString(),checkoutId:this.cartId,checkoutProducts:this.products,name:(f=this.customer)===null||f===void 0?void 0:f.name,storeName:this.storeName};try{this.bonus=await this.crmBonusService.validatePinBonus(S);if(!this.bonus.hasBonus){localStorage.setItem(e(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));this.loading=false;this.step=n.STEP_NO_BONUS;return}this.sucess="Código validado com sucesso!";localStorage.setItem(e(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));localStorage.setItem(`bc:${this.phone}`,JSON.stringify(this.bonus));localStorage.setItem(o,"use");localStorage.setItem(this.cartId,this.bonus.bonusBalance.toString());this.updateMetadata({storeId:Number(v),userId:Number(b)},S.cellphone);console.log("RESERVE",this.bonus);this.step=n.STEP_RESERVE}catch(t){const i=(m=(u=t===null||t===void 0?void 0:t.response)===null||u===void 0?void 0:u.data)===null||m===void 0?void 0:m.response;const s=(p=t===null||t===void 0?void 0:t.response)===null||p===void 0?void 0:p.data;if(i&&i.includes("Pin")){this.error="Código inválido!"}else if([403,500].includes(s.statusCode)){this.error="ocorreu um error, atualize a pagina e tente novamente!"}else{this.error=i;this.step=n.STEP_NO_BONUS}}finally{this.loading=false;this.loadingAllComponent=false}}async updateMetadata(t,i){try{if(this.reservedInfo.isExpired()){console.log("[CRM:updateMetadata]");await a(this.storeName,this.cartId,{createdAt:Date.now(),url:window.location.href,storeId:t.storeId,userId:t.userId,cellphone:i});localStorage.removeItem("bc:time")}else{await a(this.storeName,this.cartId,{url:window.location.href,storeId:t.storeId,userId:t.userId,cellphone:i})}}catch(t){console.error("[CRMBONUS:updateMetadata]: ",t)}}handleCancel(){this.cancel()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartId);localStorage.setItem(o,"dontUse");this.save(0);await this.updateMetadata({storeId:null,userId:null},null)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async reserveApply(t){this.loading=true;this.message="";try{await this.reserve(t);this.save(t)}catch(t){this.message="ocorreu um error ao solicitar a aplicação do bonus! tente novamente";this.step=n.STEP_NO_BONUS;localStorage.removeItem(this.cartId)}finally{this.loading=false}}save(t){localStorage.setItem(this.cartId,t.toString())}async reserve(t){await this.crmBonusService.reserve({redeemedBonus:t,cartId:this.cartId,ticket:this.cartId,grossValue:Number(this.bonus.totalValue),storeName:this.storeName,storeId:this.bonus.storeId.toString(),userId:this.bonus.userId})}render(){console.log("cartId",this.cartId);return i("div",{key:"ec6f957d4b375fd6abe2c11eeae23fa69dfa2ac8",class:"crm-container-form fbits-responsive-carrinho-desconto",style:this.customStyles},i("label",{key:"a743c2f5565c5403f6daba01f45a1dc665fde99d",class:"crm-title"},this.config.giftbackTitle),this.error&&i("label",{key:"e5dcc4b20685bac97fc12c6153d68939e0f88956",class:"crm-message-error"},this.error),this.step===n.STEP_PHONE&&i("phone-form",{key:"1f2bc519ec31f4293c75d5284c9fa4fa593187f2",value:this.customer.phone,config:this.config,loading:this.loading,handlerSubmit:t=>this.handleSendPin(t)}),this.step===n.STEP_PIN&&i("pin-form",{key:"7ff43b9a51a638feafda8dbefd8f641546037fa4",config:this.config,phone:this.phone,cancel:()=>this.changePhone(),resend:()=>this.sendPin(),validate:t=>this.validateBonus(t),loading:this.loading},this.sucess&&i("p",{key:"ff486afaf126a8cbeeabc6a11d9647e9cf5b22dd",class:"crm-message-info"},this.sucess),this.error&&i("p",{key:"444f7fdfd86a05884086eff15e9aa3b4fface993",class:"crm-message-error"},this.error)),this.step===n.STEP_RESERVE&&i("giftback-info",{key:"cbeb32249da8c5fa088b43e6c2c94eb427fea6a4",storeName:this.storeName,infoBonus:this.reservedInfo,config:this.config,loading:this.loading,cancel:()=>this.handleCancel(),bonus:this.bonus,reserve:()=>this.processBonus(),cartId:this.cartId}),this.step===n.STEP_NO_BONUS&&i("div",{key:"3d1c697af1c4b495f928b493f9c056bb7b84042a",class:"container-message"},h.t("noGiftback",{storename:this.config.giftbackTitle})))}};d.style=l;export{d as crm_giftback_form};
2
- //# sourceMappingURL=p-f37f3f3f.entry.js.map
1
+ import{r as t,h as i}from"./p-8c362346.js";import{a as s,c as e,U as o,p as a}from"./p-b5da6ce1.js";import{S as n,i as h}from"./p-702d5a6f.js";import{g as r}from"./p-1b441909.js";const c="*{margin:0;padding:0;box-sizing:border-box}:host{--crmfont-sizebodymd:14px;--crmline-heightbodymd:20px;--crmletter-spacingtitle-md:0px}.container-message{font-weight:400;line-height:var(--crmline-heightbodymd);letter-spacing:var(--crmletter-spacingtitle-md);text-align:left;text-underline-position:from-font;text-decoration-skip-ink:none}.crm-container-form{display:flex;flex-direction:column;justify-content:space-around;height:auto;padding:20px 24px 20px 24px;border:1px solid #CCCC;writing-mode:horizontal-tb;gap:16px;border-top:1px solid #ccc !important;border-bottom:1px solid #ccc !important}.crm-phone-form{display:flex;flex-direction:column;height:100%;gap:16px}.crm-subtitle{font-size:.875rem;line-height:1.25rem}.crm-title{font-weight:700;line-height:20px;color:#262626;}.crm-message-info{color:#619013;font-weight:500;}.crm-message-error{color:#E11D48;font-weight:500;}";const l=c;const d=class{constructor(i){t(this,i);this.crmBonusService=s.getInstance();this.storeName=undefined;this.cartId=undefined;this.products=undefined;this.customer=undefined;this.loadProducts=undefined;this.loadAll=undefined;this.customStyles=undefined;this.reservedInfo=undefined;this.value=undefined;this.loading=false;this.message=undefined;this.phone=undefined;this.pinInfo=undefined;this.step=n.STEP_RESERVE;this.bonus=undefined;this.sucess="";this.error="";this.config=undefined;this.hasApplyBonus=false;this.loadingAllComponent=false}async setStep(t){this.step=t}async processBonus(t=[],i=false){await this.loadProducts();this.sucess="";console.log("processBonus",[]);if(i){this.products=t}const s=localStorage.getItem(e(this.cartId));if(s){const t=JSON.parse(s);this.bonus=t;this.phone=t.phone;this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018")}}async handleSendPin(t){await this.loadAll();this.message="";if(!t){this.message="Informe seu telefone";return}this.phone=t;this.sendPin()}async componentWillLoad(){this.sucess="";this.error="";this.config=r(this.storeName);const t=this.getPhoneNumberAgain();if(t){this.step=n.STEP_PHONE;return}await this.processBonus()}getPhoneNumberAgain(){const t=localStorage.getItem(e(this.cartId));if(!t)return true;const i=JSON.parse(t);return!i.hasBonus}convertStringToNumber(){var t;const i=(t=this.phone)===null||t===void 0?void 0:t.replace(/\D/g,"");return Number(i)}async sendPin(){var t,i,s;this.loading=true;this.message="";this.sucess="";this.error="";try{const i=this.convertStringToNumber();const s=localStorage.getItem(`bc:${this.phone}`);if(!s){this.pinInfo=await this.crmBonusService.sendPin(i,(t=this.customer)===null||t===void 0?void 0:t.name,this.storeName)}if(s){const t=JSON.parse(s);this.pinInfo={storeId:t.storeId,userId:t.userId};await this.validateBonus("2018")}else{this.step=n.STEP_PIN}}catch(t){this.message=(s=(i=t===null||t===void 0?void 0:t.response)===null||i===void 0?void 0:i.data)===null||s===void 0?void 0:s.message}finally{this.loading=false}}changePhone(){this.sucess="";this.error="";this.step=n.STEP_PHONE}async validateBonus(t){var i,s,a,h,r,c,l,d,f,u,m,p;this.loadingAllComponent=true;await this.loadProducts();const g=localStorage.getItem(o);if(g=="dontUse"){this.step=n.STEP_RESERVE;return}this.loading=true;this.sucess="";this.error="";const v=((i=this.pinInfo)===null||i===void 0?void 0:i.storeId)||((a=(s=this.reservedInfo)===null||s===void 0?void 0:s.metadata)===null||a===void 0?void 0:a.storeId);const b=((h=this.pinInfo)===null||h===void 0?void 0:h.userId)||((c=(r=this.reservedInfo)===null||r===void 0?void 0:r.metadata)===null||c===void 0?void 0:c.userId);const y=(d=(l=this.reservedInfo)===null||l===void 0?void 0:l.metadata)===null||d===void 0?void 0:d.cellphone;const S={pin:t,cellphone:y||this.convertStringToNumber(),storeId:v.toString(),userId:b.toString(),checkoutId:this.cartId,checkoutProducts:this.products,name:(f=this.customer)===null||f===void 0?void 0:f.name,storeName:this.storeName};try{this.bonus=await this.crmBonusService.validatePinBonus(S);if(!this.bonus.hasBonus){localStorage.setItem(e(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));this.loading=false;this.step=n.STEP_NO_BONUS;return}this.sucess="Código validado com sucesso!";localStorage.setItem(e(this.cartId),JSON.stringify(Object.assign(Object.assign({},this.bonus),{phone:this.phone})));localStorage.setItem(`bc:${this.phone}`,JSON.stringify(this.bonus));localStorage.setItem(o,"use");localStorage.setItem(this.cartId,this.bonus.bonusBalance.toString());this.updateMetadata({storeId:Number(v),userId:Number(b)},S.cellphone);console.log("RESERVE",this.bonus);this.step=n.STEP_RESERVE}catch(t){const i=(m=(u=t===null||t===void 0?void 0:t.response)===null||u===void 0?void 0:u.data)===null||m===void 0?void 0:m.response;const s=(p=t===null||t===void 0?void 0:t.response)===null||p===void 0?void 0:p.data;if(i&&i.includes("Pin")){this.error="Código inválido!"}else if([403,500].includes(s.statusCode)){this.error="ocorreu um error, atualize a pagina e tente novamente!"}else{this.error=i;this.step=n.STEP_NO_BONUS}}finally{this.loading=false;this.loadingAllComponent=false}}async updateMetadata(t,i){try{if(this.reservedInfo.isExpired()){console.log("[CRM:updateMetadata]");await a(this.storeName,this.cartId,{createdAt:Date.now(),url:window.location.href,storeId:t.storeId,userId:t.userId,cellphone:i});localStorage.removeItem("bc:time")}else{await a(this.storeName,this.cartId,{url:window.location.href,storeId:t.storeId,userId:t.userId,cellphone:i})}}catch(t){console.error("[CRMBONUS:updateMetadata]: ",t)}}handleCancel(){this.cancel()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartId);localStorage.setItem(o,"dontUse");this.save(0);await this.updateMetadata({storeId:null,userId:null},null)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async reserveApply(t){this.loading=true;this.message="";try{await this.reserve(t);this.save(t)}catch(t){this.message="ocorreu um error ao solicitar a aplicação do bonus! tente novamente";this.step=n.STEP_NO_BONUS;localStorage.removeItem(this.cartId)}finally{this.loading=false}}save(t){localStorage.setItem(this.cartId,t.toString())}async reserve(t){await this.crmBonusService.reserve({redeemedBonus:t,cartId:this.cartId,ticket:this.cartId,grossValue:Number(this.bonus.totalValue),storeName:this.storeName,storeId:this.bonus.storeId.toString(),userId:this.bonus.userId})}render(){console.log("cartId",this.cartId);return i("div",{key:"ec6f957d4b375fd6abe2c11eeae23fa69dfa2ac8",class:"crm-container-form fbits-responsive-carrinho-desconto",style:this.customStyles},i("label",{key:"a743c2f5565c5403f6daba01f45a1dc665fde99d",class:"crm-title"},this.config.giftbackTitle),this.error&&i("label",{key:"e5dcc4b20685bac97fc12c6153d68939e0f88956",class:"crm-message-error"},this.error),this.step===n.STEP_PHONE&&i("phone-form",{key:"1f2bc519ec31f4293c75d5284c9fa4fa593187f2",value:this.customer.phone,config:this.config,loading:this.loading,handlerSubmit:t=>this.handleSendPin(t)}),this.step===n.STEP_PIN&&i("pin-form",{key:"7ff43b9a51a638feafda8dbefd8f641546037fa4",config:this.config,phone:this.phone,cancel:()=>this.changePhone(),resend:()=>this.sendPin(),validate:t=>this.validateBonus(t),loading:this.loading},this.sucess&&i("p",{key:"ff486afaf126a8cbeeabc6a11d9647e9cf5b22dd",class:"crm-message-info"},this.sucess),this.error&&i("p",{key:"444f7fdfd86a05884086eff15e9aa3b4fface993",class:"crm-message-error"},this.error)),this.step===n.STEP_RESERVE&&i("giftback-info",{key:"cbeb32249da8c5fa088b43e6c2c94eb427fea6a4",storeName:this.storeName,infoBonus:this.reservedInfo,config:this.config,loading:this.loading,cancel:()=>this.handleCancel(),bonus:this.bonus,reserve:()=>this.processBonus(),cartId:this.cartId}),this.step===n.STEP_NO_BONUS&&i("div",{key:"3d1c697af1c4b495f928b493f9c056bb7b84042a",class:"container-message"},h.t("noGiftback",{storename:this.config.giftbackTitle})))}};d.style=l;export{d as crm_giftback_form};
2
+ //# sourceMappingURL=p-e992d997.entry.js.map
@@ -1,2 +1,2 @@
1
- import{r as t,h as s}from"./p-8c362346.js";import{a as i,U as o,g as e,b as n,C as a}from"./p-c74567c6.js";import{d as r,S as c,i as h}from"./p-702d5a6f.js";import{b as l}from"./p-4c7e066c.js";const d=".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";const u=d;const f=class{constructor(s){t(this,s);this.crmBonusService=i.getInstance();this.cart=undefined;this.canhidden=false;this.showModal=false;this.cartWake=undefined;this.customer={birthDate:"",document:"",name:"",phone:""};this.loading=false;this.message=undefined;this.phone=undefined;this.canCancel=false;this.amountCancel=undefined;this.sent=undefined;this.session=undefined;this.loading_reprocess=false;this.styles=r;this.reservedInfo=undefined}async resetBonus(){console.log("[START RESET BONUS]!!!!!");try{await this.crmBonusRef.processBonus(this.buildProducts(),true);console.log("[BONUS RESETADO]!!!!!")}catch(t){this.loading=false;console.log("[error ao reprocessar bonous]");await this.crmBonusRef.setStep(c.STEP_PHONE)}finally{this.loading=false}}async setloading(){this.loading_reprocess=!this.loading_reprocess}async reprocess(){console.log("[CRMBONUS] - reprocess");this.loading_reprocess=true;try{const t=localStorage.getItem(o);if(!t)return;this.cartWake=await e();await this.resetBonus()}catch(t){console.debug("[watchProducts]",t.message)}finally{this.loading_reprocess=false}}async componentWillLoad(){window.addEventListener("productRemovedFromCart",(async()=>{console.log("[CRMBONUS] - productRemovedFromCart");await this.reprocess()}));window.addEventListener("productAddedToCart",(async()=>{console.log("[CRMBONUS] - productAddedToCart");await this.reprocess()}));document.querySelectorAll("form").forEach((t=>{t.addEventListener("submit",(()=>{console.log("[CRMBONUS] - Formulário está sendo submetido!");setTimeout((async()=>{await this.reprocess()}))}))}));await this.observerHandle();h.changeLanguage(h.language);await this.loadSession();this.handleLoad();await this.loadConfigStore()}async componentDidLoad(){console.log("[did load]")}async observerHandle(){const t=document.getElementsByTagName("a");for(let s of t){console.log("[el.href]",s.href);if(s.href.includes("Produto/Delete")){s.addEventListener("click",(async()=>{console.log("[CRMBONUS] - Produto removido do carrinho");setTimeout((async()=>{await this.reprocess();this.observerHandle()}),2e3)}))}if(s.href.includes("Produto/Add")){s.addEventListener("click",(async()=>{console.log("[CRMBONUS] - Produto adicionado ao carrinho");setTimeout((async()=>{await this.reprocess();this.observerHandle()}),2e3)}))}}}async loadConfigStore(){const[t,s]=await Promise.all([this.crmBonusService.getCustomization(this.cartWake.store.name),n(this.cartWake.id,this.cartWake.store.name)]);console.log("[infoBonus]",s);this.reservedInfo=s;if(t.keepStoreFrontStyle){console.log("[bc:usar estilo da loja]");this.styles=null}}async fetchCustomer(t,s){try{return await this.crmBonusService.getCustomer(t,s)}catch(t){console.error("[fetchCustomer] Error fetching customer:",t);return null}}async handleLoad(){try{if(this.cartWake.user.id){this.fetchCustomer(this.cartWake.user.id,this.cartWake.store.name).then((t=>{console.log("[bc:loading customer]");if(t){this.customer=t;console.log("customer",this.customer)}}))}const t=localStorage.getItem(this.cartWake.id);if(t){this.canCancel=true;this.amountCancel=t}await this.buildAndGetProducts(this.cartWake.products)}catch(t){console.log("info customer")}}async loadSession(){this.cartWake=this.cart?new a(JSON.parse(this.cart)):await e();console.log("[bc:carregou carrinho]");this.session=await this.crmBonusService.getToken(this.cartWake.store.name);console.log("[bc:carregou session]");setTimeout((()=>{this.loadSession()}),15e5)}async buildAndGetProducts(t){console.log();const s=`bc-products:${this.cartWake.id}`;const i=JSON.stringify(t);localStorage.setItem(s,i);const o=JSON.parse(localStorage.getItem(s));const e=[];for(const s of t){const[t]=o.filter((t=>t.ProdutoVarianteId==s.ProdutoVarianteId));if(t){e.push(Object.assign(Object.assign({},s),{PrecoPor:t.PrecoPor,PrecoDe:t.PrecoDe,Quantidade:t.Quantidade,Ajustes:t.Ajustes}))}else{e.push(s)}}this.cartWake.products=e}async sendPin(t){var s,i;this.loading=true;this.message="";try{const s=t.replace(/\D/g,"");this.phone=Number(s);this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.cartWake.store.name);await this.crmBonusRef.setStep(c.STEP_PIN);this.showModal=true}catch(t){this.message=(i=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||i===void 0?void 0:i.message}finally{this.loading=false}}async sendPinName(t){var s,i;this.loading=true;this.message="";try{this.customer.name=t;this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.cartWake.store.name);await this.crmBonusRef.setStep(c.STEP_PIN);this.showModal=true}catch(t){this.message=(i=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||i===void 0?void 0:i.message}finally{this.loading=false}}buildProducts(){return l(this.cartWake.products)}handleCloseModal(){this.showModal=false}save(t){localStorage.setItem(this.cartWake.id,t.toString());this.canCancel=true;this.amountCancel=t.toString()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartWake.id);this.canCancel=false;localStorage.removeItem(this.cartWake.id)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async handleSendPin(t){this.message="";if(!t){this.message="Informe seu telefone";return}this.customer.phone=t;const s=t.replace(/\D/g,"");this.phone=Number(s);if(this.customer.name){return this.sendPin(t)}await this.crmBonusRef.setStep(c.STEP_NAME);this.showModal=true}render(){if(this.canhidden){return null}return s("loading-container",{loading:this.loading_reprocess},s("crm-giftback-form",{customStyles:this.styles,style:{position:"relative"},ref:t=>this.crmBonusRef=t,storeName:this.cartWake.store.name,products:this.buildProducts(),cartId:this.cartWake.id,customer:this.customer,loadProducts:()=>this.buildProducts(),loadAll:()=>this.handleLoad(),reservedInfo:this.reservedInfo}))}static get assetsDirs(){return["assets"]}};f.style=u;export{f as crm_bonus};
2
- //# sourceMappingURL=p-a0d73d77.entry.js.map
1
+ import{r as t,h as s}from"./p-8c362346.js";import{a as i,U as o,g as e,b as n,C as a}from"./p-b5da6ce1.js";import{d as r,S as c,i as h}from"./p-702d5a6f.js";import{b as l}from"./p-b0ef2c0b.js";const d=".container-button{cursor:pointer;padding:5px 5px 5px 14px;}.section-crm{border:1px solid #dbd4d4;text-align:-webkit-center;margin-bottom:20px}.section-cart-crm{margin-top:10px}.section-cart-crm p{padding:0;margin:0px 0px 0px 15px}.button{top:50%;background-color:#6c6c7e;color:#fff;border:none;padding:15px;min-height:30px;min-width:120px;cursor:pointer;margin-left:10px;height:70px}.form-container{width:97%;display:flex;justify-content:space-around}.btn{display:inline-block;padding:6px 12px;margin-bottom:0;font-weight:400;line-height:1.42857143;text-align:center;white-space:nowrap;vertical-align:middle;-ms-touch-action:manipulation;touch-action:manipulation;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-image:none;border:1px solid transparent;border-radius:0px}.form-container .btnCrm{background:#00162e;border-color:#00162e;width:30%;color:#fff}.message-alert{color:#df4d4d;margin-top:5px}";const u=d;const f=class{constructor(s){t(this,s);this.crmBonusService=i.getInstance();this.cart=undefined;this.canhidden=false;this.showModal=false;this.cartWake=undefined;this.customer={birthDate:"",document:"",name:"",phone:""};this.loading=false;this.message=undefined;this.phone=undefined;this.canCancel=false;this.amountCancel=undefined;this.sent=undefined;this.session=undefined;this.loading_reprocess=false;this.styles=r;this.reservedInfo=undefined}async resetBonus(){console.log("[START RESET BONUS]!!!!!");try{await this.crmBonusRef.processBonus(this.buildProducts(),true);console.log("[BONUS RESETADO]!!!!!")}catch(t){this.loading=false;console.log("[error ao reprocessar bonous]");await this.crmBonusRef.setStep(c.STEP_PHONE)}finally{this.loading=false}}async setloading(){this.loading_reprocess=!this.loading_reprocess}async reprocess(){console.log("[CRMBONUS] - reprocess");this.loading_reprocess=true;try{const t=localStorage.getItem(o);if(!t)return;this.cartWake=await e();await this.resetBonus()}catch(t){console.debug("[watchProducts]",t.message)}finally{this.loading_reprocess=false}}async componentWillLoad(){window.addEventListener("productRemovedFromCart",(async()=>{console.log("[CRMBONUS] - productRemovedFromCart");await this.reprocess()}));window.addEventListener("productAddedToCart",(async()=>{console.log("[CRMBONUS] - productAddedToCart");await this.reprocess()}));document.querySelectorAll("form").forEach((t=>{t.addEventListener("submit",(()=>{console.log("[CRMBONUS] - Formulário está sendo submetido!");setTimeout((async()=>{await this.reprocess()}))}))}));await this.observerHandle();h.changeLanguage(h.language);await this.loadSession();this.handleLoad();await this.loadConfigStore()}async componentDidLoad(){console.log("[did load]")}async observerHandle(){const t=document.getElementsByTagName("a");for(let s of t){console.log("[el.href]",s.href);if(s.href.includes("Produto/Delete")){s.addEventListener("click",(async()=>{console.log("[CRMBONUS] - Produto removido do carrinho");setTimeout((async()=>{await this.reprocess();this.observerHandle()}),2e3)}))}if(s.href.includes("Produto/Add")){s.addEventListener("click",(async()=>{console.log("[CRMBONUS] - Produto adicionado ao carrinho");setTimeout((async()=>{await this.reprocess();this.observerHandle()}),2e3)}))}}}async loadConfigStore(){const[t,s]=await Promise.all([this.crmBonusService.getCustomization(this.cartWake.store.name),n(this.cartWake.id,this.cartWake.store.name)]);console.log("[infoBonus]",s);this.reservedInfo=s;if(t.keepStoreFrontStyle){console.log("[bc:usar estilo da loja]");this.styles=null}}async fetchCustomer(t,s){try{return await this.crmBonusService.getCustomer(t,s)}catch(t){console.error("[fetchCustomer] Error fetching customer:",t);return null}}async handleLoad(){try{if(this.cartWake.user.id){this.fetchCustomer(this.cartWake.user.id,this.cartWake.store.name).then((t=>{console.log("[bc:loading customer]");if(t){this.customer=t;console.log("customer",this.customer)}}))}const t=localStorage.getItem(this.cartWake.id);if(t){this.canCancel=true;this.amountCancel=t}await this.buildAndGetProducts(this.cartWake.products)}catch(t){console.log("info customer")}}async loadSession(){this.cartWake=this.cart?new a(JSON.parse(this.cart)):await e();console.log("[bc:carregou carrinho]");this.session=await this.crmBonusService.getToken(this.cartWake.store.name);console.log("[bc:carregou session]");setTimeout((()=>{this.loadSession()}),15e5)}async buildAndGetProducts(t){console.log();const s=`bc-products:${this.cartWake.id}`;const i=JSON.stringify(t);localStorage.setItem(s,i);const o=JSON.parse(localStorage.getItem(s));const e=[];for(const s of t){const[t]=o.filter((t=>t.ProdutoVarianteId==s.ProdutoVarianteId));if(t){e.push(Object.assign(Object.assign({},s),{PrecoPor:t.PrecoPor,PrecoDe:t.PrecoDe,Quantidade:t.Quantidade,Ajustes:t.Ajustes}))}else{e.push(s)}}this.cartWake.products=e}async sendPin(t){var s,i;this.loading=true;this.message="";try{const s=t.replace(/\D/g,"");this.phone=Number(s);this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.cartWake.store.name);await this.crmBonusRef.setStep(c.STEP_PIN);this.showModal=true}catch(t){this.message=(i=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||i===void 0?void 0:i.message}finally{this.loading=false}}async sendPinName(t){var s,i;this.loading=true;this.message="";try{this.customer.name=t;this.sent=await this.crmBonusService.sendPin(this.phone,this.customer.name,this.cartWake.store.name);await this.crmBonusRef.setStep(c.STEP_PIN);this.showModal=true}catch(t){this.message=(i=(s=t===null||t===void 0?void 0:t.response)===null||s===void 0?void 0:s.data)===null||i===void 0?void 0:i.message}finally{this.loading=false}}buildProducts(){return l(this.cartWake.products)}handleCloseModal(){this.showModal=false}save(t){localStorage.setItem(this.cartWake.id,t.toString());this.canCancel=true;this.amountCancel=t.toString()}async cancel(){this.message="";this.loading=true;try{await this.crmBonusService.cancel(this.cartWake.id);this.canCancel=false;localStorage.removeItem(this.cartWake.id)}catch(t){this.message="Não consegui cancelar o bônus, tente novamente!"}finally{this.loading=false}}async handleSendPin(t){this.message="";if(!t){this.message="Informe seu telefone";return}this.customer.phone=t;const s=t.replace(/\D/g,"");this.phone=Number(s);if(this.customer.name){return this.sendPin(t)}await this.crmBonusRef.setStep(c.STEP_NAME);this.showModal=true}render(){if(this.canhidden){return null}return s("loading-container",{loading:this.loading_reprocess},s("crm-giftback-form",{customStyles:this.styles,style:{position:"relative"},ref:t=>this.crmBonusRef=t,storeName:this.cartWake.store.name,products:this.buildProducts(),cartId:this.cartWake.id,customer:this.customer,loadProducts:()=>this.buildProducts(),loadAll:()=>this.handleLoad(),reservedInfo:this.reservedInfo}))}static get assetsDirs(){return["assets"]}};f.style=u;export{f as crm_bonus};
2
+ //# sourceMappingURL=p-eace8d0e.entry.js.map
package/dist/env.js CHANGED
@@ -1,4 +1,6 @@
1
1
  // export const CRM_BONUS_API_URL = "https://crmbonus-hub-staging-0ff7e3bf68ac.herokuapp.com/api" //"https://crmbonus-service-staging-d15ba5377115.herokuapp.com"; //"https://typically-workable-perch.ngrok-free.app"; // "http://localhost:3500";
2
- export const CRM_BONUS_API_URL = "https://typically-workable-perch.ngrok-free.app/api";
2
+ // export const CRM_BONUS_API_URL = "https://typically-workable-perch.ngrok-free.app/api";
3
+ // export const CRM_BONUS_API_URL = "https://typically-workable-perch.ngrok-free.app/api";
4
+ export const CRM_BONUS_API_URL = "https://wake.crmbonus.com/api"; //"http://localhost:4000/api";// "https://wake-middleware.crmbonus.com/api"; //"https://wake-middleware.crmbonus.com/api";// "https://crmbonus-wake-hub-staging-5daedbc4e22b.herokuapp.com/api" //"https://crmbonus-service-staging-d15ba5377115.herokuapp.com"; //"https://typically-workable-perch.ngrok-free.app"; // "http://localhost:3500";
3
5
  export const CHECKOUT_CART_WAKE = "http://localhost:3001";
4
6
  //# sourceMappingURL=env.js.map
package/dist/env.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../env.ts"],"names":[],"mappings":"AACA,mPAAmP;AACnP,MAAM,CAAC,MAAM,iBAAiB,GAAG,qDAAqD,CAAC;AACvF,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAA","sourcesContent":["\r\n// export const CRM_BONUS_API_URL = \"https://crmbonus-hub-staging-0ff7e3bf68ac.herokuapp.com/api\" //\"https://crmbonus-service-staging-d15ba5377115.herokuapp.com\"; //\"https://typically-workable-perch.ngrok-free.app\"; // \"http://localhost:3500\";\r\nexport const CRM_BONUS_API_URL = \"https://typically-workable-perch.ngrok-free.app/api\";\r\nexport const CHECKOUT_CART_WAKE = \"http://localhost:3001\""]}
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../env.ts"],"names":[],"mappings":"AACA,mPAAmP;AACnP,0FAA0F;AAC1F,0FAA0F;AAC1F,MAAM,CAAC,MAAM,iBAAiB,GAAG,+BAA+B,CAAC,CAAC,iVAAiV;AACnZ,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAA","sourcesContent":["\r\n// export const CRM_BONUS_API_URL = \"https://crmbonus-hub-staging-0ff7e3bf68ac.herokuapp.com/api\" //\"https://crmbonus-service-staging-d15ba5377115.herokuapp.com\"; //\"https://typically-workable-perch.ngrok-free.app\"; // \"http://localhost:3500\";\r\n// export const CRM_BONUS_API_URL = \"https://typically-workable-perch.ngrok-free.app/api\";\r\n// export const CRM_BONUS_API_URL = \"https://typically-workable-perch.ngrok-free.app/api\";\r\nexport const CRM_BONUS_API_URL = \"https://wake.crmbonus.com/api\"; //\"http://localhost:4000/api\";// \"https://wake-middleware.crmbonus.com/api\"; //\"https://wake-middleware.crmbonus.com/api\";// \"https://crmbonus-wake-hub-staging-5daedbc4e22b.herokuapp.com/api\" //\"https://crmbonus-service-staging-d15ba5377115.herokuapp.com\"; //\"https://typically-workable-perch.ngrok-free.app\"; // \"http://localhost:3500\";\r\nexport const CHECKOUT_CART_WAKE = \"http://localhost:3001\""]}
@@ -14,6 +14,8 @@ function buildProductsByWake(productsWake = []) {
14
14
  var value = (pw.PrecoDe * pw.Quantidade);
15
15
  var originalValue = (pw.PrecoDe * pw.Quantidade);
16
16
  var discounts_value = (discounts * -1);
17
+ const existsPromotionProduct = pw.Ajustes.filter(adj => [AjustesTipoEnum.PP].includes(adj.Tipo));
18
+ const promotion_product = (existsPromotionProduct.length > 0);
17
19
  products.push({
18
20
  sku: pw.SKU,
19
21
  value: value,
@@ -21,6 +23,7 @@ function buildProductsByWake(productsWake = []) {
21
23
  productVariantId: pw.ProdutoVarianteId.toString(),
22
24
  quantity: pw.Quantidade,
23
25
  discount: value < discounts_value ? value : discounts_value,
26
+ promotion_product
24
27
  });
25
28
  }
26
29
  return products;
@@ -46,4 +49,4 @@ function getDiscount(ajustes = []) {
46
49
 
47
50
  export { buildProductsByWake as b };
48
51
 
49
- //# sourceMappingURL=build.payload.helper-caf0a82b.js.map
52
+ //# sourceMappingURL=build.payload.helper-699a48ca.js.map
@@ -0,0 +1 @@
1
+ {"file":"build.payload.helper-699a48ca.js","mappings":"AAUA,IAAY,eAKX;AALD,WAAY,eAAe;IACvB,iCAAc,CAAA;IACd,uCAAoB,CAAA;IACpB,yCAAsB,CAAA;IACtB,gCAAa,CAAA;AACjB,CAAC,EALW,eAAe,KAAf,eAAe;;SCRX,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;;QAGvC,IAAI,KAAK,IAAI,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;QACzC,IAAI,aAAa,IAAI,EAAE,CAAC,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;QAEjD,IAAI,eAAe,IAAI,SAAS,GAAG,CAAC,CAAC,CAAC,CAAA;QAEtC,MAAM,sBAAsB,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;QAEhG,MAAM,iBAAiB,IAAI,sBAAsB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAE7D,QAAQ,CAAC,IAAI,CACT;YACI,GAAG,EAAE,EAAE,CAAC,GAAG;YACX,KAAK,EAAE,KAAK;YACZ,aAAa,EAAE,aAAa;YAC5B,gBAAgB,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,EAAE;YACjD,QAAQ,EAAE,EAAE,CAAC,UAAU;YACvB,QAAQ,EAAE,KAAK,GAAG,eAAe,GAAG,KAAK,GAAG,eAAe;YAC3D,iBAAiB;SACpB,CACJ,CAAA;KACJ;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED,SAAS,WAAW,CAAC,UAAsB,EAAE;IAEzC,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,KAAI,MAAM,QAAQ,IAAI,OAAO,EAAE;QAC3B,IAAG,CAAC,eAAe,CAAC,CAAC,EAAE,eAAe,CAAC,EAAE,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YACpF,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC;SAC/B;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;;;;","names":[],"sources":["src/dto/validate.pin.bonus.ts","src/helpers/build.payload.helper.ts"],"sourcesContent":["export interface IProduct {\r\n productVariantId: string;\r\n sku: string;\r\n value: number;\r\n originalValue: number;\r\n quantity: number;\r\n discount: number;\r\n promotion_product: boolean;\r\n}\r\n\r\nexport enum AjustesTipoEnum {\r\n P = \"Promocao\",\r\n CC = \"ContaCorrente\",\r\n PP = \"PromocaoProduto\",\r\n F = \"Formula\"\r\n}\r\n\r\nexport interface IAjustes {\r\n Tipo: AjustesTipoEnum;\r\n Valor: number;\r\n}\r\n\r\nexport interface IUser {\r\n id: number;\r\n}\r\n\r\nexport interface IStore {\r\n name: string;\r\n}\r\n\r\nexport interface IProductWake {\r\n ProdutoVarianteId: number;\r\n SKU: string;\r\n PrecoPor: number;\r\n PrecoDe: number;\r\n Quantidade: number;\r\n Ajustes: IAjustes[];\r\n}\r\n\r\nexport interface ICustomer {\r\n birthDate: string;\r\n document: string;\r\n name: string;\r\n phone: string;\r\n}\r\n\r\nexport interface IProccesPinBonusDto {\r\n storeName: string;\r\n name: string;\r\n checkoutId: string;\r\n checkoutProducts: Array<IProduct>;\r\n storeId: string;\r\n userId: string;\r\n cellphone: number;\r\n pin: string;\r\n\r\n}\r\n\r\nexport interface IBonus {\r\n hasBonus: boolean;\r\n bonusBalance: number;\r\n totalBonus: number;\r\n minimumPurchase: number;\r\n bonusIds: string;\r\n firstValidityDate: string\r\n history: [\r\n {\r\n validityStart: string;\r\n validityEnd: string;\r\n value: number\r\n },\r\n {\r\n validityStart: string;\r\n validityEnd: string\r\n value: number\r\n }\r\n ]\r\n storeId: number;\r\n userId: number;\r\n cartId: string\r\n calculatedValue: number;\r\n totalValue: number\r\n}\r\n\r\n\r\nexport interface IReserveDTO {\r\n storeName: string;\r\n cartId: string;\r\n grossValue: number;\r\n redeemedBonus: number;\r\n ticket: string;\r\n storeId: string;\r\n userId: number;\r\n}","import { AjustesTipoEnum, IAjustes, IProduct, IProductWake } from \"../dto/validate.pin.bonus\";\r\n\r\nexport function buildProductsByWake(productsWake: Array<IProductWake> = []): Array<IProduct> {\r\n\r\n const products: Array<IProduct> = [];\r\n\r\n for ( const pw of productsWake ) {\r\n let discounts = getDiscount(pw.Ajustes)\r\n // let discounts_formula = getDiscountFormula(pw.Ajustes);\r\n\r\n var value = (pw.PrecoDe * pw.Quantidade);\r\n var originalValue = (pw.PrecoDe * pw.Quantidade);\r\n\r\n var discounts_value = (discounts * -1)\r\n\r\n const existsPromotionProduct = pw.Ajustes.filter(adj => [AjustesTipoEnum.PP].includes(adj.Tipo))\r\n\r\n const promotion_product = (existsPromotionProduct.length > 0)\r\n\r\n products.push(\r\n {\r\n sku: pw.SKU,\r\n value: value,\r\n originalValue: originalValue,\r\n productVariantId: pw.ProdutoVarianteId.toString(),\r\n quantity: pw.Quantidade,\r\n discount: value < discounts_value ? value : discounts_value,\r\n promotion_product\r\n }\r\n )\r\n }\r\n\r\n return products;\r\n}\r\n\r\nfunction getDiscount(ajustes: IAjustes[] = []) {\r\n \r\n let discounts = 0;\r\n \r\n for(const discount of ajustes) {\r\n if([AjustesTipoEnum.P, AjustesTipoEnum.CC, AjustesTipoEnum.PP].includes(discount.Tipo)) {\r\n discounts += discount.Valor;\r\n }\r\n }\r\n\r\n return discounts;\r\n}\r\n\r\n// function getDiscountFormula(ajustes: IAjustes[] = []) {\r\n \r\n// let discounts = 0;\r\n \r\n// for(const discount of ajustes) {\r\n// if([AjustesTipoEnum.F].includes(discount.Tipo)) {\r\n// discounts += (discount.Valor * -1);\r\n// }\r\n// }\r\n\r\n// return discounts;\r\n// }"],"version":3}
@@ -3750,7 +3750,9 @@ axios.default = axios;
3750
3750
  const axios$1 = axios;
3751
3751
 
3752
3752
  // export const CRM_BONUS_API_URL = "https://crmbonus-hub-staging-0ff7e3bf68ac.herokuapp.com/api" //"https://crmbonus-service-staging-d15ba5377115.herokuapp.com"; //"https://typically-workable-perch.ngrok-free.app"; // "http://localhost:3500";
3753
- const CRM_BONUS_API_URL = "https://typically-workable-perch.ngrok-free.app/api";
3753
+ // export const CRM_BONUS_API_URL = "https://typically-workable-perch.ngrok-free.app/api";
3754
+ // export const CRM_BONUS_API_URL = "https://typically-workable-perch.ngrok-free.app/api";
3755
+ const CRM_BONUS_API_URL = "https://wake.crmbonus.com/api"; //"http://localhost:4000/api";// "https://wake-middleware.crmbonus.com/api"; //"https://wake-middleware.crmbonus.com/api";// "https://crmbonus-wake-hub-staging-5daedbc4e22b.herokuapp.com/api" //"https://crmbonus-service-staging-d15ba5377115.herokuapp.com"; //"https://typically-workable-perch.ngrok-free.app"; // "http://localhost:3500";
3754
3756
  const CHECKOUT_CART_WAKE = "http://localhost:3001";
3755
3757
 
3756
3758
  const getKeyReserveByCartId = (cartId) => {
@@ -4017,4 +4019,4 @@ const buildUrlBase = () => {
4017
4019
 
4018
4020
  export { CartWake as C, USED_KEY as U, CrmBonusService as a, getInfoBonusByCartIdAndStoreName as b, getKeyReserveByCartId as c, getCart as g, persisteMetadata as p };
4019
4021
 
4020
- //# sourceMappingURL=cart.helper-7101c047.js.map
4022
+ //# sourceMappingURL=cart.helper-4f1913ce.js.map