@ikas/storefront 4.0.0 → 4.0.1
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/components/checkout/components/master-pass/credit-card-form/index.js +1 -1
- package/build/components/checkout/components/master-pass/credit-card-form/style.module.scss.js +1 -1
- package/build/components/checkout/components/master-pass/modal/index.d.ts +1 -2
- package/build/components/checkout/components/master-pass/modal/index.js +1 -1
- package/build/components/checkout/components/master-pass/modal/style.module.scss.js +1 -1
- package/build/components/checkout/components/master-pass/{modal-success → modal}/svg/master-pass-by-master-card-small.d.ts +0 -0
- package/build/components/checkout/components/master-pass/{modal-success → modal}/svg/master-pass-by-master-card-small.js +0 -0
- package/build/components/checkout/components/master-pass/modal/svg/modal-close.js +1 -1
- package/build/components/checkout/components/master-pass/modal-link-card-to-client/style.module.scss.js +1 -1
- package/build/components/checkout/components/master-pass/modal-success/index.js +1 -1
- package/build/components/checkout/components/master-pass/modal-success/style.module.scss.js +1 -1
- package/build/components/checkout/components/master-pass/payment-gateway/svg/troy.d.ts +6 -0
- package/build/components/checkout/components/master-pass/payment-gateway/svg/troy.js +1 -0
- package/build/components/checkout/components/master-pass/payment-gateway/svg/visa.d.ts +6 -0
- package/build/components/checkout/components/master-pass/payment-gateway/svg/visa.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/style.module.scss.js +1 -1
- package/build/store/base.d.ts +1 -2
- package/build/store/customer/index.js +1 -1
- package/build/store/index.d.ts +1 -0
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";import{observer as a}from"mobx-react-lite";import t from"../svg/master-pass-by-master-card.js";import o from"../../../style.module.scss.js";import r from"./style.module.scss.js";import{createTranslationInputData as s,useTranslation as n}from"../../../../../utils/i18n.js";import{IkasStorefrontConfig as m}from"@ikas/storefront-config";import{Button as i}from"../../button/index.js";import{Checkbox as c}from"../../checkbox/index.js";import{FormItem as d}from"../../form-item/index.js";import{FormItemType as l}from"../../form-item/model.js";var u=a((function(a){var u=a.vm,p=n().t,C=m.getTranslations()["checkout-page"],v=e.useMemo((function(){var e,a;return s(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:r.CheckboxLabel},v.map((function(a,o){return a.isVariable?e.createElement("span",{key:o,className:r.Logo},e.createElement(t,null)):e.createElement(e.Fragment,{key:o},a.value)})))}),[v]),M=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(c,{label:P,value:u.mpVM.saveCardToMasterPass.isCheckboxChecked,onChange:u.mpVM.onSaveCardToMasterPassCheckedChange}),u.mpVM.saveCardToMasterPass.isCheckboxChecked&&e.createElement("div",{className:r.FormWrapper},e.createElement("div",{className:o.RowPB},e.createElement(d,{name:"masterPassCardName",type:l.TEXT,label:p("checkout-page:masterPass.creditCardForm.cardName"),value:u.mpVM.saveCardToMasterPass.cardName,onChange:u.mpVM.onSaveCardToMasterPassCardNameChange})),u.mpVM.isSaveCardToMasterPassPhoneNumberInputVisible&&e.createElement("div",{className:o.RowPB},e.createElement(d,{name:"masterPassPhoneNumber",autocomplete:"tel",type:l.TEL,currentCountryCode:u.store.currentCountryCode,disabled:u.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled,label:p("checkout-page:masterPass.creditCardForm.phoneNumber"),value:M,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,r,s={creditCard:{rtaPan:u.cardData.cardNumber.replace(/ /g,""),expiryDate:(a=u.cardData.expirationDate,t=a.replace(" / ",""),o=t.substring(0,2),r=t.substring(2,4),"".concat(r).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",s),u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending=!0,u.mpVM.onSaveCardToMasterPassSendConfirmationButtonClick(s)}}}})))}));export{u as default};
|
|
1
|
+
import e from"react";import{observer as a}from"mobx-react-lite";import t from"../svg/master-pass-by-master-card.js";import o from"../../../style.module.scss.js";import r from"./style.module.scss.js";import{createTranslationInputData as s,useTranslation as n}from"../../../../../utils/i18n.js";import{IkasStorefrontConfig as m}from"@ikas/storefront-config";import{Button as i}from"../../button/index.js";import{Checkbox as c}from"../../checkbox/index.js";import{FormItem as d}from"../../form-item/index.js";import{FormItemType as l}from"../../form-item/model.js";var u=a((function(a){var u=a.vm,p=n().t,C=m.getTranslations()["checkout-page"],v=e.useMemo((function(){var e,a;return s(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:r.CheckboxLabel},v.map((function(a,o){var s,n,m,i;return a.isVariable?"{{ link }}"===a.value?e.createElement("a",{key:o,className:r.MasterPassInfoLink,title:null===(n=null===(s=null==C?void 0:C.masterPass)||void 0===s?void 0:s.creditCardForm)||void 0===n?void 0:n.moreInformation,target:"_blank",href:"https://www.masterpassturkiye.com/TermsAndConditions.aspx"},null===(i=null===(m=null==C?void 0:C.masterPass)||void 0===m?void 0:m.creditCardForm)||void 0===i?void 0:i.checkboxLabelLink):e.createElement("span",{key:o,className:r.Logo},e.createElement(t,null)):e.createElement(e.Fragment,{key:o},a.value)})))}),[v]),M=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(c,{label:P,value:u.mpVM.saveCardToMasterPass.isCheckboxChecked,onChange:u.mpVM.onSaveCardToMasterPassCheckedChange}),u.mpVM.saveCardToMasterPass.isCheckboxChecked&&e.createElement("div",{className:r.FormWrapper},e.createElement("div",{className:o.RowPB},e.createElement(d,{name:"masterPassCardName",type:l.TEXT,label:p("checkout-page:masterPass.creditCardForm.cardName"),value:u.mpVM.saveCardToMasterPass.cardName,onChange:u.mpVM.onSaveCardToMasterPassCardNameChange})),u.mpVM.isSaveCardToMasterPassPhoneNumberInputVisible&&e.createElement("div",{className:o.RowPB},e.createElement(d,{name:"masterPassPhoneNumber",autocomplete:"tel",type:l.TEL,currentCountryCode:u.store.currentCountryCode,disabled:u.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled,label:p("checkout-page:masterPass.creditCardForm.phoneNumber"),value:M,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,r,s={creditCard:{rtaPan:u.cardData.cardNumber.replace(/ /g,""),expiryDate:(a=u.cardData.expirationDate,t=a.replace(" / ",""),o=t.substring(0,2),r=t.substring(2,4),"".concat(r).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",s),u.mpVM.saveCardToMasterPass.isSendConfirmationButtonPending=!0,u.mpVM.onSaveCardToMasterPassSendConfirmationButtonClick(s)}}}})))}));export{u as default};
|
package/build/components/checkout/components/master-pass/credit-card-form/style.module.scss.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var o={FormWrapper:"style-module_FormWrapper__cXImD",CheckboxLabel:"style-module_CheckboxLabel__KFrUu",Logo:"style-module_Logo__83gZK"};e(".style-module_FormWrapper__cXImD {\n margin-top: 16px;\n}\n\n.style-module_CheckboxLabel__KFrUu {\n color: var(--checkout-primary-text-color);\n}\n.style-module_CheckboxLabel__KFrUu .style-module_Logo__83gZK {\n display: inline-block;\n vertical-align: middle;\n margin: 0 8px;\n}");export{o as default};
|
|
1
|
+
import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var o={FormWrapper:"style-module_FormWrapper__cXImD",MasterPassInfoLink:"style-module_MasterPassInfoLink__UsDhH",CheckboxLabel:"style-module_CheckboxLabel__KFrUu",Logo:"style-module_Logo__83gZK"};e(".style-module_FormWrapper__cXImD {\n margin-top: 16px;\n}\n\n.style-module_MasterPassInfoLink__UsDhH {\n text-decoration: underline;\n}\n\n.style-module_CheckboxLabel__KFrUu {\n color: var(--checkout-primary-text-color);\n}\n.style-module_CheckboxLabel__KFrUu .style-module_Logo__83gZK {\n display: inline-block;\n vertical-align: middle;\n margin: 0 8px;\n}");export{o as default};
|
|
@@ -2,10 +2,9 @@ import React from "react";
|
|
|
2
2
|
declare type Props = {
|
|
3
3
|
visible: boolean;
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
-
footer?: React.ReactNode;
|
|
6
5
|
onClose: () => void;
|
|
7
6
|
};
|
|
8
|
-
declare const Modal: (({ visible,
|
|
7
|
+
declare const Modal: (({ visible, children, onClose }: Props) => JSX.Element | null) & {
|
|
9
8
|
displayName: string;
|
|
10
9
|
};
|
|
11
10
|
export default Modal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";import{observer as
|
|
1
|
+
import e from"react";import{observer as l}from"mobx-react-lite";import t from"./svg/modal-close.js";import a from"./style.module.scss.js";import o from"../../modal/useEscape.js";import r from"./svg/master-pass-by-master-card-small.js";var m=l((function(l){var m=l.visible,s=l.children,n=l.onClose;return o({callback:function(){return n()}}),m?e.createElement("div",{className:a.ModalContainer},e.createElement("div",{role:"dialog","aria-modal":"true",className:a.Modal},e.createElement("button",{className:a.CloseButton,onClick:n},e.createElement(t,null)),e.createElement("div",{className:a.ModalContent},s),e.createElement("footer",{className:a.ModalFooter},e.createElement("div",null,e.createElement(r,null))))):null}));export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from'./../../../../../ext/style-inject/dist/style-inject.es.js';var
|
|
1
|
+
import n from'./../../../../../ext/style-inject/dist/style-inject.es.js';var o={ModalContainer:"style-module_ModalContainer__-ISMu",Modal:"style-module_Modal__MIUmp",CloseButton:"style-module_CloseButton__TK27f",ModalContent:"style-module_ModalContent__E-xV-",ModalFooter:"style-module_ModalFooter__9oRTZ"};n(".style-module_ModalContainer__-ISMu {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n background-color: rgba(39, 39, 39, 0.7);\n z-index: 99999999;\n}\n\n.style-module_Modal__MIUmp {\n position: relative;\n border-radius: 8px;\n background-color: #fff;\n width: 100%;\n max-width: 440px;\n}\n@media only screen and (max-width: 1000px) {\n .style-module_Modal__MIUmp {\n width: calc(100% - 32px);\n margin: 0 16px;\n }\n}\n\n.style-module_CloseButton__TK27f {\n position: absolute;\n top: 16px;\n right: 16px;\n cursor: pointer;\n display: flex;\n align-items: center;\n width: 24px;\n height: 24px;\n background-color: transparent;\n border: none;\n outline: none;\n}\n\n.style-module_ModalContent__E-xV- {\n padding: 24px;\n}\n\n.style-module_ModalFooter__9oRTZ {\n display: flex;\n justify-content: center;\n align-items: center;\n padding: 12px 0;\n border-top: 1px solid var(--checkout-border-color);\n}");export{o as default};
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";var t=function(){return e.createElement("svg",{
|
|
1
|
+
import e from"react";var t=function(){return e.createElement("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:"0",viewBox:"0 0 1024 1024",height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"}))};export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var n={Logo:"style-module_Logo__M-qDd",Text:"style-module_Text__o9r-L",SubInfoText:"style-module_SubInfoText__prqP-"};e(".style-module_Logo__M-qDd[data-mb] {\n margin-bottom: 16px;\n}\n\n.style-module_Text__o9r-L {\n font-size: 16px;\n line-height: 24px;\n color: var(--checkout-secondary-text-color);\n margin-bottom: 32px;\n}\n\n.style-module_SubInfoText__prqP- {\n margin-top: 12px;\n font-size: 14px;\n line-height: 20px;\n text-align: center;\n color: var(--checkout-secondary-text-color);\n}\n.style-module_SubInfoText__prqP- span {\n display: inline-block;\n margin-right: 8px;\n width: 16px;\n height: 16px;\n}");export{n as default};
|
|
1
|
+
import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var n={Logo:"style-module_Logo__M-qDd",Text:"style-module_Text__o9r-L",SubInfoText:"style-module_SubInfoText__prqP-"};e(".style-module_Logo__M-qDd[data-mb] {\n margin-bottom: 16px;\n}\n\n.style-module_Text__o9r-L {\n font-size: 16px;\n line-height: 24px;\n color: var(--checkout-secondary-text-color);\n margin-bottom: 32px;\n}\n\n.style-module_SubInfoText__prqP- {\n margin-top: 12px;\n font-size: 14px;\n line-height: 20px;\n text-align: center;\n color: var(--checkout-secondary-text-color);\n}\n.style-module_SubInfoText__prqP- span {\n display: inline-block;\n vertical-align: middle;\n margin-right: 8px;\n width: 16px;\n height: 16px;\n}");export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"react";import{observer as s}from"mobx-react-lite";import t from"../modal/index.js";import r from"./svg/success.js";import a from"./
|
|
1
|
+
import e from"react";import{observer as s}from"mobx-react-lite";import t from"../modal/index.js";import r from"./svg/success.js";import a from"./style.module.scss.js";import{useTranslation as o}from"../../../../../utils/i18n.js";var c=s((function(s){var c=s.visible,l=s.type,m=s.onClose,i=o().t,n=e.createElement("div",{className:a.Wrapper},e.createElement("span",{"data-mr":!0,className:a.Logo},e.createElement(r,null)),e.createElement("p",{className:a.Text},"linkCardToClient"===l&&i("checkout-page:masterPass.successModal.linkCardToClientSuccessText"),"register"===l&&i("checkout-page:masterPass.successModal.otpSuccessText")));return e.createElement(t,{visible:c,onClose:m},n)}));export{c as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var
|
|
1
|
+
import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var t={Wrapper:"style-module_Wrapper__Um8hI",Logo:"style-module_Logo__JxQj2",Text:"style-module_Text__gNKCp"};e(".style-module_Wrapper__Um8hI {\n display: flex;\n padding-right: 24px;\n margin-bottom: 20px;\n}\n\n.style-module_Logo__JxQj2[data-mr] {\n margin-right: 16px;\n}\n\n.style-module_Text__gNKCp {\n font-size: 16px;\n line-height: 24px;\n font-weight: 600;\n}");export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";var l=function(l){var L=l.className;return e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",className:L,viewBox:"6 8 20 9.21"}," ",e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24.331 9.4811C24.0522 9.4811 23.7446 9.63656 23.6219 9.91598L22.3183 12.9041L21.8488 9.91598C21.7937 9.63656 21.6037 9.4811 21.3033 9.4811L19.652 9.4811L21.0644 14.4436C21.0904 14.5389 21.0953 14.6443 21.0764 14.7553C21.0023 15.1694 20.6068 15.5054 20.1924 15.5054L19.2677 15.5054C19.0328 15.5054 18.8782 15.6509 18.8026 15.9801L18.5972 17.21L20.2258 17.21C21.0754 17.21 22.0733 16.7831 22.7389 15.6027L26 9.4811L24.331 9.4811Z",fill:"#2F3842"})," ",e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.2998 8.00041C8.78746 8.00041 9.02309 8.19493 8.93741 8.68384L8.79675 9.48037L9.91728 9.48037L9.67046 10.8795L8.54946 10.8795L8.24405 12.612C8.13851 13.2156 8.73595 13.2959 9.07869 13.2959C9.14705 13.2959 9.20376 13.2945 9.24439 13.2921L8.97033 14.8524C8.88574 14.8614 8.79848 14.873 8.61404 14.873C7.76333 14.873 6.15404 14.6453 6.47048 12.85L6.817 10.8795L6 10.8795L6.24587 9.48037L7.05484 9.48037L7.31521 8.00041L8.2998 8.00041Z",fill:"#2F3842"})," ",e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.7158 9.54448L17.428 11.1758C17.7829 11.3571 18.0261 11.7254 18.0261 12.1506C18.0261 12.7114 17.6057 13.171 17.0645 13.237L16.7769 14.868C16.8276 14.8713 16.8792 14.873 16.9307 14.873C18.4351 14.873 19.6536 13.6538 19.6536 12.1506C19.6536 10.9217 18.8376 9.88187 17.7158 9.54448Z",fill:"#00A6B6"})," ",e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.4343 13.1255C16.0797 12.9452 15.8359 12.5752 15.8359 12.1504C15.8359 11.5931 16.2572 11.1302 16.7983 11.0651L17.0856 9.43397C17.0346 9.43082 16.9826 9.42846 16.9314 9.42846C15.4281 9.42846 14.209 10.6485 14.209 12.1504C14.209 13.3799 15.0254 14.4204 16.1471 14.7578L16.4343 13.1255Z",fill:"#00A6B6"})," ",e.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.5661 9.48044L11.529 9.48044C12.0168 9.48044 12.2515 9.67543 12.1655 10.1645L12.0601 10.7561C12.4189 10.0279 13.197 9.4272 13.9951 9.4272C14.0999 9.4272 14.2007 9.44799 14.2007 9.44799L13.8894 11.2123C13.8894 11.2123 13.7497 11.1798 13.5317 11.1798C13.1064 11.1798 12.3871 11.3146 11.9867 12.1138C11.8913 12.3109 11.8179 12.5505 11.767 12.8392L11.4186 14.8213L9.625 14.8213L10.5661 9.48044Z",fill:"#2F3842"})," ")};export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";var t=function(t){return t.className,e.createElement("svg",{stroke:"currentColor",fill:"#1A1876","stroke-width":"0",viewBox:"0 0 24 24",height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg"},e.createElement("g",null,e.createElement("path",{fill:"none",d:"M0 0h24v24H0z"}),e.createElement("path",{d:"M22.222 15.768l-.225-1.125h-2.514l-.4 1.117-2.015.004a4199.19 4199.19 0 0 1 2.884-6.918c.164-.391.455-.59.884-.588.328.003.863.003 1.606.001L24 15.765l-1.778.003zm-2.173-2.666h1.62l-.605-2.82-1.015 2.82zM7.06 8.257l2.026.002-3.132 7.51-2.051-.002a950.849 950.849 0 0 1-1.528-5.956c-.1-.396-.298-.673-.679-.804C1.357 8.89.792 8.71 0 8.465V8.26h3.237c.56 0 .887.271.992.827.106.557.372 1.975.8 4.254L7.06 8.257zm4.81.002l-1.602 7.508-1.928-.002L9.94 8.257l1.93.002zm3.91-.139c.577 0 1.304.18 1.722.345l-.338 1.557c-.378-.152-1-.357-1.523-.35-.76.013-1.23.332-1.23.638 0 .498.816.749 1.656 1.293.959.62 1.085 1.177 1.073 1.782-.013 1.256-1.073 2.495-3.309 2.495-1.02-.015-1.388-.101-2.22-.396l.352-1.625c.847.355 1.206.468 1.93.468.663 0 1.232-.268 1.237-.735.004-.332-.2-.497-.944-.907-.744-.411-1.788-.98-1.774-2.122.017-1.462 1.402-2.443 3.369-2.443z"})))};export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/blog/category/index.js";import"../../../../../models/data/blog/content/index.js";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../models/data/blog/tag/index.js";import"mobx";import"../../../../../models/data/blog/index.js";import"../../../../../models/data/brand/index.js";import{IkasPaymentMethodType as a,IkasPaymentGatewayTransactionFeeType as n,IkasPaymentGatewayAdditionalPriceType as o,IkasPaymentGatewayType as r}from"@ikas/storefront-models";import"../../../../../models/data/campaign-offer/index.js";import"../../../../../models/data/cart/campaign-offer/index.js";import"../../../../../models/data/cart/index.js";import"../../../../../models/data/category/path-item/index.js";import"../../../../../models/data/category/index.js";import"../../../../../models/data/checkout/index.js";import"../../../../../models/data/checkout-settings/index.js";import"../../../../../models/data/city/index.js";import"../../../../../models/data/country/index.js";import"../../../../../models/data/customer/address/index.js";import"../../../../../models/data/customer/attribute/index.js";import"../../../../../models/data/customer/review/summary/index.js";import"../../../../../models/data/customer/review/index.js";import"../../../../../models/data/customer/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/option-set/option/index.js";import"../../../../../models/data/product/option-set/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/raffle/index.js";import"../../../../../models/data/state/index.js";import"../../../../../models/data/theme-json/index.js";import"../../../../../models/data/theme-json/custom-data/index.js";import"../../../../../models/data/variant-type/variant-value/index.js";import{CreditCardForm as m}from"../../../components/credit-card-form/index.js";import{Installments as i}from"./installments/index.js";import d from"../../../components/select-box/index.js";import l from"./style.module.scss.js";import"@ikas/storefront-config";import{formatCurrency as s}from"../../../../../utils/currency.js";import{useTranslation as c}from"../../../../../utils/i18n.js";import p from"../../../components/svg/external.js";import u from"
|
|
1
|
+
import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/blog/category/index.js";import"../../../../../models/data/blog/content/index.js";import"../../../../../models/data/blog/meta-data/index.js";import"../../../../../models/data/blog/tag/index.js";import"mobx";import"../../../../../models/data/blog/index.js";import"../../../../../models/data/brand/index.js";import{IkasPaymentMethodType as a,IkasPaymentGatewayTransactionFeeType as n,IkasPaymentGatewayAdditionalPriceType as o,IkasPaymentGatewayType as r}from"@ikas/storefront-models";import"../../../../../models/data/campaign-offer/index.js";import"../../../../../models/data/cart/campaign-offer/index.js";import"../../../../../models/data/cart/index.js";import"../../../../../models/data/category/path-item/index.js";import"../../../../../models/data/category/index.js";import"../../../../../models/data/checkout/index.js";import"../../../../../models/data/checkout-settings/index.js";import"../../../../../models/data/city/index.js";import"../../../../../models/data/country/index.js";import"../../../../../models/data/customer/address/index.js";import"../../../../../models/data/customer/attribute/index.js";import"../../../../../models/data/customer/review/summary/index.js";import"../../../../../models/data/customer/review/index.js";import"../../../../../models/data/customer/index.js";import"../../../../../models/data/district/index.js";import"../../../../../models/data/favorite-product/index.js";import"../../../../../models/data/filter-category/index.js";import"../../../../../models/data/html-meta-data/index.js";import"../../../../../models/data/image/index.js";import"../../../../../models/data/order/address/index.js";import"../../../../../models/data/order/line-item/variant/value/index.js";import"../../../../../models/data/order/line-item/variant/index.js";import"../../../../../models/data/order/line-item/index.js";import"../../../../../models/data/order/package/index.js";import"../../../../../models/data/order/index.js";import"../../../../../models/data/payment-gateway/index.js";import"../../../../../models/data/product/attribute-value/index.js";import"../../../../../models/data/product/filter/index.js";import"../../../../../models/data/product/option-set/option/index.js";import"../../../../../models/data/product/option-set/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/raffle/index.js";import"../../../../../models/data/state/index.js";import"../../../../../models/data/theme-json/index.js";import"../../../../../models/data/theme-json/custom-data/index.js";import"../../../../../models/data/variant-type/variant-value/index.js";import{CreditCardForm as m}from"../../../components/credit-card-form/index.js";import{Installments as i}from"./installments/index.js";import d from"../../../components/select-box/index.js";import l from"./style.module.scss.js";import"@ikas/storefront-config";import{formatCurrency as s}from"../../../../../utils/currency.js";import{useTranslation as c}from"../../../../../utils/i18n.js";import p from"../../../components/svg/external.js";import u from"next/dynamic";import y from"../../../components/credit-card-form/model.js";import x from"../../../components/master-pass/credit-card-form/index.js";import{Klarna as f}from"../../../components/klarna/index.js";import{Toggle as v}from"../../../components/toggle/index.js";import j from"../../../components/select-box/style.module.scss.js";import g from"../../../components/master-pass/payment-gateway/svg/master-card.js";import E from"../../../components/master-pass/payment-gateway/svg/troy.js";import h from"../../../components/master-pass/payment-gateway/svg/visa.js";var C=u((function(){return import("../../../components/stripe/index.js").then((function(e){return e.StripeForm}))})),w=t((function(t){var u=t.vm,w=c().t,P=function(t){return e.createElement("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",flexWrap:"wrap"}},t.children)},k=function(t){return e.createElement("div",{className:l.AdditionalPrice},t.children)},I=function(e){return 0===e.amount?"":"".concat(e.amountType===n.AMOUNT?s(e.amount,u.checkout.currencyCode,u.checkout.currencySymbol):" %"+e.amount).concat(e.type===o.DECREMENT?" "+w("checkout-page:paymentMethodDiscount"):" "+w("checkout-page:paymentMethodAdditionalPrice"))},N=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,!!u.mpVM.cards.length&&u.mpVM.cards.map((function(t,n){var o,m=u.paymentGateways.find((function(e){return e.id===t.paymentGatewayId})),s=e.createElement("button",{className:l.MasterPassSelectBoxDeleteButton,onClick:function(e){e.stopPropagation(),u.mpVM.deleteCard({store:u.store,checkout:u.checkout,card:t})}},w("checkout-page:masterPass.paymentGatewaySelectBox.delete")),c=function(e){return t.Value1.startsWith(e)},p=c("4"),x=c("5")||c("6"),f=c("9"),v=e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement("span",{className:l.MasterPassSelectBoxLabelLogo},p&&e.createElement(h,null),x&&e.createElement(g,null),f&&e.createElement(E,null)),t.Name," ",t.Value1),j=(null==m?void 0:m.id)&&m.paymentMethodType===a.CREDIT_CARD&&m.type===r.INTERNAL?u.installmentInfo&&e.createElement(i,{vm:u}):void 0;return e.createElement(d,{key:n,isSelected:(null===(o=u.mpVM.selectedCard)||void 0===o?void 0:o.UniqueId)===t.UniqueId,label:v,rightContent:s,bottomContent:j,onClick:function(){var e;(null===(e=u.mpVM.selectedCard)||void 0===e?void 0:e.UniqueId)!==t.UniqueId&&(u.checkout.selectedPaymentGateway=null,u.cardData=new y,u.installmentInfo=void 0,u.mpVM.selectedCard=t,t.Value1&&t.paymentGatewayId&&u.checkout.totalFinalPrice&&u.retrieveInstallmentInfo({input:{binNumber:t.Value1.slice(0,6),paymentGatewayId:t.paymentGatewayId,price:u.checkout.totalFinalPrice}}))}})})),u.paymentGateways.filter((function(e){return"in-store"!==u.deliveryMethod||e.paymentMethodType!==a.CASH_ON_DELIVERY&&e.paymentMethodType!==a.CREDIT_CARD_ON_DELIVERY})).map((function(t,n){var o;if(function(e){return"KLARNA"===e.code}(t))return null;var s=t.paymentMethodType===a.CREDIT_CARD&&t.type===r.INTERNAL?e.createElement(e.Fragment,null,N(t)?e.createElement(C,{vm:u,pg:t}):e.createElement("div",null,e.createElement(m,{vm:u}),u.isPaymentGatewayHasMasterPass&&e.createElement(x,{vm:u}),u.installmentInfo&&e.createElement(i,{vm:u}))):t.description?e.createElement(e.Fragment,null,t.type===r.EXTERNAL&&e.createElement("div",{style:{height:"52px",display:"flex",justifyContent:"center",margin:"24px 0"}},e.createElement(p,null)),e.createElement("div",{dangerouslySetInnerHTML:{__html:t.description}})):void 0;return e.createElement(d,{key:t.id,label:t.paymentMethodType===a.CREDIT_CARD&&t.type===r.INTERNAL?N(t)?" ":w("checkout-page:creditCard"):t.name,isSelected:u.selectedPaymentGatewayIndex===n,rightContent:(null===(o=t.additionalPrices)||void 0===o?void 0:o.length)?e.createElement(k,null,I(t.additionalPrices[0])):e.createElement(P,null,!!t.logoUrl&&e.createElement("div",{className:l.PaymentLogoContainer},e.createElement("img",{src:t.logoUrl}))),bottomContent:s,onClick:function(){u.selectedPaymentGatewayIndex!==n&&(u.setPaymentGateway(n),u.mpVM.selectedCard=void 0)}})})),u.klarnaPaymentGateway&&function(){var t,a=u.selectedPaymentGatewayIndex===u.klarnaPaymentGatewayIndex;return u.klarnaPaymentGateway?e.createElement("div",{className:j.SelectBoxContainer},e.createElement("div",{className:"".concat(j.SelectBox," ").concat(a?j.Selected:""),onClick:function(){u.setPaymentGateway(u.klarnaPaymentGatewayIndex),u.mpVM.selectedCard=void 0}},e.createElement("div",{className:j.TopContent},e.createElement(v,{value:a,label:u.klarnaPaymentGateway.name,removePadding:!0}),e.createElement("div",{className:j.RightContent},(null===(t=u.klarnaPaymentGateway.additionalPrices)||void 0===t?void 0:t.length)?e.createElement(k,null,I(u.klarnaPaymentGateway.additionalPrices[0])):e.createElement(P,null,!!u.klarnaPaymentGateway.logoUrl&&e.createElement("div",{className:l.PaymentLogoContainer},e.createElement("img",{src:u.klarnaPaymentGateway.logoUrl}))))),e.createElement("div",{className:"".concat(a?j.BottomContent:""," ").concat(a?"":l.Hidden)},e.createElement(f,{vm:u})))):null}())}));export{w as PaymentGateways};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var t={PaymentLogoContainer:"style-module_PaymentLogoContainer__h4VF0",AdditionalPrice:"style-module_AdditionalPrice__42TO1",MasterPassSelectBoxDeleteButton:"style-module_MasterPassSelectBoxDeleteButton__J1RSJ",MasterPassSelectBoxLabelLogo:"style-module_MasterPassSelectBoxLabelLogo__fIhG7",Hidden:"style-module_Hidden__5-IfX"};e(".style-module_PaymentLogoContainer__h4VF0 {\n margin-left: 10px;\n font-size: 0.7em;\n}\n.style-module_PaymentLogoContainer__h4VF0 img {\n height: 20px;\n}\n\n.style-module_AdditionalPrice__42TO1 {\n color: var(--checkout-primary-text-color);\n font-weight: 600;\n}\n\n.style-module_MasterPassSelectBoxDeleteButton__J1RSJ {\n font-size: 14px;\n line-height: 20px;\n color: var(--checkout-primary-text-color);\n padding: 4px 8px;\n margin-right: -8px;\n}\n.style-module_MasterPassSelectBoxDeleteButton__J1RSJ:hover {\n text-decoration: underline;\n}\n\n.style-module_MasterPassSelectBoxLabelLogo__fIhG7 {\n display: inline-
|
|
1
|
+
import e from'./../../../../../ext/style-inject/dist/style-inject.es.js';var t={PaymentLogoContainer:"style-module_PaymentLogoContainer__h4VF0",AdditionalPrice:"style-module_AdditionalPrice__42TO1",MasterPassSelectBoxDeleteButton:"style-module_MasterPassSelectBoxDeleteButton__J1RSJ",MasterPassSelectBoxLabelLogo:"style-module_MasterPassSelectBoxLabelLogo__fIhG7",Hidden:"style-module_Hidden__5-IfX"};e(".style-module_PaymentLogoContainer__h4VF0 {\n margin-left: 10px;\n font-size: 0.7em;\n}\n.style-module_PaymentLogoContainer__h4VF0 img {\n height: 20px;\n}\n\n.style-module_AdditionalPrice__42TO1 {\n color: var(--checkout-primary-text-color);\n font-weight: 600;\n}\n\n.style-module_MasterPassSelectBoxDeleteButton__J1RSJ {\n font-size: 14px;\n line-height: 20px;\n color: var(--checkout-primary-text-color);\n padding: 4px 8px;\n margin-right: -8px;\n}\n.style-module_MasterPassSelectBoxDeleteButton__J1RSJ:hover {\n text-decoration: underline;\n}\n\n.style-module_MasterPassSelectBoxLabelLogo__fIhG7 {\n display: inline-flex;\n margin-right: 12px;\n width: 32px;\n}\n.style-module_MasterPassSelectBoxLabelLogo__fIhG7 svg {\n width: 100%;\n height: 100%;\n}\n\n.style-module_Hidden__5-IfX {\n display: none;\n}");export{t as default};
|
package/build/store/base.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class IkasBaseStore {
|
|
|
28
28
|
getProductCampaigns(product: IkasProduct): Promise<void>;
|
|
29
29
|
private init;
|
|
30
30
|
}
|
|
31
|
-
declare type IkasLocaleOption = {
|
|
31
|
+
export declare type IkasLocaleOption = {
|
|
32
32
|
readonly id: string;
|
|
33
33
|
readonly countryName?: string;
|
|
34
34
|
readonly iso2?: string;
|
|
@@ -36,4 +36,3 @@ declare type IkasLocaleOption = {
|
|
|
36
36
|
readonly routing: IkasStorefrontRouting;
|
|
37
37
|
readonly isRecommended: boolean;
|
|
38
38
|
};
|
|
39
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import o from"lodash/uniqBy";import s from"./api.js";import{IkasCustomer as n}from"../../models/data/customer/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as a}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/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{IkasRaffleParticipant as c}from"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import u from"../raffle/index.js";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import d from"../product/index.js";import{Analytics as l}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as h}from"@ikas/storefront-config";import{SaveMyCustomerInput as m}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as p}from"@ikas/storefront-providers";var f="undefined"==typeof localStorage,v=function(){function v(o){var n=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this.toAnalyticsCustomer=function(t){return i(i({},t),{consentGranted:n._customerConsentGranted})},this.login=function(i,r){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.login({email:i,password:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&l.customerLogin(),(n=null===(a=this.baseStore)||void 0===a?void 0:a.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(n.orderLineItems[0],n.orderLineItems[0].quantity)]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,!0];case 5:return[2,!1]}}))}))},this.logout=function(){var t;n.clearLocalData(),null===(t=n.baseStore)||void 0===t||t.cartStore.removeCart(),l.customerLogout()},this.register=function(i,r,o,a,c,u){return t(n,void 0,void 0,(function(){var t,n;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.register({email:o,password:a,firstName:i,lastName:r,isAcceptMarketing:c,attributes:u,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(n=t.data)||void 0===n?void 0:n.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),l.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return l.contactForm(r),[4,this.getCaptcha()];case 1:return e.sent(),[4,s.sendContactFormToMerchant(i(i({},r),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.checkEmail({email:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.forgotPassword=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.forgotPassword({email:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.recoverPassword=function(i,r,o){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.recoverPassword({password:i,passwordAgain:r,token:o,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.saveCustomer({input:new m(i)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(i){return t(n,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.getOrders({orderId:i})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?(r=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),r.refundSettings=this._refundSettings,[2,r]}}))}))},this.getOrderTransactions=function(i){return void 0===i&&(i={}),t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listOrderTransactions({checkoutId:{eq:i.checkoutId},id:{eq:i.checkoutId},orderId:{eq:i.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProductsIds=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listFavoriteProducts()];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(n,void 0,void 0,(function(){var t,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.listFavoriteProducts()];case 1:return(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)?[4,d.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:h.getPriceListId(),salesChannelId:h.getSalesChannelId()}})]:[2,[]];case 2:return i=e.sent(),[2,(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.data)||[]]}}))}))},this.addProductToFavorites=function(i){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!0,productId:i})];case 1:return t=e.sent(),l.addToWishlist(i),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(i){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!1,productId:i})];case 1:return t=e.sent(),l.addToWishlist(i),[2,t.data||!1]}}))}))},this.isProductFavorite=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,s.isFavoriteProduct({productId:i})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.subscribeToMarketingNotifications({input:{email:i,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,a.SUBSCRIBED):this._visitorSubscribedEmail=!0,l.createEmailSubscripition(i)),[2,t.isSuccess]}}))}))},this.sendReview=function(r){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:if(t=h.getCustomerReviewSettings(),o=h.getSalesChannelId(),!t)return[2];if(!(n=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,s.createCustomerReview({input:i(i({},r),{customerId:t.customerLoginRequired?n:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},this.onCustomerConsentGrant=function(){n.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.setCaptchaToken=function(t){n._captchaToken=t},this.getRaffles=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,u.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,p(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new c(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,s.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(i=this.customer.attributes)||void 0===i||i.forEach((function(e){var i,r,o;e.customerAttribute=(null===(i=t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(r=e.customerAttribute)||void 0===r?void 0:r.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderByEmail=function(i,r){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrderByEmail({email:i,orderNumber:r})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderRefundSettings=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,s.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.baseStore=o,r(this)}return Object.defineProperty(v.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||f||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"isCaptchaRequired",{get:function(){var t;return null===(t=h.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation},enumerable:!1,configurable:!0}),v.prototype.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",r="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(i,"/login/authenticate?redirect=").concat(t),[4,fetch(r,{headers:{"x-api-key":h.getApiKey()||"","x-sfid":h.getStorefrontId()||"","x-sfrid":h.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),window.location.href=o.redirectUrl,[2]}}))}))},v.prototype.socialLoginToken=function(i){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.socialLogin({code:i})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(r=t.data)||void 0===r?void 0:r.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer&&l.customerLogin(),[2,!0]):[2,!1]}}))}))},v.prototype.refundOrder=function(i){return t(this,void 0,void 0,(function(){var t,r,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],i.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,s.createOrderRefundRequest({input:{orderId:i.id,orderLineItems:t}})];case 1:return(r=e.sent()).isSuccess&&r.data?(Object.entries(r.data).forEach((function(t){var e=t[0],i=t[1];o[e]=i})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},v.prototype.getCaptcha=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.isCaptchaRequired?(window.grecaptcha.execute(),[4,this.waitUntilCaptchaTokenInitialized()]):[3,2];case 1:e.sent(),window.grecaptcha.reset(),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}}))}))},v.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer&&l.customerVisit(),[2]}}))}))},v.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},v.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return f||!this.token?[2]:[4,s.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},v.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,s.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},v.prototype.setCustomer=function(t){this.customer=new n(t)},v.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,s.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=t.data||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},v.prototype.saveLastViewedProducts=function(){f||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},v.prototype.loadLastViewedProducts=function(){if(!f)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"))}catch(t){}},v.prototype.removeLastViewedProducts=function(){f||window.localStorage.removeItem("lastViewedProducts")},v.prototype.onProductView=function(i,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===i}))?[2]:[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:i,variantId:r}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:i,variantId:r}),[3,3];case 2:this._lastViewedProducts.push({productId:i,variantId:r}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},v.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(f)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:this._lastViewedProducts}})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},v.prototype.saveCustomerConsent=function(){f||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},v.prototype.loadCustomerConsent=function(){f||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},v.prototype.removeCustomerConsent=function(){f||window.localStorage.removeItem("customerConsent")},v.prototype.setToken=function(t,e){f||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),h.init({customerToken:t}))},v.prototype.loadToken=function(){if(!f){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},v.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},v.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,h.init({customerToken:""}),this.clearCaptchaToken()},v.prototype.clearCaptchaToken=function(){this._captchaToken=null},v}();export{v as IkasCustomerStore};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import o from"lodash/uniqBy";import s from"./api.js";import{IkasCustomer as n}from"../../models/data/customer/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as a}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/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{IkasRaffleParticipant as c}from"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import u from"../raffle/index.js";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import d from"../product/index.js";import{Analytics as l}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as h}from"@ikas/storefront-config";import{SaveMyCustomerInput as m}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as p}from"@ikas/storefront-providers";var f="undefined"==typeof localStorage,v=function(){function v(o){var n=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this.toAnalyticsCustomer=function(t){return i(i({},t),{consentGranted:n._customerConsentGranted})},this.login=function(i,r){return t(n,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.login({email:i,password:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&l.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.logout=function(){var t;n.clearLocalData(),null===(t=n.baseStore)||void 0===t||t.cartStore.removeCart(),l.customerLogout()},this.register=function(i,r,o,a,c,u){return t(n,void 0,void 0,(function(){var t,n;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.register({email:o,password:a,firstName:i,lastName:r,isAcceptMarketing:c,attributes:u,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(n=t.data)||void 0===n?void 0:n.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),l.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return l.contactForm(r),[4,this.getCaptcha()];case 1:return e.sent(),[4,s.sendContactFormToMerchant(i(i({},r),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.checkEmail({email:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.forgotPassword=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.forgotPassword({email:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.recoverPassword=function(i,r,o){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.recoverPassword({password:i,passwordAgain:r,token:o,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.saveCustomer({input:new m(i)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(i){return t(n,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.getOrders({orderId:i})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?(r=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),r.refundSettings=this._refundSettings,[2,r]}}))}))},this.getOrderTransactions=function(i){return void 0===i&&(i={}),t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listOrderTransactions({checkoutId:{eq:i.checkoutId},id:{eq:i.checkoutId},orderId:{eq:i.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProductsIds=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listFavoriteProducts()];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(n,void 0,void 0,(function(){var t,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.listFavoriteProducts()];case 1:return(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)?[4,d.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:h.getPriceListId(),salesChannelId:h.getSalesChannelId()}})]:[2,[]];case 2:return i=e.sent(),[2,(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.data)||[]]}}))}))},this.addProductToFavorites=function(i){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!0,productId:i})];case 1:return t=e.sent(),l.addToWishlist(i),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(i){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!1,productId:i})];case 1:return t=e.sent(),l.addToWishlist(i),[2,t.data||!1]}}))}))},this.isProductFavorite=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,s.isFavoriteProduct({productId:i})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.subscribeToMarketingNotifications({input:{email:i,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,a.SUBSCRIBED):this._visitorSubscribedEmail=!0,l.createEmailSubscripition(i)),[2,t.isSuccess]}}))}))},this.sendReview=function(r){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:if(t=h.getCustomerReviewSettings(),o=h.getSalesChannelId(),!t)return[2];if(!(n=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,s.createCustomerReview({input:i(i({},r),{customerId:t.customerLoginRequired?n:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},this.onCustomerConsentGrant=function(){n.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.setCaptchaToken=function(t){n._captchaToken=t},this.getRaffles=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,u.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,p(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new c(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,s.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(i=this.customer.attributes)||void 0===i||i.forEach((function(e){var i,r,o;e.customerAttribute=(null===(i=t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(r=e.customerAttribute)||void 0===r?void 0:r.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderByEmail=function(i,r){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrderByEmail({email:i,orderNumber:r})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderRefundSettings=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,s.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.baseStore=o,r(this)}return Object.defineProperty(v.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||f||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"isCaptchaRequired",{get:function(){var t;return null===(t=h.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation},enumerable:!1,configurable:!0}),v.prototype.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",r="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(i,"/login/authenticate?redirect=").concat(t),[4,fetch(r,{headers:{"x-api-key":h.getApiKey()||"","x-sfid":h.getStorefrontId()||"","x-sfrid":h.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),window.location.href=o.redirectUrl,[2]}}))}))},v.prototype.socialLoginToken=function(i){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.socialLogin({code:i})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(r=t.data)||void 0===r?void 0:r.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer&&l.customerLogin(),[2,!0]):[2,!1]}}))}))},v.prototype.refundOrder=function(i){return t(this,void 0,void 0,(function(){var t,r,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],i.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,s.createOrderRefundRequest({input:{orderId:i.id,orderLineItems:t}})];case 1:return(r=e.sent()).isSuccess&&r.data?(Object.entries(r.data).forEach((function(t){var e=t[0],i=t[1];o[e]=i})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},v.prototype.getCaptcha=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.isCaptchaRequired?(window.grecaptcha.execute(),[4,this.waitUntilCaptchaTokenInitialized()]):[3,2];case 1:e.sent(),window.grecaptcha.reset(),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}}))}))},v.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer&&l.customerVisit(),[2]}}))}))},v.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},v.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return f||!this.token?[2]:[4,s.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},v.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,s.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},v.prototype.setCustomer=function(t){this.customer=new n(t)},v.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,s.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=t.data||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},v.prototype.saveLastViewedProducts=function(){f||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},v.prototype.loadLastViewedProducts=function(){if(!f)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"))}catch(t){}},v.prototype.removeLastViewedProducts=function(){f||window.localStorage.removeItem("lastViewedProducts")},v.prototype.onProductView=function(i,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===i}))?[2]:[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:i,variantId:r}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:i,variantId:r}),[3,3];case 2:this._lastViewedProducts.push({productId:i,variantId:r}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},v.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(f)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:this._lastViewedProducts}})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},v.prototype.saveCustomerConsent=function(){f||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},v.prototype.loadCustomerConsent=function(){f||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},v.prototype.removeCustomerConsent=function(){f||window.localStorage.removeItem("customerConsent")},v.prototype.setToken=function(t,e){f||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),h.init({customerToken:t}))},v.prototype.loadToken=function(){if(!f){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},v.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},v.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,h.init({customerToken:""}),this.clearCaptchaToken()},v.prototype.clearCaptchaToken=function(){this._captchaToken=null},v}();export{v as IkasCustomerStore};
|
package/build/store/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"libphonenumber-js": "^1.10.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ikas/storefront-api": "^4.0.
|
|
27
|
-
"@ikas/storefront-config": "^4.0.
|
|
28
|
-
"@ikas/storefront-model-functions": "^4.0.
|
|
29
|
-
"@ikas/storefront-models": "^4.0.
|
|
30
|
-
"@ikas/storefront-providers": "^4.0.
|
|
26
|
+
"@ikas/storefront-api": "^4.0.1",
|
|
27
|
+
"@ikas/storefront-config": "^4.0.1",
|
|
28
|
+
"@ikas/storefront-model-functions": "^4.0.1",
|
|
29
|
+
"@ikas/storefront-models": "^4.0.1",
|
|
30
|
+
"@ikas/storefront-providers": "^4.0.1",
|
|
31
31
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
32
32
|
"@rollup/plugin-json": "^4.1.0",
|
|
33
33
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"query-string": "^6.13.8"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@ikas/storefront-api": "^4.0.
|
|
57
|
-
"@ikas/storefront-config": "^4.0.
|
|
58
|
-
"@ikas/storefront-model-functions": "^4.0.
|
|
59
|
-
"@ikas/storefront-models": "^4.0.
|
|
60
|
-
"@ikas/storefront-providers": "^4.0.
|
|
56
|
+
"@ikas/storefront-api": "^4.0.1",
|
|
57
|
+
"@ikas/storefront-config": "^4.0.1",
|
|
58
|
+
"@ikas/storefront-model-functions": "^4.0.1",
|
|
59
|
+
"@ikas/storefront-models": "^4.0.1",
|
|
60
|
+
"@ikas/storefront-providers": "^4.0.1",
|
|
61
61
|
"mobx": "^6.1.3",
|
|
62
62
|
"mobx-react-lite": "^3.1.5",
|
|
63
63
|
"next": "12.2.0",
|