@ikas/storefront 6.1.0-beta.221 → 6.1.0-beta.223

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.
@@ -39,4 +39,7 @@ export declare class Analytics {
39
39
  static viewSearchResults(searchKeyword: string, productDetails: IkasProduct[]): void;
40
40
  static viewListing(productDetails: IkasProduct[]): void;
41
41
  static contactForm(form: IkasContactForm): void;
42
+ static addCouponCode(cart: IkasCart): void;
43
+ static removeCouponCode(cart: IkasCart): void;
44
+ static removeLoyaltyPoints(cart: IkasCart): void;
42
45
  }
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as r}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"../models/data/blog/index.js";import{IkasBrand as s}from"../models/data/brand/index.js";import"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import{IkasCart as i}from"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as a}from"../models/data/category/index.js";import{IkasCheckout as n}from"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as c}from"../models/data/product/index.js";import"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import{IkasStorefrontPopup as d}from"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import{FacebookPixel as m}from"./facebookPixel.js";import{GoogleTagManager as u}from"./googleTagManager.js";import{IkasEventType as l}from"./events.js";import p from"lodash/cloneDeep";import{tryForEach as b}from"../utils/helper.js";import f from"./ikasV3.js";import{GoogleAnalytics as g}from"./googleAnalytics.js";import{TiktokPixel as h}from"./tiktokPixel.js";import{IkasBaseStore as j}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";var v=function(){function v(){o(this)}return v.getCustomerInfo=function(){return t(this,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,(t=j.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),(o=t.customerStore.customer)?[2,r(r({},o.basicInfo),{consentGranted:t.customerStore.customerConsentGranted})]:[2,null]}}))}))},v.pageView=function(r){return t(this,void 0,void 0,(function(){var t,o,s,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),[4,f.checkJourneyId()];case 1:return e.sent(),t=window.location.href,[4,v.getCustomerInfo()];case 2:return o=e.sent(),s=Date.now().toString(),u.pageView(t),m.pageView(t,s),[4,f.pageView(r,s)];case 3:return e.sent(),h.pageView(t),b(v.subscribers,(function(e){e.callback({type:l.PAGE_VIEW,data:{url:t,pageType:r,customer:o}})})),[3,5];case 4:return i=e.sent(),console.error(i),[3,5];case 5:return[2]}}))}))},v.productView=function(r){return t(this,void 0,void 0,(function(){var t,o,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=Date.now().toString(),m.productView(r,t),u.productView(r),[4,f.productView(r,t)];case 1:return e.sent(),g.productView(r),h.productView(r),v.subscribers.length&&(o=new c(p(r)),b(v.subscribers,(function(t){t.callback({type:l.PRODUCT_VIEW,data:{productDetail:o}})}))),[3,3];case 2:return s=e.sent(),console.error(s),[3,3];case 3:return[2]}}))}))},v.addToCart=function(t,e,r,o,s){try{if(m.addToCart(t,e,r),u.addToCart(t,e,s),f.addToCart(t,e,o,r),g.addToCart(t,e),h.addToCart(t,e),v.subscribers.length){var a=p(t),n=new i(p(o));b(v.subscribers,(function(t){t.callback({type:l.ADD_TO_CART,data:{item:a,quantity:e,cart:n}})}))}}catch(t){console.error(t)}},v.removeFromCart=function(t,e,r){try{if(u.removeFromCart(t,e),g.removeFromCart(t,e),v.subscribers.length){var o=p(t),s=new i(p(r));b(v.subscribers,(function(t){t.callback({type:l.REMOVE_FROM_CART,data:{item:o,quantity:e,cart:s}})}))}}catch(t){console.error(t)}},v.beginCheckout=function(t){try{var e=localStorage.getItem("gtmBeginCheckout");if(e&&t.id===e)return;localStorage.setItem("gtmBeginCheckout",t.id);var r=Date.now().toString();if(m.beginCheckout(t,r),u.beginCheckout(t),f.beginCheckout(t,r),g.beginCheckout(t),h.beginCheckout(t),v.subscribers.length){var o=new n(p(t));b(v.subscribers,(function(t){t.callback({type:l.BEGIN_CHECKOUT,data:{checkout:o}})}))}}catch(t){console.error(t)}},v.purchase=function(t,e){try{if(localStorage.removeItem("gtmBeginCheckout"),m.purchase(t,e.id||""),u.purchase(t,t.orderNumber||""),f.orderSuccess(t,e.id||""),g.purchase(t,t.orderNumber||""),h.purchase(t),v.subscribers.length){var r=new n(p(t)),o=p(e);b(v.subscribers,(function(t){t.callback({type:l.COMPLETE_CHECKOUT,data:{checkout:r,transaction:o}})}))}}catch(t){console.error(t)}},v.checkoutStep=function(t,e,r){try{if(u.checkoutStep(t,e,r),f.checkoutStep(t,e),g.checkoutStep(t,e),v.subscribers.length){var o=new n(p(t));b(v.subscribers,(function(t){t.callback({type:l.CHECKOUT_STEP,data:{checkout:o,step:e}})}))}}catch(t){console.error(t)}},v.disableHTML=function(){try{u.disableHTML()}catch(t){console.error(t)}},v.addToWishlist=function(t,e){try{var r=Date.now().toString();m.addToWishlist(t,r),h.addToWishlist(t),f.addToWishlist(t,r),v.subscribers.length&&b(v.subscribers,(function(r){r.callback({type:e?l.REMOVE_FROM_WISHLIST:l.ADD_TO_WISHLIST,data:{productId:t}})}))}catch(t){console.error(t)}},v.search=function(t,e){try{var r=Date.now().toString();m.search(t,r),u.search(t),h.search(t),g.search(t),f.search(t,r,e),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:l.SEARCH,data:{searchKeyword:t}})}))}catch(t){console.error(t)}},v.completeRegistration=function(t,e){try{var o=Date.now().toString();e||(m.completeRegistration(o),u.completeRegistration(t),h.completeRegistration()),f.customerRegister(o),v.subscribers.length&&b(v.subscribers,(function(o){o.callback({type:l.CUSTOMER_REGISTER,data:r({email:t.email,firstName:t.firstName,lastName:t.lastName,notificationsAccepted:t.subscriptionStatus},e?{attributes:t.attributes}:{})})}))}catch(t){console.error(t)}},v.createEmailSubscripition=function(t){try{v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:l.EMAIL_SUBSCRIPTION,data:{email:t}})}))}catch(t){console.error(t)}},v.customerLogin=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,v.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(u.customerLogin(t),[4,f.customerLogin()]):[2];case 2:return e.sent(),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:l.CUSTOMER_LOGIN,data:{customer:t}})})),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},v.customerLogout=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){try{u.customerLogout(),v.subscribers.length&&b(v.subscribers,(function(t){t.callback({type:l.CUSTOMER_LOGOUT,data:{}})}))}catch(t){console.error(t)}return[2]}))}))},v.customerVisit=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,v.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(u.customerVisit(t),[4,f.customerVisit()]):[2];case 2:return e.sent(),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:l.CUSTOMER_VISIT,data:{customer:t}})})),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},v.viewCart=function(t){try{if(t){var e=Date.now().toString();if(m.viewCart(t,e),f.viewCart(t,e),g.viewCart(t),u.viewCart(t),v.subscribers.length){var r=new i(p(t));b(v.subscribers,(function(t){t.callback({type:l.VIEW_CART,data:{cart:r}})}))}}}catch(t){console.error(t)}},v.viewCategory=function(t,e){try{var r=Date.now().toString();if(m.viewCategory(t,r),u.viewCategory(e,t),f.viewCategory(e,t,r),h.viewCategory(e),v.subscribers.length){var o=new a(p(e));b(v.subscribers,(function(e){e.callback({type:l.VIEW_CATEGORY,data:{categoryPath:t,category:o}})}))}}catch(t){console.error(t)}},v.viewBrand=function(t){try{if(f.viewBrand(t),v.subscribers.length){var e=new s(p(t));b(v.subscribers,(function(t){t.callback({type:l.VIEW_BRAND,data:{brand:e}})}))}}catch(t){console.error(t)}},v.viewStorefrontPopup=function(t){try{if(f.viewPopup(t.id),v.subscribers.length){var e=new d(p(t));b(v.subscribers,(function(t){t.callback({type:l.POPUP_VIEW,data:{popup:e}})}))}}catch(t){console.error(t)}},v.viewSearchResults=function(t,e){try{if(v.subscribers.length){var r=p(e).map((function(t){return new c(t)}));b(v.subscribers,(function(e){e.callback({type:l.VIEW_SEARCH_RESULTS,data:{searchKeyword:t,productDetails:r}})}))}}catch(t){console.error(t)}},v.viewListing=function(t){try{if(v.subscribers.length){var e=p(t).map((function(t){return new c(t)}));b(v.subscribers,(function(t){t.callback({type:l.VIEW_LISTING,data:{productDetails:e}})}))}}catch(t){console.error(t)}},v.contactForm=function(t){try{var e=Date.now().toString();if(m.contactForm(e),h.contactForm(),f.contactForm(e),v.subscribers.length){var r=p(t);b(v.subscribers,(function(t){t.callback({type:l.CONTACT_FORM,data:{form:r}})}))}}catch(t){console.error(t)}},v.subscribers=[],v}();export{v as Analytics};
1
+ import{__awaiter as t,__generator as e,__assign as r}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"../models/data/blog/index.js";import{IkasBrand as s}from"../models/data/brand/index.js";import"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import{IkasCart as i}from"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as a}from"../models/data/category/index.js";import{IkasCheckout as n}from"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as c}from"../models/data/product/index.js";import"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import{IkasStorefrontPopup as d}from"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import{FacebookPixel as m}from"./facebookPixel.js";import{GoogleTagManager as u}from"./googleTagManager.js";import{IkasEventType as l}from"./events.js";import p from"lodash/cloneDeep";import{tryForEach as b}from"../utils/helper.js";import f from"./ikasV3.js";import{GoogleAnalytics as h}from"./googleAnalytics.js";import{TiktokPixel as g}from"./tiktokPixel.js";import{IkasBaseStore as j}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";var v=function(){function v(){o(this)}return v.getCustomerInfo=function(){return t(this,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,(t=j.getInstance()).customerStore.waitUntilInitialized()];case 1:return e.sent(),(o=t.customerStore.customer)?[2,r(r({},o.basicInfo),{consentGranted:t.customerStore.customerConsentGranted})]:[2,null]}}))}))},v.pageView=function(r){return t(this,void 0,void 0,(function(){var t,o,s,i;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),[4,f.checkJourneyId()];case 1:return e.sent(),t=window.location.href,[4,v.getCustomerInfo()];case 2:return o=e.sent(),s=Date.now().toString(),u.pageView(t),m.pageView(t,s),[4,f.pageView(r,s)];case 3:return e.sent(),g.pageView(t),b(v.subscribers,(function(e){e.callback({type:l.PAGE_VIEW,data:{url:t,pageType:r,customer:o}})})),[3,5];case 4:return i=e.sent(),console.error(i),[3,5];case 5:return[2]}}))}))},v.productView=function(r){return t(this,void 0,void 0,(function(){var t,o,s;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=Date.now().toString(),m.productView(r,t),u.productView(r),[4,f.productView(r,t)];case 1:return e.sent(),h.productView(r),g.productView(r),v.subscribers.length&&(o=new c(p(r)),b(v.subscribers,(function(t){t.callback({type:l.PRODUCT_VIEW,data:{productDetail:o}})}))),[3,3];case 2:return s=e.sent(),console.error(s),[3,3];case 3:return[2]}}))}))},v.addToCart=function(t,e,r,o,s){try{if(m.addToCart(t,e,r),u.addToCart(t,e,s),f.addToCart(t,e,o,r),h.addToCart(t,e),g.addToCart(t,e),v.subscribers.length){var a=p(t),n=new i(p(o));b(v.subscribers,(function(t){t.callback({type:l.ADD_TO_CART,data:{item:a,quantity:e,cart:n}})}))}}catch(t){console.error(t)}},v.removeFromCart=function(t,e,r){try{if(u.removeFromCart(t,e),h.removeFromCart(t,e),v.subscribers.length){var o=p(t),s=new i(p(r));b(v.subscribers,(function(t){t.callback({type:l.REMOVE_FROM_CART,data:{item:o,quantity:e,cart:s}})}))}}catch(t){console.error(t)}},v.beginCheckout=function(t){try{var e=localStorage.getItem("gtmBeginCheckout");if(e&&t.id===e)return;localStorage.setItem("gtmBeginCheckout",t.id);var r=Date.now().toString();if(m.beginCheckout(t,r),u.beginCheckout(t),f.beginCheckout(t,r),h.beginCheckout(t),g.beginCheckout(t),v.subscribers.length){var o=new n(p(t));b(v.subscribers,(function(t){t.callback({type:l.BEGIN_CHECKOUT,data:{checkout:o}})}))}}catch(t){console.error(t)}},v.purchase=function(t,e){try{if(localStorage.removeItem("gtmBeginCheckout"),m.purchase(t,e.id||""),u.purchase(t,t.orderNumber||""),f.orderSuccess(t,e.id||""),h.purchase(t,t.orderNumber||""),g.purchase(t),v.subscribers.length){var r=new n(p(t)),o=p(e);b(v.subscribers,(function(t){t.callback({type:l.COMPLETE_CHECKOUT,data:{checkout:r,transaction:o}})}))}}catch(t){console.error(t)}},v.checkoutStep=function(t,e,r){try{if(u.checkoutStep(t,e,r),f.checkoutStep(t,e),h.checkoutStep(t,e),v.subscribers.length){var o=new n(p(t));b(v.subscribers,(function(t){t.callback({type:l.CHECKOUT_STEP,data:{checkout:o,step:e}})}))}}catch(t){console.error(t)}},v.disableHTML=function(){try{u.disableHTML()}catch(t){console.error(t)}},v.addToWishlist=function(t,e){try{var r=Date.now().toString();m.addToWishlist(t,r),g.addToWishlist(t),f.addToWishlist(t,r),v.subscribers.length&&b(v.subscribers,(function(r){r.callback({type:e?l.REMOVE_FROM_WISHLIST:l.ADD_TO_WISHLIST,data:{productId:t}})}))}catch(t){console.error(t)}},v.search=function(t,e){try{var r=Date.now().toString();m.search(t,r),u.search(t),g.search(t),h.search(t),f.search(t,r,e),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:l.SEARCH,data:{searchKeyword:t}})}))}catch(t){console.error(t)}},v.completeRegistration=function(t,e){try{var o=Date.now().toString();e||(m.completeRegistration(o),u.completeRegistration(t),g.completeRegistration()),f.customerRegister(o),v.subscribers.length&&b(v.subscribers,(function(o){o.callback({type:l.CUSTOMER_REGISTER,data:r({email:t.email,firstName:t.firstName,lastName:t.lastName,notificationsAccepted:t.subscriptionStatus},e?{attributes:t.attributes}:{})})}))}catch(t){console.error(t)}},v.createEmailSubscripition=function(t){try{v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:l.EMAIL_SUBSCRIPTION,data:{email:t}})}))}catch(t){console.error(t)}},v.customerLogin=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,v.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(u.customerLogin(t),[4,f.customerLogin()]):[2];case 2:return e.sent(),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:l.CUSTOMER_LOGIN,data:{customer:t}})})),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},v.customerLogout=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){try{u.customerLogout(),v.subscribers.length&&b(v.subscribers,(function(t){t.callback({type:l.CUSTOMER_LOGOUT,data:{}})}))}catch(t){console.error(t)}return[2]}))}))},v.customerVisit=function(){return t(this,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,v.getCustomerInfo()];case 1:return(t=e.sent())&&t.email?(u.customerVisit(t),[4,f.customerVisit()]):[2];case 2:return e.sent(),v.subscribers.length&&b(v.subscribers,(function(e){e.callback({type:l.CUSTOMER_VISIT,data:{customer:t}})})),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}}))}))},v.viewCart=function(t){try{if(t){var e=Date.now().toString();if(m.viewCart(t,e),f.viewCart(t,e),h.viewCart(t),u.viewCart(t),v.subscribers.length){var r=new i(p(t));b(v.subscribers,(function(t){t.callback({type:l.VIEW_CART,data:{cart:r}})}))}}}catch(t){console.error(t)}},v.viewCategory=function(t,e){try{var r=Date.now().toString();if(m.viewCategory(t,r),u.viewCategory(e,t),f.viewCategory(e,t,r),g.viewCategory(e),v.subscribers.length){var o=new a(p(e));b(v.subscribers,(function(e){e.callback({type:l.VIEW_CATEGORY,data:{categoryPath:t,category:o}})}))}}catch(t){console.error(t)}},v.viewBrand=function(t){try{if(f.viewBrand(t),v.subscribers.length){var e=new s(p(t));b(v.subscribers,(function(t){t.callback({type:l.VIEW_BRAND,data:{brand:e}})}))}}catch(t){console.error(t)}},v.viewStorefrontPopup=function(t){try{if(f.viewPopup(t.id),v.subscribers.length){var e=new d(p(t));b(v.subscribers,(function(t){t.callback({type:l.POPUP_VIEW,data:{popup:e}})}))}}catch(t){console.error(t)}},v.viewSearchResults=function(t,e){try{if(v.subscribers.length){var r=p(e).map((function(t){return new c(t)}));b(v.subscribers,(function(e){e.callback({type:l.VIEW_SEARCH_RESULTS,data:{searchKeyword:t,productDetails:r}})}))}}catch(t){console.error(t)}},v.viewListing=function(t){try{if(v.subscribers.length){var e=p(t).map((function(t){return new c(t)}));b(v.subscribers,(function(t){t.callback({type:l.VIEW_LISTING,data:{productDetails:e}})}))}}catch(t){console.error(t)}},v.contactForm=function(t){try{var e=Date.now().toString();if(m.contactForm(e),g.contactForm(),f.contactForm(e),v.subscribers.length){var r=p(t);b(v.subscribers,(function(t){t.callback({type:l.CONTACT_FORM,data:{form:r}})}))}}catch(t){console.error(t)}},v.addCouponCode=function(t){try{if(t&&v.subscribers.length){var e=new i(p(t));b(v.subscribers,(function(t){t.callback({type:l.ADD_COUPON_CODE,data:{cart:e}})}))}}catch(t){console.error(t)}},v.removeCouponCode=function(t){try{if(t&&v.subscribers.length){var e=new i(p(t));b(v.subscribers,(function(t){t.callback({type:l.REMOVE_COUPON_CODE,data:{cart:e}})}))}}catch(t){console.error(t)}},v.removeLoyaltyPoints=function(t){try{if(t&&v.subscribers.length){var e=new i(p(t));b(v.subscribers,(function(t){t.callback({type:l.REMOVE_LOYALTY_POINTS,data:{cart:e}})}))}}catch(t){console.error(t)}},v.subscribers=[],v}();export{v as Analytics};
@@ -27,7 +27,10 @@ export declare enum IkasEventType {
27
27
  VIEW_LISTING = "VIEW_LISTING",
28
28
  CONTACT_FORM = "CONTACT_FORM",
29
29
  EMAIL_SUBSCRIPTION = "EMAIL_SUBSCRIPTION",
30
- POPUP_VIEW = "POPUP_VIEW"
30
+ POPUP_VIEW = "POPUP_VIEW",
31
+ ADD_COUPON_CODE = "ADD_COUPON_CODE",
32
+ REMOVE_COUPON_CODE = "REMOVE_COUPON_CODE",
33
+ REMOVE_LOYALTY_POINTS = "REMOVE_LOYALTY_POINTS"
31
34
  }
32
35
  export declare type IkasEventSubscriber = {
33
36
  id: string;
@@ -1 +1 @@
1
- import{Analytics as E}from"./analytics.js";function s(s){var r=function(s){if(T(s)){var r=E.subscribers.findIndex((function(E){return E.id===s.id}));-1!==r?E.subscribers[r]=s:E.subscribers.push(s)}};return s.forEach(r),{subscribe:r,unsubscribe:function(s){var r=E.subscribers.findIndex((function(E){return E.id===s}));-1!==r&&E.subscribers.splice(r,1)}}}function r(){if("undefined"!=typeof window){var E=[];try{var r=window.IkasEvents;r&&r.subscribers&&r.subscribers.length&&(E=r.subscribers)}catch(E){}window.IkasEvents=s(E)}}function n(){return"<script>\n var subscribers = [];\n var subscribe = (subscriber) => { subscribers.push(subscriber); }; \n var unsubscribe = () => {};\n \n window.IkasEvents = {\n subscribers,\n subscribe,\n unsubscribe\n };\n <\/script>"}function T(E){return!!(E&&E.id&&"string"==typeof E.id&&E.callback&&"function"==typeof E.callback)}var _;!function(E){E.PAGE_VIEW="PAGE_VIEW",E.PRODUCT_VIEW="PRODUCT_VIEW",E.ADD_TO_CART="ADD_TO_CART",E.REMOVE_FROM_CART="REMOVE_FROM_CART",E.BEGIN_CHECKOUT="BEGIN_CHECKOUT",E.CHECKOUT_STEP="CHECKOUT_STEP",E.COMPLETE_CHECKOUT="COMPLETE_CHECKOUT",E.ADD_TO_WISHLIST="ADD_TO_WISHLIST",E.REMOVE_FROM_WISHLIST="REMOVE_FROM_WISHLIST",E.SEARCH="SEARCH",E.CUSTOMER_REGISTER="CUSTOMER_REGISTER",E.CUSTOMER_LOGIN="CUSTOMER_LOGIN",E.CUSTOMER_LOGOUT="CUSTOMER_LOGOUT",E.CUSTOMER_VISIT="CUSTOMER_VISIT",E.VIEW_CART="VIEW_CART",E.VIEW_CATEGORY="VIEW_CATEGORY",E.VIEW_BRAND="VIEW_BRAND",E.VIEW_SEARCH_RESULTS="VIEW_SEARCH_RESULTS",E.VIEW_LISTING="VIEW_LISTING",E.CONTACT_FORM="CONTACT_FORM",E.EMAIL_SUBSCRIPTION="EMAIL_SUBSCRIPTION",E.POPUP_VIEW="POPUP_VIEW"}(_||(_={}));export{_ as IkasEventType,s as IkasEvents,n as getIkasEventsScript,r as initIkasEvents,T as isValidIkasEventSubscriber};
1
+ import{Analytics as E}from"./analytics.js";function O(O){var _=function(O){if(r(O)){var _=E.subscribers.findIndex((function(E){return E.id===O.id}));-1!==_?E.subscribers[_]=O:E.subscribers.push(O)}};return O.forEach(_),{subscribe:_,unsubscribe:function(O){var _=E.subscribers.findIndex((function(E){return E.id===O}));-1!==_&&E.subscribers.splice(_,1)}}}function _(){if("undefined"!=typeof window){var E=[];try{var _=window.IkasEvents;_&&_.subscribers&&_.subscribers.length&&(E=_.subscribers)}catch(E){}window.IkasEvents=O(E)}}function s(){return"<script>\n var subscribers = [];\n var subscribe = (subscriber) => { subscribers.push(subscriber); }; \n var unsubscribe = () => {};\n \n window.IkasEvents = {\n subscribers,\n subscribe,\n unsubscribe\n };\n <\/script>"}function r(E){return!!(E&&E.id&&"string"==typeof E.id&&E.callback&&"function"==typeof E.callback)}var T;!function(E){E.PAGE_VIEW="PAGE_VIEW",E.PRODUCT_VIEW="PRODUCT_VIEW",E.ADD_TO_CART="ADD_TO_CART",E.REMOVE_FROM_CART="REMOVE_FROM_CART",E.BEGIN_CHECKOUT="BEGIN_CHECKOUT",E.CHECKOUT_STEP="CHECKOUT_STEP",E.COMPLETE_CHECKOUT="COMPLETE_CHECKOUT",E.ADD_TO_WISHLIST="ADD_TO_WISHLIST",E.REMOVE_FROM_WISHLIST="REMOVE_FROM_WISHLIST",E.SEARCH="SEARCH",E.CUSTOMER_REGISTER="CUSTOMER_REGISTER",E.CUSTOMER_LOGIN="CUSTOMER_LOGIN",E.CUSTOMER_LOGOUT="CUSTOMER_LOGOUT",E.CUSTOMER_VISIT="CUSTOMER_VISIT",E.VIEW_CART="VIEW_CART",E.VIEW_CATEGORY="VIEW_CATEGORY",E.VIEW_BRAND="VIEW_BRAND",E.VIEW_SEARCH_RESULTS="VIEW_SEARCH_RESULTS",E.VIEW_LISTING="VIEW_LISTING",E.CONTACT_FORM="CONTACT_FORM",E.EMAIL_SUBSCRIPTION="EMAIL_SUBSCRIPTION",E.POPUP_VIEW="POPUP_VIEW",E.ADD_COUPON_CODE="ADD_COUPON_CODE",E.REMOVE_COUPON_CODE="REMOVE_COUPON_CODE",E.REMOVE_LOYALTY_POINTS="REMOVE_LOYALTY_POINTS"}(T||(T={}));export{T as IkasEventType,O as IkasEvents,s as getIkasEventsScript,_ as initIkasEvents,r as isValidIkasEventSubscriber};
@@ -1 +1 @@
1
- import{__assign as e}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as t}from"mobx";import"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as o}from"../models/data/product/index.js";import"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import{CheckoutStep as r}from"../components/checkout/model.js";import"./analytics.js";import"./head/index.js";import"../components/page/index.js";import"../components/page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"@ikas/storefront-config";import"../components/link/index.js";import"../components/page-editor/loader/style.module.scss.js";import"../components/google-captcha/index.js";import"../components/paypal-express-checkout/index.js";import"../pages/home.js";import"../pages/_slug_/index.js";import"../pages/pages/_slug_.js";import"../pages/checkout.js";import"../pages/account/index.js";import"../pages/account/addresses.js";import"../pages/account/orders/index.js";import"../pages/account/orders/_id_.js";import"../pages/account/login.js";import"../pages/account/register.js";import"../pages/account/forgot-password.js";import"../pages/account/recover-password.js";import"../pages/cart.js";import"../pages/editor.js";import"../pages/account/favorite-products.js";import"../pages/search.js";import"next/error.js";import"../pages/blog/index.js";import"../pages/blog/_slug_.js";import"../pages/raffle/_slug_.js";import"../pages/raffle/index.js";import"../pages/account/raffles.js";import"../pages/account/activate.js";import{IkasBaseStore as a}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";import"lodash/get";import i from"lodash/cloneDeep";var s="undefined"==typeof window,d=function(){function e(){t(this)}return e.pageView=function(e){try{var t={event:"page-view-GTM",page:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.productView=function(e){var t,o;try{var r={event:"view_item-GTM",ecommerce:{items:[n(e)],extraParams:{parent_id:e.id,currency:e.selectedVariant.price.currency,url:"https://".concat(window.location.hostname).concat(e.href),item_image:(null===(o=null===(t=e.selectedVariant.mainImage)||void 0===t?void 0:t.image)||void 0===o?void 0:o.src)||"",barcode:e.selectedVariant.barcodeList&&e.selectedVariant.barcodeList.length?e.selectedVariant.barcodeList[0]:"",sellPrice:e.selectedVariant.sellPrice,discountPrice:e.selectedVariant.discountPrice||0}}};return!s&&window.dataLayer&&window.dataLayer.push(r),r}catch(e){console.error(e)}},e.addToCart=function(e,t,r){var i=a.getInstance().cartStore.cart;try{var d={event:"add_to_cart-GTM",ecommerce:{items:[e instanceof o?n(e,t):m(e,t,r)],cart:i}};return!s&&window.dataLayer&&window.dataLayer.push(d),d}catch(e){console.error(e)}},e.removeFromCart=function(e,t){var r=a.getInstance().cartStore.cart;try{var i={event:"remove_from_cart-GTM",ecommerce:{items:[e instanceof o?n(e,t):m(e,t)],cart:0===(null==r?void 0:r.itemCount)?null:r}};return!s&&window.dataLayer&&window.dataLayer.push(i),i}catch(e){console.error(e)}},e.beginCheckout=function(e){try{var t={event:"begin_checkout-GTM",ecommerce:{items:e.items.map((function(e){return m(e,e.quantity)}))}};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.purchase=function(e,t){try{var o={event:"purchase-GTM",ecommerce:{purchase:{transaction_id:t,affiliation:window.location.hostname,value:""+e.totalFinalPrice,tax:""+e.totalTax,shipping:""+e.shippingTotal,currency:e.currencyCode,coupon:e.couponCode,items:e.items.map((function(e){return m(e,e.quantity)})),customer:e.customer}}};return!s&&window.dataLayer&&window.dataLayer.push(o),o}catch(e){console.error(e)}},e.checkoutStep=function(e,t,o){var a,d,n;if(!(o&&t===r.INFO&&o.isAccountRequired&&(null===(a=e.customer)||void 0===a?void 0:a.isGuestCheckout))){var m=i(e);null===(d=m.shippingAddress)||void 0===d||delete d.checkoutSettings,null===(n=m.billingAddress)||void 0===n||delete n.checkoutSettings;var c="";t===r.INFO?c="checkout_info-GTM":t===r.SHIPPING?c="checkout_shipping-GTM":t===r.PAYMENT?c="checkout_payment-GTM":t===r.SUCCESS&&(c="checkout_success-GTM");try{var p={event:c,ecommerce:{cart:m}};return!s&&window.dataLayer&&window.dataLayer.push(p),p}catch(e){console.error(e)}}},e.disableHTML=function(){try{!s&&window.dataLayer&&window.dataLayer.push({"gtm.blocklist":["html","customScripts","customPixels","nonGoogleScripts"]})}catch(e){console.error(e)}},e.completeRegistration=function(e){try{var t={event:"customer_register-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.search=function(e){try{var t={event:"search-GTM",search_string:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.viewCategory=function(e,t){try{var o={event:"view_category-GTM",ecommerce:{category:[{id:e.id,name:e.name,metaData:e.metaData,href:e.href,image:e.image,path:t}]}};return!s&&window.dataLayer&&window.dataLayer.push(o),o}catch(e){console.error(e)}},e.customerLogin=function(e){try{var t={event:"customer_login-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.customerLogout=function(){try{var e={event:"customer_logout-GTM"};return!s&&window.dataLayer&&window.dataLayer.push(e),e}catch(e){console.error(e)}},e.customerVisit=function(e){try{var t={event:"customer_visit-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.viewCart=function(e){try{var t={event:"view_cart-GTM",ecommerce:{cart:e}};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e}();function n(e,t){var o;void 0===t&&(t=1);var r=[],a=e.categories;return a&&a.length&&(a[0].categoryPath&&a[0].categoryPath.map((function(e){return r.push(e)})),r.push(a[0].name)),{item_name:e.name,item_id:e.selectedVariant.id,price:e.selectedVariant.price.finalPrice,item_brand:(null===(o=e.brand)||void 0===o?void 0:o.name)||"",item_category:r.length?r[0]:"",item_category_2:r.length>1?r[1]:"",item_category_3:r.length>2?r[2]:"",item_category_4:r.length>3?r.slice(3,r.length).join(" > "):"",item_variant:e.selectedVariant.variantValues.map((function(e){return e.name})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:t}}function m(t,o,r){var a,i;void 0===o&&(o=1);var s=[],d=null==r?void 0:r.categories;return d&&d.length&&(d[0].categoryPath&&d[0].categoryPath.map((function(e){return s.push(e)})),s.push(d[0].name)),e(e({item_name:t.variant.name,item_id:t.variant.id,price:t.finalPrice||""},r?{item_brand:(null===(a=r.brand)||void 0===a?void 0:a.name)||"",item_category:s.length?s[0]:"",item_category_2:s.length>1?s[1]:"",item_category_3:s.length>2?s[2]:"",item_category_4:s.length>3?s.slice(3,s.length).join(" > "):""}:{item_brand:"",item_category:"",item_category_2:"",item_category_3:"",item_category_4:""}),{item_variant:null===(i=t.variant.variantValues)||void 0===i?void 0:i.map((function(e){return e.variantValueName})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:o})}export{d as GoogleTagManager};
1
+ import{__assign as e}from'./../ext/tslib/tslib.es6.js';import{makeAutoObservable as t}from"mobx";import"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/region/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/address/ikas-localized-customer-address.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/customer-form-data-input/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/order/address/region/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/order-transaction-with-prices/index.js";import"../models/data/order/package/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/campaign-offer/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/stock-location/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as o}from"../models/data/product/index.js";import"../models/data/raffle/index.js";import"../models/data/shipping-zone/state/city/district/region/index.js";import"../models/data/state/index.js";import"../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../models/data/storefront-popup/index.js";import"../models/data/theme-json/index.js";import"../models/data/theme-json/component/index.js";import"../models/data/theme-json/custom-data/index.js";import"../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/brand-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/ikas-address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import{CheckoutStep as r}from"../components/checkout/model.js";import"./analytics.js";import"./head/index.js";import"../components/page/index.js";import"../components/page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"@ikas/storefront-config";import"../components/link/index.js";import"../components/page-editor/loader/style.module.scss.js";import"../components/google-captcha/index.js";import"../components/paypal-express-checkout/index.js";import{IkasBaseStore as a}from"../store/base.js";import"../pages/home.js";import"../pages/_slug_/index.js";import"../pages/pages/_slug_.js";import"../pages/checkout.js";import"../pages/account/index.js";import"../pages/account/addresses.js";import"../pages/account/orders/index.js";import"../pages/account/orders/_id_.js";import"../pages/account/login.js";import"../pages/account/register.js";import"../pages/account/forgot-password.js";import"../pages/account/recover-password.js";import"../pages/cart.js";import"../pages/editor.js";import"../pages/account/favorite-products.js";import"../pages/search.js";import"next/error.js";import"../pages/blog/index.js";import"../pages/blog/_slug_.js";import"../pages/raffle/_slug_.js";import"../pages/raffle/index.js";import"../pages/account/raffles.js";import"../pages/account/activate.js";import"../store/customer/index.js";import"../store/cart/index.js";import"lodash/get";import i from"lodash/cloneDeep";var s="undefined"==typeof window,d=function(){function e(){t(this)}return e.pageView=function(e){try{var t={event:"page-view-GTM",page:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.productView=function(e){var t,o;try{var r={event:"view_item-GTM",ecommerce:{items:[n(e)],extraParams:{parent_id:e.id,currency:e.selectedVariant.price.currency,url:"https://".concat(window.location.hostname).concat(e.href),item_image:(null===(o=null===(t=e.selectedVariant.mainImage)||void 0===t?void 0:t.image)||void 0===o?void 0:o.src)||"",barcode:e.selectedVariant.barcodeList&&e.selectedVariant.barcodeList.length?e.selectedVariant.barcodeList[0]:"",sellPrice:e.selectedVariant.sellPrice,discountPrice:e.selectedVariant.discountPrice||0}}};return!s&&window.dataLayer&&window.dataLayer.push(r),r}catch(e){console.error(e)}},e.addToCart=function(e,t,r){var i=a.getInstance().cartStore.cart;try{var d={event:"add_to_cart-GTM",ecommerce:{items:[e instanceof o?n(e,t):m(e,t,r)],cart:i}};return!s&&window.dataLayer&&window.dataLayer.push(d),d}catch(e){console.error(e)}},e.removeFromCart=function(e,t){var r=a.getInstance().cartStore.cart;try{var i={event:"remove_from_cart-GTM",ecommerce:{items:[e instanceof o?n(e,t):m(e,t)],cart:0===(null==r?void 0:r.itemCount)?null:r}};return!s&&window.dataLayer&&window.dataLayer.push(i),i}catch(e){console.error(e)}},e.beginCheckout=function(e){try{var t={event:"begin_checkout-GTM",ecommerce:{items:e.items.map((function(e){return m(e,e.quantity)}))}};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.purchase=function(e,t){try{var o={event:"purchase-GTM",ecommerce:{purchase:{transaction_id:t,affiliation:window.location.hostname,value:""+e.totalFinalPrice,tax:""+e.totalTax,shipping:""+e.shippingTotal,currency:e.currencyCode,coupon:e.couponCode,items:e.items.map((function(e){return m(e,e.quantity)})),customer:e.customer}}};return!s&&window.dataLayer&&window.dataLayer.push(o),o}catch(e){console.error(e)}},e.checkoutStep=function(e,t,o){var a,d,n;if(!(o&&t===r.INFO&&o.isAccountRequired&&(null===(a=e.customer)||void 0===a?void 0:a.isGuestCheckout))){var m=i(e);null===(d=m.shippingAddress)||void 0===d||delete d.checkoutSettings,null===(n=m.billingAddress)||void 0===n||delete n.checkoutSettings;var c="";t===r.INFO?c="checkout_info-GTM":t===r.SHIPPING?c="checkout_shipping-GTM":t===r.PAYMENT?c="checkout_payment-GTM":t===r.SUCCESS&&(c="checkout_success-GTM");try{var p={event:c,ecommerce:{cart:m}};return!s&&window.dataLayer&&window.dataLayer.push(p),p}catch(e){console.error(e)}}},e.disableHTML=function(){try{!s&&window.dataLayer&&window.dataLayer.push({"gtm.blocklist":["html","customScripts","customPixels","nonGoogleScripts"]})}catch(e){console.error(e)}},e.completeRegistration=function(e){try{var t={event:"customer_register-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.search=function(e){try{var t={event:"search-GTM",search_string:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.viewCategory=function(e,t){try{var o={event:"view_category-GTM",ecommerce:{category:[{id:e.id,name:e.name,metaData:e.metaData,href:e.href,image:e.image,path:t}]}};return!s&&window.dataLayer&&window.dataLayer.push(o),o}catch(e){console.error(e)}},e.customerLogin=function(e){try{var t={event:"customer_login-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.customerLogout=function(){try{var e={event:"customer_logout-GTM"};return!s&&window.dataLayer&&window.dataLayer.push(e),e}catch(e){console.error(e)}},e.customerVisit=function(e){try{var t={event:"customer_visit-GTM",customer:e};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e.viewCart=function(e){try{var t={event:"view_cart-GTM",ecommerce:{cart:e}};return!s&&window.dataLayer&&window.dataLayer.push(t),t}catch(e){console.error(e)}},e}();function n(e,t){var o;void 0===t&&(t=1);var r=[],a=e.categories;return a&&a.length&&(a[0].categoryPath&&a[0].categoryPath.map((function(e){return r.push(e)})),r.push(a[0].name)),{item_name:e.name,item_id:e.selectedVariant.id,price:e.selectedVariant.price.finalPrice,item_brand:(null===(o=e.brand)||void 0===o?void 0:o.name)||"",item_category:r.length?r[0]:"",item_category_2:r.length>1?r[1]:"",item_category_3:r.length>2?r[2]:"",item_category_4:r.length>3?r.slice(3,r.length).join(" > "):"",item_variant:e.selectedVariant.variantValues.map((function(e){return e.name})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:t}}function m(t,o,r){var a,i;void 0===o&&(o=1);var s=[],d=null==r?void 0:r.categories;return d&&d.length&&(d[0].categoryPath&&d[0].categoryPath.map((function(e){return s.push(e)})),s.push(d[0].name)),e(e({item_name:t.variant.name,item_id:t.variant.id,price:t.finalPrice||""},r?{item_brand:(null===(a=r.brand)||void 0===a?void 0:a.name)||"",item_category:s.length?s[0]:"",item_category_2:s.length>1?s[1]:"",item_category_3:s.length>2?s[2]:"",item_category_4:s.length>3?s.slice(3,s.length).join(" > "):""}:{item_brand:"",item_category:"",item_category_2:"",item_category_3:"",item_category_4:""}),{item_variant:null===(i=t.variant.variantValues)||void 0===i?void 0:i.map((function(e){return e.variantValueName})).join(" / "),item_list_name:"",item_list_id:"",index:1,quantity:o})}export{d as GoogleTagManager};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import*as n from"react";import{observer as o}from"mobx-react-lite";import a from"lodash/sortBy";import c from"../input-with-button/index.js";import r from"../notification-box/index.js";import{CheckoutStep as l}from"../../model.js";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{formatCurrency as u}from"../../../../utils/currency.js";import{useTranslation as s}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import C from"../tooltip/index.js";import E from"../svg/arrow-down.js";import h from"../svg/cross.js";import v from"../svg/gift.js";import f from"../../styles/common.module.scss.js";import g from"./style.module.scss.js";import y from"../svg/ikas.js";import{Button as k}from"../button/index.js";import{IkasCampaignCreatedFor as N,IkasGiftCardType as S}from"@ikas/storefront-models";import T from"../../../../hooks/useDimension.js";import b from"../svg/coupon-code-tag.js";import O from"../svg/gift-cart-tag.js";import P from"../svg/store-credit-tag.js";var I;!function(e){e.COUPON_CODE_NOT_EXIST="COUPON_CODE_NOT_EXIST",e.COUPON_CODE_NOT_EXIST_FOR_GUESS="COUPON_CODE_NOT_EXIST_FOR_GUESS",e.COUPON_APPLIED_WITHOUT_DISCOUNT="COUPON_APPLIED_WITHOUT_DISCOUNT"}(I||(I={}));var x=o((function(e){var t,o,a,c,d,p,C=e.vm,h=e.allowExpand,v=e.isSuccessPageSummary,f=C.checkout,k=s().t,N=n.useState(!h),S=N[0],b=N[1],O=n.useState(!1),P=O[0],x=O[1],w=n.useState(null),D=w[0],U=w[1],M=n.useState(0),B=M[0],F=M[1],G=n.useState(null),V=G[0],W=G[1],X=n.useState(!1),H=X[0],q=X[1],z=n.useState(!1),Y=z[0],$=z[1],K=n.useState(!1),Q=K[0],J=K[1];T().isMobile,n.useEffect((function(){h&&(S?V&&F(V.getBoundingClientRect().height):F(0))}),[S,V,h,H,Y,P,Q]);var Z=n.useMemo((function(){switch(D){case I.COUPON_CODE_NOT_EXIST:return k("checkout-page:giftCodeErrorDescription");case I.COUPON_CODE_NOT_EXIST_FOR_GUESS:return k("checkout-page:mustBeSignInToApplyCampaign");case I.COUPON_APPLIED_WITHOUT_DISCOUNT:return k("checkout-page:couponInvalidForCartItems");default:return""}}),[D]),ee=[g.CartSummary,h?g.HideOnDesktop:"",v?g.SuccessPageCartSummary:""].join(" "),te=h?{height:B+"px"}:void 0,ne=[g.ArrowDown,S?g.Rotated:""].join(" ");return f?n.createElement(n.Fragment,null,!!h&&n.createElement(n.Fragment,null,n.createElement("div",{id:"checkout-mobile-summary-header"}),n.createElement("div",{className:g.ExpandHeader,onClick:function(){if(!S){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}b(!S)}},n.createElement("div",{className:g.Left},k("checkout-page:summary")),n.createElement("div",{className:g.Price},n.createElement("span",{className:g.PriceText},"".concat(u(C.finalPrice||0,f.currencyCode,f.currencySymbol)," (").concat(f.itemQuantity," ").concat(k("checkout-page:cartItemProduct"),")")),n.createElement("span",{className:ne},n.createElement(E,null))))),n.createElement("div",{className:ee},n.createElement("div",{className:[g.DetailsContainer,v?g.SuccessPageDetailContainer:""].join(" "),style:te},n.createElement("div",{className:g.Details,ref:W},n.createElement("div",{className:g.ItemsContainer},n.createElement("div",null,f.items.map((function(e,t){return n.createElement(m,{key:t,vm:C,cartItem:e,currencyCode:f.currencyCode,onChange:J,isSuccessPageSummary:v})})))),n.createElement("div",{className:g.Divider}),n.createElement("div",{className:g.SubTotalInfo},P&&n.createElement("div",{className:g.NotificationContainer},n.createElement(r,{type:"warning",title:k("checkout-page:giftCodeErrorTitle"),content:Z,onClose:function(){x(!1),U(null)}})),n.createElement(j,{label:k("checkout-page:subtotal"),value:f.formattedTotalPrice,tooltipText:k("checkout-page:subtotalTooltip")}),!!(null===(t=f.shippingLines)||void 0===t?void 0:t.length)&&(C.step===l.SUCCESS?n.createElement(j,{label:k("checkout-page:cartShippingTitle"),value:f.shippingTotal?f.formattedShippingTotal:k("checkout-page:free")}):f.shippingLines.map((function(e,t){return n.createElement(j,{key:t,label:e.paymentMethod?e.title:k("checkout-page:cartShippingTitle"),value:e.finalPrice?u(e.finalPrice,f.currencyCode,f.currencySymbol):k("checkout-page:free")})}))),n.createElement(L,{vm:C}),n.createElement(_,{vm:C}),(C.step===l.SUCCESS&&(!!C.checkout.note||!!C.checkout.appliedCouponCode)||C.step!==l.SUCCESS)&&C.isCouponCodeVisible&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(A,{vm:C,isAddingCoupon:Y,setAddingCoupon:$,setCouponError:x,setCouponErrorCode:U}),n.createElement(R,{vm:C,isAddingNote:H,setAddingNote:q}),!!C.installmentExtraPrice&&C.installmentExtraPrice>0&&n.createElement(n.Fragment,null,n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(j,{label:k("checkout-page:cartInterest"),value:u(C.installmentExtraPrice,f.currencyCode,f.currencySymbol)}))),C.isOpenEditOrderWithTransaction&&n.createElement("div",{className:g.SubTotalInfo,style:{}},!!(null===(o=C.openEditOrderTransaction)||void 0===o?void 0:o.chargedAmount)&&n.createElement(j,{label:k("checkout-page:chargedAmount"),value:u((null===(a=C.openEditOrderTransaction)||void 0===a?void 0:a.chargedAmount)||0,f.currencyCode,f.currencySymbol)}),!!(null===(c=C.openEditOrderTransaction)||void 0===c?void 0:c.refundedAmount)&&n.createElement(j,{label:k("checkout-page:refundedAmount"),value:u((null===(d=C.openEditOrderTransaction)||void 0===d?void 0:d.refundedAmount)||0,f.currencyCode,f.currencySymbol)})),n.createElement("div",{className:[g.TotalContainer,v?g.SuccessPageTotalContainer:""].join(" ")},n.createElement("div",{className:g.TitleContainer},n.createElement("div",{className:g.Title},C.isOpenEditOrderWithTransaction?k("checkout-page:totalAmountPayable"):k("checkout-page:total"))),n.createElement("div",null,n.createElement("div",{className:g.TotalPricesContainer},n.createElement("div",{className:g.TotalPrice},u(C.finalPrice||0,f.currencyCode,f.currencySymbol)),!!f.$totalTax&&!!(null===(p=C.customizationProps)||void 0===p?void 0:p.showTax)&&n.createElement("div",{className:[g.TotalTax].join(" ")},k("checkout-page:cartTaxTitle")+" "+f.$formattedTotalTax)))),!v&&!C.isPoweredByHidden&&n.createElement("div",{className:g.PoweredBy},n.createElement("span",null,"powered by"),n.createElement("a",{href:"https://ikas.com"+("tr"===i.getCurrentLocale()?"/tr":""),target:"_blank"},n.createElement(y,null))))))):null})),j=o((function(e){var t=e.label,o=e.value,a=e.tooltipText,c=e.hideMarginBottom;return n.createElement("div",{className:[g.InfoRow,c?g.hideMb:""].join(" ")},n.createElement("div",{className:g.Label},n.createElement("span",null,t),!!a&&n.createElement(C,{text:a,style:{marginLeft:"8px"}})),n.createElement("div",{className:g.Value},o))})),L=o((function(e){var t=e.vm,o=s().t;return t.checkout?n.createElement(n.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").filter((function(e){return e.createdFor!==N.LOYALTY_SPEND})).map((function(e,a){return n.createElement("div",{className:g.InfoRow,key:a},n.createElement("div",{className:g.Label},"INTEREST"===e.name?o("checkout-page:cartInterest"):e.name),n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,u(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),_=o((function(e){var t,o=e.vm,a=s().t;return o.checkout?n.createElement(n.Fragment,null,null===(t=o.checkout.giftPackageLines)||void 0===t?void 0:t.map((function(e,t){return n.createElement("div",{className:g.InfoRow,key:t},n.createElement("div",{className:g.Label},n.createElement("div",{className:g.GiftLabel},n.createElement(v,{style:{position:"relative",top:"-1px"}}),n.createElement("span",null,a("checkout-page:giftPackage")))),n.createElement("div",{className:g.Value},n.createElement("span",null,u(e.price,o.checkout.currencyCode,o.checkout.currencySymbol))))}))):null})),A=o((function(o){var a=o.vm,r=o.isAddingCoupon,i=o.setAddingCoupon,u=o.setCouponError,m=o.setCouponErrorCode,C=o.isOpenCouponCode,E=o.isMobile,h=o.showOnlyMobile,v=s().t,y=n.useState(""),N=y[0],S=y[1],T=n.useState(!1),b=T[0],O=T[1],P=n.useRef(null);n.useEffect((function(){r&&P.current&&P.current.focus()}),[r]);var I=function(){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return a.checkout.couponCode=N,O(!0),[4,a.onCouponCodeApply()];case 1:return t.sent(),O(!1),S(""),e=a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length,a.couponError?[3,4]:a.checkout.appliedCouponCode||e?(u(!1),m(null),[4,a.reInitPaymentMethod()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:a.checkout.couponCode=null,u(!0),m(a.couponError),t.label=5;case 5:return[2]}}))}))},x=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return O(!0),[4,a.removeGiftCardLine(n)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),O(!1),[2]}}))}))},j=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return O(!0),[4,a.removeLoyaltyPointsFromCart(n)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),O(!1),[2]}}))}))};a.step,l.SUCCESS;var L=a.step===l.SHIPPING,_=!!a.checkout.appliedCouponCode||!!(a.checkout.giftCardLines&&a.checkout.giftCardLines.length>0)||!!(a.checkout.loyaltyLines&&a.checkout.loyaltyLines.length>0),A=!!a.checkout.appliedCouponCode&&C,R=!r&&a.isCouponCodeVisible&&!a.isCouponCodeRequirementOpen&&a.step!==l.SUCCESS,U=_&&(!C||E);return n.createElement(n.Fragment,null,!!C&&n.createElement(n.Fragment,null,n.createElement("div",{className:[g.CartSummary,g.OpenCouponCodeSummary].join(" ")},n.createElement("div",{className:f.FormSectionTitle},n.createElement("div",{style:{paddingBottom:A?0:6},className:f.Title},v("checkout-page:couponCode"))))),_&&!L&&!a.isCouponCodeRequirementDefult&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement("div",{className:R?g.InfoRow:""},R&&n.createElement("div",{className:g.ActionTextBtn,onClick:function(){return i(!0)}},v("checkout-page:addCouponCode")),r&&!C&&n.createElement("div",{style:{marginBottom:"10px"}},n.createElement(c,{value:N,placeholder:v("checkout-page:couponCode"),buttonLabel:v("checkout-page:actions.apply"),inputRef:P,onClick:I,isLoading:b,onChange:S})),C&&n.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&I()},className:[g.OpenCouponCodeMain,U?g.OpenCouponCodeMainWithMb:""].join(" ")},n.createElement(d,{name:"couponCode",label:v("checkout-page:addCouponCode"),type:p.TEXT,value:N,onChange:S}),n.createElement(k,{style:{width:"33%"},text:v("checkout-page:actions.apply"),isLoading:b,onClick:I}))),U&&n.createElement(n.Fragment,null,!!a.checkout.appliedCouponCode&&n.createElement("div",{className:[g.InfoRow,h?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(w,{vm:a,onClearCouponCode:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return a.checkout.couponCode=null,O(!0),[4,a.onCouponCodeApply()];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),O(!1),[2]}}))}))},couponCode:a.checkout.appliedCouponCode})),!!a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length&&a.checkout.giftCardLines.map((function(e){return n.createElement("div",{className:[g.InfoRow,h?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(w,{vm:a,onClearGiftCode:x,couponCode:e.code,giftCardLine:e}))})),!!a.checkout.loyaltyLines&&!!a.checkout.loyaltyLines.length&&a.checkout.loyaltyLines.map((function(e){return n.createElement("div",{className:[g.InfoRow,h?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(D,{vm:a,onClearLoyaltyPoints:j,loyaltyPointsLine:e}))}))))})),w=o((function(e){var t=e.vm,o=e.onClearCouponCode,a=e.couponCode,c=e.giftCardLine,r=e.onClearGiftCode,i=t.checkout.couponAdjustment,m=s().t,d=!c,p=(null==c?void 0:c.type)===S.STORE_CREDIT;return n.createElement(n.Fragment,null,n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline].join(" ")},c&&p&&n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"5px"}},n.createElement("span",{style:{height:"20px"}},n.createElement(P,null)),n.createElement("span",{className:g.StoreCreditTag},m("checkout-page:storeCredit"))),!p&&n.createElement("span",{className:[g.AppliedCoupon,t.isCouponCodeRequirementDefult?"":g.NotClosed].join(" ")},d?n.createElement("span",{style:{height:"16px"}},n.createElement(b,null)):!p&&n.createElement("span",{style:{height:"16px"}},n.createElement(O,null)),n.createElement("span",{className:g.CouponCode},a),t.step!==l.SUCCESS&&!t.isOpenEditOrderWithTransaction&&n.createElement("span",{className:g.ClearCoupon,onClick:function(){return c?r&&r(c.giftCardId):o&&o()}},n.createElement(h,null)))),n.createElement("div",null,c?n.createElement("div",{className:g.Value},n.createElement("span",null,"-")," ",n.createElement("span",null,u((null==c?void 0:c.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol))):n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===(null==i?void 0:i.type)?"- ":"")," ",n.createElement("span",null,u((null==i?void 0:i.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol)))))})),D=o((function(e){var t,o=e.vm,a=e.onClearLoyaltyPoints,c=e.loyaltyPointsLine,r=null===(t=o.checkout.nonCouponAdjustments)||void 0===t?void 0:t.find((function(e){return e.campaignId===c.id})),i=s().t;return n.createElement(n.Fragment,null,n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline].join(" ")},n.createElement("span",{className:[g.AppliedCoupon,o.isCouponCodeRequirementDefult?"":g.NotClosed].join(" ")},n.createElement("span",{style:{height:"16px"}},n.createElement(b,null)),n.createElement("span",{className:g.CouponCode},c.amount," ",i("checkout-page:loyaltyPoints")),o.step!==l.SUCCESS&&!o.isOpenEditOrderWithTransaction&&n.createElement("span",{className:g.ClearCoupon,onClick:function(){return a&&a(c.loyaltySpendingMethodId)}},n.createElement(h,null)))),n.createElement("div",null,n.createElement("div",{className:g.Value},n.createElement("span",null,"-")," ",n.createElement("span",null,u((null==r?void 0:r.amount)||0,o.checkout.currencyCode,o.checkout.currencySymbol)))))})),R=o((function(e){var t=e.vm,o=e.isAddingNote,a=e.setAddingNote,c=s().t,r=n.useState(t.checkout.note?c("checkout-page:editOrderNote"):c("checkout-page:addOrderNote"))[0],i=n.useCallback((function(){a(!0)}),[]),u=n.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===l.SUCCESS;return m&&!t.checkout.note?null:n.createElement("div",{className:g.InfoRow},!o&&!m&&n.createElement("div",{className:g.ActionTextBtn,onClick:i},r),(o||m)&&n.createElement("div",{className:[g.CheckoutNoteContainer,m?g.Success:""].join(" ")},n.createElement("div",{className:g.Title},c("checkout-page:orderNote")),m?n.createElement("div",{className:g.CheckoutNoteDisplay},t.checkout.note):n.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:u,maxLength:320})))}));export{x as CartSummary,A as Coupon,I as CouponErrorCode};
1
+ import{__awaiter as e,__generator as t}from'./../../../../ext/tslib/tslib.es6.js';import*as n from"react";import{observer as o}from"mobx-react-lite";import a from"lodash/sortBy";import c from"../input-with-button/index.js";import r from"../notification-box/index.js";import{CheckoutStep as l}from"../../model.js";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import{formatCurrency as u}from"../../../../utils/currency.js";import{useTranslation as s}from"../../../../utils/i18n.js";import{CartItem as m}from"./cart-item/index.js";import{FormItem as d}from"../form-item/index.js";import{FormItemType as p}from"../form-item/model.js";import C from"../tooltip/index.js";import E from"../svg/arrow-down.js";import h from"../svg/cross.js";import v from"../svg/gift.js";import f from"../../styles/common.module.scss.js";import g from"./style.module.scss.js";import y from"../svg/ikas.js";import{Button as k}from"../button/index.js";import{IkasCampaignCreatedFor as N,IkasGiftCardType as S}from"@ikas/storefront-models";import T from"../../../../hooks/useDimension.js";import b from"../svg/coupon-code-tag.js";import O from"../svg/gift-cart-tag.js";import P from"../svg/store-credit-tag.js";var I;!function(e){e.COUPON_CODE_NOT_EXIST="COUPON_CODE_NOT_EXIST",e.COUPON_CODE_NOT_EXIST_FOR_GUESS="COUPON_CODE_NOT_EXIST_FOR_GUESS",e.COUPON_APPLIED_WITHOUT_DISCOUNT="COUPON_APPLIED_WITHOUT_DISCOUNT"}(I||(I={}));var x=o((function(e){var t,o,a,c,d,p,C=e.vm,h=e.allowExpand,v=e.isSuccessPageSummary,f=C.checkout,k=s().t,N=n.useState(!h),S=N[0],b=N[1],O=n.useState(!1),P=O[0],x=O[1],w=n.useState(null),D=w[0],U=w[1],M=n.useState(0),B=M[0],F=M[1],G=n.useState(null),V=G[0],W=G[1],X=n.useState(!1),H=X[0],q=X[1],z=n.useState(!1),Y=z[0],$=z[1],K=n.useState(!1),Q=K[0],J=K[1];T().isMobile,n.useEffect((function(){h&&(S?V&&F(V.getBoundingClientRect().height):F(0))}),[S,V,h,H,Y,P,Q]);var Z=n.useMemo((function(){switch(D){case I.COUPON_CODE_NOT_EXIST:return k("checkout-page:giftCodeErrorDescription");case I.COUPON_CODE_NOT_EXIST_FOR_GUESS:return k("checkout-page:mustBeSignInToApplyCampaign");case I.COUPON_APPLIED_WITHOUT_DISCOUNT:return k("checkout-page:couponInvalidForCartItems");default:return""}}),[D]),ee=[g.CartSummary,h?g.HideOnDesktop:"",v?g.SuccessPageCartSummary:""].join(" "),te=h?{height:B+"px"}:void 0,ne=[g.ArrowDown,S?g.Rotated:""].join(" ");return f?n.createElement(n.Fragment,null,!!h&&n.createElement(n.Fragment,null,n.createElement("div",{id:"checkout-mobile-summary-header"}),n.createElement("div",{className:g.ExpandHeader,onClick:function(){if(!S){var e=document.getElementById("Checkout"),t=document.getElementById("checkout-mobile-summary-header");e&&t&&e.scrollTo({top:t.offsetTop,behavior:"smooth"})}b(!S)}},n.createElement("div",{className:g.Left},k("checkout-page:summary")),n.createElement("div",{className:g.Price},n.createElement("span",{className:g.PriceText},"".concat(u(C.finalPrice||0,f.currencyCode,f.currencySymbol)," (").concat(f.itemQuantity," ").concat(k("checkout-page:cartItemProduct"),")")),n.createElement("span",{className:ne},n.createElement(E,null))))),n.createElement("div",{className:ee},n.createElement("div",{className:[g.DetailsContainer,v?g.SuccessPageDetailContainer:""].join(" "),style:te},n.createElement("div",{className:g.Details,ref:W},n.createElement("div",{className:g.ItemsContainer},n.createElement("div",null,f.items.map((function(e,t){return n.createElement(m,{key:t,vm:C,cartItem:e,currencyCode:f.currencyCode,onChange:J,isSuccessPageSummary:v})})))),n.createElement("div",{className:g.Divider}),n.createElement("div",{className:g.SubTotalInfo},P&&n.createElement("div",{className:g.NotificationContainer},n.createElement(r,{type:"warning",title:k("checkout-page:giftCodeErrorTitle"),content:Z,onClose:function(){x(!1),U(null)}})),n.createElement(j,{label:k("checkout-page:subtotal"),value:f.formattedTotalPrice,tooltipText:k("checkout-page:subtotalTooltip")}),!!(null===(t=f.shippingLines)||void 0===t?void 0:t.length)&&(C.step===l.SUCCESS?n.createElement(j,{label:k("checkout-page:cartShippingTitle"),value:f.shippingTotal?f.formattedShippingTotal:k("checkout-page:free")}):f.shippingLines.map((function(e,t){return n.createElement(j,{key:t,label:e.paymentMethod?e.title:k("checkout-page:cartShippingTitle"),value:e.finalPrice?u(e.finalPrice,f.currencyCode,f.currencySymbol):k("checkout-page:free")})}))),n.createElement(L,{vm:C}),n.createElement(_,{vm:C}),(C.step===l.SUCCESS&&(!!C.checkout.note||!!C.checkout.appliedCouponCode)||C.step!==l.SUCCESS)&&C.isCouponCodeVisible&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(A,{vm:C,isAddingCoupon:Y,setAddingCoupon:$,setCouponError:x,setCouponErrorCode:U}),n.createElement(R,{vm:C,isAddingNote:H,setAddingNote:q}),!!C.installmentExtraPrice&&C.installmentExtraPrice>0&&n.createElement(n.Fragment,null,n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement(j,{label:k("checkout-page:cartInterest"),value:u(C.installmentExtraPrice,f.currencyCode,f.currencySymbol)}))),C.isOpenEditOrderWithTransaction&&n.createElement("div",{className:g.SubTotalInfo,style:{}},!!(null===(o=C.openEditOrderTransaction)||void 0===o?void 0:o.chargedAmount)&&n.createElement(j,{label:k("checkout-page:chargedAmount"),value:u((null===(a=C.openEditOrderTransaction)||void 0===a?void 0:a.chargedAmount)||0,f.currencyCode,f.currencySymbol)}),!!(null===(c=C.openEditOrderTransaction)||void 0===c?void 0:c.refundedAmount)&&n.createElement(j,{label:k("checkout-page:refundedAmount"),value:u((null===(d=C.openEditOrderTransaction)||void 0===d?void 0:d.refundedAmount)||0,f.currencyCode,f.currencySymbol)})),n.createElement("div",{className:[g.TotalContainer,v?g.SuccessPageTotalContainer:""].join(" ")},n.createElement("div",{className:g.TitleContainer},n.createElement("div",{className:g.Title},C.isOpenEditOrderWithTransaction?k("checkout-page:totalAmountPayable"):k("checkout-page:total"))),n.createElement("div",null,n.createElement("div",{className:g.TotalPricesContainer},n.createElement("div",{className:g.TotalPrice},u(C.finalPrice||0,f.currencyCode,f.currencySymbol)),!!f.$totalTax&&!!(null===(p=C.customizationProps)||void 0===p?void 0:p.showTax)&&n.createElement("div",{className:[g.TotalTax].join(" ")},k("checkout-page:cartTaxTitle")+" "+f.$formattedTotalTax)))),!v&&!C.isPoweredByHidden&&n.createElement("div",{className:g.PoweredBy},n.createElement("span",null,"powered by"),n.createElement("a",{href:"https://ikas.com"+("tr"===i.getCurrentLocale()?"/tr":""),target:"_blank"},n.createElement(y,null))))))):null})),j=o((function(e){var t=e.label,o=e.value,a=e.tooltipText,c=e.hideMarginBottom;return n.createElement("div",{className:[g.InfoRow,c?g.hideMb:""].join(" ")},n.createElement("div",{className:g.Label},n.createElement("span",null,t),!!a&&n.createElement(C,{text:a,style:{marginLeft:"8px"}})),n.createElement("div",{className:g.Value},o))})),L=o((function(e){var t=e.vm,o=s().t;return t.checkout?n.createElement(n.Fragment,null,a(t.checkout.nonCouponAdjustments||[],"order").filter((function(e){return e.createdFor!==N.LOYALTY_SPEND})).map((function(e,a){return n.createElement("div",{className:g.InfoRow,key:a},n.createElement("div",{className:g.Label},"INTEREST"===e.name?o("checkout-page:cartInterest"):e.name),n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===e.type?"- ":"")," ",n.createElement("span",null,u(e.amount,t.checkout.currencyCode,t.checkout.currencySymbol))))}))):null})),_=o((function(e){var t,o=e.vm,a=s().t;return o.checkout?n.createElement(n.Fragment,null,null===(t=o.checkout.giftPackageLines)||void 0===t?void 0:t.map((function(e,t){return n.createElement("div",{className:g.InfoRow,key:t},n.createElement("div",{className:g.Label},n.createElement("div",{className:g.GiftLabel},n.createElement(v,{style:{position:"relative",top:"-1px"}}),n.createElement("span",null,a("checkout-page:giftPackage")))),n.createElement("div",{className:g.Value},n.createElement("span",null,u(e.price,o.checkout.currencyCode,o.checkout.currencySymbol))))}))):null})),A=o((function(o){var a=o.vm,r=o.isAddingCoupon,i=o.setAddingCoupon,u=o.setCouponError,m=o.setCouponErrorCode,C=o.isOpenCouponCode,E=o.isMobile,h=o.showOnlyMobile,v=s().t,y=n.useState(""),N=y[0],S=y[1],T=n.useState(!1),b=T[0],O=T[1],P=n.useRef(null);n.useEffect((function(){r&&P.current&&P.current.focus()}),[r]);var I=function(){return e(void 0,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return a.checkout.couponCode=N,O(!0),[4,a.onCouponCodeApply(!0)];case 1:return t.sent(),O(!1),S(""),e=a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length,a.couponError?[3,4]:a.checkout.appliedCouponCode||e?(u(!1),m(null),[4,a.reInitPaymentMethod()]):[3,3];case 2:t.sent(),t.label=3;case 3:return[3,5];case 4:a.checkout.couponCode=null,u(!0),m(a.couponError),t.label=5;case 5:return[2]}}))}))},x=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return O(!0),[4,a.removeGiftCardLine(n)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),O(!1),[2]}}))}))},j=function(n){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return O(!0),[4,a.removeLoyaltyPointsFromCart(n)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),O(!1),[2]}}))}))};a.step,l.SUCCESS;var L=a.step===l.SHIPPING,_=!!a.checkout.appliedCouponCode||!!(a.checkout.giftCardLines&&a.checkout.giftCardLines.length>0)||!!(a.checkout.loyaltyLines&&a.checkout.loyaltyLines.length>0),A=!!a.checkout.appliedCouponCode&&C,R=!r&&a.isCouponCodeVisible&&!a.isCouponCodeRequirementOpen&&a.step!==l.SUCCESS,U=_&&(!C||E);return n.createElement(n.Fragment,null,!!C&&n.createElement(n.Fragment,null,n.createElement("div",{className:[g.CartSummary,g.OpenCouponCodeSummary].join(" ")},n.createElement("div",{className:f.FormSectionTitle},n.createElement("div",{style:{paddingBottom:A?0:6},className:f.Title},v("checkout-page:couponCode"))))),_&&!L&&!a.isCouponCodeRequirementDefult&&n.createElement("div",{className:g.Divider,style:{marginTop:"24px",marginBottom:"24px"}}),n.createElement("div",{className:R?g.InfoRow:""},R&&n.createElement("div",{className:g.ActionTextBtn,onClick:function(){return i(!0)}},v("checkout-page:addCouponCode")),r&&!C&&n.createElement("div",{style:{marginBottom:"10px"}},n.createElement(c,{value:N,placeholder:v("checkout-page:couponCode"),buttonLabel:v("checkout-page:actions.apply"),inputRef:P,onClick:I,isLoading:b,onChange:S})),C&&n.createElement("div",{tabIndex:0,onKeyDown:function(e){"Enter"===e.key&&I()},className:[g.OpenCouponCodeMain,U?g.OpenCouponCodeMainWithMb:""].join(" ")},n.createElement(d,{name:"couponCode",label:v("checkout-page:addCouponCode"),type:p.TEXT,value:N,onChange:S}),n.createElement(k,{style:{width:"33%"},text:v("checkout-page:actions.apply"),isLoading:b,onClick:I}))),U&&n.createElement(n.Fragment,null,!!a.checkout.appliedCouponCode&&n.createElement("div",{className:[g.InfoRow,h?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(w,{vm:a,onClearCouponCode:function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return a.checkout.couponCode=null,O(!0),[4,a.onCouponCodeApply(!1)];case 1:return e.sent(),[4,a.reInitPaymentMethod()];case 2:return e.sent(),O(!1),[2]}}))}))},couponCode:a.checkout.appliedCouponCode})),!!a.checkout.giftCardLines&&!!a.checkout.giftCardLines.length&&a.checkout.giftCardLines.map((function(e){return n.createElement("div",{className:[g.InfoRow,h?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(w,{vm:a,onClearGiftCode:x,couponCode:e.code,giftCardLine:e}))})),!!a.checkout.loyaltyLines&&!!a.checkout.loyaltyLines.length&&a.checkout.loyaltyLines.map((function(e){return n.createElement("div",{className:[g.InfoRow,h?g.InfoRowGiftCardMobile:""].join(" ")},n.createElement(D,{vm:a,onClearLoyaltyPoints:j,loyaltyPointsLine:e}))}))))})),w=o((function(e){var t=e.vm,o=e.onClearCouponCode,a=e.couponCode,c=e.giftCardLine,r=e.onClearGiftCode,i=t.checkout.couponAdjustment,m=s().t,d=!c,p=(null==c?void 0:c.type)===S.STORE_CREDIT;return n.createElement(n.Fragment,null,n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline].join(" ")},c&&p&&n.createElement("div",{style:{display:"flex",alignItems:"center",gap:"5px"}},n.createElement("span",{style:{height:"20px"}},n.createElement(P,null)),n.createElement("span",{className:g.StoreCreditTag},m("checkout-page:storeCredit"))),!p&&n.createElement("span",{className:[g.AppliedCoupon,t.isCouponCodeRequirementDefult?"":g.NotClosed].join(" ")},d?n.createElement("span",{style:{height:"16px"}},n.createElement(b,null)):!p&&n.createElement("span",{style:{height:"16px"}},n.createElement(O,null)),n.createElement("span",{className:g.CouponCode},a),t.step!==l.SUCCESS&&!t.isOpenEditOrderWithTransaction&&n.createElement("span",{className:g.ClearCoupon,onClick:function(){return c?r&&r(c.giftCardId):o&&o()}},n.createElement(h,null)))),n.createElement("div",null,c?n.createElement("div",{className:g.Value},n.createElement("span",null,"-")," ",n.createElement("span",null,u((null==c?void 0:c.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol))):n.createElement("div",{className:g.Value},n.createElement("span",null,"DECREMENT"===(null==i?void 0:i.type)?"- ":"")," ",n.createElement("span",null,u((null==i?void 0:i.amount)||0,t.checkout.currencyCode,t.checkout.currencySymbol)))))})),D=o((function(e){var t,o=e.vm,a=e.onClearLoyaltyPoints,c=e.loyaltyPointsLine,r=null===(t=o.checkout.nonCouponAdjustments)||void 0===t?void 0:t.find((function(e){return e.campaignId===c.id})),i=s().t;return n.createElement(n.Fragment,null,n.createElement("div",{className:[g.ActionTextBtn,g.NoUnderline].join(" ")},n.createElement("span",{className:[g.AppliedCoupon,o.isCouponCodeRequirementDefult?"":g.NotClosed].join(" ")},n.createElement("span",{style:{height:"16px"}},n.createElement(b,null)),n.createElement("span",{className:g.CouponCode},c.amount," ",i("checkout-page:loyaltyPoints")),o.step!==l.SUCCESS&&!o.isOpenEditOrderWithTransaction&&n.createElement("span",{className:g.ClearCoupon,onClick:function(){return a&&a(c.loyaltySpendingMethodId)}},n.createElement(h,null)))),n.createElement("div",null,n.createElement("div",{className:g.Value},n.createElement("span",null,"-")," ",n.createElement("span",null,u((null==r?void 0:r.amount)||0,o.checkout.currencyCode,o.checkout.currencySymbol)))))})),R=o((function(e){var t=e.vm,o=e.isAddingNote,a=e.setAddingNote,c=s().t,r=n.useState(t.checkout.note?c("checkout-page:editOrderNote"):c("checkout-page:addOrderNote"))[0],i=n.useCallback((function(){a(!0)}),[]),u=n.useCallback((function(e){t.checkout.note=e}),[t,t.checkout]);if(!t.checkoutSettings.showCheckoutNote)return null;var m=t.step===l.SUCCESS;return m&&!t.checkout.note?null:n.createElement("div",{className:g.InfoRow},!o&&!m&&n.createElement("div",{className:g.ActionTextBtn,onClick:i},r),(o||m)&&n.createElement("div",{className:[g.CheckoutNoteContainer,m?g.Success:""].join(" ")},n.createElement("div",{className:g.Title},c("checkout-page:orderNote")),m?n.createElement("div",{className:g.CheckoutNoteDisplay},t.checkout.note):n.createElement(d,{style:{width:"100%"},type:p.TEXT_AREA,disableResize:!0,label:"",value:t.checkout.note||"",onChange:u,maxLength:320})))}));export{x as CartSummary,A as Coupon,I as CouponErrorCode};
@@ -156,7 +156,7 @@ export default class CheckoutViewModel {
156
156
  createBillingAddress: () => void;
157
157
  onShippingMethodChange: (shippingMethod: IkasAvailableShippingMethod) => Promise<void>;
158
158
  onStockLocationChange: (location: IkasStockLocation) => Promise<void>;
159
- onCouponCodeApply: () => Promise<void>;
159
+ onCouponCodeApply: (isAddingCoupon?: boolean) => Promise<void>;
160
160
  removeGiftCardLine: (giftCardId: string | null) => Promise<void>;
161
161
  removeLoyaltyPointsFromCart: (loyaltySpendingMethodId: string) => Promise<void>;
162
162
  getAvailableShippingZones: () => Promise<void>;