@ikas/storefront 2.0.0-alpha.11 → 2.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/build/analytics/head/index.js +1 -1
  2. package/build/components/checkout/index.js +1 -1
  3. package/build/components/checkout/model.js +1 -1
  4. package/build/components/checkout/steps/step-success/index.js +1 -1
  5. package/build/components/index.d.ts +1 -1
  6. package/build/components/page/ThemeComponent.js +1 -1
  7. package/build/components/page/index.js +1 -1
  8. package/build/components/page-editor/ThemeComponentEditor.d.ts +0 -3
  9. package/build/components/page-editor/ThemeComponentEditor.js +1 -1
  10. package/build/components/page-editor/index.d.ts +3 -1
  11. package/build/components/page-editor/index.js +1 -1
  12. package/build/components/page-editor/loader/index.d.ts +5 -1
  13. package/build/components/page-editor/loader/index.js +1 -1
  14. package/build/components/page-editor/loader/style.module.scss.js +1 -1
  15. package/build/components/page-editor/model.d.ts +5 -4
  16. package/build/components/page-editor/model.js +1 -1
  17. package/build/ikas.js +1 -1
  18. package/build/models/theme/component/prop/index.d.ts +3 -0
  19. package/build/models/theme/component/prop/index.js +1 -1
  20. package/build/models/theme/settings/{prop/color → color}/index.d.ts +0 -0
  21. package/build/models/theme/settings/color/index.js +1 -0
  22. package/build/models/theme/settings/{prop/favicon → favicon}/index.d.ts +0 -0
  23. package/build/models/theme/settings/{prop/favicon → favicon}/index.js +0 -0
  24. package/build/models/theme/settings/font-family/index.d.ts +5 -0
  25. package/build/models/theme/settings/font-family/index.js +1 -0
  26. package/build/models/theme/settings/index.d.ts +4 -2
  27. package/build/models/theme/settings/index.js +1 -1
  28. package/build/models/ui/product-detail/index.js +1 -1
  29. package/build/models/ui/product-list/index.js +1 -1
  30. package/build/models/ui/validator/form/register.js +1 -1
  31. package/build/pages/editor.d.ts +5 -2
  32. package/build/pages/editor.js +1 -1
  33. package/build/providers/page-data-next.d.ts +2 -1
  34. package/build/providers/page-data-next.js +1 -1
  35. package/build/store/cart.js +1 -1
  36. package/build/store/customer.js +1 -1
  37. package/build/storefront/index.d.ts +1 -1
  38. package/build/utils/google-fonts.d.ts +2 -0
  39. package/build/utils/google-fonts.js +1 -0
  40. package/package.json +1 -1
  41. package/build/models/theme/settings/prop/color/index.js +0 -1
@@ -1 +1 @@
1
- import*as e from"react";import{IkasStorefrontConfig as t}from"../../storefront/index.js";import n from'../../ext/html-react-parser/index.js';import{getIkasEventsScript as r}from"../events.js";var a=function(a){var s=a.blockHTML,o=t.gtmId,l=t.fbpId,i=t.storefrontJSScripts;return e.createElement(e.Fragment,null,s&&e.createElement("script",{dangerouslySetInnerHTML:{__html:"dataLayer = [{'gtm.blocklist': ['html']}];"}}),o&&e.createElement("script",{defer:!0,dangerouslySetInnerHTML:{__html:"(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','"+o+"');"}}),l&&e.createElement("script",{defer:!0,dangerouslySetInnerHTML:{__html:"!function(f,b,e,v,n,t,s)\n {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n n.queue=[];t=b.createElement(e);t.async=!0;\n t.src=v;s=b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t,s)}(window, document,'script',\n 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '"+l+"');\n fbq('track', 'PageView');"}}),n(r()),i.map((function(e){return n(e)})))},s=function(){var n=t.gtmId,r=t.fbpId;return e.createElement(e.Fragment,null,n&&e.createElement("noscript",{dangerouslySetInnerHTML:{__html:'<iframe src="https://www.googletagmanager.com/ns.html?id='+n+'" height="0" width="0" style="display:none;visibility:hidden"></iframe>'}}),r&&e.createElement("noscript",{dangerouslySetInnerHTML:{__html:'<img height="1" width="1" style="display:none" \n src="https://www.facebook.com/tr?id='+r+'&ev=PageView&noscript=1"/>'}}))};export{s as AnalyticsBody,a as AnalyticsHead};
1
+ import*as e from"react";import{IkasStorefrontConfig as t}from"../../storefront/index.js";import n from'../../ext/html-react-parser/index.js';import{getIkasEventsScript as r}from"../events.js";import{observer as s}from"mobx-react-lite";var a=s((function(s){var a=s.blockHTML,i=t.gtmId,o=t.fbpId,l=t.storefrontJSScripts;return e.createElement(e.Fragment,null,a&&!t.isEditor&&e.createElement("script",{dangerouslySetInnerHTML:{__html:"dataLayer = [{'gtm.blocklist': ['html']}];"}}),i&&!t.isEditor&&e.createElement("script",{defer:!0,dangerouslySetInnerHTML:{__html:"(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n })(window,document,'script','dataLayer','"+i+"');"}}),o&&!t.isEditor&&e.createElement("script",{defer:!0,dangerouslySetInnerHTML:{__html:"!function(f,b,e,v,n,t,s)\n {if(f.fbq)return;n=f.fbq=function(){n.callMethod?\n n.callMethod.apply(n,arguments):n.queue.push(arguments)};\n if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\n n.queue=[];t=b.createElement(e);t.async=!0;\n t.src=v;s=b.getElementsByTagName(e)[0];\n s.parentNode.insertBefore(t,s)}(window, document,'script',\n 'https://connect.facebook.net/en_US/fbevents.js');\n fbq('init', '"+o+"');\n fbq('track', 'PageView');"}}),n(r()),l.map((function(e){return n(e)})))})),i=function(){var n=t.gtmId,r=t.fbpId;return e.createElement(e.Fragment,null,n&&!t.isEditor&&e.createElement("noscript",{dangerouslySetInnerHTML:{__html:'<iframe src="https://www.googletagmanager.com/ns.html?id='+n+'" height="0" width="0" style="display:none;visibility:hidden"></iframe>'}}),r&&!t.isEditor&&e.createElement("noscript",{dangerouslySetInnerHTML:{__html:'<img height="1" width="1" style="display:none" \n src="https://www.facebook.com/tr?id='+r+'&ev=PageView&noscript=1"/>'}}))};export{i as AnalyticsBody,a as AnalyticsHead};
@@ -1 +1 @@
1
- import*as e from"react";import{observer as t}from"mobx-react-lite";import{useRouter as o}from"next/router.js";import r,{CheckoutStep as s}from"./model.js";import i from"./steps/step-info/index.js";import{CheckoutStepShipping as c}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as l}from"./steps/step-payment/index.js";import{CartSummary as n}from"./components/cart-summary/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"mobx";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as m}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/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/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{StepSuccess as a}from"./steps/step-success/index.js";import{Modal as d}from"./components/modal/index.js";import u from"./style.module.scss.js";import{IkasPageHead as p}from"../page/head.js";import{Analytics as v}from"../../analytics/analytics.js";import{IkasStorefrontConfig as h}from"../../storefront/index.js";import'../../ext/html-react-parser/index.js';import"../../analytics/events.js";import{Image as E}from"../image/index.js";import g from"next/link.js";import f,{Step as y}from"./components/step-container/index.js";import'../../ext/lodash/isArguments.js';import'../../ext/lodash/isBuffer.js';import'../../ext/lodash/isTypedArray.js';import'../../ext/lodash/_baseGetTag.js';import{formatMoney as k}from"../../utils/currency.js";import{useTranslation as j}from"../../utils/i18n.js";import{StockError as x}from"./components/error/stock-error/index.js";import C from"./components/svg/ikas.js";import N from'../../ext/react-tooltip/dist/index.es.js';import{FullscreenLoading as F}from"./components/fullscreen-loading/index.js";var b=t((function(t){var i,c,l,E=t.checkout,g=t.checkoutSettings,f=t.merchantSettings,y=t.customizationProps,k=t.returnPolicy,b=t.privacyPolicy,S=t.termsOfService,A=j().t,I=o(),w=e.useState((function(){return new r(E,g,f,I,k,b,S,A)}))[0];return w.step===s.PAYMENT&&v.disableHTML(),e.useEffect((function(){w.checkoutSettings.isAccountRequired&&!w.checkout.hasCustomer&&I.push("/account/login?redirect="+encodeURIComponent(w.checkoutUrl)),v.beginCheckout(w.checkout),v.pageView(m.CHECKOUT)}),[]),e.useEffect((function(){!function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==e?void 0:e.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==e?void 0:e.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==e?void 0:e.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==e?void 0:e.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==e?void 0:e.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==e?void 0:e.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==e?void 0:e.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==e?void 0:e.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==e?void 0:e.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==e?void 0:e.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==e?void 0:e.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==e?void 0:e.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==e?void 0:e.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==e?void 0:e.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==e?void 0:e.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==e?void 0:e.successLightColor)||"#F6FFED")}(y)}),[y]),w.isCheckoutLoaded&&w.store.customerStore.initialized?w.checkout.hasCustomer&&(null===(i=w.store.customerStore.customer)||void 0===i?void 0:i.id)!==(null===(c=w.checkout.customer)||void 0===c?void 0:c.id)?(I.push("/account/login?redirect="+encodeURIComponent(w.checkoutUrl)),null):e.createElement(e.Fragment,null,e.createElement(p,{pageType:m.CHECKOUT,pageTitle:((null===(l=w.merchantSettings)||void 0===l?void 0:l.merchantName)||"")+" - "+A("checkout-page:securePayment"),pageDescription:A("checkout-page:securePayment")}),e.createElement("div",{id:"Checkout",className:u.CheckoutPage},e.createElement(N,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:u.ReactTooltipWrap,globalEventOff:"touchstart"}),e.createElement("div",{className:u.Left},e.createElement("div",{className:u.LeftContent},e.createElement("div",null,e.createElement(P,{vm:w}),w.hasStockError&&e.createElement("div",{className:u.ErrorContainer},e.createElement(x,{vm:w,error:w.error})),!w.hasStockError&&e.createElement(e.Fragment,null,e.createElement("div",{className:u.MobileCartSummary},e.createElement(n,{vm:w,allowExpand:!0})),w.step===s.SUCCESS?e.createElement(a,{vm:w}):e.createElement(T,{vm:w})),e.createElement("div",{className:u.Space})),e.createElement(M,{vm:w}))),e.createElement("div",{className:u.Right},e.createElement("div",{className:u.RightContent},e.createElement(n,{vm:w}),e.createElement("div",{className:u.PoweredBy},e.createElement("span",null,"powered by"),e.createElement("a",{href:"https://ikas.com"+("tr"===h.getCurrentLocale()?"/tr":""),target:"_blank"},e.createElement(C,null))))),!!w.policyModalText&&e.createElement(d,{title:w.policyModalTitle,modalContent:w.policyModalText,onClose:function(){w.policyModalText=""}}))):e.createElement(F,null)})),P=t((function(t){var o,r,s=t.vm,i=j().t;return e.createElement("div",{className:u.Header},e.createElement(g,{href:"/",passHref:!0},e.createElement("a",null,(null===(o=s.merchantSettings)||void 0===o?void 0:o.logoId)?e.createElement("div",{className:u.Logo},e.createElement(E,{layout:"fill",image:s.merchantSettings.logo,sizes:"360px"})):(null===(r=s.merchantSettings)||void 0===r?void 0:r.merchantName)||"")),!s.checkout.hasCustomer&&e.createElement("div",{className:u.LoginText},e.createElement("span",{className:u.LoginCta},i("checkout-page:alreadyHaveAnAccount")),e.createElement(g,{href:"/account/login?redirect="+encodeURIComponent(s.checkoutUrl),passHref:!0},e.createElement("a",{className:u.LoginBtn},i("checkout-page:actions.login")))),s.checkout.hasCustomer&&e.createElement("div",{className:u.CustomerInfo},e.createElement("div",{className:u.Name},s.checkout.customerFullName),e.createElement("div",{className:u.Email},s.checkout.customerEmail)))})),T=t((function(t){var o=t.vm,r=j().t,n=e.useMemo((function(){switch(o.step){case s.INFO:return e.createElement(i,{vm:o});case s.SHIPPING:return e.createElement(c,{vm:o});case s.PAYMENT:return e.createElement(l,{vm:o});case s.SUCCESS:return e.createElement(a,{vm:o})}}),[o,o.step]),m=[new y(r("checkout-page:address"),o.step===s.INFO,o.step!==s.INFO,o.step!==s.INFO?e.createElement("div",{className:u.AdressStepInfo},e.createElement(S,{vm:o}),e.createElement("div",{className:u.EditBtn,onClick:o.onBackToInfoClick},r("checkout-page:actions.edit"))):void 0,o.step!==s.INFO?e.createElement("div",{className:u.AddressStepInfoMobile},e.createElement(S,{vm:o})):void 0),new y(r("checkout-page:shipping"),o.step===s.SHIPPING,o.step===s.PAYMENT,o.step===s.PAYMENT?e.createElement("div",{className:u.AdressStepInfo},e.createElement(A,{vm:o}),o.checkout.availableShippingMethods.length>1&&e.createElement("div",{className:u.EditBtn,onClick:o.onBackToShippingClick},r("checkout-page:actions.edit"))):void 0,o.step===s.PAYMENT?e.createElement("div",{className:u.AddressStepInfoMobile},e.createElement(A,{vm:o})):void 0),new y(r("checkout-page:payment"),o.step===s.PAYMENT,!1)];return e.createElement(f,{steps:m,stepContent:n})})),S=t((function(t){var o,r,s,i,c,l=t.vm;return e.createElement("div",{className:u.Address},e.createElement("div",{className:[u.Text,u.WithMBottom].join(" ")},(null===(o=l.checkout.customer)||void 0===o?void 0:o.email)||""),e.createElement("div",{className:u.Text},((null===(r=l.checkout.customer)||void 0===r?void 0:r.firstName)||"")+" "+((null===(s=l.checkout.customer)||void 0===s?void 0:s.lastName)||"")),e.createElement("div",{className:[u.Text,u.Gray].join(" ")},null===(i=l.checkout.shippingAddress)||void 0===i?void 0:i.phone),e.createElement("div",{className:[u.Text,u.Gray].join(" ")},null===(c=l.checkout.shippingAddress)||void 0===c?void 0:c.addressText))})),A=t((function(t){var o=t.vm,r=j().t;return e.createElement("div",{className:u.Address},o.checkout.shippingLines&&o.checkout.shippingLines.length?e.createElement(e.Fragment,null,e.createElement("span",null,o.checkout.shippingLines[0].title),e.createElement("span",{className:u.LightText}," / "+(0===o.checkout.shippingLines[0].price?r("checkout-page:free"):k(o.checkout.shippingLines[0].price,o.checkout.cart.currencyCode)))):r("checkout-page:standartShipping"))})),M=t((function(t){var o=t.vm,r=j().t;return e.createElement("div",{className:u.Footer},e.createElement("div",{className:u.FooterItem,onClick:function(){o.policyModalTitle=r("checkout-page:returnPolicy"),o.policyModalText=o.returnPolicy}},r("checkout-page:returnPolicy")),e.createElement("div",{className:u.FooterBullet},"•"),e.createElement("div",{className:u.FooterItem,onClick:function(){o.policyModalTitle=r("checkout-page:privacyPolicy"),o.policyModalText=o.privacyPolicy}},r("checkout-page:privacyPolicy")),e.createElement("div",{className:u.FooterBullet},"•"),e.createElement("div",{className:u.FooterItem,onClick:function(){o.policyModalTitle=r("checkout-page:termsOfService"),o.policyModalText=o.termsOfService}},r("checkout-page:termsOfService")))}));export{b as default};
1
+ import*as e from"react";import{observer as t}from"mobx-react-lite";import{useRouter as o}from"next/router.js";import r,{CheckoutStep as i}from"./model.js";import s from"./steps/step-info/index.js";import{CheckoutStepShipping as c}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as l}from"./steps/step-payment/index.js";import{CartSummary as n}from"./components/cart-summary/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"mobx";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as a}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/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/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{StepSuccess as m}from"./steps/step-success/index.js";import{Modal as d}from"./components/modal/index.js";import u from"./style.module.scss.js";import{IkasPageHead as p}from"../page/head.js";import{Analytics as v}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{Image as h}from"../image/index.js";import E from"next/link.js";import g,{Step as f}from"./components/step-container/index.js";import{IkasStorefrontConfig as y}from"../../storefront/index.js";import'../../ext/lodash/isArguments.js';import'../../ext/lodash/isBuffer.js';import'../../ext/lodash/isTypedArray.js';import'../../ext/lodash/_baseGetTag.js';import{formatMoney as k}from"../../utils/currency.js";import{useTranslation as x}from"../../utils/i18n.js";import{StockError as j}from"./components/error/stock-error/index.js";import C from"./components/svg/ikas.js";import N from'../../ext/react-tooltip/dist/index.es.js';import{FullscreenLoading as F}from"./components/fullscreen-loading/index.js";var b=t((function(t){var s,c,l,h=t.checkout,E=t.checkoutSettings,g=t.merchantSettings,f=t.customizationProps,k=t.returnPolicy,b=t.privacyPolicy,S=t.termsOfService,A=x().t,I=o(),w=e.useState((function(){return new r(h,E,g,I,k,b,S,A)}))[0];return w.step===i.PAYMENT&&v.disableHTML(),e.useEffect((function(){w.checkoutSettings.isAccountRequired&&!w.checkout.hasCustomer&&I.push("/account/login?redirect="+encodeURIComponent(w.checkoutUrl)),v.beginCheckout(w.checkout),v.pageView(a.CHECKOUT)}),[]),e.useEffect((function(){!function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==e?void 0:e.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==e?void 0:e.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==e?void 0:e.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==e?void 0:e.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==e?void 0:e.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==e?void 0:e.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==e?void 0:e.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==e?void 0:e.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==e?void 0:e.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==e?void 0:e.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==e?void 0:e.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==e?void 0:e.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==e?void 0:e.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==e?void 0:e.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==e?void 0:e.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==e?void 0:e.successLightColor)||"#F6FFED")}(f)}),[f]),w.isCheckoutLoaded&&w.store.customerStore.initialized?w.checkout.hasCustomer&&(null===(s=w.store.customerStore.customer)||void 0===s?void 0:s.id)!==(null===(c=w.checkout.customer)||void 0===c?void 0:c.id)?(I.push("/account/login?redirect="+encodeURIComponent(w.checkoutUrl)),null):e.createElement(e.Fragment,null,e.createElement(p,{pageType:a.CHECKOUT,pageTitle:((null===(l=w.merchantSettings)||void 0===l?void 0:l.merchantName)||"")+" - "+A("checkout-page:securePayment"),pageDescription:A("checkout-page:securePayment")}),e.createElement("div",{id:"Checkout",className:u.CheckoutPage},e.createElement(N,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:u.ReactTooltipWrap,globalEventOff:"touchstart"}),e.createElement("div",{className:u.Left},e.createElement("div",{className:u.LeftContent},e.createElement("div",null,e.createElement(P,{vm:w}),w.hasStockError&&e.createElement("div",{className:u.ErrorContainer},e.createElement(j,{vm:w,error:w.error})),!w.hasStockError&&e.createElement(e.Fragment,null,e.createElement("div",{className:u.MobileCartSummary},e.createElement(n,{vm:w,allowExpand:!0})),w.step===i.SUCCESS?e.createElement(m,{vm:w}):e.createElement(T,{vm:w})),e.createElement("div",{className:u.Space})),e.createElement(M,{vm:w}))),e.createElement("div",{className:u.Right},e.createElement("div",{className:u.RightContent},e.createElement(n,{vm:w}),e.createElement("div",{className:u.PoweredBy},e.createElement("span",null,"powered by"),e.createElement("a",{href:"https://ikas.com"+("tr"===y.getCurrentLocale()?"/tr":""),target:"_blank"},e.createElement(C,null))))),!!w.policyModalText&&e.createElement(d,{title:w.policyModalTitle,modalContent:w.policyModalText,onClose:function(){w.policyModalText=""}}))):e.createElement(F,null)})),P=t((function(t){var o,r,i=t.vm,s=x().t;return e.createElement("div",{className:u.Header},e.createElement(E,{href:"/",passHref:!0},e.createElement("a",null,(null===(o=i.merchantSettings)||void 0===o?void 0:o.logoId)?e.createElement("div",{className:u.Logo},e.createElement(h,{layout:"fill",image:i.merchantSettings.logo,sizes:"360px"})):(null===(r=i.merchantSettings)||void 0===r?void 0:r.merchantName)||"")),!i.checkout.hasCustomer&&e.createElement("div",{className:u.LoginText},e.createElement("span",{className:u.LoginCta},s("checkout-page:alreadyHaveAnAccount")),e.createElement(E,{href:"/account/login?redirect="+encodeURIComponent(i.checkoutUrl),passHref:!0},e.createElement("a",{className:u.LoginBtn},s("checkout-page:actions.login")))),i.checkout.hasCustomer&&e.createElement("div",{className:u.CustomerInfo},e.createElement("div",{className:u.Name},i.checkout.customerFullName),e.createElement("div",{className:u.Email},i.checkout.customerEmail)))})),T=t((function(t){var o=t.vm,r=x().t,n=e.useMemo((function(){switch(o.step){case i.INFO:return e.createElement(s,{vm:o});case i.SHIPPING:return e.createElement(c,{vm:o});case i.PAYMENT:return e.createElement(l,{vm:o});case i.SUCCESS:return e.createElement(m,{vm:o})}}),[o,o.step]),a=[new f(r("checkout-page:address"),o.step===i.INFO,o.step!==i.INFO,o.step!==i.INFO?e.createElement("div",{className:u.AdressStepInfo},e.createElement(S,{vm:o}),e.createElement("div",{className:u.EditBtn,onClick:o.onBackToInfoClick},r("checkout-page:actions.edit"))):void 0,o.step!==i.INFO?e.createElement("div",{className:u.AddressStepInfoMobile},e.createElement(S,{vm:o})):void 0),new f(r("checkout-page:shipping"),o.step===i.SHIPPING,o.step===i.PAYMENT,o.step===i.PAYMENT?e.createElement("div",{className:u.AdressStepInfo},e.createElement(A,{vm:o}),o.checkout.availableShippingMethods.length>1&&e.createElement("div",{className:u.EditBtn,onClick:o.onBackToShippingClick},r("checkout-page:actions.edit"))):void 0,o.step===i.PAYMENT?e.createElement("div",{className:u.AddressStepInfoMobile},e.createElement(A,{vm:o})):void 0),new f(r("checkout-page:payment"),o.step===i.PAYMENT,!1)];return e.createElement(g,{steps:a,stepContent:n})})),S=t((function(t){var o,r,i,s,c,l=t.vm;return e.createElement("div",{className:u.Address},e.createElement("div",{className:[u.Text,u.WithMBottom].join(" ")},(null===(o=l.checkout.customer)||void 0===o?void 0:o.email)||""),e.createElement("div",{className:u.Text},((null===(r=l.checkout.customer)||void 0===r?void 0:r.firstName)||"")+" "+((null===(i=l.checkout.customer)||void 0===i?void 0:i.lastName)||"")),e.createElement("div",{className:[u.Text,u.Gray].join(" ")},null===(s=l.checkout.shippingAddress)||void 0===s?void 0:s.phone),e.createElement("div",{className:[u.Text,u.Gray].join(" ")},null===(c=l.checkout.shippingAddress)||void 0===c?void 0:c.addressText))})),A=t((function(t){var o=t.vm,r=x().t;return e.createElement("div",{className:u.Address},o.checkout.shippingLines&&o.checkout.shippingLines.length?e.createElement(e.Fragment,null,e.createElement("span",null,o.checkout.shippingLines[0].title),e.createElement("span",{className:u.LightText}," / "+(0===o.checkout.shippingLines[0].price?r("checkout-page:free"):k(o.checkout.shippingLines[0].price,o.checkout.cart.currencyCode)))):r("checkout-page:standartShipping"))})),M=t((function(t){var o=t.vm,r=x().t;return e.createElement("div",{className:u.Footer},e.createElement("div",{className:u.FooterItem,onClick:function(){o.policyModalTitle=r("checkout-page:returnPolicy"),o.policyModalText=o.returnPolicy}},r("checkout-page:returnPolicy")),e.createElement("div",{className:u.FooterBullet},"•"),e.createElement("div",{className:u.FooterItem,onClick:function(){o.policyModalTitle=r("checkout-page:privacyPolicy"),o.policyModalText=o.privacyPolicy}},r("checkout-page:privacyPolicy")),e.createElement("div",{className:u.FooterBullet},"•"),e.createElement("div",{className:u.FooterItem,onClick:function(){o.policyModalTitle=r("checkout-page:termsOfService"),o.policyModalText=o.termsOfService}},r("checkout-page:termsOfService")))}));export{b as default};
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from'../../ext/lodash/cloneDeep.js';import r from'../../ext/lodash/sortBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as o,IkasCheckoutCustomer as a}from"../../models/data/checkout/index.js";import{IkasCustomerAddress as c}from"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import{IkasTransactionStatusEnum as d}from"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/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/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasOrderAddress as u}from"../../models/data/order/address/index.js";import{IkasPaymentMethodType as h,IkasPaymentGatewayType as l}from"../../models/data/payment-gateway/index.js";import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import{IkasCheckoutAPI as p}from"../../api/checkout/index.js";import"../../api/city/index.js";import{IkasCountryAPI as m}from"../../api/country/index.js";import{IkasCustomerAPI as f}from"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import{IkasMerchantAPI as g}from"../../api/merchant/index.js";import"../../api/product-search/index.js";import"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import v from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as S}from"../../storefront/index.js";import{IkasCheckoutSettings as k}from"../../models/data/checkout-settings/index.js";import{Analytics as y}from"../../analytics/analytics.js";import"react";import'../../ext/html-react-parser/index.js';import"../../analytics/events.js";import C from'../../ext/uuid/dist/esm-browser/v4.js';var b,I,P=/^\d+$/,A="undefined"==typeof localStorage,j=function(){function P(P,j,w,x,E,O,T,D){var G=this;this.checkout=new o,this.checkoutSettings=new k,this.storefront=null,this.store=S.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.step=b.INFO,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!1,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.policyModalTitle="",this.policyModalText="",this.error=null,this.init=function(){return t(G,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.store.customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getMerchantSettings()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(G,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(S.isEditor)return this.step=b.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===b.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(b.INFO)];if(this.step===b.PAYMENT&&!this.canProceedToPayment)return[2,this.changeStep(b.INFO)];if(![b.INFO,b.SUCCESS,b.SHIPPING,b.PAYMENT].includes(this.step))return[2,this.changeStep(b.INFO)]}return s&&(this.error={type:I.PAYMENT_ERROR,data:n||null}),this.step!==b.INFO?[3,2]:[4,this.getShippingCountries()];case 1:e.sent(),this.checkShippingCountries(),e.label=2;case 2:return this.step!==b.SHIPPING||1!==this.checkout.availableShippingMethods.length||this.checkoutSettings.isGiftPackageEnabled||(this.step=b.PAYMENT,this.router.replace("/checkout?id="+this.checkout.id+"&step="+this.step,void 0,{shallow:!0})),this.step!==b.SHIPPING||this.checkout.availableShippingMethods.length?this.step!==b.PAYMENT&&this.step!==b.SUCCESS?[3,4]:[4,this.listPaymentGateways()]:(this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 3:if(e.sent(),!this.paymentGateways.length)return this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=4;case 4:return this.step===b.SUCCESS?[3,8]:this.checkout.isComplete?[2,this.changeStep(b.SUCCESS)]:[3,5];case 5:return[4,this.initialStockCheck()];case 6:e.sent(),e.label=7;case 7:return[3,11];case 8:return r=this,[4,p.getOrder(this.checkout.orderId)];case 9:return r.order=e.sent(),[4,f.getOrderTransactions({orderId:this.checkout.orderId})];case 10:o=e.sent(),this.successTransaction=o.length?o[0]:void 0,this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===a}))),e.label=11;case 11:return this.isCheckoutLoaded=!0,y.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:(t=this,[4,g.listMerchantSettings()]);case 1:t.merchantSettings=e.sent(),e.label=2;case 2:return[2]}}))}))},this.saveCheckout=function(){return t(G,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:return[4,p.saveCheckout(this.checkout)];case 1:if((null==(t=e.sent())?void 0:t.errors)&&t.errors.length)throw i=t.errors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(s=i.extensions)||void 0===s?void 0:s.code)?{type:I.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:I.API_ERROR};return[2]}}))}))},this.checkStocks=function(){return t(G,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,h;return e(this,(function(e){switch(e.label){case 0:return t=this.cart.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,p.checkStocks(t,S.stockLocationIds||[])];case 1:if(!(i=e.sent()))throw{type:I.API_ERROR};if(null==(s=null===(u=i.lines)||void 0===u?void 0:u.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(h=o.store.cartStore.cart)||void 0===h?void 0:h.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push(e)},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:I.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(G,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,this.store.cartStore.removeItem(n)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,m.listShippingCountries(S.salesChannelId)];case 1:return t.shippingCountryIds=e.sent(),[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=G.shippingCountryIds)||void 0===t?void 0:t.length)||(G.error={type:I.NO_SHIPPING_ERROR})},this.initialStockCheck=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(G,void 0,void 0,(function(){var t,i,s,n,o,a,c=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=S.paymentGateways.map((function(t){return t.id})),[4,p.listPaymentGateway(t?void 0:i)];case 1:return(s=e.sent())&&s.length?(this.step===b.PAYMENT&&(s=s.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(c.checkout.cart.currencyCode)})),(n=null===(a=this.checkout.shippingAddress)||void 0===a?void 0:a.country)&&(s=s.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(n.iso2||"")})))),o=[],r(S.paymentGateways,"order").forEach((function(t){var e=null==s?void 0:s.find((function(e){return e.id===t.id}));e&&o.push(e)})),this.paymentGateways=t?s:o,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),[2]):(this.error={type:I.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p.retrieveInstallmentInfo(i)];case 1:return null==(t=e.sent())||t.installmentPrices.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=t,[2]}}))}))},this.createCustomer=function(){G.store.customerStore.customer?(G.store.customerStore.customer.addresses.forEach((function(t){return t.checkoutSettings=G.checkoutSettings})),G.checkout.customer=new a(G.store.customerStore.customer)):G.checkout.customer||(G.checkout.customer=new a({}))},this.createShippingAddress=function(){var t;if(G.checkout.shippingAddress)G.selectedShippingAddressId=G.checkout.shippingAddress.id||"-1",G.checkout.shippingAddress.checkoutSettings=G.checkoutSettings;else{var e=null===(t=G.store.customerStore.customer)||void 0===t?void 0:t.addresses;G.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(G.useDifferentAddress=!!localStorage.getItem("sAddr"),G.useDifferentAddress?(G.checkout.billingAddress&&(G.selectedBillingAddressId=G.checkout.billingAddress.id||"-1"),G.checkout.billingAddress=G.checkout.billingAddress||new u):G.checkout.billingAddress=new u(n(G.checkout.shippingAddress)||{}),G.checkout.billingAddress.checkoutSettings=G.checkoutSettings)},this.onShippingMethodChange=function(i){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCheckout()]);case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(this.checkout=t),this.isChangingShippingMethod=!1,[2]}}))}))},this.onCouponCodeApply=function(){return t(G,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!this.checkout.couponCode)return[2];e.label=1;case 1:return e.trys.push([1,5,,6]),[4,p.addCouponCodeToCheckout(this.checkout.id,this.checkout.couponCode)];case 2:return e.sent()?[4,p.getCheckoutById(this.checkout.id)]:[3,4];case 3:(t=e.sent())&&(s=this.checkout,this.checkout=new o(i(i({},t),{shippingAddress:s.shippingAddress,billingAddress:s.billingAddress,customer:s.customer}))),e.label=4;case 4:return[3,6];case 5:return e.sent(),[3,6];case 6:return[2]}}))}))},this.onCouponCodeDelete=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,this.saveCheckout()];case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(this.checkout=t),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(G.selectedShippingAddressId=t,"-1"===t)G.checkout.shippingAddress=new u;else{var i=null===(e=G.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(G.checkout.shippingAddress=new u(i))}G.checkout.shippingAddress&&(G.checkout.shippingAddress.checkoutSettings=G.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(G.selectedBillingAddressId=t,"-1"===t)G.checkout.billingAddress=new u;else{var i=null===(e=G.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(G.checkout.billingAddress=new u(i))}G.checkout.billingAddress&&(G.checkout.billingAddress.checkoutSettings=G.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){G.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(G.cardData&&(!(t.length>G.cardData.cardNumber.length)||N(t))){var e=(G.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!G.installmentInfo?G.retrieveInstallmentInfo({binNumber:i.slice(0,6),paymentGatewayId:G.checkout.selectedPaymentGateway.id,price:G.checkout.totalFinalPrice}):i.length<6&&e.length>i.length&&(G.cardData.installmentCount=1,G.installmentInfo=void 0),G.cardData.cardNumber=R(i,4).join(" "))}},this.onCardHolderNameChange=function(t){G.cardData&&(G.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(G.cardData&&(!(t.length>G.cardData.expirationDate.length)||N(t))){if(0===(null===(e=G.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(G.cardData.expirationDate=(o<10?"0"+o:o)+" / "+(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(G.cardData.expirationDate=(o<10?"0"+o:o)+" / "+(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(G.cardData.expirationDate=R(a,2).join(" / "))}},this.onCvcChange=function(t){G.cardData&&(t.length>G.cardData.cvv.length&&!N(t)||t.length>4||(G.cardData.cvv=t))},this.saveAddress=function(s){return t(G,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this.shouldSaveAddress?(t=new c(i(i({},"shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:C()})),(r=n(this.store.customerStore.customer)).addresses.push(t),[4,this.store.customerStore.saveCustomer(r)]):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=t.id,this.selectedShippingAddressId=t.id||"-1"):(this.checkout.billingAddress.id=t.id,this.selectedBillingAddressId=t.id||"-1"),e.label=2;case 2:return[2]}}))}))},this.onGoToCartClick=function(){G.router.push("/cart")},this.onBackToShoppingClick=function(){G.router.push("/")},this.onProceedToShippingClick=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,5,,6]),this.isStepLoading=!0,[4,this.saveAddress("shipping")];case 2:return e.sent(),[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),this.changeStep(b.SHIPPING),[3,6];case 5:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,6];case 6:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCheckout()];case 3:return e.sent(),this.error=void 0,this.changeStep(b.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),e.label=1;case 1:return e.trys.push([1,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveAddress("billing")];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(t=e.sent()).type?this.error=t:this.error={type:I.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(G,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?[4,p.createSaleTransactionWithCheckout(this.checkout.id,this.checkout.selectedPaymentGateway.id,this.checkout.selectedPaymentGateway.paymentMethodType===h.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===l.INTERNAL&&this.cardData?this.cardData.toInput():void 0)]:[2];case 1:return t=e.sent(),i=null==t?void 0:t.transactionStatus,s=i&&[d.SUCCESS,d.AUTHORIZED].includes(i),n=i===d.PENDING,s?[4,this.onCheckoutTransactionSuccess()]:[3,3];case 2:return e.sent(),[3,4];case 3:if(!n||!(null==t?void 0:t.returnSlug))throw{type:I.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+t.returnSlug,e.label=4;case 4:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(G,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(b.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){G.changeStep(b.INFO)},this.onBackToShippingClick=function(){G.changeStep(b.SHIPPING)},this.setCustomerConsentGranted=function(t){G.checkout.customer&&(G.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){G.useDifferentAddress=t,G.useDifferentAddress?(localStorage.setItem("sAddr","1"),G.checkout.billingAddress=G.checkout.billingAddress||new u):(localStorage.removeItem("sAddr"),G.checkout.billingAddress=G.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){G.shouldSaveAddress=t},this.setAddressTitle=function(t){G.addressTitle=t},this.setPaymentGateway=function(t){if(G.paymentGateways.length){var e=G.paymentGateways[t];G.checkout.selectedPaymentGateway=e,G.step!==b.SUCCESS&&(e.paymentMethodType===h.CREDIT_CARD&&e.type===l.INTERNAL&&(G.cardData=new v),G.installmentInfo=void 0)}},this.setInstallmentCount=function(t){G.cardData&&(G.cardData.installmentCount=t)},this.changeStep=function(i){return t(G,void 0,void 0,(function(){return e(this,(function(t){return A||window.location.replace(window.location.pathname+"?id="+this.checkout.id+"&step="+i),[2]}))}))},this.logout=function(){return t(G,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=void 0,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCheckout()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.checkout=P,this.checkoutSettings=j,this.router=x,this.returnPolicy=E,this.privacyPolicy=O,this.termsOfService=T,this.t=D,w&&(this.merchantSettings=w),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked,this.store.cartStore.cart=this.checkout.cart,this.init(),s(this)}return Object.defineProperty(P.prototype,"cart",{get:function(){return this.checkout.cart},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"selectedInstallmentIndex",{get:function(){var t,e=this;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices.findIndex((function(t){var i;return t.installmentCount===(null===(i=e.cardData)||void 0===i?void 0:i.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"checkoutUrl",{get:function(){return"/checkout?id="+this.checkout.id+"&step=info"},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"customerAddressOptions",{get:function(){var t,e={label:this.t("checkout-page:newAddress"),value:"-1"},i=(null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[e].concat(i)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentPrice",{get:function(){var t,e,i=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(e=this.installmentInfo.installmentPrices.find((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===e?void 0:e.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"finalPrice",{get:function(){return this.step===b.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===I.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomer&&(null===(e=this.error)||void 0===e?void 0:e.type)!==I.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway;return this.canProceedToShipping&&!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid)&&((null==i?void 0:i.paymentMethodType)!==h.CREDIT_CARD||i.type!==l.INTERNAL||(null===(e=this.cardData)||void 0===e?void 0:e.isValid))},enumerable:!1,configurable:!0}),P}();function R(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function N(t){return t&&P.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(b||(b={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(I||(I={}));export{b as CheckoutStep,I as ErrorType,j as default};
1
+ import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from'../../ext/lodash/cloneDeep.js';import r from'../../ext/lodash/sortBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as o,IkasCheckoutCustomer as a}from"../../models/data/checkout/index.js";import{IkasCustomerAddress as c}from"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import{IkasTransactionStatusEnum as d}from"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/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/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasOrderAddress as u}from"../../models/data/order/address/index.js";import{IkasPaymentMethodType as h,IkasPaymentGatewayType as l}from"../../models/data/payment-gateway/index.js";import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import{IkasCheckoutAPI as p}from"../../api/checkout/index.js";import"../../api/city/index.js";import{IkasCountryAPI as m}from"../../api/country/index.js";import{IkasCustomerAPI as f}from"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import{IkasMerchantAPI as g}from"../../api/merchant/index.js";import"../../api/product-search/index.js";import"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import v from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as S}from"../../storefront/index.js";import{IkasCheckoutSettings as k}from"../../models/data/checkout-settings/index.js";import{Analytics as y}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import C from'../../ext/uuid/dist/esm-browser/v4.js';var b,I,P=/^\d+$/,A="undefined"==typeof localStorage,j=function(){function P(P,j,w,x,E,O,T,D){var G=this;this.checkout=new o,this.checkoutSettings=new k,this.storefront=null,this.store=S.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.step=b.INFO,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!1,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.policyModalTitle="",this.policyModalText="",this.error=null,this.init=function(){return t(G,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.store.customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getMerchantSettings()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(G,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(S.isEditor)return this.step=b.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===b.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(b.INFO)];if(this.step===b.PAYMENT&&!this.canProceedToPayment)return[2,this.changeStep(b.INFO)];if(![b.INFO,b.SUCCESS,b.SHIPPING,b.PAYMENT].includes(this.step))return[2,this.changeStep(b.INFO)]}return s&&(this.error={type:I.PAYMENT_ERROR,data:n||null}),this.step!==b.INFO?[3,2]:[4,this.getShippingCountries()];case 1:e.sent(),this.checkShippingCountries(),e.label=2;case 2:return this.step!==b.SHIPPING||1!==this.checkout.availableShippingMethods.length||this.checkoutSettings.isGiftPackageEnabled||(this.step=b.PAYMENT,this.router.replace("/checkout?id="+this.checkout.id+"&step="+this.step,void 0,{shallow:!0})),this.step!==b.SHIPPING||this.checkout.availableShippingMethods.length?this.step!==b.PAYMENT&&this.step!==b.SUCCESS?[3,4]:[4,this.listPaymentGateways()]:(this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 3:if(e.sent(),!this.paymentGateways.length)return this.error={type:I.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=4;case 4:return this.step===b.SUCCESS?[3,8]:this.checkout.isComplete?[2,this.changeStep(b.SUCCESS)]:[3,5];case 5:return[4,this.initialStockCheck()];case 6:e.sent(),e.label=7;case 7:return[3,11];case 8:return r=this,[4,p.getOrder(this.checkout.orderId)];case 9:return r.order=e.sent(),[4,f.getOrderTransactions({orderId:this.checkout.orderId})];case 10:o=e.sent(),this.successTransaction=o.length?o[0]:void 0,this.successTransaction&&(a=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===a}))),e.label=11;case 11:return this.isCheckoutLoaded=!0,y.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:(t=this,[4,g.listMerchantSettings()]);case 1:t.merchantSettings=e.sent(),e.label=2;case 2:return[2]}}))}))},this.saveCheckout=function(){return t(G,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:return[4,p.saveCheckout(this.checkout)];case 1:if((null==(t=e.sent())?void 0:t.errors)&&t.errors.length)throw i=t.errors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(s=i.extensions)||void 0===s?void 0:s.code)?{type:I.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:I.API_ERROR};return[2]}}))}))},this.checkStocks=function(){return t(G,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,h;return e(this,(function(e){switch(e.label){case 0:return t=this.cart.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,p.checkStocks(t,S.stockLocationIds||[])];case 1:if(!(i=e.sent()))throw{type:I.API_ERROR};if(null==(s=null===(u=i.lines)||void 0===u?void 0:u.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(h=o.store.cartStore.cart)||void 0===h?void 0:h.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push(e)},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:I.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(G,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,this.store.cartStore.removeItem(n)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,m.listShippingCountries(S.salesChannelId)];case 1:return t.shippingCountryIds=e.sent(),[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=G.shippingCountryIds)||void 0===t?void 0:t.length)||(G.error={type:I.NO_SHIPPING_ERROR})},this.initialStockCheck=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(G,void 0,void 0,(function(){var t,i,s,n,o,a,c=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=S.paymentGateways.map((function(t){return t.id})),[4,p.listPaymentGateway(t?void 0:i)];case 1:return(s=e.sent())&&s.length?(this.step===b.PAYMENT&&(s=s.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(c.checkout.cart.currencyCode)})),(n=null===(a=this.checkout.shippingAddress)||void 0===a?void 0:a.country)&&(s=s.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(n.iso2||"")})))),o=[],r(S.paymentGateways,"order").forEach((function(t){var e=null==s?void 0:s.find((function(e){return e.id===t.id}));e&&o.push(e)})),this.paymentGateways=t?s:o,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),[2]):(this.error={type:I.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p.retrieveInstallmentInfo(i)];case 1:return null==(t=e.sent())||t.installmentPrices.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=t,[2]}}))}))},this.createCustomer=function(){G.store.customerStore.customer?(G.store.customerStore.customer.addresses.forEach((function(t){return t.checkoutSettings=G.checkoutSettings})),G.checkout.customer=new a(G.store.customerStore.customer)):G.checkout.customer||(G.checkout.customer=new a({}))},this.createShippingAddress=function(){var t;if(G.checkout.shippingAddress)G.selectedShippingAddressId=G.checkout.shippingAddress.id||"-1",G.checkout.shippingAddress.checkoutSettings=G.checkoutSettings;else{var e=null===(t=G.store.customerStore.customer)||void 0===t?void 0:t.addresses;G.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(G.useDifferentAddress=!!localStorage.getItem("sAddr"),G.useDifferentAddress?(G.checkout.billingAddress&&(G.selectedBillingAddressId=G.checkout.billingAddress.id||"-1"),G.checkout.billingAddress=G.checkout.billingAddress||new u):G.checkout.billingAddress=new u(n(G.checkout.shippingAddress)||{}),G.checkout.billingAddress.checkoutSettings=G.checkoutSettings)},this.onShippingMethodChange=function(i){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCheckout()]);case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(this.checkout=t),this.isChangingShippingMethod=!1,[2]}}))}))},this.onCouponCodeApply=function(){return t(G,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!this.checkout.couponCode)return[2];e.label=1;case 1:return e.trys.push([1,5,,6]),[4,p.addCouponCodeToCheckout(this.checkout.id,this.checkout.couponCode)];case 2:return e.sent()?[4,p.getCheckoutById(this.checkout.id)]:[3,4];case 3:(t=e.sent())&&(s=this.checkout,this.checkout=new o(i(i({},t),{shippingAddress:s.shippingAddress,billingAddress:s.billingAddress,customer:s.customer}))),e.label=4;case 4:return[3,6];case 5:return e.sent(),[3,6];case 6:return[2]}}))}))},this.onCouponCodeDelete=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,this.saveCheckout()];case 1:return e.sent(),[4,p.getCheckoutById(this.checkout.id)];case 2:return(t=e.sent())&&(this.checkout=t),[3,4];case 3:return e.sent(),[3,4];case 4:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e;if(G.selectedShippingAddressId=t,"-1"===t)G.checkout.shippingAddress=new u;else{var i=null===(e=G.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(G.checkout.shippingAddress=new u(i))}G.checkout.shippingAddress&&(G.checkout.shippingAddress.checkoutSettings=G.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e;if(G.selectedBillingAddressId=t,"-1"===t)G.checkout.billingAddress=new u;else{var i=null===(e=G.store.customerStore.customer)||void 0===e?void 0:e.addresses.find((function(e){return e.id===t}));i&&(G.checkout.billingAddress=new u(i))}G.checkout.billingAddress&&(G.checkout.billingAddress.checkoutSettings=G.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){G.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(G.cardData&&(!(t.length>G.cardData.cardNumber.length)||N(t))){var e=(G.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!G.installmentInfo?G.retrieveInstallmentInfo({binNumber:i.slice(0,6),paymentGatewayId:G.checkout.selectedPaymentGateway.id,price:G.checkout.totalFinalPrice}):i.length<6&&e.length>i.length&&(G.cardData.installmentCount=1,G.installmentInfo=void 0),G.cardData.cardNumber=R(i,4).join(" "))}},this.onCardHolderNameChange=function(t){G.cardData&&(G.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(G.cardData&&(!(t.length>G.cardData.expirationDate.length)||N(t))){if(0===(null===(e=G.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(G.cardData.expirationDate=(o<10?"0"+o:o)+" / "+(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(G.cardData.expirationDate=(o<10?"0"+o:o)+" / "+(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(G.cardData.expirationDate=R(a,2).join(" / "))}},this.onCvcChange=function(t){G.cardData&&(t.length>G.cardData.cvv.length&&!N(t)||t.length>4||(G.cardData.cvv=t))},this.saveAddress=function(s){return t(G,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this.shouldSaveAddress?(t=new c(i(i({},"shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:C()})),(r=n(this.store.customerStore.customer)).addresses.push(t),[4,this.store.customerStore.saveCustomer(r)]):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=t.id,this.selectedShippingAddressId=t.id||"-1"):(this.checkout.billingAddress.id=t.id,this.selectedBillingAddressId=t.id||"-1"),e.label=2;case 2:return[2]}}))}))},this.onGoToCartClick=function(){G.router.push("/cart")},this.onBackToShoppingClick=function(){G.router.push("/")},this.onProceedToShippingClick=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,5,,6]),this.isStepLoading=!0,[4,this.saveAddress("shipping")];case 2:return e.sent(),[4,this.checkStocks()];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),this.changeStep(b.SHIPPING),[3,6];case 5:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,6];case 6:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCheckout()];case 3:return e.sent(),this.error=void 0,this.changeStep(b.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:I.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(G,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),e.label=1;case 1:return e.trys.push([1,6,,7]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveAddress("billing")];case 3:return e.sent(),[4,this.saveCheckout()];case 4:return e.sent(),[4,this.createSaleTransaction()];case 5:return e.sent(),[3,7];case 6:return(t=e.sent()).type?this.error=t:this.error={type:I.UNKNOWN},this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.createSaleTransaction=function(){return t(G,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return this.checkout.selectedPaymentGateway?[4,p.createSaleTransactionWithCheckout(this.checkout.id,this.checkout.selectedPaymentGateway.id,this.checkout.selectedPaymentGateway.paymentMethodType===h.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===l.INTERNAL&&this.cardData?this.cardData.toInput():void 0)]:[2];case 1:return t=e.sent(),i=null==t?void 0:t.transactionStatus,s=i&&[d.SUCCESS,d.AUTHORIZED].includes(i),n=i===d.PENDING,s?[4,this.onCheckoutTransactionSuccess()]:[3,3];case 2:return e.sent(),[3,4];case 3:if(!n||!(null==t?void 0:t.returnSlug))throw{type:I.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+t.returnSlug,e.label=4;case 4:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(G,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(b.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){G.changeStep(b.INFO)},this.onBackToShippingClick=function(){G.changeStep(b.SHIPPING)},this.setCustomerConsentGranted=function(t){G.checkout.customer&&(G.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){G.useDifferentAddress=t,G.useDifferentAddress?(localStorage.setItem("sAddr","1"),G.checkout.billingAddress=G.checkout.billingAddress||new u):(localStorage.removeItem("sAddr"),G.checkout.billingAddress=G.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){G.shouldSaveAddress=t},this.setAddressTitle=function(t){G.addressTitle=t},this.setPaymentGateway=function(t){if(G.paymentGateways.length){var e=G.paymentGateways[t];G.checkout.selectedPaymentGateway=e,G.step!==b.SUCCESS&&(e.paymentMethodType===h.CREDIT_CARD&&e.type===l.INTERNAL&&(G.cardData=new v),G.installmentInfo=void 0)}},this.setInstallmentCount=function(t){G.cardData&&(G.cardData.installmentCount=t)},this.changeStep=function(i){return t(G,void 0,void 0,(function(){return e(this,(function(t){return A||window.location.replace(window.location.pathname+"?id="+this.checkout.id+"&step="+i),[2]}))}))},this.logout=function(){return t(G,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=void 0,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCheckout()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.checkout=P,this.checkoutSettings=j,this.router=x,this.returnPolicy=E,this.privacyPolicy=O,this.termsOfService=T,this.t=D,w&&(this.merchantSettings=w),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked,this.store.cartStore.cart=this.checkout.cart,this.init(),s(this)}return Object.defineProperty(P.prototype,"cart",{get:function(){return this.checkout.cart},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"selectedInstallmentIndex",{get:function(){var t,e=this;return(null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices.findIndex((function(t){var i;return t.installmentCount===(null===(i=e.cardData)||void 0===i?void 0:i.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"checkoutUrl",{get:function(){return"/checkout?id="+this.checkout.id+"&step=info"},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"customerAddressOptions",{get:function(){var t,e={label:this.t("checkout-page:newAddress"),value:"-1"},i=(null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[e].concat(i)},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentPrice",{get:function(){var t,e,i=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(e=this.installmentInfo.installmentPrices.find((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===e?void 0:e.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"finalPrice",{get:function(){return this.step===b.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===I.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomer&&(null===(e=this.error)||void 0===e?void 0:e.type)!==I.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(P.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway;return this.canProceedToShipping&&!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid)&&((null==i?void 0:i.paymentMethodType)!==h.CREDIT_CARD||i.type!==l.INTERNAL||(null===(e=this.cardData)||void 0===e?void 0:e.isValid))},enumerable:!1,configurable:!0}),P}();function R(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function N(t){return t&&P.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(b||(b={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(I||(I={}));export{b as CheckoutStep,I as ErrorType,j as default};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'../../../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as a}from"mobx-react-lite";import{Button as s}from"../../components/button/index.js";import{CART_LS_KEY as r,CHECKOUT_LS_KEY as i}from"../../../../store/cart.js";import n from"./style.module.scss.js";import{Analytics as l}from"../../../../analytics/analytics.js";import"../../../../storefront/index.js";import'../../../../ext/html-react-parser/index.js';import"../../../../analytics/events.js";import c from"../../components/svg/success-circle.js";import m from"../../components/expandable-section/index.js";import{IkasTransactionCardAssociationEnum as d}from"../../../../models/data/order-transaction/index.js";import u from"../../components/credit-card-form/svg/amex.js";import p from"../../components/credit-card-form/svg/master-card.js";import v from"../../components/credit-card-form/svg/troy.js";import E from"../../components/credit-card-form/svg/visa.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{formatMoney as f}from"../../../../utils/currency.js";import{useTranslation as g}from"../../../../utils/i18n.js";import{Modal as h}from"../../components/modal/index.js";import{FormItem as x}from"../../components/form-item/index.js";import{FormItemType as j}from"../../components/form-item/model.js";import{ContactForm as k}from"../../../../models/ui/validator/form/contact-form.js";import T from"../../components/notification-box/index.js";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/checkout/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/customer-review/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import"../../../../models/data/installment-info/index.js";import{IkasOrderPackageStatus as N}from"../../../../models/data/order/index.js";import"../../../../models/data/order/line-item/index.js";import"mobx";import"../../../../models/data/product/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product-attribute/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product-filter/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/data/product-option-set/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/theme/theme.js";import"../../../../models/theme/page/index.js";import"../../../../models/theme/component/prop/index.js";import"../../../../models/theme/page/component/prop-value/link.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-detail/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/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/register.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"../../../../models/theme/settings/index.js";import"../../../../models/theme/custom-data/index.js";import{IkasPaymentMethodType as I,IkasPaymentGatewayType as y}from"../../../../models/data/payment-gateway/index.js";var A=a((function(e){var t,a,h,x,j=e.vm,k=g().t,T=o.useState(!1),N=T[0],A=T[1];o.useEffect((function(){if("undefined"!=typeof localStorage){var e=localStorage.getItem(r),t=localStorage.getItem(i);e&&e===j.checkout.cartId&&localStorage.removeItem(r),t&&t===j.checkout.id&&localStorage.removeItem(i)}j.successTransaction&&l.purchase(j.checkout,j.successTransaction)}),[]);var S=((null===(t=j.checkout.customer)||void 0===t?void 0:t.firstName)||"")+" "+((null===(a=j.checkout.customer)||void 0===a?void 0:a.lastName)||""),D=j.paymentGateways.find((function(e){var t;return e.id===(null===(t=j.successTransaction)||void 0===t?void 0:t.paymentGatewayId)})),R=null===(h=j.successTransaction)||void 0===h?void 0:h.paymentMethodDetail,b=o.useMemo((function(){var e,t,a,s;return o.createElement("div",{className:[n.InfoGrid].join(" ")},o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:paymentMethod")),D&&o.createElement(o.Fragment,null,!!D.logoUrl&&o.createElement("div",{className:n.PaymentLogoContainer},o.createElement("img",{src:D.logoUrl})),!D.logoUrl&&o.createElement("div",{className:n.InfoText},D.paymentMethodType===I.CREDIT_CARD&&D.type===y.INTERNAL?k("checkout-page:creditCard"):D.name),!!D.description&&D.type!==y.EXTERNAL&&o.createElement("div",{className:n.InfoText},o.createElement("div",{dangerouslySetInnerHTML:{__html:D.description}}))),"CREDIT_CARD"===(null===(e=j.successTransaction)||void 0===e?void 0:e.paymentMethod)&&o.createElement(o.Fragment,null,o.createElement("div",{className:n.InfoText},o.createElement("div",{className:n.CardLogoContainer},function(){var e,t;switch(null===(t=null===(e=j.successTransaction)||void 0===e?void 0:e.paymentMethodDetail)||void 0===t?void 0:t.cardAssociation){case d.AMERICAN_EXPRESS:return o.createElement(u,null);case d.MASTER_CARD:return o.createElement(p,null);case d.TROY:return o.createElement(v,null);case d.VISA:return o.createElement(E,null);default:return o.createElement("div",null)}}()),o.createElement("span",null,"**** "+((null==R?void 0:R.lastFourDigits)||""))),(null===(t=null==R?void 0:R.installment)||void 0===t?void 0:t.installmentCount)&&R.installment.installmentCount>1&&o.createElement(o.Fragment,null,o.createElement("div",{className:n.InfoText},R.installment.installmentCount+" "+k("checkout-page:installments")),null!==R.installment.installmentPrice&&o.createElement("div",{className:n.InfoText},R.installment.installmentCount+" x "+f(R.installment.installmentPrice,j.checkout.cart.currencyCode))))),o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:billingAddress")),!!(null===(a=j.checkout.billingAddress)||void 0===a?void 0:a.company)&&o.createElement("div",{className:[n.InfoText,n.InfoTextBold].join(" ")},j.checkout.billingAddress.company),o.createElement("div",{className:n.InfoText},null===(s=j.checkout.billingAddress)||void 0===s?void 0:s.addressText)))}),[]),_=o.useMemo((function(){var e,t,a,s,r;return o.createElement("div",{className:[n.InfoGrid].join(" ")},o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:contactInfo")),o.createElement("div",{className:n.InfoText},null===(e=j.checkout.customer)||void 0===e?void 0:e.email),o.createElement("div",{className:n.InfoText},S),!!(null===(t=j.checkout.shippingAddress)||void 0===t?void 0:t.phone)&&o.createElement("div",{className:n.InfoText},null===(a=j.checkout.shippingAddress)||void 0===a?void 0:a.phone)),o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:shippingAddress")),!!(null===(s=j.checkout.shippingAddress)||void 0===s?void 0:s.company)&&o.createElement("div",{className:[n.InfoText,n.InfoTextBold].join(" ")},j.checkout.shippingAddress.company),o.createElement("div",{className:n.InfoText},null===(r=j.checkout.shippingAddress)||void 0===r?void 0:r.addressText)))}),[]);return o.createElement("div",{className:n.StepSuccess},o.createElement("div",{className:n.SuccessTitleContainer},o.createElement(c,null),o.createElement("span",{className:n.SuccessTitle},k("checkout-page:orderSuccessTitle"))),o.createElement("div",{className:n.SuccessSubTitle},k("checkout-page:orderSuccessDescription",{customerName:S})),o.createElement("div",{className:[n.InfoGrid,n.WithBorder].join(" ")},o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:orderNoAndDate")),o.createElement("div",{className:[n.InfoText,n.InfoTextBold].join(" ")},"#"+(j.checkout.orderNumber||"")),o.createElement("div",{className:n.InfoText},j.checkout.dateStr),o.createElement(C,{vm:j})),o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:contactInfo")),o.createElement("div",{className:n.InfoText},null===(x=j.checkout.customer)||void 0===x?void 0:x.email),o.createElement("div",{className:n.InfoText},S))),o.createElement(m,{title:k("checkout-page:paymentSummary")},b),o.createElement(m,{title:k("checkout-page:shippingSummary")},_),o.createElement("div",{className:n.Actions},o.createElement("div",{className:n.HelpText},o.createElement("span",null,k("checkout-page:helpCtaQuestion")),o.createElement("span",{className:n.Cta,onClick:function(){return A(!0)}},k("checkout-page:helpCta"))),o.createElement(s,{text:k("checkout-page:actions.backToShopping"),onClick:j.onBackToShoppingClick,style:{flex:"0 0 auto"}})),N&&o.createElement(L,{vm:j,setVisible:A}))})),L=a((function(a){var r,i,n=a.vm,l=a.setVisible,c=g().t,m=o.useState(!1),d=m[0],u=m[1],p=o.useState(!1),v=p[0],E=p[1],f=o.useState(new k({message:{requiredRule:"",emailRule:"",minRule:""},store:n.store}))[0];f.email=n.checkout.customerEmail,f.firstName=(null===(r=n.checkout.customer)||void 0===r?void 0:r.firstName)||"",f.lastName=(null===(i=n.checkout.customer)||void 0===i?void 0:i.lastName)||"";var N=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return v?[2,l(!1)]:(u(!0),[4,f.saveContactForm()]);case 1:return e.sent()&&E(!0),u(!1),[2]}}))}))}),[d]);return o.createElement(h,{title:c("checkout-page:contactForm"),modalContent:o.createElement("div",null,v&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(T,{type:"success",title:c("checkout-page:contactFormSent"),content:c("checkout-page:contactFormDescription")})),o.createElement(x,{type:j.TEXT_AREA,label:"",value:f.message||"",onChange:f.onMessageChange,textAreaPlaceholder:c("checkout-page:contactFormCta")}),o.createElement(s,{style:{width:"100%",marginTop:"24px"},text:c(v?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:d,isDisabled:!f.message,onClick:N})),onClose:function(){return l(!1)}})})),C=a((function(e){var t,a,s,r=e.vm,i=g().t,l=n.Yellow;switch(null===(t=r.order)||void 0===t?void 0:t.orderPackageStatus){case N.FULFILLED:case N.PARTIALLY_FULFILLED:case N.DELIVERED:case N.PARTIALLY_DELIVERED:l=n.Green;break;case N.CANCELLED:case N.PARTIALLY_CANCELLED:case N.CANCEL_REJECTED:case N.CANCEL_REQUESTED:l=n.Red}return o.createElement("div",{className:[n.OrderStatus,l].join(" ")},(null===(a=r.order)||void 0===a?void 0:a.orderPackageStatus)?null===(s=[{types:[N.UNFULFILLED],text:i("checkout-page:orderPackageStatus.unfulfilled")},{types:[N.READY_FOR_SHIPMENT],text:i("checkout-page:orderPackageStatus.readyForShipment")},{types:[N.PARTIALLY_FULFILLED],text:i("checkout-page:orderPackageStatus.partiallyFulfilled")},{types:[N.FULFILLED],text:i("checkout-page:orderPackageStatus.fulfilled")},{types:[N.DELIVERED,N.PARTIALLY_DELIVERED],text:i("checkout-page:orderPackageStatus.delivered")},{types:[N.UNABLE_TO_DELIVER],text:i("checkout-page:orderPackageStatus.unableToDeliver")},{types:[N.CANCELLED,N.PARTIALLY_CANCELLED],text:i("checkout-page:orderPackageStatus.cancelled")},{types:[N.CANCEL_REJECTED],text:i("checkout-page:orderPackageStatus.cancelRejected")},{types:[N.REFUNDED,N.PARTIALLY_REFUNDED],text:i("checkout-page:orderPackageStatus.refunded")},{types:[N.REFUND_REQUEST_ACCEPTED],text:i("checkout-page:orderPackageStatus.refundRequestAccepted")},{types:[N.REFUND_REJECTED],text:i("checkout-page:orderPackageStatus.refundRejected")},{types:[N.REFUND_REQUESTED],text:i("checkout-page:orderPackageStatus.refundRequested")}].find((function(e){return e.types.includes(r.order.orderPackageStatus)})))||void 0===s?void 0:s.text:"")}));export{A as StepSuccess};
1
+ import{__awaiter as e,__generator as t}from'../../../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as a}from"mobx-react-lite";import{Button as s}from"../../components/button/index.js";import{CART_LS_KEY as r,CHECKOUT_LS_KEY as i}from"../../../../store/cart.js";import n from"./style.module.scss.js";import{Analytics as l}from"../../../../analytics/analytics.js";import"../../../../analytics/head/index.js";import c from"../../components/svg/success-circle.js";import m from"../../components/expandable-section/index.js";import{IkasTransactionCardAssociationEnum as d}from"../../../../models/data/order-transaction/index.js";import u from"../../components/credit-card-form/svg/amex.js";import p from"../../components/credit-card-form/svg/master-card.js";import v from"../../components/credit-card-form/svg/troy.js";import E from"../../components/credit-card-form/svg/visa.js";import"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{formatMoney as f}from"../../../../utils/currency.js";import{useTranslation as g}from"../../../../utils/i18n.js";import{Modal as h}from"../../components/modal/index.js";import{FormItem as x}from"../../components/form-item/index.js";import{FormItemType as j}from"../../components/form-item/model.js";import{ContactForm as k}from"../../../../models/ui/validator/form/contact-form.js";import T from"../../components/notification-box/index.js";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/checkout/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/customer-review/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import"../../../../models/data/installment-info/index.js";import{IkasOrderPackageStatus as N}from"../../../../models/data/order/index.js";import"../../../../models/data/order/line-item/index.js";import"mobx";import"../../../../models/data/product/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product-attribute/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product-filter/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/data/product-option-set/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/theme/theme.js";import"../../../../models/theme/page/index.js";import"../../../../models/theme/component/prop/index.js";import"../../../../models/theme/page/component/prop-value/link.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-detail/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/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/register.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"../../../../models/theme/settings/index.js";import"../../../../models/theme/custom-data/index.js";import{IkasPaymentMethodType as I,IkasPaymentGatewayType as y}from"../../../../models/data/payment-gateway/index.js";var A=a((function(e){var t,a,h,x,j=e.vm,k=g().t,T=o.useState(!1),N=T[0],A=T[1];o.useEffect((function(){if("undefined"!=typeof localStorage){var e=localStorage.getItem(r),t=localStorage.getItem(i);e&&e===j.checkout.cartId&&localStorage.removeItem(r),t&&t===j.checkout.id&&localStorage.removeItem(i)}j.successTransaction&&l.purchase(j.checkout,j.successTransaction)}),[]);var S=((null===(t=j.checkout.customer)||void 0===t?void 0:t.firstName)||"")+" "+((null===(a=j.checkout.customer)||void 0===a?void 0:a.lastName)||""),D=j.paymentGateways.find((function(e){var t;return e.id===(null===(t=j.successTransaction)||void 0===t?void 0:t.paymentGatewayId)})),R=null===(h=j.successTransaction)||void 0===h?void 0:h.paymentMethodDetail,b=o.useMemo((function(){var e,t,a,s;return o.createElement("div",{className:[n.InfoGrid].join(" ")},o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:paymentMethod")),D&&o.createElement(o.Fragment,null,!!D.logoUrl&&o.createElement("div",{className:n.PaymentLogoContainer},o.createElement("img",{src:D.logoUrl})),!D.logoUrl&&o.createElement("div",{className:n.InfoText},D.paymentMethodType===I.CREDIT_CARD&&D.type===y.INTERNAL?k("checkout-page:creditCard"):D.name),!!D.description&&D.type!==y.EXTERNAL&&o.createElement("div",{className:n.InfoText},o.createElement("div",{dangerouslySetInnerHTML:{__html:D.description}}))),"CREDIT_CARD"===(null===(e=j.successTransaction)||void 0===e?void 0:e.paymentMethod)&&o.createElement(o.Fragment,null,o.createElement("div",{className:n.InfoText},o.createElement("div",{className:n.CardLogoContainer},function(){var e,t;switch(null===(t=null===(e=j.successTransaction)||void 0===e?void 0:e.paymentMethodDetail)||void 0===t?void 0:t.cardAssociation){case d.AMERICAN_EXPRESS:return o.createElement(u,null);case d.MASTER_CARD:return o.createElement(p,null);case d.TROY:return o.createElement(v,null);case d.VISA:return o.createElement(E,null);default:return o.createElement("div",null)}}()),o.createElement("span",null,"**** "+((null==R?void 0:R.lastFourDigits)||""))),(null===(t=null==R?void 0:R.installment)||void 0===t?void 0:t.installmentCount)&&R.installment.installmentCount>1&&o.createElement(o.Fragment,null,o.createElement("div",{className:n.InfoText},R.installment.installmentCount+" "+k("checkout-page:installments")),null!==R.installment.installmentPrice&&o.createElement("div",{className:n.InfoText},R.installment.installmentCount+" x "+f(R.installment.installmentPrice,j.checkout.cart.currencyCode))))),o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:billingAddress")),!!(null===(a=j.checkout.billingAddress)||void 0===a?void 0:a.company)&&o.createElement("div",{className:[n.InfoText,n.InfoTextBold].join(" ")},j.checkout.billingAddress.company),o.createElement("div",{className:n.InfoText},null===(s=j.checkout.billingAddress)||void 0===s?void 0:s.addressText)))}),[]),_=o.useMemo((function(){var e,t,a,s,r;return o.createElement("div",{className:[n.InfoGrid].join(" ")},o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:contactInfo")),o.createElement("div",{className:n.InfoText},null===(e=j.checkout.customer)||void 0===e?void 0:e.email),o.createElement("div",{className:n.InfoText},S),!!(null===(t=j.checkout.shippingAddress)||void 0===t?void 0:t.phone)&&o.createElement("div",{className:n.InfoText},null===(a=j.checkout.shippingAddress)||void 0===a?void 0:a.phone)),o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:shippingAddress")),!!(null===(s=j.checkout.shippingAddress)||void 0===s?void 0:s.company)&&o.createElement("div",{className:[n.InfoText,n.InfoTextBold].join(" ")},j.checkout.shippingAddress.company),o.createElement("div",{className:n.InfoText},null===(r=j.checkout.shippingAddress)||void 0===r?void 0:r.addressText)))}),[]);return o.createElement("div",{className:n.StepSuccess},o.createElement("div",{className:n.SuccessTitleContainer},o.createElement(c,null),o.createElement("span",{className:n.SuccessTitle},k("checkout-page:orderSuccessTitle"))),o.createElement("div",{className:n.SuccessSubTitle},k("checkout-page:orderSuccessDescription",{customerName:S})),o.createElement("div",{className:[n.InfoGrid,n.WithBorder].join(" ")},o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:orderNoAndDate")),o.createElement("div",{className:[n.InfoText,n.InfoTextBold].join(" ")},"#"+(j.checkout.orderNumber||"")),o.createElement("div",{className:n.InfoText},j.checkout.dateStr),o.createElement(C,{vm:j})),o.createElement("div",null,o.createElement("div",{className:n.InfoTitle},k("checkout-page:contactInfo")),o.createElement("div",{className:n.InfoText},null===(x=j.checkout.customer)||void 0===x?void 0:x.email),o.createElement("div",{className:n.InfoText},S))),o.createElement(m,{title:k("checkout-page:paymentSummary")},b),o.createElement(m,{title:k("checkout-page:shippingSummary")},_),o.createElement("div",{className:n.Actions},o.createElement("div",{className:n.HelpText},o.createElement("span",null,k("checkout-page:helpCtaQuestion")),o.createElement("span",{className:n.Cta,onClick:function(){return A(!0)}},k("checkout-page:helpCta"))),o.createElement(s,{text:k("checkout-page:actions.backToShopping"),onClick:j.onBackToShoppingClick,style:{flex:"0 0 auto"}})),N&&o.createElement(L,{vm:j,setVisible:A}))})),L=a((function(a){var r,i,n=a.vm,l=a.setVisible,c=g().t,m=o.useState(!1),d=m[0],u=m[1],p=o.useState(!1),v=p[0],E=p[1],f=o.useState(new k({message:{requiredRule:"",emailRule:"",minRule:""},store:n.store}))[0];f.email=n.checkout.customerEmail,f.firstName=(null===(r=n.checkout.customer)||void 0===r?void 0:r.firstName)||"",f.lastName=(null===(i=n.checkout.customer)||void 0===i?void 0:i.lastName)||"";var N=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return v?[2,l(!1)]:(u(!0),[4,f.saveContactForm()]);case 1:return e.sent()&&E(!0),u(!1),[2]}}))}))}),[d]);return o.createElement(h,{title:c("checkout-page:contactForm"),modalContent:o.createElement("div",null,v&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(T,{type:"success",title:c("checkout-page:contactFormSent"),content:c("checkout-page:contactFormDescription")})),o.createElement(x,{type:j.TEXT_AREA,label:"",value:f.message||"",onChange:f.onMessageChange,textAreaPlaceholder:c("checkout-page:contactFormCta")}),o.createElement(s,{style:{width:"100%",marginTop:"24px"},text:c(v?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:d,isDisabled:!f.message,onClick:N})),onClose:function(){return l(!1)}})})),C=a((function(e){var t,a,s,r=e.vm,i=g().t,l=n.Yellow;switch(null===(t=r.order)||void 0===t?void 0:t.orderPackageStatus){case N.FULFILLED:case N.PARTIALLY_FULFILLED:case N.DELIVERED:case N.PARTIALLY_DELIVERED:l=n.Green;break;case N.CANCELLED:case N.PARTIALLY_CANCELLED:case N.CANCEL_REJECTED:case N.CANCEL_REQUESTED:l=n.Red}return o.createElement("div",{className:[n.OrderStatus,l].join(" ")},(null===(a=r.order)||void 0===a?void 0:a.orderPackageStatus)?null===(s=[{types:[N.UNFULFILLED],text:i("checkout-page:orderPackageStatus.unfulfilled")},{types:[N.READY_FOR_SHIPMENT],text:i("checkout-page:orderPackageStatus.readyForShipment")},{types:[N.PARTIALLY_FULFILLED],text:i("checkout-page:orderPackageStatus.partiallyFulfilled")},{types:[N.FULFILLED],text:i("checkout-page:orderPackageStatus.fulfilled")},{types:[N.DELIVERED,N.PARTIALLY_DELIVERED],text:i("checkout-page:orderPackageStatus.delivered")},{types:[N.UNABLE_TO_DELIVER],text:i("checkout-page:orderPackageStatus.unableToDeliver")},{types:[N.CANCELLED,N.PARTIALLY_CANCELLED],text:i("checkout-page:orderPackageStatus.cancelled")},{types:[N.CANCEL_REJECTED],text:i("checkout-page:orderPackageStatus.cancelRejected")},{types:[N.REFUNDED,N.PARTIALLY_REFUNDED],text:i("checkout-page:orderPackageStatus.refunded")},{types:[N.REFUND_REQUEST_ACCEPTED],text:i("checkout-page:orderPackageStatus.refundRequestAccepted")},{types:[N.REFUND_REJECTED],text:i("checkout-page:orderPackageStatus.refundRejected")},{types:[N.REFUND_REQUESTED],text:i("checkout-page:orderPackageStatus.refundRequested")}].find((function(e){return e.types.includes(r.order.orderPackageStatus)})))||void 0===s?void 0:s.text:"")}));export{A as StepSuccess};
@@ -1,4 +1,4 @@
1
1
  export { IkasPage } from "./page";
2
2
  export { IkasPageHead } from "./page/head";
3
- export { IkasPageEditor } from "./page-editor";
3
+ export { default as IkaspageEditor } from "./page-editor";
4
4
  export { Image } from "./image";
@@ -1 +1 @@
1
- import{__extends as e,__assign as r}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{makeObservable as t,computed as n}from"mobx";import{IkasStorefrontConfig as p}from"../../storefront/index.js";import{IkasPageDataInit as a}from"../../providers/page-data-init.js";import{Observer as i}from"mobx-react-lite";var l=function(l){function u(e){var r=l.call(this,e)||this;return r.state={hasError:!1},t(r,{hasNullValue:n,Component:n}),r}return e(u,l),u.getDerivedStateFromError=function(e){return console.error(e),{hasError:!0}},Object.defineProperty(u.prototype,"hasNullValue",{get:function(){var e=this.props.pageComponentPropValue,r=e.propValues;return e.component.props.some((function(e){if(e.isRequired){var o=(r||{})[e.name];return null===o||null==o}}))},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"Component",{get:function(){var e=this.props.pageComponentPropValue,r=p.currentPageComponents,o=e.pageComponent;return r?r[o.componentId]:null},enumerable:!1,configurable:!0}),u.prototype.render=function(){var e=this;return o.createElement(i,null,(function(){var t=e.props,n=t.index,i=t.pageComponentPropValue,l=t.settings,u=p.store,s=e.Component,m=i.pageComponent,c=i.propValues;return s?e.state.hasError?null:o.createElement("div",{id:n+""},e.hasNullValue?null:o.createElement(s,r({key:m.id},c,{settings:l,store:u,pageSpecificData:a.pageSpecificData}))):(console.error("COMPONENT NOT FOUND!"),null)}))},u}(o.Component);export{l as ThemeComponent};
1
+ import{__extends as e,__assign as r}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{makeObservable as t,computed as n}from"mobx";import{IkasStorefrontConfig as p}from"../../storefront/index.js";import{IkasPageDataInit as i}from"../../providers/page-data-init.js";import{Observer as a}from"mobx-react-lite";import{IkasThemeComponentPropType as u}from"../../models/theme/component/prop/index.js";var l=function(l){function m(e){var r=l.call(this,e)||this;return r.state={hasError:!1},t(r,{hasNullValue:n,Component:n}),r}return e(m,l),m.getDerivedStateFromError=function(e){return console.error(e),{hasError:!0}},Object.defineProperty(m.prototype,"hasNullValue",{get:function(){var e=this.props.pageComponentPropValue,r=e.propValues;return e.component.props.some((function(o){if(o.isRequired){var t=(r||{})[o.name],n=null==e?void 0:e.component.props.find((function(e){return e.id===o.requiredPropId}));if(n){var p=(r||{})[n.name];if(n.type===u.BOOLEAN&&!p||n.type===u.CUSTOM&&p!==o.requiredEnumOptionValue)return!1}return null===t||null==t}}))},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"Component",{get:function(){var e=this.props.pageComponentPropValue,r=p.currentPageComponents,o=e.pageComponent;return r?r[o.componentId]:null},enumerable:!1,configurable:!0}),m.prototype.render=function(){var e=this;return o.createElement(a,null,(function(){var t=e.props,n=t.index,a=t.pageComponentPropValue,u=t.settings,l=p.store,m=e.Component,s=a.pageComponent,c=a.propValues;return m?e.state.hasError?null:o.createElement("div",{id:n+""},e.hasNullValue?null:o.createElement(m,r({key:s.id},c,{settings:u,store:l,pageSpecificData:i.pageSpecificData}))):(console.error("COMPONENT NOT FOUND!"),null)}))},m}(o.Component);export{l as ThemeComponent};
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as r}from"mobx-react-lite";import{useRouter as i}from"next/router.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"mobx";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as a}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductDetail as s}from"../../models/ui/product-detail/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/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/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{IkasThemeSettings as n}from"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{Analytics as m}from"../../analytics/analytics.js";import{IkasStorefrontConfig as d}from"../../storefront/index.js";import'../../ext/html-react-parser/index.js';import{initIkasEvents as p}from"../../analytics/events.js";import{IkasPageDataInit as l}from"../../providers/page-data-init.js";import{ThemeComponent as u}from"./ThemeComponent.js";import{IkasPageHead as c}from"./head.js";var f=r((function(r){var u=r.propValuesStr,f=r.pageType,x=r.pageTitle,g=r.pageDescription,v=r.pageSpecificDataStr,h=r.settingsStr,S=r.merchantSettingsStr,w=r.configJson,y=r.reInitOnBrowser,b=r.addOgpMetas,C=r.components;d.initWithJson(w),d.currentPageComponents=C;var E=d.store;E.currentPageType=f;var O=i(),T=o.useState(!1),V=T[0],D=T[1],P=o.useState(new n(JSON.parse(h)))[0],J=o.useMemo((function(){return l.setPageSpecificData(v,f,V),l.initPropValues(u,O,h,!0,V)}),[V,u,f,h,v]);o.useEffect((function(){y&&D("undefined"!=typeof window),E.cartStore.getCart(),E.checkLocalization(),p()}),[]),o.useEffect((function(){var e=function(){d.store.customerStore.routeChangeInit()};return O.events.on("routeChangeStart",e),function(){O.events.off("routeChangeStart",e)}}),[]),o.useEffect((function(){!function(o,r,i){e(this,void 0,void 0,(function(){var e,n,p,u,c;return t(this,(function(t){switch(t.label){case 0:m.pageView(o),t.label=1;case 1:return t.trys.push([1,4,,5]),o===a.PRODUCT&&(e=JSON.parse(r),n=new s(e.product,e.selectedVariantValues),"undefined"!=typeof window&&l._initProductDetailOnBrowser(n),m.productView(n),d.store.customerStore.onProductView(n.product.id,n.selectedVariant.id)),o===a.CATEGORY&&(p=JSON.parse(r),u=p.path.map((function(e){return e.name})).join(" > "),u=p.path.length>0?u+" > "+p.name:p.name,m.viewCategory(u,p)),o!==a.CART?[3,3]:[4,i.cartStore.waitUntilInitialized()];case 2:t.sent(),m.viewCart(i.cartStore.cart),t.label=3;case 3:return[3,5];case 4:return c=t.sent(),console.error(c),[3,5];case 5:return[2]}}))}))}(f,v,E)}),[f,v,J]);var k=o.useMemo((function(){var e=J.find((function(e){return e.component.isHeader})),t=J.find((function(e){return e.component.isFooter})),r=J.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[];return o.createElement("div",{style:{position:"relative",minHeight:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between"}},o.createElement("div",null,e&&j(e,P,-1),r.map((function(e,t){return j(e,P,t)}))),t&&j(t,P,-1))}),[J,P]);return o.createElement(o.Fragment,null,o.createElement(c,{pageType:f,pageTitle:x,pageDescription:g,pageSpecificDataStr:v,merchantSettingsStr:S,addOgpMetas:b}),k)})),j=function(e,t,r){return o.createElement(u,{key:e.pageComponent.id,index:r,pageComponentPropValue:e,settings:t})};export{f as IkasPage,j as renderComponent};
1
+ import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as r}from"mobx-react-lite";import{useRouter as i}from"next/router.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"mobx";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as a}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import{IkasProductDetail as s}from"../../models/ui/product-detail/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/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/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{IkasThemeSettings as n}from"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{Analytics as d}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasPageDataInit as m}from"../../providers/page-data-init.js";import{ThemeComponent as p}from"./ThemeComponent.js";import{IkasPageHead as l}from"./head.js";import{IkasStorefrontConfig as u}from"../../storefront/index.js";import{initIkasEvents as c}from"../../analytics/events.js";var f=r((function(r){var p=r.propValuesStr,f=r.pageType,x=r.pageTitle,g=r.pageDescription,v=r.pageSpecificDataStr,h=r.settingsStr,S=r.merchantSettingsStr,w=r.configJson,y=r.reInitOnBrowser,b=r.addOgpMetas,C=r.components;u.initWithJson(w),u.currentPageComponents=C;var E=u.store;E.currentPageType=f;var O=i(),T=o.useState(!1),V=T[0],D=T[1],P=o.useState(new n(JSON.parse(h)))[0],J=o.useMemo((function(){return m.setPageSpecificData(v,f,V),m.initPropValues(p,O,h,!0,V)}),[V,p,f,h,v]);o.useEffect((function(){y&&D("undefined"!=typeof window),E.cartStore.getCart(),E.checkLocalization(),c()}),[]),o.useEffect((function(){var e=function(){u.store.customerStore.routeChangeInit()};return O.events.on("routeChangeStart",e),function(){O.events.off("routeChangeStart",e)}}),[]),o.useEffect((function(){!function(o,r,i){e(this,void 0,void 0,(function(){var e,n,p,l,c;return t(this,(function(t){switch(t.label){case 0:d.pageView(o),t.label=1;case 1:return t.trys.push([1,4,,5]),o===a.PRODUCT&&(e=JSON.parse(r),n=new s(e.product,e.selectedVariantValues),"undefined"!=typeof window&&m._initProductDetailOnBrowser(n),d.productView(n),u.store.customerStore.onProductView(n.product.id,n.selectedVariant.id)),o===a.CATEGORY&&(p=JSON.parse(r),l=p.path.map((function(e){return e.name})).join(" > "),l=p.path.length>0?l+" > "+p.name:p.name,d.viewCategory(l,p)),o!==a.CART?[3,3]:[4,i.cartStore.waitUntilInitialized()];case 2:t.sent(),d.viewCart(i.cartStore.cart),t.label=3;case 3:return[3,5];case 4:return c=t.sent(),console.error(c),[3,5];case 5:return[2]}}))}))}(f,v,E)}),[f,v,J]);var k=o.useMemo((function(){var e=J.find((function(e){return e.component.isHeader})),t=J.find((function(e){return e.component.isFooter})),r=J.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[];return o.createElement("div",{style:{position:"relative",minHeight:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between"}},o.createElement("div",null,e&&j(e,P,-1),r.map((function(e,t){return j(e,P,t)}))),t&&j(t,P,-1))}),[J,P]);return o.createElement(o.Fragment,null,o.createElement(l,{pageType:f,pageTitle:x,pageDescription:g,pageSpecificDataStr:v,merchantSettingsStr:S,addOgpMetas:b}),k)})),j=function(e,t,r){return o.createElement(p,{key:e.pageComponent.id,index:r,pageComponentPropValue:e,settings:t})};export{f as IkasPage,j as renderComponent};
@@ -8,13 +8,10 @@ declare type Props = {
8
8
  export declare class ThemeEditorComponent extends React.Component<Props> {
9
9
  ref: React.RefObject<HTMLDivElement>;
10
10
  error: any;
11
- disposer?: () => void;
12
11
  state: {
13
12
  hasError: boolean;
14
13
  };
15
14
  constructor(props: Props);
16
- componentDidMount(): void;
17
- componentWillUnmount(): void;
18
15
  static getDerivedStateFromError(error: any): {
19
16
  hasError: boolean;
20
17
  };
@@ -1 +1 @@
1
- import{__extends as e,__assign as o}from'../../ext/tslib/tslib.es6.js';import*as t from"react";import r from"./error/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as i}from"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import{IkasOrderLineItem as n}from"../../models/data/order/line-item/index.js";import{reaction as s,makeObservable as a,computed as d}from"mobx";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as m}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/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/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasStorefrontConfig as p}from"../../storefront/index.js";import{IkasCheckoutSettings as l}from"../../models/data/checkout-settings/index.js";import u from"../checkout/index.js";import{IkasCart as c}from"../../models/data/cart/index.js";import{IkasPageDataInit as v}from"../../providers/page-data-init.js";import{Observer as f}from"mobx-react-lite";var j=function(j){function h(e){var o=j.call(this,e)||this;return o.state={hasError:!1},o.onMouseEnter=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseOver(r.id)},o.onMouseLeave=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseLeave(r.id)},o.onClick=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onClick(r.id)},o.ref=t.createRef(),a(o,{pageComponentPropValue:d,propValues:d,isSelected:d,isHovered:d,hasNullValue:d,rendered:d,Component:d}),o}return e(h,j),h.prototype.componentDidMount=function(){var e=this.props.vm;this.disposer&&this.disposer(),this.disposer=s((function(){var o;return null===(o=e.theme)||void 0===o?void 0:o.settings}),(function(){var o;null===(o=e.theme)||void 0===o||o.settings.colors.map((function(e){return document.documentElement.style.setProperty(e.key,e.color)}))}))},h.prototype.componentWillUnmount=function(){this.disposer&&this.disposer()},h.getDerivedStateFromError=function(e){return console.error(e),{hasError:!0}},Object.defineProperty(h.prototype,"pageComponentPropValue",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.pageDataProvider.pageComponentPropValues.find((function(e){return e.pageComponent.id===t.id}))},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"propValues",{get:function(){var e,t,r=this.props.vm,s=null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.propValues;(null===(t=r.page)||void 0===t?void 0:t.type)===m.CHECKOUT&&(s={checkout:new i({cart:new c({items:[new n({currencyCode:"TRY",finalPrice:100,finalPriceWithQuantity:100,price:100,priceWithQuantity:100,quantity:1})]})}),checkoutSettings:new l,merchantSettings:null,customizationProps:o({},s),returnPolicy:"",privacyPolicy:"",termsOfService:""});return s},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isSelected",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.selectedPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isHovered",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.hoveredPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"hasNullValue",{get:function(){var e,o=this;return!!(null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.props.some((function(e){if(e.isRequired){var t=(o.propValues||{})[e.name];return null===t||null==t}})))},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"rendered",{get:function(){var e,i,n=this.Component,s=this.props.vm,a=p.store;return this.hasNullValue||this.state.hasError?t.createElement(r,{name:null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.displayName}):t.createElement(n,o({},this.propValues,{store:a,settings:null===(i=s.theme)||void 0===i?void 0:i.settings,pageSpecificData:v.pageSpecificData}))},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"Component",{get:function(){var e,o=this.props,t=o.vm,r=o.pageComponent,i=p.currentPageComponents;if(!i)return null;var n=i[r.componentId];return(null===(e=t.page)||void 0===e?void 0:e.type)===m.CHECKOUT&&(n=u),n},enumerable:!1,configurable:!0}),h.prototype.render=function(){var e=this;return t.createElement(f,null,(function(){var o;return e.state.hasError?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,onClick:e.onClick},t.createElement(r,{name:null===(o=e.pageComponentPropValue)||void 0===o?void 0:o.component.displayName}),";"):p.currentPageComponents?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,onClick:e.onClick},e.rendered,(e.isSelected||e.isHovered)&&t.createElement("div",{style:g})):(console.error("Components for the page not found."),null)}))},h}(t.Component),g={position:"absolute",top:"0px",left:"0px",width:"100%",height:"100%",border:"4px solid rgb(0, 161, 255)",zIndex:1e19};export{j as ThemeEditorComponent};
1
+ import{__extends as e,__assign as o}from'../../ext/tslib/tslib.es6.js';import*as t from"react";import r from"./error/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import{IkasCheckout as i}from"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/order/index.js";import{IkasOrderLineItem as n}from"../../models/data/order/line-item/index.js";import{makeObservable as a,computed as s}from"mobx";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as m}from"../../models/theme/page/index.js";import{IkasThemeComponentPropType as d}from"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/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/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/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"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{IkasStorefrontConfig as p}from"../../storefront/index.js";import{IkasCheckoutSettings as l}from"../../models/data/checkout-settings/index.js";import u from"../checkout/index.js";import{IkasCart as c}from"../../models/data/cart/index.js";import{IkasPageDataInit as f}from"../../providers/page-data-init.js";import{Observer as v}from"mobx-react-lite";var j=function(j){function g(e){var o=j.call(this,e)||this;return o.state={hasError:!1},o.onMouseEnter=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseOver(r.id)},o.onMouseLeave=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onMouseLeave(r.id)},o.onClick=function(){var e=o.props,t=e.vm,r=e.pageComponent;t.onClick(r.id)},o.ref=t.createRef(),a(o,{pageComponentPropValue:s,propValues:s,isSelected:s,isHovered:s,hasNullValue:s,rendered:s,Component:s}),o}return e(g,j),g.getDerivedStateFromError=function(e){return console.error(e),{hasError:!0}},Object.defineProperty(g.prototype,"pageComponentPropValue",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.pageDataProvider.pageComponentPropValues.find((function(e){return e.pageComponent.id===t.id}))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"propValues",{get:function(){var e,t,r=this.props.vm,a=null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.propValues;(null===(t=r.page)||void 0===t?void 0:t.type)===m.CHECKOUT&&(a={checkout:new i({cart:new c({items:[new n({currencyCode:"TRY",finalPrice:100,finalPriceWithQuantity:100,price:100,priceWithQuantity:100,quantity:1})]})}),checkoutSettings:new l,merchantSettings:null,customizationProps:o({},a),returnPolicy:"",privacyPolicy:"",termsOfService:""});return a},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isSelected",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.selectedPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isHovered",{get:function(){var e=this.props,o=e.vm,t=e.pageComponent;return o.hoveredPageComponentId===t.id},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"hasNullValue",{get:function(){var e,o=this;return!!(null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.props.some((function(e){var t;if(e.isRequired){var r=(o.propValues||{})[e.name],i=null===(t=o.pageComponentPropValue)||void 0===t?void 0:t.component.props.find((function(o){return o.id===e.requiredPropId}));if(i){var n=(o.propValues||{})[i.name];if(i.type===d.BOOLEAN&&!n||i.type===d.CUSTOM&&n!==e.requiredEnumOptionValue)return!1}return null===r||null==r}})))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"rendered",{get:function(){var e,i,n=this.Component,a=this.props.vm,s=p.store;return this.hasNullValue||this.state.hasError?t.createElement(r,{name:null===(e=this.pageComponentPropValue)||void 0===e?void 0:e.component.displayName}):t.createElement(n,o({},this.propValues,{store:s,settings:null===(i=a.theme)||void 0===i?void 0:i.settings,pageSpecificData:f.pageSpecificData}))},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"Component",{get:function(){var e,o=this.props,t=o.vm,r=o.pageComponent,i=p.currentPageComponents;if(!i)return null;var n=i[r.componentId];return(null===(e=t.page)||void 0===e?void 0:e.type)===m.CHECKOUT&&(n=u),n},enumerable:!1,configurable:!0}),g.prototype.render=function(){var e=this;return t.createElement(v,null,(function(){var o;return e.state.hasError?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave,onClick:e.onClick},t.createElement(r,{name:null===(o=e.pageComponentPropValue)||void 0===o?void 0:o.component.displayName}),";"):p.currentPageComponents?t.createElement("div",{ref:e.ref,style:{position:"relative"},onMouseEnter:e.onMouseEnter,onMouseLeave:e.onMouseLeave},e.rendered):(console.error("Components for the page not found."),null)}))},g}(t.Component);export{j as ThemeEditorComponent};
@@ -1,2 +1,4 @@
1
1
  import * as React from "react";
2
- export declare const IkasPageEditor: React.FC;
2
+ import { WithRouterProps } from "next/dist/client/with-router";
3
+ declare const _default: React.ComponentType<Pick<WithRouterProps, never>>;
4
+ export default _default;
@@ -1 +1 @@
1
- import*as e from"react";import{observer as o}from"mobx-react-lite";import{useRouter as n}from"next/router.js";import{ThemeEditorComponent as t}from"./ThemeComponentEditor.js";import i from"./model.js";import{IkasPageHead as r}from"../page/head.js";var m=o((function(){var o,m,l,p=n(),a=e.useState((function(){return new i(p)}))[0];if(a.isLoading)return null;var v=null===(o=a.pageComponents)||void 0===o?void 0:o.find((function(e){var o,n;return e.componentId===(null===(n=null===(o=a.theme)||void 0===o?void 0:o.headerComponent)||void 0===n?void 0:n.id)})),u=null===(m=a.pageComponents)||void 0===m?void 0:m.find((function(e){var o,n;return e.componentId===(null===(n=null===(o=a.theme)||void 0===o?void 0:o.footerComponent)||void 0===n?void 0:n.id)})),c=null===(l=a.pageComponents)||void 0===l?void 0:l.filter((function(e){var o,n,t,i;return e.componentId!==(null===(n=null===(o=a.theme)||void 0===o?void 0:o.headerComponent)||void 0===n?void 0:n.id)&&e.componentId!==(null===(i=null===(t=a.theme)||void 0===t?void 0:t.footerComponent)||void 0===i?void 0:i.id)}));return e.createElement(e.Fragment,null,!!a.page&&e.createElement(r,{pageType:a.page.type,pageTitle:a.page.pageTitle,pageDescription:a.page.description}),e.createElement("div",{style:d},e.createElement("div",null,!!v&&e.createElement(t,{key:v.id,vm:a,pageComponent:v}),null==c?void 0:c.map((function(o){return e.createElement(t,{key:o.id,vm:a,pageComponent:o})}))),!!u&&e.createElement(t,{key:u.id,vm:a,pageComponent:u})))})),d={minHeight:"100vh",width:"100vw",display:"flex",flexDirection:"column",justifyContent:"space-between"};export{m as IkasPageEditor};
1
+ import{__extends as e}from'../../ext/tslib/tslib.es6.js';import*as t from"react";import{Observer as o}from"mobx-react-lite";import{withRouter as n}from"next/router.js";import{ThemeEditorComponent as r}from"./ThemeComponentEditor.js";import i from"./model.js";import{IkasPageHead as m}from"../page/head.js";import{IkasEditorComponentLoader as a}from"./loader/index.js";import{reaction as l,makeObservable as p,computed as d}from"mobx";import{getGoogleFontHref as s}from"../../utils/google-fonts.js";var u=n(function(n){function u(e){var t=n.call(this,e)||this;return t.interceptClickEvent=function(e){var t=e.target;"A"===t.tagName&&(t.getAttribute("href"),e.preventDefault())},t.handleRouteChangeStart=function(e,o){throw o.shallow||t.vm.onPageChange(e),""},t.injectFontScript=function(){var e;if(null===(e=t.vm.theme)||void 0===e?void 0:e.settings.fontFamily.name){var o=t.vm.theme.settings.fontFamily,n=document.getElementById("ikas-font");n&&n.remove();var r=s(o);if(r){var i=document.createElement("link");i.setAttribute("id","ikas-font"),i.setAttribute("rel","stylesheet"),i.setAttribute("href",r),document.getElementsByTagName("head")[0].appendChild(i),document.body.style.setProperty("font-family",o.name,"important")}}},t.vm=new i(e.router),p(t,{headerPageComponent:d,footerPageComponent:d,otherComponents:d}),t}return e(u,n),u.prototype.componentDidMount=function(){var e=this;this.props.router.events.on("routeChangeStart",this.handleRouteChangeStart),document.addEventListener&&document.addEventListener("click",this.interceptClickEvent),this.disposer&&this.disposer(),this.disposer=l((function(){var t;return null===(t=e.vm.theme)||void 0===t?void 0:t.settings}),(function(){var t;null===(t=e.vm.theme)||void 0===t||t.settings.colors.map((function(e){return document.documentElement.style.setProperty(e.key,e.color)})),e.injectFontScript()}))},u.prototype.componentWillUnmount=function(){this.props.router.events.off("routeChangeStart",this.handleRouteChangeStart),document.removeEventListener("click",this.interceptClickEvent),this.disposer&&this.disposer()},Object.defineProperty(u.prototype,"headerPageComponent",{get:function(){var e,t=this.vm;return null===(e=t.pageComponents)||void 0===e?void 0:e.find((function(e){var o,n;return e.componentId===(null===(n=null===(o=t.theme)||void 0===o?void 0:o.headerComponent)||void 0===n?void 0:n.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"footerPageComponent",{get:function(){var e,t=this.vm;return null===(e=t.pageComponents)||void 0===e?void 0:e.find((function(e){var o,n;return e.componentId===(null===(n=null===(o=t.theme)||void 0===o?void 0:o.footerComponent)||void 0===n?void 0:n.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(u.prototype,"otherComponents",{get:function(){var e,t=this.vm;return null===(e=t.pageComponents)||void 0===e?void 0:e.filter((function(e){var o,n,r,i;return e.componentId!==(null===(n=null===(o=t.theme)||void 0===o?void 0:o.headerComponent)||void 0===n?void 0:n.id)&&e.componentId!==(null===(i=null===(r=t.theme)||void 0===r?void 0:r.footerComponent)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),u.prototype.render=function(){var e=this,n=this.vm;return t.createElement(o,null,(function(){var o;return n.isLoading?t.createElement(a,{isFullPage:!0}):t.createElement(t.Fragment,null,!!n.page&&t.createElement(m,{pageType:n.page.type,pageTitle:n.page.pageTitle,pageDescription:n.page.description}),t.createElement("div",{style:v},t.createElement("div",null,!!e.headerPageComponent&&t.createElement(r,{key:e.headerPageComponent.id,vm:n,pageComponent:e.headerPageComponent}),null===(o=e.otherComponents)||void 0===o?void 0:o.map((function(e){return t.createElement(r,{key:e.id,vm:n,pageComponent:e})}))),!!e.footerPageComponent&&t.createElement(r,{key:e.footerPageComponent.id,vm:n,pageComponent:e.footerPageComponent})))}))},u}(t.Component)),v={minHeight:"100vh",width:"100vw",display:"flex",flexDirection:"column",justifyContent:"space-between"};export{u as default};
@@ -1,2 +1,6 @@
1
1
  import * as React from "react";
2
- export declare const IkasEditorComponentLoader: React.FC;
2
+ declare type Props = {
3
+ isFullPage?: boolean;
4
+ };
5
+ export declare const IkasEditorComponentLoader: React.FC<Props>;
6
+ export {};
@@ -1 +1 @@
1
- import*as e from"react";import r from"./style.module.scss.js";var t=function(){return e.createElement("div",{className:r.Container},e.createElement("div",{className:r.loader}))};export{t as IkasEditorComponentLoader};
1
+ import*as e from"react";import a from"./style.module.scss.js";var r=function(r){var t=r.isFullPage;return e.createElement("div",{className:[a.Container,t?a.fullPage:""].join(" ")},e.createElement("div",{className:a.loader}))};export{r as IkasEditorComponentLoader};
@@ -1 +1 @@
1
- import e from'../../../ext/style-inject/dist/style-inject.es.js';var n={Container:"style-module_Container__1eB6f",loader:"style-module_loader__1ahiK",load8:"style-module_load8__1jjFg"};e(".style-module_Container__1eB6f {\n width: 100%;\n height: 300px;\n background-color: white;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.style-module_Container__1eB6f .style-module_loader__1ahiK,\n.style-module_Container__1eB6f .style-module_loader__1ahiK:after {\n border-radius: 50%;\n width: 5em;\n height: 5em;\n}\n.style-module_Container__1eB6f .style-module_loader__1ahiK {\n font-size: 6px;\n position: relative;\n text-indent: -9999em;\n border-top: 0.5em solid rgba(255, 255, 255, 0.2);\n border-right: 0.5em solid rgba(255, 255, 255, 0.2);\n border-bottom: 0.5em solid rgba(255, 255, 255, 0.2);\n border-left: 0.5em solid black;\n -webkit-transform: translateZ(0);\n -ms-transform: translateZ(0);\n transform: translateZ(0);\n -webkit-animation: style-module_load8__1jjFg 1.1s infinite linear;\n animation: style-module_load8__1jjFg 1.1s infinite linear;\n}\n@-webkit-keyframes style-module_load8__1jjFg {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@keyframes style-module_load8__1jjFg {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}");export{n as default};
1
+ import e from'../../../ext/style-inject/dist/style-inject.es.js';var n={Container:"style-module_Container__1eB6f",fullPage:"style-module_fullPage__3P2Pz",loader:"style-module_loader__1ahiK",load8:"style-module_load8__1jjFg"};e(".style-module_Container__1eB6f {\n width: 100%;\n height: 300px;\n background-color: white;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n.style-module_Container__1eB6f.style-module_fullPage__3P2Pz {\n height: 100vh;\n}\n.style-module_Container__1eB6f .style-module_loader__1ahiK,\n.style-module_Container__1eB6f .style-module_loader__1ahiK:after {\n border-radius: 50%;\n width: 5em;\n height: 5em;\n}\n.style-module_Container__1eB6f .style-module_loader__1ahiK {\n font-size: 6px;\n position: relative;\n text-indent: -9999em;\n border-top: 0.5em solid rgba(255, 255, 255, 0.2);\n border-right: 0.5em solid rgba(255, 255, 255, 0.2);\n border-bottom: 0.5em solid rgba(255, 255, 255, 0.2);\n border-left: 0.5em solid black;\n -webkit-transform: translateZ(0);\n -ms-transform: translateZ(0);\n transform: translateZ(0);\n -webkit-animation: style-module_load8__1jjFg 1.1s infinite linear;\n animation: style-module_load8__1jjFg 1.1s infinite linear;\n}\n@-webkit-keyframes style-module_load8__1jjFg {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}\n@keyframes style-module_load8__1jjFg {\n 0% {\n -webkit-transform: rotate(0deg);\n transform: rotate(0deg);\n }\n 100% {\n -webkit-transform: rotate(360deg);\n transform: rotate(360deg);\n }\n}");export{n as default};
@@ -1,7 +1,7 @@
1
1
  import { NextRouter } from "next/router.js";
2
2
  import { IkasThemePage, IkasThemePageComponent, IkasTheme, IkasThemeComponent } from "../../models";
3
3
  import { IkasPageDataProvider } from "../../providers/page-data-get";
4
- import { IkasThemePageSpecification } from "../../models/theme/page";
4
+ import { IkasThemePageSpecification, IkasThemePageType } from "../../models/theme/page";
5
5
  export default class IkasPageEditorViewModel {
6
6
  theme?: IkasTheme | null;
7
7
  page?: IkasThemePage | null;
@@ -12,7 +12,6 @@ export default class IkasPageEditorViewModel {
12
12
  locale: string;
13
13
  translations?: Record<string, any>;
14
14
  pageParams: Record<string, any>;
15
- queryParams: Record<string, any>;
16
15
  apiKey?: string | null;
17
16
  pageDataProvider?: IkasPageDataProvider | null;
18
17
  router: NextRouter;
@@ -26,8 +25,9 @@ export default class IkasPageEditorViewModel {
26
25
  onClick: (id: string) => void;
27
26
  onMouseOver: (id: string) => void;
28
27
  onMouseLeave: (id: string) => void;
28
+ onPageChange: (url: string) => Promise<void>;
29
29
  sendMessage: (type: BridgeMessageType, data?: any) => void;
30
- getPagePropValues: () => Promise<void>;
30
+ getPagePropValues: (theme: IkasTheme, pageType: IkasThemePageType, pageParams: Record<string, any>) => Promise<IkasPageDataProvider>;
31
31
  setComponentRef: (element: React.ElementType, component: IkasThemePageComponent) => void;
32
32
  isScrolledIntoView: (el: HTMLElement) => boolean;
33
33
  handleUpdateFrameData: (data: any) => Promise<void>;
@@ -61,5 +61,6 @@ export declare enum BridgeMessageType {
61
61
  SET_SELECTED_COMPONENT = "SET_SELECTED_COMPONENT",
62
62
  SET_HOVERED_COMPONENT = "SET_HOVERED_COMPONENT",
63
63
  SCROLL_TO_COMPONENT = "SCROLL_TO_COMPONENT",
64
- UPDATE_THEME_SETTINGS = "UPDATE_THEME_SETTINGS"
64
+ UPDATE_THEME_SETTINGS = "UPDATE_THEME_SETTINGS",
65
+ EDITOR_PAGE_CHANGE = "EDITOR_PAGE_CHANGE"
65
66
  }