File: /var/www/vhost/disk-apps/pwa.sports-crowd.com/www/6483.9e0591fd5e46a070.js
"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[6483],{76483:(I,L,c)=>{c.r(L),c.d(L,{ConfirmOrderPageModule:()=>Z});var C=c(56610),a=c(77897),_=c(37222),E=c(22882),R=c(36075),d=c(73308),S=c(59269),e=c(2978),p=c(57291),y=c(46868),f=c(29885),T=c(54171),O=c(99657),A=c(45588),b=c(23793);function D(o,u){if(1&o){const t=e.RV6();e.j41(0,"ion-item",20)(1,"ion-label"),e.EFF(2,"Recoger en tienda"),e.k0s(),e.j41(3,"ion-toggle",21),e.bIt("ngModelChange",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.pointSale=i)})("ionChange",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.pointSaleChange())}),e.k0s()()}if(2&o){const t=e.XpG();e.R7$(3),e.Y8G("ngModel",t.pointSale)}}function U(o,u){if(1&o&&(e.j41(0,"ion-label",3),e.EFF(1),e.k0s()),2&o){const t=e.XpG(2);e.R7$(1),e.JRh(t.addressUserLastUsed.direction)}}function N(o,u){if(1&o&&(e.j41(0,"ion-label",3),e.EFF(1),e.k0s()),2&o){const t=e.XpG(2);e.R7$(1),e.JRh(t.addressUserLastUsed.district)}}function x(o,u){if(1&o&&(e.j41(0,"div")(1,"ion-item",22)(2,"ion-label",23),e.EFF(3),e.nI1(4,"translate"),e.k0s()(),e.j41(5,"ion-item",22),e.DNE(6,U,2,1,"ion-label",24),e.k0s(),e.j41(7,"ion-item",22),e.DNE(8,N,2,1,"ion-label",24),e.k0s()()),2&o){const t=e.XpG();e.R7$(3),e.JRh(e.bMT(4,3,"LABEL_CONFIRM_ORDER")),e.R7$(3),e.Y8G("ngIf",t.addressUserLastUsed),e.R7$(2),e.Y8G("ngIf",t.addressUserLastUsed)}}function F(o,u){if(1&o&&(e.j41(0,"ion-select-option",29),e.EFF(1),e.k0s()),2&o){const t=u.$implicit;e.Y8G("value",t.id),e.R7$(1),e.SpI("",t.direction," ")}}function X(o,u){if(1&o){const t=e.RV6();e.j41(0,"ion-item",25)(1,"ion-label"),e.EFF(2),e.nI1(3,"translate"),e.k0s(),e.j41(4,"ion-select",26,27),e.bIt("ngModelChange",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.infoConfirmOrder.address=i)})("ngModelChange",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.changeAddress(i.infoConfirmOrder.address))}),e.nI1(6,"translate"),e.nI1(7,"translate"),e.DNE(8,F,2,2,"ion-select-option",28),e.k0s()()}if(2&o){const t=e.XpG();e.R7$(2),e.JRh(e.bMT(3,5,"LABEL_ADDRESS")),e.R7$(2),e.FS9("okText",e.bMT(6,7,"TEXT_OK_SELECT")),e.FS9("cancelText",e.bMT(7,9,"TEXT_CANCEL_SELECT")),e.Y8G("ngModel",t.infoConfirmOrder.address),e.R7$(4),e.Y8G("ngForOf",t.listAddressUser)}}function j(o,u){if(1&o&&(e.j41(0,"ion-select-option",29),e.EFF(1),e.k0s()),2&o){const t=u.$implicit;e.Y8G("value",t.id),e.R7$(1),e.JRh(t.name)}}function G(o,u){if(1&o){const t=e.RV6();e.j41(0,"ion-item",25)(1,"ion-label"),e.EFF(2),e.nI1(3,"translate"),e.k0s(),e.j41(4,"ion-select",30,31),e.bIt("ngModelChange",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.infoConfirmOrder.point_sale_id=i)}),e.nI1(6,"translate"),e.nI1(7,"translate"),e.DNE(8,j,2,2,"ion-select-option",28),e.k0s()()}if(2&o){const t=e.XpG();e.R7$(2),e.JRh(e.bMT(3,5,"LABEL_POINT")),e.R7$(2),e.FS9("okText",e.bMT(6,7,"TEXT_OK_SELECT")),e.FS9("cancelText",e.bMT(7,9,"TEXT_CANCEL_SELECT")),e.Y8G("ngModel",t.infoConfirmOrder.point_sale_id),e.R7$(4),e.Y8G("ngForOf",t.pointSalesList)}}function k(o,u){if(1&o&&(e.j41(0,"ion-select-option",29),e.EFF(1),e.k0s()),2&o){const t=u.$implicit;e.Y8G("value",t.id),e.R7$(1),e.SpI(" ",t.name,"")}}function $(o,u){if(1&o){const t=e.RV6();e.j41(0,"ion-item",25)(1,"ion-label"),e.EFF(2),e.nI1(3,"translate"),e.k0s(),e.j41(4,"ion-select",32,33),e.bIt("ngModelChange",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.infoConfirmOrder.wayPay=i)})("ngModelChange",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.changeTypePayment(i.infoConfirmOrder.wayPay))}),e.nI1(6,"translate"),e.nI1(7,"translate"),e.DNE(8,k,2,2,"ion-select-option",28),e.k0s()()}if(2&o){const t=e.XpG();e.R7$(2),e.JRh(e.bMT(3,5,"LABEL_WAY_TO_PAY")),e.R7$(2),e.FS9("okText",e.bMT(6,7,"TEXT_OK_SELECT")),e.FS9("cancelText",e.bMT(7,9,"TEXT_CANCEL_SELECT")),e.Y8G("ngModel",t.infoConfirmOrder.wayPay),e.R7$(4),e.Y8G("ngForOf",t.selectablePaymentTypes)}}function Y(o,u){if(1&o){const t=e.RV6();e.j41(0,"ion-item",12)(1,"ion-input",34,35),e.bIt("ngModelChange",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.effectivePaymentWayPay=i)})("keyup",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.onPriceUp(i.target.value))}),e.nI1(3,"translate"),e.k0s()()}if(2&o){const t=e.XpG();e.R7$(1),e.FS9("placeholder",e.bMT(3,2,"EFFECTIVE_PAYMENT")),e.Y8G("ngModel",t.effectivePaymentWayPay)}}function V(o,u){if(1&o&&(e.j41(0,"ion-select-option",29),e.EFF(1),e.k0s()),2&o){const t=u.$implicit;e.Y8G("value",t.id),e.R7$(1),e.SpI("",t.obfuscated_number," ")}}function w(o,u){if(1&o){const t=e.RV6();e.j41(0,"ion-item",25)(1,"ion-label"),e.EFF(2),e.nI1(3,"translate"),e.k0s(),e.j41(4,"ion-select",36,37),e.bIt("ngModelChange",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.paymentTdc=i)})("ngModelChange",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.changeDefaultCard(i.paymentTdc))}),e.nI1(6,"translate"),e.nI1(7,"translate"),e.DNE(8,V,2,2,"ion-select-option",28),e.k0s()()}if(2&o){const t=e.XpG();e.R7$(2),e.JRh(e.bMT(3,5,"LABEL_PAYMENT_ONLINE")),e.R7$(2),e.FS9("okText",e.bMT(6,7,"TEXT_OK_SELECT")),e.FS9("cancelText",e.bMT(7,9,"TEXT_CANCEL_SELECT")),e.Y8G("ngModel",t.paymentTdc),e.R7$(4),e.Y8G("ngForOf",t.listCard)}}function B(o,u){if(1&o){const t=e.RV6();e.j41(0,"div",38)(1,"ion-button",39),e.bIt("click",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.addNewCard())}),e.EFF(2,"Agregar Tarjeta"),e.k0s()()}}function H(o,u){if(1&o){const t=e.RV6();e.j41(0,"ion-item",12)(1,"ion-input",40,41),e.bIt("ngModelChange",function(i){e.eBV(t);const n=e.XpG();return e.Njj(n.infoConfirmOrder.cellphone=i)}),e.nI1(3,"translate"),e.k0s()()}if(2&o){const t=e.XpG();e.R7$(1),e.FS9("placeholder",e.bMT(3,2,"CELL_PHONE")),e.Y8G("ngModel",t.infoConfirmOrder.cellphone)}}function W(o,u){if(1&o){const t=e.RV6();e.j41(0,"ion-item",42),e.bIt("click",function(){e.eBV(t);const i=e.XpG();return e.Njj(i.validateCoupon())}),e.j41(1,"ion-label"),e.EFF(2),e.nI1(3,"translate"),e.k0s()()}2&o&&(e.R7$(2),e.SpI(" ",e.bMT(3,1,"BUTTON_INSERT_COUPON")," "))}function K(o,u){if(1&o&&(e.j41(0,"ion-item",22)(1,"ion-label",43),e.EFF(2),e.k0s()()),2&o){const t=e.XpG();e.R7$(2),e.JRh(t.params.automatic_bag_text)}}const J=[{path:"",component:(()=>{class o{constructor(t,r,i,n,s,l,m,v,M,g,P,q){this.storage=t,this.cartProvider=r,this.alertCtrl=i,this.translateService=n,this.currencyPipe=s,this.modalCtrl=l,this.userProvider=m,this.utilsService=v,this.router=M,this.routerOutlet=g,this.analyticsFacebookService=P,this.lealService=q,this.infoConfirmOrder={address:"",wayPay:"",cellphone:"",observations:"",point_sale_id:""},this.statusSendCreateOrder=!1,this.pointSale=!1,this.discountList=[],this.discountDelivery=[],this.couponList=[],this.campaignList=[],this.categoryList=[],this.percentageList=[],this.pointSalesList=[],this.old_price_domicile=0,this.pco_value=.15,this.pco_quantity=0,this.pco_quantity_max=1e3,this.sucursalSelected=null,this.selectablePaymentTypes=[],this.translateService.get(["TITLE_ALERT_CONFIRM_ORDER","TEXT_ALERT_CONFIRM_ORDER_ADDRESS","TEXT_ALERT_CONFIRM_ORDER_WAYPAY","TEXT_ALERT_CONFIRM_ORDER_CELLPHONE","TEXT_ALERT_CONFIRM_ORDER_EFFECTIVE_PAYMENT","TEXT_ALERT_CONFIRM_ORDER_PAYMENT_TDC","TEXT_ALERT_CONFIRM_ORDER_PAYMENT_TDC2","TEXT_TOAST_OUT_OF_TIME","TEXT1_ALERT_COUPON","TEXT2_ALERT_COUPON","TEXT3_ALERT_COUPON","TEXT4_ALERT_COUPON","TEXT5_ALERT_COUPON","TEXT6_ALERT_COUPON","TEXT7_ALERT_COUPON","OTP_ALERT_MESSAGE"]).subscribe(h=>{this.messageText={titleAlertConfirmOrder:h.TITLE_ALERT_CONFIRM_ORDER,textAlertConfirmOrderAddress:h.TEXT_ALERT_CONFIRM_ORDER_ADDRESS,textAlertConfirmOrderWayPay:h.TEXT_ALERT_CONFIRM_ORDER_WAYPAY,textAlertConfirmOrderCellPhone:h.TEXT_ALERT_CONFIRM_ORDER_CELLPHONE,textAlertConfirmOrderEffevtivePayment:h.TEXT_ALERT_CONFIRM_ORDER_EFFECTIVE_PAYMENT,textAlertConfirmOrderPaymentTdc:h.TEXT_ALERT_CONFIRM_ORDER_PAYMENT_TDC,textAlertConfirmOrderPaymentTdc2:h.TEXT_ALERT_CONFIRM_ORDER_PAYMENT_TDC2,textToastOutofTime:h.TEXT_TOAST_OUT_OF_TIME,text1AlertCoupon:h.TEXT1_ALERT_COUPON,text2AlertCoupon:h.TEXT2_ALERT_COUPON,text3AlertCoupon:h.TEXT3_ALERT_COUPON,text4AlertCoupon:h.TEXT4_ALERT_COUPON,text5AlertCoupon:h.TEXT5_ALERT_COUPON,text6AlertCoupon:h.TEXT6_ALERT_COUPON,text7AlertCoupon:h.TEXT7_ALERT_COUPON,OTP_ALERT_MESSAGE:h.OTP_ALERT_MESSAGE}}),M.events.subscribe(h=>{"popstate"===h.navigationTrigger&&h.url.includes("confirm-order")&&setTimeout(()=>{this.getInfoAddressLastUsed()},500)})}ngOnInit(){var t={};t.CONTENT=this.cartProvider.productsCart,t.NUM_ITEMS=this.cartProvider.productsCart.length,t.CURRENCY="COP",this.analyticsFacebookService.createLogEvent("EVENT_NAME_INITIATED_CHECKOUT",t,this.cartProvider._total),this.price_using_pco=this.cartProvider._subtotal,this.pco_quantity_max=this.price_using_pco*this.pco_value,this.selectablePaymentTypes=this.cartProvider._paymentTypes}ionViewDidLoad(){}ionViewWillEnter(){this.infoUser=this.userProvider._infoUser,this.infoConfirmOrder.cellphone=this.infoUser.phone,this.getInfoAddressLastUsed(),this.storage.get("parameters").then(t=>{t&&(this.params=t,this.validateServiceHour(t)&&this.utilsService.presentToast(4e3,"warning","top",this.messageText.textToastOutofTime+this.hourInitial+" y "+this.hourEnd))}),this.storage.get("sucursalSelected").then(t=>{t&&(this.sucursalSelected=t.id)}),(this.paymentTdc||4==this.infoConfirmOrder.wayPay)&&this.changeTypePayment(4),this.cartProvider.calculatePrice(),this.resetDiscount()}ionViewWillLeave(){this.pointSale?this.cartProvider.getPriceDomicile():this.cartProvider.calculatePrice()}resetDiscount(){this.cartProvider._activeDiscount=!1,this.cartProvider._discountDelivery=0,this.cartProvider._discount=0,this.cartProvider._discountsApplied=[],this.cartProvider._listShowToast=[],this.couponList=[],this.campaignList=[],this.discountDelivery=[],this.categoryList=[],this.getDiscounts()}rangeChange(t){this.pco_quantity=t.detail.value,this.price_using_pco=this.cartProvider._subtotal-this.cartProvider._subtotal*this.pco_quantity/this.pco_quantity_max}pointSaleChange(){this.pointSale?(this.cartProvider._priceDomicile=0,this.cartProvider.calculatePrice(),this.getPointsSale()):this.cartProvider.getPriceDomicile(),setTimeout(()=>{this.resetDiscount()},500)}getPointsSale(){var t=this;this.storage.get("token").then(function(){var r=(0,d.A)(function*(i){i&&(yield t.userProvider.getPointsSale(i.access_token)).subscribe(n=>{"success"==n.status&&(t.pointSalesList=n.d)},n=>{console.log("error getPointsSale: ",n)})});return function(i){return r.apply(this,arguments)}}())}addNewAddress(){this.router.navigate(["/address/confirmOrder/true"])}addNewCard(){this.router.navigate(["/app/tabs/settings/card-add"])}validateServiceHour(t){let r=!0,i=new Date,n=i.getDay();if(n>0){6==n?(this.hourInitial=this.formartHour(t.holiday_start_time),this.hourEnd=this.formartHour(t.holiday_final_time)):(this.hourInitial=this.formartHour(t.business_start_time),this.hourEnd=this.formartHour(t.business_final_time));let s=t.business_start_time.split(":")[0],l=t.business_start_time.split(":")[1],m=t.business_final_time.split(":")[0],v=t.business_final_time.split(":")[1];return i.getHours()>Number(s)&&i.getHours()<Number(m)&&(r=!1),i.getHours()==Number(s)&&i.getMinutes()>=Number(l)&&(r=!1),i.getHours()==Number(m)&&i.getMinutes()<=Number(v)&&(r=!1),r}{this.hourInitial=this.formartHour(t.business_start_time),this.hourEnd=this.formartHour(t.business_final_time);let s=t.holiday_start_time.split(":")[0],l=t.holiday_start_time.split(":")[1],m=t.holiday_final_time.split(":")[0],v=t.holiday_final_time.split(":")[1];return i.getHours()>Number(s)&&i.getHours()<Number(m)&&(r=!1),i.getHours()==Number(s)&&i.getMinutes()>=Number(l)&&(r=!1),i.getHours()==Number(m)&&i.getMinutes()<=Number(v)&&(r=!1),r}}formartHour(t){var r=t.split(":");r[0]=Number(r[0]),r[0]>12&&(r[0]-=12);var i="AM";return t.split(":")[0]>11&&(i="PM"),r[0]+":"+r[1]+" "+i}getCurrency(t){return this.currencyPipe.transform(t,"USD","symbol","1.0-0")}onPriceUp(t){this.effectivePayment=t.replace(/[^0-9.]/g,""),this.effectivePaymentWayPay=this.getCurrency(this.effectivePayment)}changeAddress(t){for(let r=0;r<this.listAddressUser.length;r++)this.listAddressUser[r].id===t&&(this.addressUserLastUsed=this.listAddressUser[r],this.cartProvider.updateAddressPrice(this.addressUserLastUsed))}changeTypePayment(t){var r=this;4==t&&(this.listCard=[],this.storage.get("token").then(i=>{i&&this.utilsService.presentLoading(this.translateService.instant("all.loading")).then((0,d.A)(function*(){(yield r.userProvider.listCreditCard(i.access_token)).subscribe(n=>{r.utilsService.dismissLoading();for(let s=0;s<n.length;s++)n[s].verified&&(n[s].obfuscated_number=n[s].obfuscated_number.substring(10,19),r.listCard.push(n[s]),n[s].current&&(r.paymentTdc=n[s].id))},n=>{r.utilsService.dismissLoading()})}))})),6!=t&&(this.price_using_pco=this.cartProvider._subtotal,this.pco_quantity=0)}changeDefaultCard(t){t&&0!=t&&this.listCard.length>1&&this.storage.get("token").then(r=>{r&&(this.utilsService.presentLoading(this.translateService.instant("all.loading")),this.userProvider.selectDefaultCard(t,r.access_token).subscribe(i=>{this.utilsService.dismissLoading(),this.changeTypePayment(4)},i=>{this.utilsService.dismissLoading()}))})}alertsValidations(t,r){var i=this;return(0,d.A)(function*(){yield(yield i.alertCtrl.create({header:t,message:r,buttons:["OK"]})).present()})()}presentModalUpdateProfile(){var t=this;return(0,d.A)(function*(){const r=yield t.modalCtrl.create({component:S.Z,swipeToClose:!0,presentingElement:t.routerOutlet.nativeEl,componentProps:{accountUser:t.userProvider._infoUser}});yield r.present(),yield r.onWillDismiss().then(i=>{t.infoUser=t.userProvider._infoUser,t.infoConfirmOrder.cellphone=t.infoUser.phone})})()}validatedConfirmOrder(t){var r=this;if(this.pointSale||t.controls.address.valid)if(!this.pointSale||t.controls.point_sale_id.valid)if(t.controls.wayPay.valid)if(this.userProvider._infoUser.document&&""!=this.userProvider._infoUser.document&&" "!=this.userProvider._infoUser.document)if(this.userProvider._infoUser.user_info.dob&&""!=this.userProvider._infoUser.user_info.dob&&" "!=this.userProvider._infoUser.user_info.dob)if(t.controls.cellphone.valid)if(!t.controls.effectivePayment||t.controls.effectivePayment.valid){if(t.value.effectivePayment&&!Number.isInteger(t.value.effectivePayment)){let i=t.value.effectivePayment.replace(/,/g,""),n=parseInt(i.replace("$",""));t.value.effectivePayment=n}4!==t.value.wayPay||this.paymentTdc?this.storage.get("infoEndVersion").then(i=>{i&&i.end_version_home&&null!=i.end_version_home?this.modalEndVersion(i):this.storage.get("token").then(function(){var n=(0,d.A)(function*(s){s&&(r.statusSendCreateOrder=!0,r.utilsService.presentLoading(r.translateService.instant("all.loading")),4===t.value.wayPay&&r.paymentTdc?(yield r.userProvider.generateOrderPaymentTDC(r.cartProvider._total,s.access_token)).subscribe(l=>{l.r&&r.generateOrder(t,s,l.d)},l=>{r.statusSendCreateOrder=!1,r.utilsService.dismissLoading(),r.utilsService.presentToast(3e3,"danger","top",r.messageText.textAlertConfirmOrderPaymentTdc2)}):6===t.value.wayPay?r.generateOrderPaymentCoins(t,s):r.generateOrder(t,s))});return function(s){return n.apply(this,arguments)}}())}):this.alertsValidations(this.messageText.titleAlertConfirmOrder,this.messageText.textAlertConfirmOrderPaymentTdc)}else this.alertsValidations(this.messageText.titleAlertConfirmOrder,this.messageText.textAlertConfirmOrderEffevtivePayment);else this.alertsValidations(this.messageText.titleAlertConfirmOrder,this.messageText.textAlertConfirmOrderCellPhone);else this.presentModalUpdateProfile();else this.presentModalUpdateProfile();else this.alertsValidations(this.messageText.titleAlertConfirmOrder,this.messageText.textAlertConfirmOrderWayPay);else this.alertsValidations(this.messageText.titleAlertConfirmOrder,this.translateService.instant("TEXT_ALERT_CONFIRM_ORDER_POINT"));else this.alertsValidations(this.messageText.titleAlertConfirmOrder,this.messageText.textAlertConfirmOrderAddress)}modalEndVersion(t){var r=this;return(0,d.A)(function*(){let i={image_end_version:t.image_end_version,text_end_version:t.text_end_version,link_end_version:t.link_end_version};yield(yield r.modalCtrl.create({component:"EndVersionPage",swipeToClose:!0,presentingElement:r.routerOutlet.nativeEl,componentProps:i})).present()})()}generateOrder(t,r,i){var n=this,s=t.value.wayPay;this.storage.get("productsNotFound").then(function(){var l=(0,d.A)(function*(m){let v=null;v=m||null,n.orderInfo={products:n.cartProvider.productsCart,confirmOrder:t.value,subtotal:n.cartProvider._subtotal,serviceCharge:n.cartProvider._serviceCharge,priceDomicile:n.cartProvider._priceDomicile,total:n.cartProvider._total,discount:n.cartProvider._discount,discountDelivery:n.cartProvider._discountDelivery,productsNotFound:v,order_type_id:5,activeDiscount:n.cartProvider._activeDiscount,discountsApplied:n.cartProvider._discountsApplied,paymentHistory_id:i,sucursal:n.sucursalSelected,storeType:n.cartProvider.storeType,currentAcademyUserId:n.cartProvider.currentAcademyUserId};let M={data:n.orderInfo};(yield n.cartProvider.generateOrder(M,r.access_token)).subscribe(g=>{if(n.statusSendCreateOrder=!1,n.utilsService.dismissLoading(),"success"==g.status){var P={};P.CONTENT=n.cartProvider.productsCart,P.NUM_ITEMS=n.cartProvider.productsCart.length,P.CURRENCY="COP",n.analyticsFacebookService.createLogEvent("EVENT_NAME_PURCHASED",P,n.cartProvider._total),n.storage.remove("productsNotFound"),n.router.navigate("main"!=n.cartProvider.storeType?["/shop/"+n.cartProvider.storeType]:["/shop"]),setTimeout(()=>{n.cartProvider.deleteAllProductsCart(),5==s?(n.utilsService.presentToast(6e3,"success","top",n.translateService.instant("order.msg_order_confirm",{code:g.order.code}),!0),n.router.navigate(["/payment-gateway-selection"],{state:{orderId:g.order_id}})):n.router.navigate(["/app/tabs/settings/order/"+g.order_id+"/confirmOrder"])},500)}else n.utilsService.presentToast(5e3,"danger","top",g.m)},g=>{n.utilsService.presentToast(2e3,"danger","top","Hubo un error, intenta mas tarde."),console.log("error generateOrder",g),n.utilsService.dismissLoading(),n.statusSendCreateOrder=!1})});return function(m){return l.apply(this,arguments)}}())}generateOrderPaymentCoins(t,r,i){var n=this;this.storage.get("productsNotFound").then(s=>{let l=null;l=s||null,this.orderInfo={products:this.cartProvider.productsCart,confirmOrder:t.value,subtotal:this.cartProvider._subtotal,priceDomicile:this.cartProvider._priceDomicile,total:this.cartProvider._total,discount:this.cartProvider._discount,discountDelivery:this.cartProvider._discountDelivery,productsNotFound:l,order_type_id:6,activeDiscount:this.cartProvider._activeDiscount,discountsApplied:this.cartProvider._discountsApplied,paymentHistory_id:i,sucursal:this.sucursalSelected,storeType:this.cartProvider.storeType},this.storage.get("infoUser").then(function(){var m=(0,d.A)(function*(v){if(v){let M={userInfo:n.infoUser,order:{data:n.orderInfo}};(yield n.lealService.generateOrderPaymentCoins(r.access_token,M)).subscribe(g=>{if(n.statusSendCreateOrder=!1,n.utilsService.dismissLoading(),"success"==g.status){var P={};P.CONTENT=n.cartProvider.productsCart,P.NUM_ITEMS=n.cartProvider.productsCart.length,P.CURRENCY="COP",n.analyticsFacebookService.createLogEvent("EVENT_NAME_PURCHASED",P,n.cartProvider._total),n.storage.remove("productsNotFound"),n.router.navigate(["/app/tabs/shop"]),setTimeout(()=>{n.cartProvider.deleteAllProductsCart(),n.router.navigate(["/app/tabs/settings/order/"+g.order_id+"/confirmOrder"])},500)}else n.utilsService.presentToast(5e3,"danger","top",null!=g.m?g.m:g.message)},g=>{n.utilsService.presentToast(2e3,"danger","top","Hubo un error, intenta mas tarde."),console.log("error generateOrder",g),n.utilsService.dismissLoading(),n.statusSendCreateOrder=!1})}});return function(v){return m.apply(this,arguments)}}())})}getDiscounts(){var t=this;this.utilsService.presentLoading(this.translateService.instant("all.loading")),this.storage.get("token").then(function(){var r=(0,d.A)(function*(i){i&&(yield t.cartProvider.getDiscounts(i.access_token)).subscribe(n=>{if(t.utilsService.dismissLoading(),"success"==n.status){t.discountList=n.discountList;for(let s=0;s<t.discountList.length;s++)4==t.discountList[s].discount_type_id?t.couponList.push(t.discountList[s]):3==t.discountList[s].discount_type_id?t.campaignList.push(t.discountList[s]):1==t.discountList[s].discount_type_id?t.discountDelivery.push(t.discountList[s]):10==t.discountList[s].discount_type_id?t.categoryList.push(t.discountList[s]):7==t.discountList[s].discount_type_id&&t.percentageList.push(t.discountList[s]);t.validateDiscount()}},n=>{console.log("error generateOrder",n),t.utilsService.dismissLoading(),t.discountList=[]})});return function(i){return r.apply(this,arguments)}}())}validateCoupon(){var t=this;return(0,d.A)(function*(){yield(yield t.alertCtrl.create({header:t.messageText.text1AlertCoupon,inputs:[{name:"couponUser",placeholder:t.messageText.text2AlertCoupon}],buttons:[{text:"Cancelar",handler:i=>{}},{text:t.messageText.text3AlertCoupon,handler:i=>{if(""!=i.couponUser.trim()){let n=!1;for(let s=0;s<t.couponList.length;s++)if(t.couponList[s].code_coupon===i.couponUser.trim()){n=!0,t.couponList[s].discountOrderUsers&&!t.couponList[s].is_multiple_redeem?t.utilsService.presentToast(4e3,"warning","top",t.messageText.text4AlertCoupon):t.cartProvider._subtotal>=t.couponList[s].value_for_win?t.cartProvider.applyDiscount(t.couponList[s]):t.utilsService.presentToast(4e3,"warning","top",t.messageText.text6AlertCoupon+t.couponList[s].name+t.messageText.text6AlertCoupon+t.couponList[s].value_for_win);break}n||t.utilsService.presentToast(4e3,"warning","top",t.messageText.text5AlertCoupon)}}}]})).present()})()}showOTPCodeAlert(){var t=this;return(0,d.A)(function*(){yield(yield t.alertCtrl.create({message:t.messageText.OTP_ALERT_MESSAGE,inputs:[{name:"couponUser",placeholder:t.messageText.text2AlertCoupon}],buttons:[{text:"Cancelar",handler:i=>{}},{text:"Reenviar",handler:i=>{}},{text:t.messageText.text3AlertCoupon,handler:i=>{if(""!=i.couponUser.trim()){let n=!1;for(let s=0;s<t.couponList.length;s++)if(t.couponList[s].code_coupon===i.couponUser.trim()){n=!0,t.couponList[s].discountOrderUsers&&!t.couponList[s].is_multiple_redeem?t.utilsService.presentToast(4e3,"warning","top",t.messageText.text4AlertCoupon):t.cartProvider._subtotal>=t.couponList[s].value_for_win?t.cartProvider.applyDiscount(t.couponList[s]):t.utilsService.presentToast(4e3,"warning","top",t.messageText.text6AlertCoupon+t.couponList[s].name+t.messageText.text6AlertCoupon+t.couponList[s].value_for_win);break}n||t.utilsService.presentToast(4e3,"warning","top",t.messageText.text5AlertCoupon)}}}]})).present()})()}validateOTPCode(){var t=this;return(0,d.A)(function*(){t.storage.get("infoUser").then(r=>{r&&t.storage.get("token").then(function(){var i=(0,d.A)(function*(n){if(n){t.utilsService.presentLoading(t.translateService.instant("all.loading"));let s={uid:t.infoUser.coin_uid,valor:t.cartProvider._subtotal};(yield t.lealService.generateOTP(n.access_token,s)).subscribe(l=>{console.log(l)},l=>{console.log("Error coins",l),t.utilsService.dismissLoading()})}});return function(n){return i.apply(this,arguments)}}())})})()}validateDiscount(){if(this.discountDelivery.length)for(let t=0;t<this.discountDelivery.length;t++)if(this.discountDelivery[t].discount_global_shipping){let r=this.cartProvider._priceDomicile*this.discountDelivery[t].discount_global_shipping/100;this.cartProvider._discountDelivery=r,this.cartProvider._priceDomicile-=r,this.cartProvider._total-=r,this.cartProvider._discountsApplied.push({discount_id:this.discountDelivery[t].id,discount_type_id:this.discountDelivery[t].discount_type_id}),this.cartProvider._activeDiscount=!0}else if(this.discountDelivery[t].discountOrderUsers&&this.discountDelivery[t].discountOrderUsers.limit_discount){if(this.discountDelivery[t].price_discount)this.cartProvider._discountDelivery=this.discountDelivery[t].price_discount,this.cartProvider._priceDomicile-=this.discountDelivery[t].price_discount,this.cartProvider._total-=this.discountDelivery[t].price_discount;else{let i=this.cartProvider._priceDomicile*this.discountDelivery[t].percentage_discount/100;this.cartProvider._discountDelivery=i,this.cartProvider._priceDomicile-=i,this.cartProvider._total-=i}this.cartProvider._discountsApplied.push({discount_id:this.discountDelivery[t].id,discount_type_id:this.discountDelivery[t].discount_type_id}),this.cartProvider._activeDiscount=!0}if(this.campaignList.length)for(let t=0;t<this.campaignList.length;t++)this.cartProvider._subtotal>=this.campaignList[t].value_for_win?this.cartProvider.applyDiscount(this.campaignList[t]):this.cartProvider.validateDateDiscount(this.campaignList[t])&&this.cartProvider.toatDiscountApply(this.messageText.text6AlertCoupon+this.campaignList[t].name+this.messageText.text7AlertCoupon+this.campaignList[t].value_for_win);this.categoryList.length&&this.storage.get("productsCart").then(t=>{if(t)for(let r=0;r<this.categoryList.length;r++){let i=0,n=0,s=0;for(let l=0;l<t.length;l++)this.categoryList[r].category_id===t[l].category.id&&(i+=t[l].price*t[l].quantity,this.categoryList[r].apply_value?n+=this.categoryList[r].percentage_discount?t[l].price*t[l].quantity*this.categoryList[r].percentage_discount/100:this.categoryList[r].price_discount*t[l].quantity:!this.categoryList[r].apply_value&&0===s&&(s+=this.categoryList[r].percentage_discount?this.cartProvider._priceDomicile*this.categoryList[r].percentage_discount/100:this.categoryList[r].price_discount));if(i>=this.categoryList[r].value_for_win)if(n){this.cartProvider._discount+=n,this.cartProvider._total-=n;let l={discount_id:this.categoryList[r].id,discount_type_id:this.categoryList[r].discount_type_id};this.cartProvider._activeDiscount=!0,this.cartProvider._discountsApplied.push(l),this.cartProvider.toatDiscountApply(this.categoryList[r].message_to_user)}else if(s){this.cartProvider._discountDelivery=s,this.cartProvider._priceDomicile-=s,this.cartProvider._total-=s;let l={discount_id:this.categoryList[r].id,discount_type_id:this.categoryList[r].discount_type_id};this.cartProvider._activeDiscount=!0,this.cartProvider._discountsApplied.push(l),this.cartProvider.toatDiscountApply(this.categoryList[r].message_to_user)}}}),setTimeout(()=>{this.cartProvider.showListToast()},1e3)}getInfoAddressLastUsed(){this.userProvider.getInfoUser().then(t=>{this.listAddressUser=t.addresses,this.addressUserLastUsed=this.listAddressUser.find(r=>1===r.last_used),this.infoConfirmOrder.address=this.addressUserLastUsed.id})}static#e=this.\u0275fac=function(r){return new(r||o)(e.rXU(p.n),e.rXU(y.m),e.rXU(a.hG),e.rXU(E.c$),e.rXU(C.oe),e.rXU(a.W3),e.rXU(f.D),e.rXU(T.T),e.rXU(R.Ix),e.rXU(a.Rg),e.rXU(O.I),e.rXU(A.k))};static#t=this.\u0275cmp=e.VBU({type:o,selectors:[["page-confirm-order"]],decls:37,vars:37,consts:[[1,"ion-no-border"],["slot","start"],["defaultHref","/app/tabs/cart"],[1,"ion-text-center"],[1,"ion-padding"],["expand","block","color","secondary",3,"click"],["class","ion-margin-vertical",4,"ngIf"],[4,"ngIf"],["formConfirmOrder","ngForm"],["class","selectBorderRadius",4,"ngIf"],["class","inputBorderRadius ion-margin-top","lines","none",4,"ngIf"],["class","ion-text-center","padding-horizontal","","margin-horizontal","",4,"ngIf"],["lines","none",1,"inputBorderRadius","ion-margin-top"],["type","text","ngControl","observations","name","observations",1,"ion-text-center",3,"ngModel","placeholder","ngModelChange"],["observations","ngModel"],["button","","detail","","class","ion-margin-top",3,"click",4,"ngIf"],["lines","none",4,"ngIf"],[3,"title","pco_option","pco_price","subtotal","priceDomicile","discount","discountDelivery","total","serviceChargeEnabled","serviceCharge"],["size","12",1,"ion-no-padding","ion-no-margin"],["expand","block","fill","solid","shape","round",3,"disabled","click"],[1,"ion-margin-vertical"],[3,"ngModel","ngModelChange","ionChange"],["lines","none"],[1,"ion-text-center","textTittleConfirmOrder"],["class","ion-text-center",4,"ngIf"],[1,"selectBorderRadius"],["interface","popover","ngControl","address","name","address","required","",3,"ngModel","okText","cancelText","ngModelChange"],["address","ngModel"],[3,"value",4,"ngFor","ngForOf"],[3,"value"],["interface","popover","ngControl","point_sale_id","name","point_sale_id","required","",3,"ngModel","okText","cancelText","ngModelChange"],["point_sale_id","ngModel"],["interface","popover","ngControl","wayPay","name","wayPay","required","",3,"ngModel","okText","cancelText","ngModelChange"],["wayPay","ngModel"],["type","text","ngControl","effectivePayment","name","effectivePayment","required","",1,"ion-text-center",3,"ngModel","placeholder","ngModelChange","keyup"],["effectivePayment","ngModel"],["interface","popover","ngControl","tdc","name","tdc","required","",3,"ngModel","okText","cancelText","ngModelChange"],["tdc","ngModel"],["padding-horizontal","","margin-horizontal","",1,"ion-text-center"],["expand","block","fill","clear","color","secondary",3,"click"],["type","tel","ngControl","cellphone","name","cellphone","maxlength","191","required","",1,"ion-text-center",3,"ngModel","placeholder","ngModelChange"],["cellphone","ngModel"],["button","","detail","",1,"ion-margin-top",3,"click"],["color","medium",1,"ion-text-center","ion-text-wrap"]],template:function(r,i){if(1&r){const n=e.RV6();e.j41(0,"ion-header",0)(1,"ion-toolbar")(2,"ion-buttons",1),e.nrm(3,"ion-back-button",2),e.k0s(),e.j41(4,"ion-title",3),e.EFF(5),e.nI1(6,"translate"),e.k0s()()(),e.j41(7,"ion-content",4)(8,"ion-button",5),e.bIt("click",function(){return i.addNewAddress()}),e.EFF(9),e.nI1(10,"translate"),e.k0s(),e.DNE(11,D,4,1,"ion-item",6),e.DNE(12,x,9,5,"div",7),e.j41(13,"form",null,8),e.DNE(15,X,9,11,"ion-item",9),e.DNE(16,G,9,11,"ion-item",9),e.DNE(17,$,9,11,"ion-item",9),e.DNE(18,Y,4,4,"ion-item",10),e.DNE(19,w,9,11,"ion-item",9),e.DNE(20,B,3,0,"div",11),e.DNE(21,H,4,4,"ion-item",10),e.j41(22,"ion-item",12)(23,"ion-input",13,14),e.bIt("ngModelChange",function(l){return i.infoConfirmOrder.observations=l}),e.nI1(25,"translate"),e.k0s()()()(),e.j41(26,"ion-footer"),e.DNE(27,W,4,3,"ion-item",15),e.DNE(28,K,3,1,"ion-item",16),e.j41(29,"ion-grid"),e.nrm(30,"app-total-summary",17),e.nI1(31,"translate"),e.j41(32,"ion-row")(33,"ion-col",18)(34,"ion-button",19),e.bIt("click",function(){e.eBV(n);const l=e.sdS(14);return e.Njj(i.validatedConfirmOrder(l))}),e.EFF(35),e.nI1(36,"translate"),e.k0s()()()()()}2&r&&(e.R7$(5),e.JRh(e.bMT(6,27,"CONFIRM_ORDER_TITLE")),e.R7$(4),e.JRh(e.bMT(10,29,"ADD_ADDRESS")),e.R7$(2),e.Y8G("ngIf",i.params&&i.params.is_point_sale),e.R7$(1),e.Y8G("ngIf",!i.pointSale),e.R7$(3),e.Y8G("ngIf",!i.pointSale),e.R7$(1),e.Y8G("ngIf",i.pointSale),e.R7$(1),e.Y8G("ngIf",i.selectablePaymentTypes),e.R7$(1),e.Y8G("ngIf",1==i.infoConfirmOrder.wayPay),e.R7$(1),e.Y8G("ngIf",4==i.infoConfirmOrder.wayPay),e.R7$(1),e.Y8G("ngIf",4==i.infoConfirmOrder.wayPay),e.R7$(1),e.Y8G("ngIf",i.infoUser),e.R7$(2),e.FS9("placeholder",e.bMT(25,31,"OBSERVATIONS_CONFIRM_ORDERS")),e.Y8G("ngModel",i.infoConfirmOrder.observations),e.R7$(4),e.Y8G("ngIf",i.couponList.length),e.R7$(1),e.Y8G("ngIf",i.params&&i.params.is_automatic_bag),e.R7$(2),e.Y8G("title",e.bMT(31,33,"TEXT_SUMMARY_CONFIRM_ORDER"))("pco_option",i.infoConfirmOrder.wayPay)("pco_price",i.price_using_pco)("subtotal",i.cartProvider._subtotal)("priceDomicile",i.cartProvider._priceDomicile)("discount",i.cartProvider._discount)("discountDelivery",i.cartProvider._discountDelivery)("total",i.cartProvider._total)("serviceChargeEnabled",i.cartProvider._serviceChargeEnabled)("serviceCharge",i.cartProvider._serviceCharge),e.R7$(4),e.Y8G("disabled",i.statusSendCreateOrder),e.R7$(1),e.JRh(e.bMT(36,35,"BUTTON_CONFIRM_ORDER")))},dependencies:[C.Sq,C.bT,a.el,a.Jm,a.QW,a.hU,a.W9,a.M0,a.lO,a.eU,a.$w,a.uz,a.he,a.ln,a.Nm,a.Ip,a.BC,a.BY,a.ai,a.hB,a.Je,a.Gw,a.tY,_.qT,_.BC,_.cb,_.YS,_.tU,_.vS,_.cV,b.M,E.D9],styles:[".textTittleConfirmOrder[_ngcontent-%COMP%]{font-size:18px;color:var(--color-title)}.totalCart[_ngcontent-%COMP%]{font-weight:700}.priceDecorationThrough[_ngcontent-%COMP%]{text-decoration:line-through!important}.backgroundWhite[_ngcontent-%COMP%]{background-color:#fff}.summaryConfirm[_ngcontent-%COMP%]{font-weight:600}"]})}return o})()}];let z=(()=>{class o{static#e=this.\u0275fac=function(r){return new(r||o)};static#t=this.\u0275mod=e.$C({type:o});static#i=this.\u0275inj=e.G2t({imports:[R.iI.forChild(J),R.iI]})}return o})();var Q=c(55553);let Z=(()=>{class o{static#e=this.\u0275fac=function(r){return new(r||o)};static#t=this.\u0275mod=e.$C({type:o});static#i=this.\u0275inj=e.G2t({imports:[C.MD,a.bv,_.YN,E.h.forChild(),z,Q.h]})}return o})()},59269:(I,L,c)=>{c.d(L,{Z:()=>S});var C=c(73308),a=c(2978),_=c(77897),E=c(22882),R=c(29885),d=c(47855);let S=(()=>{class e{constructor(y,f,T,O,A){this.navParams=y,this.modalCtrl=f,this.alertController=T,this.translateService=O,this.userProvider=A}ionViewWillLeave(){this.userProvider.getInfoUser()}ngOnInit(){this.presentAlert(),this.accountUser=this.navParams.get("accountUser")}cancel(){this.modalCtrl.dismiss()}presentAlert(){var y=this;return(0,C.A)(function*(){yield(yield y.alertController.create({cssClass:"my-custom-class",message:y.translateService.instant("ALERT_UPDATE_PROFILE"),buttons:["OK"]})).present()})()}static#e=this.\u0275fac=function(f){return new(f||e)(a.rXU(_.y8),a.rXU(_.W3),a.rXU(_.hG),a.rXU(E.c$),a.rXU(R.D))};static#t=this.\u0275cmp=a.VBU({type:e,selectors:[["app-modal-update-profile"]],decls:11,vars:7,consts:[[1,"ion-no-border"],["slot","end"],["strong","","color","light",3,"click"],[3,"accountUser","closeModal"]],template:function(f,T){1&f&&(a.j41(0,"ion-header",0)(1,"ion-toolbar")(2,"ion-title"),a.EFF(3),a.nI1(4,"translate"),a.k0s(),a.j41(5,"ion-buttons",1)(6,"ion-button",2),a.bIt("click",function(){return T.cancel()}),a.EFF(7),a.nI1(8,"translate"),a.k0s()()()(),a.j41(9,"ion-content")(10,"app-edit-profile",3),a.bIt("closeModal",function(){return T.cancel()}),a.k0s()()),2&f&&(a.R7$(3),a.JRh(a.bMT(4,3,"MODAL_UPDATE_PROFILE")),a.R7$(4),a.JRh(a.bMT(8,5,"all.close")),a.R7$(3),a.Y8G("accountUser",T.accountUser))},dependencies:[_.Jm,_.QW,_.W9,_.eU,_.BC,_.ai,d.r,E.D9]})}return e})()},45588:(I,L,c)=>{c.d(L,{k:()=>R});var C=c(73308),a=c(2978),_=c(3366),E=c(57291);let R=(()=>{class d{constructor(e,p){this.api=e,this.storage=p}userValidation(e){var p=this;this.storage.get("token").then(function(){var y=(0,C.A)(function*(f){f&&(yield p.login(f.access_token)).subscribe(function(){var T=(0,C.A)(function*(O){O.r&&!e.coin_uid&&e.document&&(yield p.register(f.access_token,{})).subscribe(function(){var A=(0,C.A)(function*(b){b.uid?(e.coin_uid=b.uid,p.storage.set("infoUser",e)):(yield p.update(f.access_token)).subscribe(D=>{D.uid&&(e.coin_uid=D.uid,p.storage.set("infoUser",e))},D=>{console.log("Error update leal",D)})});return function(b){return A.apply(this,arguments)}}(),A=>{console.log("Error register leal",A)})});return function(O){return T.apply(this,arguments)}}(),T=>{console.log("Error login leal",T)})});return function(f){return y.apply(this,arguments)}}())}login(e){return this.api.post("leal/login",{},e)}coins(e,p){return this.api.get(`leal/coins/${p}`,e)}register(e,p){return this.api.post("leal/user/register",p,e)}update(e){return this.api.get("leal/user/update",e)}generateOTP(e,p){return this.api.post("leal/payment/generateOTP",p,e)}generateOrderPaymentCoins(e,p){return this.api.post("leal/payment/generateOrderPaymentCoins",p,e)}static#e=this.\u0275fac=function(p){return new(p||d)(a.KVO(_.G),a.KVO(E.n))};static#t=this.\u0275prov=a.jDH({token:d,factory:d.\u0275fac,providedIn:"root"})}return d})()}}]);