@ikas/storefront 3.0.0-alpha.45 → 3.0.0-alpha.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/_virtual/index.js_commonjs-proxy2.js +1 -1
- package/build/_virtual/index.js_commonjs-proxy3.js +1 -1
- package/build/_virtual/index.js_commonjs-proxy4.js +1 -1
- package/build/components/checkout/components/master-pass/credit-card-form/index.js +1 -0
- package/build/components/checkout/components/master-pass/credit-card-form/style.module.scss.js +1 -0
- package/build/components/checkout/components/master-pass/svg/master-pass-by-master-card.js +1 -0
- package/build/components/checkout/components/offer-product/index.js +1 -1
- package/build/components/checkout/components/offer-product/style.module.scss.js +1 -1
- package/build/components/checkout/index.js +1 -1
- package/build/components/checkout/model.d.ts +3 -3
- package/build/components/checkout/model.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from'../ext/split-on-first/index.js';export{default}from"../node_modules/split-on-first/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from'../ext/decode-uri-component/index.js';export{default}from"../node_modules/decode-uri-component/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'../ext/
|
|
1
|
+
import e from'../ext/strict-uri-encode/index.js';export{default}from"../node_modules/strict-uri-encode/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"react";import{observer as a}from"mobx-react-lite";import{IkasStorefrontConfig as t}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{createTranslationInputData as o,useTranslation as s}from"../../../../../utils/i18n.js";import{Checkbox as r}from"../../checkbox/index.js";import{FormItem as n}from"../../form-item/index.js";import{FormItemType as m}from"../../form-item/model.js";import{Button as i}from"../../button/index.js";import c from"../svg/master-pass-by-master-card.js";import d from"../../../style.module.scss.js";import l from"./style.module.scss.js";var u=a((function(a){var u=a.vm,p=s().t,C=t.translations["checkout-page"],v=e.useMemo((function(){var e,a;return o(null===(a=null===(e=null==C?void 0:C.masterPass)||void 0===e?void 0:e.creditCardForm)||void 0===a?void 0:a.checkboxLabel)}),[C]),P=e.useMemo((function(){return e.createElement("div",{className:l.CheckboxLabel},v.map((function(a,t){return a.isVariable?e.createElement("span",{key:t,className:l.Logo},e.createElement(c,null)):e.createElement(e.Fragment,{key:t},a.value)})))}),[v]),h=u.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled?u.mpVM.saveCardToMasterPassPhoneNumberDisabledInputValue({withPlus:!0,store:u.store,checkout:u.checkout}):u.mpVM.saveCardToMasterPass.phoneNumber;return e.createElement("div",null,e.createElement(r,{label:P,value:u.mpVM.saveCardToMasterPass.isCheckboxChecked,onChange:u.mpVM.onSaveCardToMasterPassCheckedChange}),u.mpVM.saveCardToMasterPass.isCheckboxChecked&&e.createElement("div",{className:l.FormWrapper},e.createElement("div",{className:d.RowPB},e.createElement(n,{name:"masterPassCardName",type:m.TEXT,label:p("checkout-page:masterPass.creditCardForm.cardName"),value:u.mpVM.saveCardToMasterPass.cardName,onChange:u.mpVM.onSaveCardToMasterPassCardNameChange})),u.mpVM.isSaveCardToMasterPassPhoneNumberInputVisible&&e.createElement("div",{className:d.RowPB},e.createElement(n,{name:"masterPassPhoneNumber",type:m.TEL,disabled:u.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled,label:p("checkout-page:masterPass.creditCardForm.phoneNumber"),value:h,onChange:u.mpVM.onSaveCardToMasterPassPhoneNumberChange})),e.createElement(i,{style:{width:"100%"},text:p("checkout-page:masterPass.creditCardForm.button"),isDisabled:u.mpVM.isSendConfirmationButtonDisabled,isLoading:u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending,onClick:function(){if(!u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending&&(console.log("onSendConfirmationButtonClick 1"),u.checkout.selectedPaymentGateway&&(console.log("onSendConfirmationButtonClick 2"),u.cardData&&u.cardData.cardNumber&&u.cardData.expirationDate&&u.cardData.cvv&&(console.log("onSendConfirmationButtonClick 3"),u.mpVM.saveCardToMasterPass.cardName)))){console.log("onSendConfirmationButtonClick 4");var e=u.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled?u.mpVM.saveCardToMasterPassPhoneNumberDisabledInputValue({withPlus:!1,store:u.store,checkout:u.checkout}):u.mpVM.saveCardToMasterPass.phoneNumber.replace("+","");if(e){var a,t,o,s,r={creditCard:{rtaPan:u.cardData.cardNumber.replace(/ /g,""),expiryDate:(a=u.cardData.expirationDate,t=a.replace(" / ",""),o=t.substring(0,2),s=t.substring(2,4),"".concat(s).concat(o)),cvc:u.cardData.cvv,accountAliasName:u.mpVM.saveCardToMasterPass.cardName,phoneNumber:e},store:u.store,checkout:u.checkout,paymentGateway:u.checkout.selectedPaymentGateway,callback:function(){u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending=!1}};console.log("onSendConfirmationButtonClick 5",r),u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending=!0,u.mpVM.onSaveCardToMasterPassSendConfirmationButtonClick(r)}}}})))}));export{u as default};
|
package/build/components/checkout/components/master-pass/credit-card-form/style.module.scss.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from'../../../../../ext/style-inject/dist/style-inject.es.js';var o={FormWrapper:"style-module_FormWrapper__2ND8S",CheckboxLabel:"style-module_CheckboxLabel__1uzMC",Logo:"style-module_Logo__1x52P"};e(".style-module_FormWrapper__2ND8S {\n margin-top: 16px;\n}\n\n.style-module_CheckboxLabel__1uzMC {\n color: var(--checkout-primary-text-color);\n}\n.style-module_CheckboxLabel__1uzMC .style-module_Logo__1x52P {\n display: inline-block;\n vertical-align: middle;\n margin: 0 8px;\n}");export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import C from"react";var V=function(){return C.createElement("svg",{width:"89",height:"16",viewBox:"0 0 89 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},C.createElement("path",{d:"M7.61913 15.6541C11.8271 15.6541 15.2383 12.2272 15.2383 8.00001C15.2383 3.77279 11.8271 0.345947 7.61913 0.345947C3.4112 0.345947 0 3.77279 0 8.00001C0 12.2272 3.4112 15.6541 7.61913 15.6541Z",fill:"#EB001B"}),C.createElement("path",{d:"M16.8222 15.6541C21.0302 15.6541 24.4414 12.2272 24.4414 8.00001C24.4414 3.77279 21.0302 0.345947 16.8222 0.345947C12.6143 0.345947 9.20312 3.77279 9.20312 8.00001C9.20312 12.2272 12.6143 15.6541 16.8222 15.6541Z",fill:"#F79E1B"}),C.createElement("path",{d:"M12.2189 1.88745C14.0534 3.28395 15.2346 5.49699 15.2346 7.98475C15.2346 10.4725 14.0534 12.6894 12.2189 14.0859C10.3844 12.6894 9.20312 10.4763 9.20312 7.98475C9.20312 5.49318 10.3882 3.28395 12.2189 1.88745Z",fill:"#FF5F00"}),C.createElement("path",{d:"M23.9646 13.0824V13.1472H23.8241V13.5134H23.7557V13.1472H23.6152V13.0824H23.9646ZM24.5 13.0824V13.5134H24.4316V13.1587L24.3063 13.4715H24.2304L24.1051 13.1625V13.5134H24.0367V13.0824H24.143L24.2683 13.3914L24.3937 13.0824H24.5Z",fill:"#F79E1B"}),C.createElement("path",{d:"M87.4696 8.25565V8.32052H87.3291V8.68681H87.2607V8.32052H87.1202V8.25565H87.4696ZM88.0014 8.25565V8.68681H87.933V8.33196L87.8077 8.64484H87.7355L87.6102 8.33578V8.68681H87.5418V8.25565H87.6482L87.7735 8.56471L87.8988 8.25565H88.0014ZM35.4157 3.41368C36.5818 3.41368 37.406 4.21876 37.406 5.37107V8.46169H36.3311V5.72592C36.3311 4.89794 35.9057 4.43625 35.1916 4.43625C34.5004 4.43625 33.923 4.89412 33.923 5.73737V8.46551H32.8482V5.72974C32.8482 4.90175 32.4228 4.44007 31.7087 4.44007C31.0174 4.44007 30.4401 4.89794 30.4401 5.74118V8.46932H29.3652V3.54722H30.4287V4.14627C30.8237 3.5663 31.4314 3.41749 31.9328 3.41749C32.681 3.41749 33.2887 3.74945 33.6268 4.29508C34.0522 3.58538 34.808 3.41368 35.4157 3.41368ZM43.6426 3.53959V8.46169H42.5753V7.87028C42.2372 8.30525 41.7321 8.58761 41.037 8.58761C39.6659 8.58761 38.5872 7.50398 38.5872 6.00064C38.5872 4.4973 39.6659 3.41368 41.037 3.41368C41.7321 3.41368 42.2372 3.69985 42.5753 4.13864V3.53959H43.6426ZM41.1623 4.42481C40.2432 4.42481 39.6849 5.13832 39.6849 6.00064C39.6849 6.86296 40.2432 7.57648 41.1623 7.57648C42.0473 7.57648 42.6398 6.8973 42.6398 6.00064C42.6398 5.10398 42.0473 4.42481 41.1623 4.42481ZM49.0208 3.93641L48.5612 4.77202C48.2649 4.58888 47.6572 4.35231 47.0495 4.35231C46.4684 4.35231 46.1228 4.58888 46.1228 4.93609C46.1228 5.2795 46.4798 5.3787 46.9318 5.44357L47.4369 5.51988C48.5042 5.6725 49.1385 6.13037 49.1385 6.97362C49.1385 7.91988 48.3219 8.57998 46.909 8.57998C46.4038 8.57998 45.5226 8.48077 44.8086 7.94659L45.3062 7.1415C45.6594 7.41241 46.1228 7.64516 46.9204 7.64516C47.6496 7.64516 48.0332 7.41241 48.0332 7.04611C48.0332 6.76757 47.7674 6.58443 47.1862 6.50048L46.6735 6.43562C45.591 6.28681 45.0137 5.78315 45.0137 4.99333C45.0137 4.01654 45.7923 3.41749 47.0381 3.41749C47.8053 3.41749 48.5156 3.60827 49.0208 3.93641ZM53.6431 3.53959V4.51638H51.7668V6.65692C51.7668 7.32083 52.1163 7.57648 52.5455 7.57648C52.8759 7.57648 53.2405 7.42767 53.533 7.24452L53.9584 8.10303C53.5634 8.37012 53.0696 8.59142 52.4543 8.59142C51.3452 8.59142 50.6958 7.99238 50.6958 6.67982V4.51638H49.7196V3.53959H50.6958V2.05151H51.7706V3.53959H53.6431ZM56.9399 3.41368C58.3111 3.41368 59.2492 4.46296 59.2568 5.99683C59.2568 6.13419 59.2454 6.27536 59.2378 6.39746H55.6182C55.7625 7.28268 56.3816 7.64897 57.0767 7.64897C57.5666 7.64897 58.0908 7.45438 58.4934 7.13005L59.0251 7.89699C58.4288 8.41209 57.7528 8.59142 57.0121 8.59142C55.546 8.59142 54.5053 7.56503 54.5053 6.00446C54.5015 4.45915 55.5004 3.41368 56.9399 3.41368ZM56.921 4.36757C56.1575 4.36757 55.7359 4.85978 55.622 5.58093H58.163C58.0452 4.814 57.6008 4.36757 56.921 4.36757ZM62.9676 3.41368C63.2943 3.41368 63.545 3.45565 63.7918 3.55104L63.5374 4.61559C63.3133 4.4973 62.9866 4.43625 62.7246 4.43625C62.0447 4.43625 61.5585 4.92083 61.5585 5.75645V8.46169H60.4912V3.53959H61.5509V4.09285C61.87 3.62735 62.3713 3.41368 62.9676 3.41368ZM67.3925 3.41368C68.7636 3.41368 69.8423 4.4973 69.8423 6.00064C69.8423 7.50398 68.7636 8.58761 67.3925 8.58761C66.6974 8.58761 66.1961 8.30525 65.8581 7.87409V10.5145H64.7908V3.53959H65.8581V4.12338C66.1961 3.69603 66.6974 3.41368 67.3925 3.41368ZM67.2634 4.42481C66.3784 4.42481 65.7859 5.10398 65.7859 6.00064C65.7859 6.8973 66.3784 7.57648 67.2634 7.57648C68.1825 7.57648 68.7409 6.86296 68.7409 6.00064C68.7409 5.13832 68.1825 4.42481 67.2634 4.42481ZM75.7751 3.53959V8.46169H74.7078V7.87028C74.3697 8.30525 73.8646 8.58761 73.1695 8.58761C71.7984 8.58761 70.7197 7.50398 70.7197 6.00064C70.7197 4.4973 71.7984 3.41368 73.1695 3.41368C73.8646 3.41368 74.3697 3.69985 74.7078 4.13864V3.53959H75.7751ZM73.2949 4.42481C72.3757 4.42481 71.8174 5.13832 71.8174 6.00064C71.8174 6.86296 72.3757 7.57648 73.2949 7.57648C74.1798 7.57648 74.7724 6.8973 74.7724 6.00064C74.7724 5.10398 74.1798 4.42481 73.2949 4.42481ZM81.1533 3.93641L80.6937 4.77202C80.3974 4.58888 79.7897 4.35231 79.182 4.35231C78.6009 4.35231 78.2553 4.58888 78.2553 4.93609C78.2553 5.2795 78.6123 5.3787 79.0643 5.44357L79.5694 5.51988C80.6367 5.6725 81.271 6.13037 81.271 6.97362C81.271 7.91988 80.4544 8.57998 79.0415 8.57998C78.5363 8.57998 77.6552 8.48077 76.9411 7.94659L77.4387 7.1415C77.7919 7.41241 78.2553 7.64516 79.0529 7.64516C79.7821 7.64516 80.1658 7.41241 80.1658 7.04611C80.1658 6.76757 79.8999 6.58443 79.3188 6.50048L78.806 6.43562C77.7235 6.28681 77.1462 5.78315 77.1462 4.99333C77.1462 4.01654 77.9248 3.41749 79.1706 3.41749C79.9379 3.41749 80.6481 3.60827 81.1533 3.93641ZM86.2314 3.93641L85.7719 4.77202C85.4756 4.58888 84.8679 4.35231 84.2602 4.35231C83.6791 4.35231 83.3334 4.58888 83.3334 4.93609C83.3334 5.2795 83.6905 5.3787 84.1424 5.44357L84.6476 5.51988C85.7149 5.6725 86.3492 6.13037 86.3492 6.97362C86.3492 7.91988 85.5326 8.57998 84.1196 8.57998C83.6145 8.57998 82.7333 8.48077 82.0193 7.94659L82.5168 7.1415C82.8701 7.41241 83.3334 7.64516 84.131 7.64516C84.8603 7.64516 85.2439 7.41241 85.2439 7.04611C85.2439 6.76757 84.978 6.58443 84.3969 6.50048L83.8842 6.43562C82.8017 6.28681 82.2244 5.78315 82.2244 4.99333C82.2244 4.01654 83.003 3.41749 84.2488 3.41749C85.016 3.41749 85.7263 3.60827 86.2314 3.93641ZM30.6604 11.1212C31.3061 11.1212 31.8113 11.6286 31.8113 12.3383C31.8113 13.048 31.3061 13.5555 30.6604 13.5555C30.3338 13.5555 30.0983 13.422 29.9388 13.2197V13.4944H29.4374V10.0185H29.9388V11.4569C30.0945 11.2547 30.3338 11.1212 30.6604 11.1212ZM30.5996 11.5981C30.1856 11.5981 29.9046 11.9186 29.9046 12.3383C29.9046 12.758 30.1818 13.0785 30.5996 13.0785C31.0326 13.0785 31.2947 12.7428 31.2947 12.3383C31.2947 11.9339 31.0326 11.5981 30.5996 11.5981ZM34.4852 11.1822L32.6658 14.4751H32.1075L32.9317 13.0213L31.9138 11.1822H32.4759L33.2166 12.51L33.9306 11.1822H34.4852ZM38.7657 11.1212C39.3126 11.1212 39.7001 11.4989 39.7001 12.0407V13.4944H39.1949V12.2086C39.1949 11.8194 38.9936 11.6019 38.6594 11.6019C38.3365 11.6019 38.063 11.8156 38.063 12.2124V13.4944H37.5579V12.2086C37.5579 11.8194 37.3604 11.6019 37.0223 11.6019C36.6995 11.6019 36.426 11.8156 36.426 12.2124V13.4944H35.9209V11.1822H36.4222V11.4646C36.6083 11.1898 36.8932 11.1212 37.1287 11.1212C37.4781 11.1212 37.7668 11.2776 37.9225 11.5332C38.1238 11.2051 38.4808 11.1212 38.7657 11.1212ZM42.5829 11.1822V13.4944H42.0815V13.2159C41.922 13.422 41.6865 13.5555 41.3599 13.5555C40.7142 13.5555 40.209 13.048 40.209 12.3383C40.209 11.6286 40.718 11.1212 41.3599 11.1212C41.6865 11.1212 41.9258 11.2547 42.0815 11.4607V11.1822H42.5829ZM41.4168 11.5981C40.9838 11.5981 40.7218 11.9339 40.7218 12.3383C40.7218 12.7428 40.9838 13.0785 41.4168 13.0785C41.8308 13.0785 42.1119 12.758 42.1119 12.3383C42.1119 11.9148 41.8346 11.5981 41.4168 11.5981ZM45.0631 11.3692L44.8466 11.7622C44.706 11.6744 44.4212 11.5638 44.1363 11.5638C43.8628 11.5638 43.6995 11.6744 43.6995 11.8385C43.6995 11.9987 43.8666 12.0445 44.0793 12.0789L44.3186 12.117C44.82 12.1895 45.12 12.4032 45.12 12.8C45.12 13.2426 44.7364 13.5555 44.0717 13.5555C43.8325 13.5555 43.4223 13.5097 43.0842 13.2579L43.3159 12.8801C43.483 13.0099 43.6995 13.1167 44.0755 13.1167C44.4174 13.1167 44.5997 13.0099 44.5997 12.8344C44.5997 12.7046 44.4744 12.6169 44.2009 12.5787L43.9616 12.5482C43.4526 12.4795 43.1792 12.2429 43.1792 11.869C43.1792 11.4111 43.5438 11.1288 44.1325 11.1288C44.4895 11.125 44.8238 11.2127 45.0631 11.3692ZM47.1862 11.1822V11.6401H46.3051V12.6474C46.3051 12.9603 46.4684 13.0785 46.6697 13.0785C46.8254 13.0785 46.9963 13.0099 47.1331 12.9221L47.3306 13.3266C47.1445 13.4525 46.9128 13.5555 46.6241 13.5555C46.1038 13.5555 45.7961 13.2731 45.7961 12.6588V11.6401H45.3365V11.1822H45.7961V10.484H46.3013V11.1822H47.1862ZM48.6865 11.1212C49.3322 11.1212 49.7728 11.6134 49.7766 12.3345C49.7766 12.3994 49.7728 12.4642 49.7652 12.5215H48.0636C48.132 12.9374 48.4207 13.1091 48.7473 13.1091C48.979 13.1091 49.2221 13.0175 49.412 12.8649L49.6627 13.2235C49.3816 13.4639 49.0625 13.5479 48.7169 13.5479C48.0256 13.5479 47.5395 13.0633 47.5395 12.3307C47.5433 11.6134 48.0105 11.1212 48.6865 11.1212ZM48.6789 11.5714C48.3219 11.5714 48.1206 11.8041 48.0674 12.1399H49.26C49.2069 11.7812 48.998 11.5714 48.6789 11.5714ZM51.4706 11.1212C51.6225 11.1212 51.7403 11.1402 51.858 11.186L51.7365 11.6859C51.6301 11.6286 51.4782 11.6019 51.3528 11.6019C51.0338 11.6019 50.8059 11.827 50.8059 12.2239V13.4944H50.3045V11.1822H50.8021V11.4417C50.954 11.2242 51.1895 11.1212 51.4706 11.1212ZM53.2291 11.1212C53.571 11.1212 53.8862 11.2471 54.0875 11.4913L53.7647 11.8347C53.6052 11.682 53.4342 11.5943 53.2101 11.5943C52.8227 11.5943 52.5303 11.8995 52.5303 12.3345C52.5303 12.7695 52.8227 13.0747 53.2101 13.0747C53.4304 13.0747 53.6279 12.9717 53.7761 12.8344L54.0875 13.1816C53.8786 13.4258 53.571 13.5517 53.2291 13.5517C52.4961 13.5517 52.0175 13.0289 52.0175 12.3345C52.0175 11.6439 52.4961 11.1212 53.2291 11.1212ZM56.7197 11.1822V13.4944H56.2183V13.2159C56.0588 13.422 55.8233 13.5555 55.4966 13.5555C54.851 13.5555 54.3458 13.048 54.3458 12.3383C54.3458 11.6286 54.851 11.1212 55.4966 11.1212C55.8233 11.1212 56.0626 11.2547 56.2183 11.4607V11.1822H56.7197ZM55.5574 11.5981C55.1244 11.5981 54.8623 11.9339 54.8623 12.3383C54.8623 12.7428 55.1244 13.0785 55.5574 13.0785C55.9714 13.0785 56.2525 12.758 56.2525 12.3383C56.2487 11.9148 55.9714 11.5981 55.5574 11.5981ZM58.5846 11.1212C58.7365 11.1212 58.8542 11.1402 58.972 11.186L58.8504 11.6859C58.7441 11.6286 58.5922 11.6019 58.4668 11.6019C58.1478 11.6019 57.9199 11.827 57.9199 12.2239V13.4944H57.4185V11.1822H57.9161V11.4417C58.0642 11.2242 58.2997 11.1212 58.5846 11.1212ZM60.3735 11.1212C60.7001 11.1212 60.9394 11.2547 61.0951 11.4607V10.0185H61.5965V13.4944H61.0951V13.2159C60.9356 13.422 60.7001 13.5555 60.3735 13.5555C59.7278 13.5555 59.2226 13.048 59.2226 12.3383C59.2226 11.6286 59.7316 11.1212 60.3735 11.1212ZM60.4343 11.5981C60.0013 11.5981 59.7392 11.9339 59.7392 12.3383C59.7392 12.7428 60.0013 13.0785 60.4343 13.0785C60.8483 13.0785 61.1293 12.758 61.1293 12.3383C61.1293 11.9148 60.8521 11.5981 60.4343 11.5981Z",fill:"black"}))};export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as t}from"mobx-react-lite";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 a}from"../../../../utils/currency.js";import{useTranslation as r}from"../../../../utils/i18n.js";import{Button as
|
|
1
|
+
import*as e from"react";import{observer as t}from"mobx-react-lite";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 a}from"../../../../utils/currency.js";import{useTranslation as r}from"../../../../utils/i18n.js";import{Button as n}from"../button/index.js";import c from"./select/index.js";import o from"../svg/cross.js";import i from"./style.module.scss.js";var d=function(t){var a=t.seconds,n=t.rejectOffer,c=r().t,o=e.useState(a),d=o[0],s=o[1];e.useEffect((function(){var e=d>0&&setInterval((function(){return s(d-1)}),1e3);return 0===d&&n(),function(){return clearInterval(e)}}),[d]);return e.createElement("div",{className:i.CountdownContainer},e.createElement("div",{className:i.CountdownText},c("checkout-page:timeRemaining",{value:function(e){var t=Math.floor(e/60/60),a=Math.floor(e/60)-60*t,r=e%60;return 0!==t?t.toString().padStart(2,"0")+":":a.toString().padStart(2,"0")+":"+r.toString().padStart(2,"0")}(d)})))},s=t((function(t){var s,m=t.vm,u=t.campaignOffer,l=r().t,f=e.useState(u.productDetail.selectedVariant),p=f[0],v=f[1],g=function(){m.updateCartCampaignOffer({accepted:!1,cartId:m.checkout.id,campaignOfferId:u.campaignOffer.campaignOfferId,campaignOfferProductId:u.offer.id,productId:u.offer.productId,variantId:p.id})},h=Math.round(((new Date).getTime()-new Date(u.campaignOffer.offerStartDate).getTime())/1e3);return e.createElement("div",{className:i.Container},u.offer.countdownMinutes&&e.createElement(d,{seconds:h>60*u.offer.countdownMinutes?0:60*u.offer.countdownMinutes-h,rejectOffer:g}),e.createElement("div",{className:i.ContentContainer},e.createElement("div",{className:i.Header},e.createElement("div",{className:i.Title},u.offer.title),e.createElement("div",{className:i.RejectButton,onClick:g},e.createElement(o,null))),e.createElement("div",{className:i.ProductContainer},e.createElement("div",{className:i.ImageContainer},e.createElement("img",{className:i.Image,src:null===(s=p.mainImage)||void 0===s?void 0:s.thumbnailSrc})),e.createElement("div",{className:i.ProductDetails},e.createElement("div",{className:i.ProductName},u.productDetail.product.name),u.productDetail.product.brand&&e.createElement("div",{className:i.Brand},u.productDetail.product.brand.name),e.createElement("div",{className:i.ProductPrice},e.createElement("span",{className:i.Discount},a(p.price.finalPrice,m.checkout.currencyCode))," ",a(p.price.finalPrice-p.price.finalPrice*(u.offer.discountAmount||100)/100,m.checkout.currencyCode)),e.createElement("div",{className:i.Actions},u.productDetail.product.hasVariant&&u.productDetail.hasStock&&e.createElement(c,{value:p.id,onSelectChange:function(e){var t=u.productDetail.product.variants.find((function(t){return t.id===e}));t&&v(t)},options:u.productDetail.product.variants.filter((function(e){return e.hasStock})).map((function(e){return{label:e.variantValues.map((function(e){return e.name})).join(", "),value:e.id}}))}),e.createElement(n,{style:{width:"100%",height:44,fontSize:14},isDisabled:!u.productDetail.hasStock,text:l("checkout-page:actions.addToCart"),onClick:function(){m.updateCartCampaignOffer({accepted:!0,cartId:m.checkout.id,campaignOfferId:u.campaignOffer.campaignOfferId,campaignOfferProductId:u.offer.id,productId:u.offer.productId,variantId:p.id})}}))))))}));export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from'../../../../ext/style-inject/dist/style-inject.es.js';var e={Container:"style-module_Container__3zW3x",CountdownContainer:"style-module_CountdownContainer__2-1gy",CountdownText:"style-module_CountdownText__X4H5U",ContentContainer:"style-module_ContentContainer__2Xs-1",Header:"style-module_Header__3xT0y",Title:"style-module_Title__2BmRm",RejectButton:"style-module_RejectButton__2ph9e",ProductContainer:"style-module_ProductContainer__1oWuO",ImageContainer:"style-module_ImageContainer__3HIYg",Image:"style-module_Image__3CWsj",ProductDetails:"style-module_ProductDetails__3qkC5",ProductName:"style-module_ProductName__hjoHz",Brand:"style-module_Brand__3LHOL",ProductPrice:"style-module_ProductPrice__2NcwT",Discount:"style-module_Discount__2mg3j",Actions:"style-module_Actions__1lwfq"};n(".style-module_Container__3zW3x {\n margin
|
|
1
|
+
import n from'../../../../ext/style-inject/dist/style-inject.es.js';var e={Container:"style-module_Container__3zW3x",CountdownContainer:"style-module_CountdownContainer__2-1gy",CountdownText:"style-module_CountdownText__X4H5U",ContentContainer:"style-module_ContentContainer__2Xs-1",Header:"style-module_Header__3xT0y",Title:"style-module_Title__2BmRm",RejectButton:"style-module_RejectButton__2ph9e",ProductContainer:"style-module_ProductContainer__1oWuO",ImageContainer:"style-module_ImageContainer__3HIYg",Image:"style-module_Image__3CWsj",ProductDetails:"style-module_ProductDetails__3qkC5",ProductName:"style-module_ProductName__hjoHz",Brand:"style-module_Brand__3LHOL",ProductPrice:"style-module_ProductPrice__2NcwT",Discount:"style-module_Discount__2mg3j",Actions:"style-module_Actions__1lwfq"};n(".style-module_Container__3zW3x {\n margin: 32px 0 48px 0;\n background-color: var(--checkout-card-bg-color);\n border-radius: 8px;\n}\n@media only screen and (max-width: 1000px) {\n .style-module_Container__3zW3x {\n margin: 24px 0 24px 0;\n border-radius: 0;\n }\n}\n\n.style-module_CountdownContainer__2-1gy {\n display: flex;\n justify-content: center;\n padding: 6px;\n background-color: #cfced3;\n border-radius: 8px 8px 0 0;\n}\n@media only screen and (max-width: 1000px) {\n .style-module_CountdownContainer__2-1gy {\n border-radius: 0;\n }\n}\n\n.style-module_CountdownText__X4H5U {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-primary-text-color);\n}\n\n.style-module_ContentContainer__2Xs-1 {\n padding: 24px;\n width: 100%;\n}\n\n.style-module_Header__3xT0y {\n display: flex;\n justify-content: space-between;\n}\n\n.style-module_Title__2BmRm {\n margin-bottom: 24px;\n font-size: 22px;\n color: var(--checkout-primary-text-color);\n font-weight: 600;\n}\n\n.style-module_RejectButton__2ph9e {\n height: 35px;\n width: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n flex: 0 0 20px;\n margin-left: 12px;\n cursor: pointer;\n}\n\n.style-module_ProductContainer__1oWuO {\n display: flex;\n}\n\n.style-module_ImageContainer__3HIYg {\n height: 136px;\n width: 136px;\n position: relative;\n background-color: #fff;\n margin-right: 24px;\n border-radius: 8px;\n flex: 0 0 136px;\n}\n\n.style-module_Image__3CWsj {\n width: 100%;\n height: 100%;\n object-fit: cover;\n border-radius: 8px;\n}\n\n.style-module_ProductDetails__3qkC5 {\n flex: 1;\n}\n\n.style-module_ProductName__hjoHz {\n margin-bottom: 2px;\n font-size: 16px;\n color: var(--checkout-primary-text-color);\n font-weight: 600;\n line-height: 24px;\n}\n\n.style-module_Brand__3LHOL {\n margin-bottom: 2px;\n font-size: 14px;\n color: var(--checkout-primary-text-color);\n line-height: 20px;\n}\n\n.style-module_ProductPrice__2NcwT {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-primary-text-color);\n line-height: 20px;\n}\n\n.style-module_Discount__2mg3j {\n font-size: 14px;\n font-weight: 600;\n color: var(--checkout-secondary-text-color);\n text-decoration: line-through;\n}\n\n.style-module_Actions__1lwfq {\n display: flex;\n margin-top: 24px;\n}");export{e 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 r}from"mobx-react-lite";import{useRouter as i}from"next/router.js";import s from"next/link.js";import a from'../../ext/react-tooltip/dist/index.es.js';import m,{CheckoutStep as n}from"./model.js";import{Analytics as l}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as c}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 d}from"../../utils/currency.js";import{useTranslation as p}from"../../utils/i18n.js";import u from"./steps/step-info/index.js";import{CheckoutStepShipping as v}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as h}from"./steps/step-payment/index.js";import{CartSummary as g}from"./components/cart-summary/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"mobx";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as E}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/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import{ContactForm as f}from"../../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 x}from"./steps/step-success/index.js";import{Modal as j}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import y from"./components/master-pass/modal-link-card-to-client/index.js";import C from"./components/master-pass/modal-response/index.js";import b from"./components/master-pass/modal-success/index.js";import{Image as M}from"../image/index.js";import N,{Step as F}from"./components/step-container/index.js";import{StockError as T}from"./components/error/stock-error/index.js";import{FullscreenLoading as S}from"./components/fullscreen-loading/index.js";import P from"./components/notification-box/index.js";import{FormItem as V}from"./components/form-item/index.js";import{FormItemType as A}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import{IkasPageHead as L}from"../page/head.js";import I from"./components/offer-product/index.js";import B from"./components/svg/ikas.js";import O from"./style.module.scss.js";var R=r((function(e){var t,r,s,d=e.checkout,u=e.checkoutSettings,v=e.merchantSettings,h=e.customizationProps,f=e.returnPolicy,M=e.privacyPolicy,N=e.termsOfService,F=p().t,P=i(),V=o.useState((function(){return new m(d,u,v,P,f,M,N,F,h||{})}))[0];return V.step===n.PAYMENT&&l.disableHTML(),o.useEffect((function(){V.checkoutSettings.isAccountRequired&&!V.checkout.hasCustomer&&P.push("/account/login?redirect="+encodeURIComponent(V.checkoutUrl)),l.beginCheckout(V.checkout),l.pageView(E.CHECKOUT)}),[]),o.useEffect((function(){V.customizationProps=h,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")}(h)}),[h]),V.isCheckoutLoaded&&V.store.customerStore.initialized?V.checkout.hasCustomer&&(null===(t=V.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(r=V.checkout.customer)||void 0===r?void 0:r.id)?(P.push("/account/login?redirect="+encodeURIComponent(V.checkoutUrl)),null):(console.log("vm.mpVM.visibleModal",V.mpVM.visibleModal),o.createElement(o.Fragment,null,o.createElement(L,{pageType:E.CHECKOUT,pageTitle:((null===(s=V.merchantSettings)||void 0===s?void 0:s.merchantName)||"")+" - "+F("checkout-page:securePayment"),pageDescription:F("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:O.CheckoutPage},o.createElement(a,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:O.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:O.Left},o.createElement("div",{className:O.LeftContent},o.createElement("div",null,o.createElement(U,{vm:V}),V.hasStockError&&o.createElement("div",{className:O.ErrorContainer},o.createElement(T,{vm:V,error:V.error})),V.checkoutCampaignOffer&&V.step!==n.SUCCESS&&o.createElement(I,{vm:V,campaignOffer:V.checkoutCampaignOffer}),!V.hasStockError&&o.createElement(o.Fragment,null,o.createElement(g,{vm:V,allowExpand:!0}),V.step===n.SUCCESS?o.createElement(x,{vm:V}):o.createElement(H,{vm:V})),o.createElement("div",{className:O.Space})),o.createElement(G,{vm:V}))),o.createElement("div",{className:O.Right},o.createElement("div",{className:O.RightContent},o.createElement(g,{vm:V}),o.createElement("div",{className:O.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(B,null))))),!!V.policyModalText&&o.createElement(j,{title:V.policyModalTitle,modalContent:V.policyModalText,onClose:function(){V.policyModalText=""}}),V.isContactModalVisible&&o.createElement(Y,{vm:V,setVisible:V.setContactModalVisible}),V.mpVM.isLinkCardToClientModalVisible&&o.createElement(y,{visible:V.mpVM.isLinkCardToClientModalVisible,vm:V,onClose:V.mpVM.hideLinkCardToClientModal}),V.mpVM.isOtpModalVisible&&o.createElement(k,{vm:V,visible:V.mpVM.isOtpModalVisible,type:V.mpVM.otpModalType,onClose:V.mpVM.hideOtpModal}),V.mpVM.isResponseModalVisible&&o.createElement(C,{visible:V.mpVM.isResponseModalVisible,text:V.mpVM.mfsResponseModalText,onClose:V.mpVM.onResponseModalClose}),V.mpVM.isSuccessModalVisible&&o.createElement(b,{visible:V.mpVM.isSuccessModalVisible,type:V.mpVM.successModalType,onClose:V.mpVM.onSuccessModalClose})))):o.createElement(S,null)})),U=r((function(e){var t,r,i=e.vm,a=p().t;return o.createElement("div",{className:O.Header},o.createElement(s,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=i.merchantSettings)||void 0===t?void 0:t.logo)?o.createElement("div",{className:O.Logo},o.createElement(M,{layout:"fill",image:i.merchantSettings.logo,sizes:"360px"})):(null===(r=i.merchantSettings)||void 0===r?void 0:r.merchantName)||"")),!i.checkout.hasCustomer&&o.createElement("div",{className:O.LoginText},o.createElement("span",{className:O.LoginCta},a("checkout-page:alreadyHaveAnAccount")),o.createElement(s,{href:"/account/login?redirect="+encodeURIComponent(i.checkoutUrl),passHref:!0},o.createElement("a",{className:O.LoginBtn},a("checkout-page:actions.login")))),i.checkout.hasCustomer&&o.createElement("div",{className:O.CustomerInfo},o.createElement("div",{className:O.Name},i.checkout.customerFullName),o.createElement("div",{className:O.Email},i.checkout.customerEmail)))})),H=r((function(e){var t=e.vm,r=p().t,i=o.useMemo((function(){switch(t.step){case n.INFO:return o.createElement(u,{vm:t});case n.SHIPPING:return o.createElement(v,{vm:t});case n.PAYMENT:return o.createElement(h,{vm:t});case n.SUCCESS:return o.createElement(x,{vm:t})}}),[t,t.step]),s=[new F(r("checkout-page:address"),t.step===n.INFO,t.step!==n.INFO,t.step!==n.INFO?o.createElement("div",{className:O.AdressStepInfo},o.createElement(_,{vm:t}),o.createElement("div",{className:O.EditBtn,onClick:t.onBackToInfoClick},r("checkout-page:actions.edit"))):void 0,t.step!==n.INFO?o.createElement("div",{className:O.AddressStepInfoMobile},o.createElement(_,{vm:t})):void 0),new F(r("checkout-page:payment"),t.step===n.PAYMENT,!1)];return"address"===t.deliveryMethod&&s.splice(1,0,new F(r("checkout-page:shipping"),t.step===n.SHIPPING,t.step===n.PAYMENT,t.step===n.PAYMENT?o.createElement("div",{className:O.AdressStepInfo},o.createElement(D,{vm:t}),t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1&&o.createElement("div",{className:O.EditBtn,onClick:t.onBackToShippingClick},r("checkout-page:actions.edit"))):void 0,t.step===n.PAYMENT?o.createElement("div",{className:O.AddressStepInfoMobile},o.createElement(D,{vm:t})):void 0)),o.createElement(N,{steps:s,stepContent:i})})),_=r((function(e){var t,r,i,s,a,m=e.vm,n=p().t,l=((null===(t=m.checkout.shippingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(r=m.checkout.shippingAddress)||void 0===r?void 0:r.lastName)||"");return o.createElement("div",{className:O.Address},o.createElement("div",{className:[O.Text,O.WithMBottom].join(" ")},(null===(i=m.checkout.customer)||void 0===i?void 0:i.email)||""),"address"===m.deliveryMethod?o.createElement("div",{className:O.Text},l):o.createElement(o.Fragment,null,o.createElement("div",{className:O.Text},n("checkout-page:receiver")),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},l)),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},null===(s=m.checkout.shippingAddress)||void 0===s?void 0:s.phone),"in-store"===m.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[O.Text,O.WithMTop].join(" ")},n("checkout-page:pickUpLocation"))),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},null===(a=m.checkout.shippingAddress)||void 0===a?void 0:a.addressText))})),D=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:O.Address},t.checkout.shippingLines&&t.checkout.shippingLines.length?o.createElement(o.Fragment,null,o.createElement("span",null,t.checkout.shippingLines[0].title),o.createElement("span",{className:O.LightText}," / "+(0===t.checkout.shippingLines[0].price?r("checkout-page:free"):d(t.checkout.shippingLines[0].price,t.checkout.currencyCode)))):r("checkout-page:standartShipping"))})),G=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:O.Footer},o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},r("checkout-page:returnPolicy")),o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},r("checkout-page:privacyPolicy")),o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},r("checkout-page:termsOfService")))})),Y=r((function(r){var i,s,a=r.vm,m=r.setVisible,n=p().t,l=o.useState(!1),c=l[0],d=l[1],u=o.useState(!1),v=u[0],h=u[1],g=o.useState(new f({message:{requiredRule:"",emailRule:"",minRule:""},store:a.store}))[0];g.email=a.checkout.customerEmail,g.firstName=(null===(i=a.checkout.customer)||void 0===i?void 0:i.firstName)||"",g.lastName=(null===(s=a.checkout.customer)||void 0===s?void 0:s.lastName)||"";var E=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,m(!1)]:(d(!0),[4,g.saveContactForm()]);case 1:return e.sent()&&h(!0),d(!1),[2]}}))}))}),[c]);return o.createElement(j,{title:n("checkout-page:contactForm"),modalContent:o.createElement("div",null,v&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(P,{type:"success",title:n("checkout-page:contactFormSent"),content:n("checkout-page:contactFormDescription")})),o.createElement(V,{type:A.TEXT_AREA,label:"",value:g.message||"",onChange:g.onMessageChange,textAreaPlaceholder:n("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:n(v?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:c,isDisabled:!g.message,onClick:E})),onClose:function(){return m(!1)}})}));export{R as default};
|
|
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 s from"next/link.js";import a from'../../ext/react-tooltip/dist/index.es.js';import m,{CheckoutStep as n}from"./model.js";import{Analytics as l}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as c}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 d}from"../../utils/currency.js";import{useTranslation as p}from"../../utils/i18n.js";import u from"./steps/step-info/index.js";import{CheckoutStepShipping as v}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as h}from"./steps/step-payment/index.js";import{CartSummary as g}from"./components/cart-summary/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"mobx";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as E}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/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import{ContactForm as f}from"../../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 x}from"./steps/step-success/index.js";import{Modal as j}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import y from"./components/master-pass/modal-link-card-to-client/index.js";import C from"./components/master-pass/modal-response/index.js";import b from"./components/master-pass/modal-success/index.js";import{Image as M}from"../image/index.js";import N,{Step as F}from"./components/step-container/index.js";import{StockError as T}from"./components/error/stock-error/index.js";import{FullscreenLoading as P}from"./components/fullscreen-loading/index.js";import S from"./components/notification-box/index.js";import{FormItem as V}from"./components/form-item/index.js";import{FormItemType as A}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import{IkasPageHead as L}from"../page/head.js";import I from"./components/offer-product/index.js";import B from"./components/svg/ikas.js";import O from"./style.module.scss.js";var R=r((function(e){var t,r,s,d=e.checkout,u=e.checkoutSettings,v=e.merchantSettings,h=e.customizationProps,f=e.returnPolicy,M=e.privacyPolicy,N=e.termsOfService,F=p().t,S=i(),V=o.useState((function(){return new m(d,u,v,S,f,M,N,F,h||{})}))[0];return V.step===n.PAYMENT&&l.disableHTML(),o.useEffect((function(){V.checkoutSettings.isAccountRequired&&!V.checkout.hasCustomer&&S.push("/account/login?redirect="+encodeURIComponent(V.checkoutUrl)),l.beginCheckout(V.checkout),l.pageView(E.CHECKOUT)}),[]),o.useEffect((function(){V.customizationProps=h,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")}(h)}),[h]),V.isCheckoutLoaded&&V.store.customerStore.initialized?V.checkout.hasCustomer&&(null===(t=V.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(r=V.checkout.customer)||void 0===r?void 0:r.id)?(S.push("/account/login?redirect="+encodeURIComponent(V.checkoutUrl)),null):(console.log("vm.mpVM.visibleModal",V.mpVM.visibleModal),o.createElement(o.Fragment,null,o.createElement(L,{pageType:E.CHECKOUT,pageTitle:((null===(s=V.merchantSettings)||void 0===s?void 0:s.merchantName)||"")+" - "+F("checkout-page:securePayment"),pageDescription:F("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:O.CheckoutPage},o.createElement(a,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:O.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:O.Left},o.createElement("div",{className:O.LeftContent},o.createElement("div",null,o.createElement(U,{vm:V}),V.hasStockError&&o.createElement("div",{className:O.ErrorContainer},o.createElement(T,{vm:V,error:V.error})),!V.hasStockError&&o.createElement(o.Fragment,null,o.createElement(g,{vm:V,allowExpand:!0}),V.step===n.SUCCESS?o.createElement(x,{vm:V}):o.createElement(o.Fragment,null,V.checkoutCampaignOffer&&o.createElement(I,{vm:V,campaignOffer:V.checkoutCampaignOffer}),o.createElement(H,{vm:V}))),o.createElement("div",{className:O.Space})),o.createElement(G,{vm:V}))),o.createElement("div",{className:O.Right},o.createElement("div",{className:O.RightContent},o.createElement(g,{vm:V}),o.createElement("div",{className:O.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(B,null))))),!!V.policyModalText&&o.createElement(j,{title:V.policyModalTitle,modalContent:V.policyModalText,onClose:function(){V.policyModalText=""}}),V.isContactModalVisible&&o.createElement(Y,{vm:V,setVisible:V.setContactModalVisible}),V.mpVM.isLinkCardToClientModalVisible&&o.createElement(y,{visible:V.mpVM.isLinkCardToClientModalVisible,vm:V,onClose:V.mpVM.hideLinkCardToClientModal}),V.mpVM.isOtpModalVisible&&o.createElement(k,{vm:V,visible:V.mpVM.isOtpModalVisible,type:V.mpVM.otpModalType,onClose:V.mpVM.hideOtpModal}),V.mpVM.isResponseModalVisible&&o.createElement(C,{visible:V.mpVM.isResponseModalVisible,text:V.mpVM.mfsResponseModalText,onClose:V.mpVM.onResponseModalClose}),V.mpVM.isSuccessModalVisible&&o.createElement(b,{visible:V.mpVM.isSuccessModalVisible,type:V.mpVM.successModalType,onClose:V.mpVM.onSuccessModalClose})))):o.createElement(P,null)})),U=r((function(e){var t,r,i=e.vm,a=p().t;return o.createElement("div",{className:O.Header},o.createElement(s,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=i.merchantSettings)||void 0===t?void 0:t.logo)?o.createElement("div",{className:O.Logo},o.createElement(M,{layout:"fill",image:i.merchantSettings.logo,sizes:"360px"})):(null===(r=i.merchantSettings)||void 0===r?void 0:r.merchantName)||"")),!i.checkout.hasCustomer&&o.createElement("div",{className:O.LoginText},o.createElement("span",{className:O.LoginCta},a("checkout-page:alreadyHaveAnAccount")),o.createElement(s,{href:"/account/login?redirect="+encodeURIComponent(i.checkoutUrl),passHref:!0},o.createElement("a",{className:O.LoginBtn},a("checkout-page:actions.login")))),i.checkout.hasCustomer&&o.createElement("div",{className:O.CustomerInfo},o.createElement("div",{className:O.Name},i.checkout.customerFullName),o.createElement("div",{className:O.Email},i.checkout.customerEmail)))})),H=r((function(e){var t=e.vm,r=p().t,i=o.useMemo((function(){switch(t.step){case n.INFO:return o.createElement(u,{vm:t});case n.SHIPPING:return o.createElement(v,{vm:t});case n.PAYMENT:return o.createElement(h,{vm:t});case n.SUCCESS:return o.createElement(x,{vm:t})}}),[t,t.step]),s=[new F(r("checkout-page:address"),t.step===n.INFO,t.step!==n.INFO,t.step!==n.INFO?o.createElement("div",{className:O.AdressStepInfo},o.createElement(_,{vm:t}),o.createElement("div",{className:O.EditBtn,onClick:t.onBackToInfoClick},r("checkout-page:actions.edit"))):void 0,t.step!==n.INFO?o.createElement("div",{className:O.AddressStepInfoMobile},o.createElement(_,{vm:t})):void 0),new F(r("checkout-page:payment"),t.step===n.PAYMENT,!1)];return"address"===t.deliveryMethod&&s.splice(1,0,new F(r("checkout-page:shipping"),t.step===n.SHIPPING,t.step===n.PAYMENT,t.step===n.PAYMENT?o.createElement("div",{className:O.AdressStepInfo},o.createElement(D,{vm:t}),t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1&&o.createElement("div",{className:O.EditBtn,onClick:t.onBackToShippingClick},r("checkout-page:actions.edit"))):void 0,t.step===n.PAYMENT?o.createElement("div",{className:O.AddressStepInfoMobile},o.createElement(D,{vm:t})):void 0)),o.createElement(N,{steps:s,stepContent:i})})),_=r((function(e){var t,r,i,s,a,m=e.vm,n=p().t,l=((null===(t=m.checkout.shippingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(r=m.checkout.shippingAddress)||void 0===r?void 0:r.lastName)||"");return o.createElement("div",{className:O.Address},o.createElement("div",{className:[O.Text,O.WithMBottom].join(" ")},(null===(i=m.checkout.customer)||void 0===i?void 0:i.email)||""),"address"===m.deliveryMethod?o.createElement("div",{className:O.Text},l):o.createElement(o.Fragment,null,o.createElement("div",{className:O.Text},n("checkout-page:receiver")),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},l)),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},null===(s=m.checkout.shippingAddress)||void 0===s?void 0:s.phone),"in-store"===m.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[O.Text,O.WithMTop].join(" ")},n("checkout-page:pickUpLocation"))),o.createElement("div",{className:[O.Text,O.Gray].join(" ")},null===(a=m.checkout.shippingAddress)||void 0===a?void 0:a.addressText))})),D=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:O.Address},t.checkout.shippingLines&&t.checkout.shippingLines.length?o.createElement(o.Fragment,null,o.createElement("span",null,t.checkout.shippingLines[0].title),o.createElement("span",{className:O.LightText}," / "+(0===t.checkout.shippingLines[0].price?r("checkout-page:free"):d(t.checkout.shippingLines[0].price,t.checkout.currencyCode)))):r("checkout-page:standartShipping"))})),G=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:O.Footer},o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},r("checkout-page:returnPolicy")),o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},r("checkout-page:privacyPolicy")),o.createElement("div",{className:O.FooterBullet},"•"),o.createElement("div",{className:O.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},r("checkout-page:termsOfService")))})),Y=r((function(r){var i,s,a=r.vm,m=r.setVisible,n=p().t,l=o.useState(!1),c=l[0],d=l[1],u=o.useState(!1),v=u[0],h=u[1],g=o.useState(new f({message:{requiredRule:"",emailRule:"",minRule:""},store:a.store}))[0];g.email=a.checkout.customerEmail,g.firstName=(null===(i=a.checkout.customer)||void 0===i?void 0:i.firstName)||"",g.lastName=(null===(s=a.checkout.customer)||void 0===s?void 0:s.lastName)||"";var E=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,m(!1)]:(d(!0),[4,g.saveContactForm()]);case 1:return e.sent()&&h(!0),d(!1),[2]}}))}))}),[c]);return o.createElement(j,{title:n("checkout-page:contactForm"),modalContent:o.createElement("div",null,v&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(S,{type:"success",title:n("checkout-page:contactFormSent"),content:n("checkout-page:contactFormDescription")})),o.createElement(V,{type:A.TEXT_AREA,label:"",value:g.message||"",onChange:g.onMessageChange,textAreaPlaceholder:n("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:n(v?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:c,isDisabled:!g.message,onClick:E})),onClose:function(){return m(!1)}})}));export{R as default};
|
|
@@ -16,8 +16,8 @@ import { CreateStripePaymentIntentResponse } from "../../__api/models/CreateStri
|
|
|
16
16
|
import { IkasCheckoutCustomizationProps } from ".";
|
|
17
17
|
import MasterPassModel from "./modelMasterPass";
|
|
18
18
|
import { CampaignOfferTargetPageTypeEnum, UpdateCartCampaignOfferInput } from "src/__api/types";
|
|
19
|
-
import { CampaignOffer } from "src/__api/models/CampaignOffer";
|
|
20
19
|
import { CampaignOfferProduct } from "src/__api/models/CampaignOfferProduct";
|
|
20
|
+
import { CartV2CampaignOffer } from "src/__api/models/CartV2CampaignOffer";
|
|
21
21
|
export default class CheckoutViewModel {
|
|
22
22
|
checkout: IkasCheckout;
|
|
23
23
|
checkoutSettings: IkasCheckoutSettings;
|
|
@@ -130,7 +130,7 @@ export default class CheckoutViewModel {
|
|
|
130
130
|
getProduct: (productId: string) => Promise<IkasProductDetail | null>;
|
|
131
131
|
getCampaignOfferProducts: (tagetPage: CampaignOfferTargetPageTypeEnum) => Promise<{
|
|
132
132
|
productDetail: IkasProductDetail;
|
|
133
|
-
campaignOffer:
|
|
133
|
+
campaignOffer: IkasCartCampaignOffer;
|
|
134
134
|
offer: import("src/__api/models/CampaignOfferProduct").CampaignOfferProductData;
|
|
135
135
|
} | undefined>;
|
|
136
136
|
getCampaignOffer: () => Promise<void>;
|
|
@@ -160,6 +160,6 @@ export declare type StockErrorData = {
|
|
|
160
160
|
};
|
|
161
161
|
export declare type CampaignOfferType = {
|
|
162
162
|
productDetail: IkasProductDetail;
|
|
163
|
-
campaignOffer:
|
|
163
|
+
campaignOffer: CartV2CampaignOffer;
|
|
164
164
|
offer: CampaignOfferProduct;
|
|
165
165
|
};
|
|
@@ -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/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as o}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as a}from"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import{IkasOrderCustomer as c}from"../../models/data/order/customer/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/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{IkasProductDetail as d}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/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/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"../../models/data/payment-gateway/index.js";import u from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as l}from"../../storefront/index.js";import{IkasCheckoutSettings as h}from"../../models/data/checkout-settings/index.js";import{Analytics as p}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import m from"../../models/data/checkout/index.js";import f from"../../store/customer/api.js";import v from"../../store/merchant/index.js";import g from"../../store/checkout/index.js";import{CheckStocksLineInput as y}from"../../__api/models/CheckStocksLineInput.js";import S from"../../store/cart/api.js";import{SaveCartInput as k}from"../../__api/models/SaveCartInput.js";import{PaymentMethodEnum as b,PaymentGatewayTypeEnum as C,CartCampaignOfferStatus as I,TransactionStatusEnum as P,CampaignOfferTargetPageTypeEnum as A}from"../../__api/types/index.js";import w from"./modelMasterPass.js";import j from"../../store/product/index.js";import N from'../../ext/uuid/dist/esm-node/v4.js';var O,R,x=/^\d+$/,E="undefined"==typeof localStorage,T=function(){function x(x,T,G,_,L,U,V,F,H){var Y=this;this.checkout=new m,this.checkoutSettings=new h,this.storefront=null,this.store=l.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=O.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(Y,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.getCampaignOffer()];case 3:return t.sent(),[4,this.initStep()];case 4:return t.sent(),[2]}}))}))},this.initStep=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,c;return e(this,(function(e){switch(e.label){case 0:if(l.isEditor)return this.step=O.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===O.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(O.INFO)];if(this.step!==O.PAYMENT||this.canProceedToPayment){if(![O.INFO,O.SUCCESS,O.SHIPPING,O.PAYMENT].includes(this.step))return[2,this.changeStep(O.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(O.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:R.PAYMENT_ERROR,data:n||null}),this.step!==O.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==O.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=O.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==O.SHIPPING||(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)?this.step!==O.PAYMENT&&this.step!==O.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:R.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:R.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===O.PAYMENT&&this.isInStoreDelivery&&(this.checkout.billingAddress=new a),this.step===O.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(O.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,p.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:[4,v.listMerchantSettings({})];case 1:t=e.sent(),this.merchantSettings=t.data||void 0,e.label=2;case 2:return[2]}}))}))},this.getSuccessTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,f.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[0]:void 0,[2]}}))}))},this.saveCart=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=new k(this.checkout)).cartId=this.checkout.id,"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step===O.INFO&&(t.billingAddress=null),[4,S.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:R.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:R.API_ERROR};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(Y,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,h,p;return e(this,(function(e){switch(e.label){case 0:return t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,g.checkStocks({lines:t.map((function(t){return new y(t)})),stockLocationIdList:l.stockLocationIds||[]})];case 1:if(!(i=e.sent()).isSuccess)throw{type:R.API_ERROR};if(null==(s=null===(h=null===(u=i.data)||void 0===u?void 0:u.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(p=o.store.cartStore.cart)||void 0===p?void 0:p.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:R.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(Y,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(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,g.getAvailableShippingCountries({salesChannelId:l.salesChannelId})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?[4,g.listStockLocation({id:{in:l.pickUpStockLocationIds}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:R.API_ERROR},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,g.getAvailableStockLocations({lines:t.map((function(t){return new y(t)})),stockLocationIdList:l.pickUpStockLocationIds})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:R.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=Y.shippingCountryIds)||void 0===t?void 0:t.length)||(Y.error={type:R.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(Y.checkout.stockLocationId=null),Y.deliveryMethod=t,Y.isErrorsVisible=!1},this.initialStockCheck=function(){return t(Y,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:R.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,o,a,c,d,u,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=l.paymentGateways.map((function(t){return t.id})),[4,g.listPaymentGateway({id:t?void 0:{in:i}})];case 1:return(s=e.sent()).isSuccess&&(null===(d=s.data)||void 0===d?void 0:d.length)?(n=s.data,this.step===O.PAYMENT&&(n=n.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(u=this.checkout.shippingAddress)||void 0===u?void 0:u.country)&&o.iso2&&(n=n.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(o.iso2||"")})))),a=[],r(l.paymentGateways,"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),console.log("1"),this.step===O.PAYMENT&&(console.log("2",{paymentGateways:n}),(c=n.find((function(t){return!!t.masterPassClientId})))&&(console.log("3"),this.checkout.masterPassPaymentGateway=c,this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),[2]):(this.error={type:R.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,g.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;Y.store.customerStore.customer?(null===(t=Y.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=Y.checkoutSettings})),Y.checkout.customer=new c(Y.store.customerStore.customer)):Y.checkout.customer||(Y.checkout.customer=new c({}))},this.createShippingAddress=function(){var t;if(Y.checkout.shippingAddress)Y.selectedShippingAddressId=Y.checkout.shippingAddress.id||"-1",Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings;else{var e=null===(t=Y.store.customerStore.customer)||void 0===t?void 0:t.addresses;Y.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(Y.useDifferentAddress=!!localStorage.getItem("sAddr"),Y.useDifferentAddress?(Y.checkout.billingAddress&&(Y.selectedBillingAddressId=Y.checkout.billingAddress.id||"-1"),Y.checkout.billingAddress=Y.checkout.billingAddress||new a):Y.isInStoreDelivery?Y.checkout.billingAddress=new a(n(Y.checkout.billingAddress)||{}):Y.checkout.billingAddress=new a(n(Y.checkout.shippingAddress)||{}),Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onShippingMethodChange=function(i){return t(Y,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.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new m(t)),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(Y,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,S.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data&&(s=t.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===O.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),s&&(r=this.checkout,this.checkout=new m(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})))),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(Y.selectedShippingAddressId=t,"-1"===t)Y.checkout.shippingAddress=new a;else{var s=null===(i=null===(e=Y.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(Y.checkout.shippingAddress=new a(s))}Y.checkout.shippingAddress&&(Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(Y.selectedBillingAddressId=t,"-1"===t)Y.checkout.billingAddress=new a;else{var s=null===(i=null===(e=Y.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(Y.checkout.billingAddress=new a(s))}Y.checkout.billingAddress&&(Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){Y.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(Y.cardData&&(!(t.length>Y.cardData.cardNumber.length)||M(t))){var e=(Y.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!Y.installmentInfo?Y.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:Y.checkout.selectedPaymentGateway.id,price:Y.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(Y.cardData.installmentCount=1,Y.installmentInfo=void 0),Y.cardData.cardNumber=D(i,4).join(" "))}},this.onCardHolderNameChange=function(t){Y.cardData&&(Y.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(Y.cardData&&(!(t.length>Y.cardData.expirationDate.length)||M(t))){if(0===(null===(e=Y.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(Y.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(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(Y.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(Y.cardData.expirationDate=D(a,2).join(" / "))}},this.onCvcChange=function(t){Y.cardData&&(t.length>Y.cardData.cvv.length&&!M(t)||t.length>4||(Y.cardData.cvv=t))},this.saveAddress=function(s){return t(Y,void 0,void 0,(function(){var t,r,a,c,d;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(d=this.store.customerStore.customer.addresses)||void 0===d?void 0:d.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=new o(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:N()})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(r),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return c=e.sent(),console.error(c),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){Y.router.push("/cart")},this.onBackToShoppingClick=function(){Y.router.push("/")},this.onProceedToShippingClick=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(O.SHIPPING):this.changeStep(O.PAYMENT),[3,7];case 6:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(Y,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.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(O.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(Y,void 0,void 0,(function(){var t,i;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,7,,8]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),"address"!==this.deliveryMethod?[3,4]:[4,this.saveAddress("billing")];case 3:e.sent(),e.label=4;case 4:return[4,this.saveCart()];case 5:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 6:return e.sent(),[3,8];case 7:return(i=e.sent()).type?this.error=i:this.error={type:R.UNKNOWN},this.isStepLoading=!1,[3,8];case 8:return[2]}}))}))},this.createSaleTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h,p,m,f;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(c=this.mpVM.selectedCard)||void 0===c?void 0:c.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(d=this.cardData)||void 0===d?void 0:d.installmentCount)?[2]:[4,g.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name},paymentGatewayId:null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(h=this.cardData)||void 0===h?void 0:h.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,g.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===b.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===C.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(m=null==s?void 0:s.data)||void 0===m?void 0:m.transactionStatus,o=r&&[P.SUCCESS,P.AUTHORIZED].includes(r),a=r===P.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!a||!(null===(f=null==s?void 0:s.data)||void 0===f?void 0:f.returnSlug))throw{type:R.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(Y,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(O.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){Y.changeStep(O.INFO)},this.onBackToShippingClick=function(){Y.changeStep(O.SHIPPING)},this.setCustomerConsentGranted=function(t){Y.checkout.customer&&(Y.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){Y.useDifferentAddress=t,Y.useDifferentAddress?(localStorage.setItem("sAddr","1"),Y.checkout.billingAddress=Y.checkout.billingAddress||new a):(localStorage.removeItem("sAddr"),Y.checkout.billingAddress=Y.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){Y.shouldSaveAddress=t},this.setAddressTitle=function(t){Y.addressTitle=t},this.setPaymentGateway=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))||this.stripeResponse?[3,2]:[4,g.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return this.checkout.selectedPaymentGateway=t,this.step!==O.SUCCESS&&(t.paymentMethodType===b.CREDIT_CARD&&t.type===C.INTERNAL&&(this.cardData=new u),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){Y.cardData&&(Y.cardData.installmentCount=t)},this.changeStep=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return E||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(Y,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){Y.isContactModalVisible=t},this.getWaitingForActionCampaignOffer=function(t){if(Y.checkout.campaignOffers&&Y.checkout.campaignOffers.length){var e=Y.checkout.campaignOffers.filter((function(e){var i;return e.status===I.WAITING_FOR_ACTION&&(null===(i=e.campaignOffer)||void 0===i?void 0:i.targetPageTypes.some((function(e){return e===t})))}));if(e.length)return e[0]}return null},this.getOffer=function(t){return t.campaignOffer?t.campaignOffer.offers.find((function(e){return e.id===t.campaignOfferProductId})):null},this.getProduct=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,j.searchProducts({input:{productIdList:[i]}})];case 1:return(t=e.sent()).isSuccess&&t.data&&t.data.data&&t.data.data.length?(s=t.data.data[0],n=s.variants.find((function(t){return t.isActive})),[2,new d(s,(n||s.variants[0]).variantValues)]):[2,null]}}))}))},this.getCampaignOfferProducts=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=this.getWaitingForActionCampaignOffer(i))&&t.campaignOffer&&(s=this.getOffer(t))?[4,this.getProduct(s.productId)]:[3,2];case 1:if(n=e.sent())return[2,{productDetail:n,campaignOffer:t.campaignOffer,offer:s}];e.label=2;case 2:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(A.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(A.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return t(Y,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,S.updateCartCampaignOffer({input:i})];case 1:return(t=e.sent())&&t.isSuccess&&t.data?(s=new m(t.data),[4,this.getCampaignOffer()]):[3,4];case 2:return e.sent(),this.checkout=s,[4,this.init()];case 3:e.sent(),e.label=4;case 4:return this.isCheckoutLoaded=!0,[2]}}))}))},this.checkout=x,this.checkoutSettings=T,this.router=_,this.returnPolicy=L,this.privacyPolicy=U,this.termsOfService=V,this.t=F,this.customizationProps=H,this.mpVM=new w,G&&(this.merchantSettings=G),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(x.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(x.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"finalPrice",{get:function(){return this.step===O.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===R.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(e=this.error)||void 0===e?void 0:e.type)!==R.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid),r=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===b.CREDIT_CARD&&i.type===C.INTERNAL?!!this.isCustomFlowStripe||(null===(e=this.cardData)||void 0===e?void 0:e.isValid):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),x}();function D(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function M(t){return t&&x.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(O||(O={})),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"}(R||(R={}));export{O as CheckoutStep,R as ErrorType,T 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/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as o}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as a}from"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import{IkasOrderCustomer as c}from"../../models/data/order/customer/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/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{IkasProductDetail as d}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/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/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"../../models/data/payment-gateway/index.js";import u from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as l}from"../../storefront/index.js";import{IkasCheckoutSettings as h}from"../../models/data/checkout-settings/index.js";import{Analytics as p}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import m from"../../models/data/checkout/index.js";import f from"../../store/customer/api.js";import v from"../../store/merchant/index.js";import g from"../../store/checkout/index.js";import{CheckStocksLineInput as y}from"../../__api/models/CheckStocksLineInput.js";import S from"../../store/cart/api.js";import{SaveCartInput as k}from"../../__api/models/SaveCartInput.js";import{PaymentMethodEnum as b,PaymentGatewayTypeEnum as C,CartCampaignOfferStatus as I,TransactionStatusEnum as P,CampaignOfferTargetPageTypeEnum as A}from"../../__api/types/index.js";import w from"./modelMasterPass.js";import j from"../../store/product/index.js";import N from'../../ext/uuid/dist/esm-node/v4.js';var O,R,x=/^\d+$/,E="undefined"==typeof localStorage,T=function(){function x(x,T,G,_,L,U,V,F,H){var Y=this;this.checkout=new m,this.checkoutSettings=new h,this.storefront=null,this.store=l.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=O.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(Y,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.getCampaignOffer()];case 3:return t.sent(),[4,this.initStep()];case 4:return t.sent(),[2]}}))}))},this.initStep=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,c;return e(this,(function(e){switch(e.label){case 0:if(l.isEditor)return this.step=O.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===O.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(O.INFO)];if(this.step!==O.PAYMENT||this.canProceedToPayment){if(![O.INFO,O.SUCCESS,O.SHIPPING,O.PAYMENT].includes(this.step))return[2,this.changeStep(O.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(O.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:R.PAYMENT_ERROR,data:n||null}),this.step!==O.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==O.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=O.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==O.SHIPPING||(null===(c=this.checkout.availableShippingMethods)||void 0===c?void 0:c.length)?this.step!==O.PAYMENT&&this.step!==O.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:R.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:R.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===O.PAYMENT&&this.isInStoreDelivery&&(this.checkout.billingAddress=new a),this.step===O.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(O.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,p.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:[4,v.listMerchantSettings({})];case 1:t=e.sent(),this.merchantSettings=t.data||void 0,e.label=2;case 2:return[2]}}))}))},this.getSuccessTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,f.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[0]:void 0,[2]}}))}))},this.saveCart=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=new k(this.checkout)).cartId=this.checkout.id,"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step===O.INFO&&(t.billingAddress=null),[4,S.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:R.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:R.API_ERROR};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(Y,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,h,p;return e(this,(function(e){switch(e.label){case 0:return t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,g.checkStocks({lines:t.map((function(t){return new y(t)})),stockLocationIdList:l.stockLocationIds||[]})];case 1:if(!(i=e.sent()).isSuccess)throw{type:R.API_ERROR};if(null==(s=null===(h=null===(u=i.data)||void 0===u?void 0:u.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(p=o.store.cartStore.cart)||void 0===p?void 0:p.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:R.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(Y,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(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,g.getAvailableShippingCountries({salesChannelId:l.salesChannelId})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?[4,g.listStockLocation({id:{in:l.pickUpStockLocationIds}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:R.API_ERROR},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,g.getAvailableStockLocations({lines:t.map((function(t){return new y(t)})),stockLocationIdList:l.pickUpStockLocationIds})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:R.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=Y.shippingCountryIds)||void 0===t?void 0:t.length)||(Y.error={type:R.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(Y.checkout.stockLocationId=null),Y.deliveryMethod=t,Y.isErrorsVisible=!1},this.initialStockCheck=function(){return t(Y,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:R.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,o,a,c,d,u,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=l.paymentGateways.map((function(t){return t.id})),[4,g.listPaymentGateway({id:t?void 0:{in:i}})];case 1:return(s=e.sent()).isSuccess&&(null===(d=s.data)||void 0===d?void 0:d.length)?(n=s.data,this.step===O.PAYMENT&&(n=n.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(u=this.checkout.shippingAddress)||void 0===u?void 0:u.country)&&o.iso2&&(n=n.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(o.iso2||"")})))),a=[],r(l.paymentGateways,"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),console.log("1"),this.step===O.PAYMENT&&(console.log("2",{paymentGateways:n}),(c=n.find((function(t){return!!t.masterPassClientId})))&&(console.log("3"),this.checkout.masterPassPaymentGateway=c,this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),[2]):(this.error={type:R.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,g.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;Y.store.customerStore.customer?(null===(t=Y.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=Y.checkoutSettings})),Y.checkout.customer=new c(Y.store.customerStore.customer)):Y.checkout.customer||(Y.checkout.customer=new c({}))},this.createShippingAddress=function(){var t;if(Y.checkout.shippingAddress)Y.selectedShippingAddressId=Y.checkout.shippingAddress.id||"-1",Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings;else{var e=null===(t=Y.store.customerStore.customer)||void 0===t?void 0:t.addresses;Y.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(Y.useDifferentAddress=!!localStorage.getItem("sAddr"),Y.useDifferentAddress?(Y.checkout.billingAddress&&(Y.selectedBillingAddressId=Y.checkout.billingAddress.id||"-1"),Y.checkout.billingAddress=Y.checkout.billingAddress||new a):Y.isInStoreDelivery?Y.checkout.billingAddress=new a(n(Y.checkout.billingAddress)||{}):Y.checkout.billingAddress=new a(n(Y.checkout.shippingAddress)||{}),Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onShippingMethodChange=function(i){return t(Y,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.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new m(t)),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(Y,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,S.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data&&(s=t.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===O.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),s&&(r=this.checkout,this.checkout=new m(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})))),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(Y.selectedShippingAddressId=t,"-1"===t)Y.checkout.shippingAddress=new a;else{var s=null===(i=null===(e=Y.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(Y.checkout.shippingAddress=new a(s))}Y.checkout.shippingAddress&&(Y.checkout.shippingAddress.checkoutSettings=Y.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(Y.selectedBillingAddressId=t,"-1"===t)Y.checkout.billingAddress=new a;else{var s=null===(i=null===(e=Y.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(Y.checkout.billingAddress=new a(s))}Y.checkout.billingAddress&&(Y.checkout.billingAddress.checkoutSettings=Y.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){Y.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(Y.cardData&&(!(t.length>Y.cardData.cardNumber.length)||M(t))){var e=(Y.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!Y.installmentInfo?Y.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:Y.checkout.selectedPaymentGateway.id,price:Y.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(Y.cardData.installmentCount=1,Y.installmentInfo=void 0),Y.cardData.cardNumber=D(i,4).join(" "))}},this.onCardHolderNameChange=function(t){Y.cardData&&(Y.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(Y.cardData&&(!(t.length>Y.cardData.expirationDate.length)||M(t))){if(0===(null===(e=Y.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(Y.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(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(Y.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(Y.cardData.expirationDate=D(a,2).join(" / "))}},this.onCvcChange=function(t){Y.cardData&&(t.length>Y.cardData.cvv.length&&!M(t)||t.length>4||(Y.cardData.cvv=t))},this.saveAddress=function(s){return t(Y,void 0,void 0,(function(){var t,r,a,c,d;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(d=this.store.customerStore.customer.addresses)||void 0===d?void 0:d.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=new o(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:N()})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(r),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return c=e.sent(),console.error(c),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){Y.router.push("/cart")},this.onBackToShoppingClick=function(){Y.router.push("/")},this.onProceedToShippingClick=function(){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(O.SHIPPING):this.changeStep(O.PAYMENT),[3,7];case 6:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(Y,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.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(O.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(Y,void 0,void 0,(function(){var t,i;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,7,,8]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),"address"!==this.deliveryMethod?[3,4]:[4,this.saveAddress("billing")];case 3:e.sent(),e.label=4;case 4:return[4,this.saveCart()];case 5:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 6:return e.sent(),[3,8];case 7:return(i=e.sent()).type?this.error=i:this.error={type:R.UNKNOWN},this.isStepLoading=!1,[3,8];case 8:return[2]}}))}))},this.createSaleTransaction=function(){return t(Y,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h,p,m,f;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(c=this.mpVM.selectedCard)||void 0===c?void 0:c.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(d=this.cardData)||void 0===d?void 0:d.installmentCount)?[2]:[4,g.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.Name},paymentGatewayId:null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(h=this.cardData)||void 0===h?void 0:h.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,g.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===b.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===C.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(m=null==s?void 0:s.data)||void 0===m?void 0:m.transactionStatus,o=r&&[P.SUCCESS,P.AUTHORIZED].includes(r),a=r===P.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!a||!(null===(f=null==s?void 0:s.data)||void 0===f?void 0:f.returnSlug))throw{type:R.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(Y,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(O.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){Y.changeStep(O.INFO)},this.onBackToShippingClick=function(){Y.changeStep(O.SHIPPING)},this.setCustomerConsentGranted=function(t){Y.checkout.customer&&(Y.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){Y.useDifferentAddress=t,Y.useDifferentAddress?(localStorage.setItem("sAddr","1"),Y.checkout.billingAddress=Y.checkout.billingAddress||new a):(localStorage.removeItem("sAddr"),Y.checkout.billingAddress=Y.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){Y.shouldSaveAddress=t},this.setAddressTitle=function(t){Y.addressTitle=t},this.setPaymentGateway=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))||this.stripeResponse?[3,2]:[4,g.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return this.checkout.selectedPaymentGateway=t,this.step!==O.SUCCESS&&(t.paymentMethodType===b.CREDIT_CARD&&t.type===C.INTERNAL&&(this.cardData=new u),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){Y.cardData&&(Y.cardData.installmentCount=t)},this.changeStep=function(i){return t(Y,void 0,void 0,(function(){return e(this,(function(t){return E||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(Y,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){Y.isContactModalVisible=t},this.getWaitingForActionCampaignOffer=function(t){if(Y.checkout.campaignOffers&&Y.checkout.campaignOffers.length){var e=Y.checkout.campaignOffers.filter((function(e){var i;return e.status===I.WAITING_FOR_ACTION&&(null===(i=e.campaignOffer)||void 0===i?void 0:i.targetPageTypes.some((function(e){return e===t})))}));if(e.length)return e[0]}return null},this.getOffer=function(t){return t.campaignOffer?t.campaignOffer.offers.find((function(e){return e.id===t.campaignOfferProductId})):null},this.getProduct=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,j.searchProducts({input:{productIdList:[i]}})];case 1:return(t=e.sent()).isSuccess&&t.data&&t.data.data&&t.data.data.length?(s=t.data.data[0],n=s.variants.find((function(t){return t.isActive})),[2,new d(s,(n||s.variants[0]).variantValues)]):[2,null]}}))}))},this.getCampaignOfferProducts=function(i){return t(Y,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=this.getWaitingForActionCampaignOffer(i))&&t.campaignOffer&&(s=this.getOffer(t))?[4,this.getProduct(s.productId)]:[3,2];case 1:if(n=e.sent())return[2,{productDetail:n,campaignOffer:t,offer:s}];e.label=2;case 2:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return t(Y,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(A.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(A.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return t(Y,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,S.updateCartCampaignOffer({input:i})];case 1:return(t=e.sent())&&t.isSuccess&&t.data?(this.checkout=new m(t.data),[4,this.init()]):[3,3];case 2:e.sent(),e.label=3;case 3:return this.isCheckoutLoaded=!0,[2]}}))}))},this.checkout=x,this.checkoutSettings=T,this.router=_,this.returnPolicy=L,this.privacyPolicy=U,this.termsOfService=V,this.t=F,this.customizationProps=H,this.mpVM=new w,G&&(this.merchantSettings=G),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(x.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(x.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"finalPrice",{get:function(){return this.step===O.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===R.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(e=this.error)||void 0===e?void 0:e.type)!==R.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid),r=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===b.CREDIT_CARD&&i.type===C.INTERNAL?!!this.isCustomFlowStripe||(null===(e=this.cardData)||void 0===e?void 0:e.isValid):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),x}();function D(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function M(t){return t&&x.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(O||(O={})),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"}(R||(R={}));export{O as CheckoutStep,R as ErrorType,T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/payment-gateway/index.js";import{CreditCardForm as n}from"../../../components/credit-card-form/index.js";import{Installments as a}from"./installments/index.js";import o from"../../../components/select-box/index.js";import r from"./style.module.scss.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 l}from"../../../../../utils/currency.js";import{useTranslation as m}from"../../../../../utils/i18n.js";import i from"../../../components/svg/external.js";import
|
|
1
|
+
import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/payment-gateway/index.js";import{CreditCardForm as n}from"../../../components/credit-card-form/index.js";import{Installments as a}from"./installments/index.js";import o from"../../../components/select-box/index.js";import r from"./style.module.scss.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 l}from"../../../../../utils/currency.js";import{useTranslation as m}from"../../../../../utils/i18n.js";import i from"../../../components/svg/external.js";import s from"../../../components/master-pass/payment-gateway/svg/master-card.js";import{StripeForm as c}from"../../../components/stripe/index.js";import d from"../../../components/credit-card-form/model.js";import p from"../../../components/master-pass/credit-card-form/index.js";import{PaymentMethodEnum as u,PaymentGatewayTypeEnum as y,PaymentGatewayTransactionFeeTypeEnum as f,PaymentGatewayAdditionalPriceTypeEnum as E}from"../../../../../__api/types/index.js";var v=t((function(t){var v=t.vm,h=m().t,g=function(t){return e.createElement("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",flexWrap:"wrap"}},t.children)},I=function(t){return e.createElement("div",{className:r.AdditionalPrice},t.children)},C=function(e){var t;return"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"allow_custom_flow"===e.label&&"true"===e.value})))};return e.createElement(e.Fragment,null,!!v.mpVM.cards.length&&v.mpVM.cards.map((function(t,n){var l,m=v.paymentGateways.find((function(e){return e.id===t.paymentGatewayId})),i=e.createElement("button",{className:r.MasterPassSelectBoxDeleteButton,onClick:function(e){e.stopPropagation(),v.mpVM.deleteCard({store:v.store,checkout:v.checkout,card:t})}},h("checkout-page:masterPass.paymentGatewaySelectBox.delete")),c=e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement("span",{className:r.MasterPassSelectBoxLabelLogo},e.createElement(s,null)),t.Name," ",t.Value1),p=(null==m?void 0:m.id)&&m.paymentMethodType===u.CREDIT_CARD&&m.type===y.INTERNAL?v.installmentInfo&&e.createElement(a,{vm:v}):void 0;return e.createElement(o,{key:n,isSelected:(null===(l=v.mpVM.selectedCard)||void 0===l?void 0:l.UniqueId)===t.UniqueId,label:c,rightContent:i,bottomContent:p,onClick:function(){var e;(null===(e=v.mpVM.selectedCard)||void 0===e?void 0:e.UniqueId)!==t.UniqueId&&(v.checkout.selectedPaymentGateway=null,v.cardData=new d,v.installmentInfo=void 0,v.mpVM.selectedCard=t,t.Value1&&t.paymentGatewayId&&v.checkout.totalFinalPrice&&v.retrieveInstallmentInfo({input:{binNumber:t.Value1.slice(0,6),paymentGatewayId:t.paymentGatewayId,price:v.checkout.totalFinalPrice}}))}})})),v.paymentGateways.filter((function(e){return"in-store"!==v.deliveryMethod||e.paymentMethodType!==u.CASH_ON_DELIVERY&&e.paymentMethodType!==u.CREDIT_CARD_ON_DELIVERY})).map((function(t,m){var s,d,x=t.paymentMethodType===u.CREDIT_CARD&&t.type===y.INTERNAL?e.createElement(e.Fragment,null,C(t)?e.createElement(c,{vm:v,pg:t}):e.createElement("div",null,e.createElement(n,{vm:v}),v.isPaymentGatewayHasMasterPass&&e.createElement(p,{vm:v}),v.installmentInfo&&e.createElement(a,{vm:v}))):t.description?e.createElement(e.Fragment,null,t.type===y.EXTERNAL&&e.createElement("div",{style:{height:"52px",display:"flex",justifyContent:"center",margin:"24px 0"}},e.createElement(i,null)),e.createElement("div",{dangerouslySetInnerHTML:{__html:t.description}})):void 0;return e.createElement(o,{key:t.id,label:t.paymentMethodType===u.CREDIT_CARD&&t.type===y.INTERNAL?C(t)?" ":h("checkout-page:creditCard"):t.name,isSelected:v.selectedPaymentGatewayIndex===m,rightContent:(null===(s=t.additionalPrices)||void 0===s?void 0:s.length)?e.createElement(I,null,(d=t.additionalPrices[0],0===d.amount?"":"".concat(d.amountType===f.AMOUNT?l(d.amount,v.checkout.currencyCode):" %"+d.amount).concat(d.type===E.DECREMENT?" "+h("checkout-page:paymentMethodDiscount"):" "+h("checkout-page:paymentMethodAdditionalPrice")))):e.createElement(g,null,!!t.logoUrl&&e.createElement("div",{className:r.PaymentLogoContainer},e.createElement("img",{src:t.logoUrl}))),bottomContent:x,onClick:function(){v.selectedPaymentGatewayIndex!==m&&(v.setPaymentGateway(m),v.mpVM.selectedCard=void 0)}})})))}));export{v as PaymentGateways};
|