@ikas/storefront 6.1.0-beta.302 → 6.1.0-beta.304
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from'./../../../../ext/tslib/tslib.es6.js';import*as r from"react";import{observer as t}from"mobx-react-lite";import{IkasCheckoutRequirement as o}from"@ikas/storefront-models";import{FormItem as i}from"../form-item/index.js";import{FormItemType as a,FormItemInputMode as n}from"../form-item/model.js";import l from"./model.js";import{Checkbox as s}from"../checkbox/index.js";import"@ikas/storefront-config";import{useTranslation as d}from"../../../../utils/i18n.js";import{AddressFormItem as c,BillingFormItem as u}from"@ikas/localized-address";import v from"../../styles/common.module.scss.js";import m from"../../style.module.scss.js";var E=t((function(t){var o=r.useMemo((function(){return new l(e({},t))}),[]);return r.useEffect((function(){Object.entries(t).forEach((function(e){o[e[0]]=e[1]}))}),Object.values(t)),"in-store"===t.deliveryMethod?r.createElement(p,{props:t,vm:o}):r.createElement(h,{props:t,vm:o})})),p=t((function(t){var i=t.props,a=t.vm;return d().t,r.createElement("div",null,r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},r.createElement(g,e({},i,{vm:a})),r.createElement(f,e({},i,{vm:a})),r.createElement("div",null)," "),!!a.address.checkoutSettings&&a.address.checkoutSettings.phoneRequirement!==o.INVISIBLE&&r.createElement("div",{className:m.RowPB},r.createElement(I,e({},i,{vm:a})),r.createElement("div",null)," "))})),h=t((function(t){var o,i,a,n=t.props,l=t.vm,E=d().t,p=function(t){var o=t.map((function(t){return function(t){switch(t){case c.FIRSTNAME:return r.createElement(g,e({},n,{vm:l}));case c.LASTNAME:return r.createElement(f,e({},n,{vm:l}));case c.IDENTITY_NUMBER:return r.createElement(b,e({},n,{vm:l}));case c.ADDRESS_LINE_1:return r.createElement(y,e({},n,{vm:l}));case c.ADDRESS_LINE_2:return r.createElement(T,e({},n,{vm:l}));case c.POSTAL_CODE:return r.createElement(N,e({},n,{vm:l}));case c.COUNTRY:return r.createElement(k,e({},n,{vm:l}));case c.STATE:return r.createElement(L,e({},n,{vm:l}));case c.CITY:return l.address.isFreeTextCity?r.createElement(R,e({},n,{vm:l})):r.createElement(x,e({},n,{vm:l}));case c.DISTRICT:return l.address.isFreeTextDistrict?r.createElement(S,e({},n,{vm:l})):r.createElement(O,e({},n,{vm:l}));case c.REGION:return r.createElement(A,e({},n,{vm:l}));case c.PHONE:return r.createElement(I,e({},n,{vm:l}));default:return null}}(t)}));return r.createElement(r.Fragment,null,1===t.length&&r.createElement("div",{className:m.RowPB},o),2===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},o,r.createElement("div",null)," "),3===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2,v.Grid3].join(" ")},o,r.createElement("div",null)," "))},h=function(t){var o=t.map((function(t){return function(t){switch(t){case u.COMPANY:return r.createElement(V,e({},n,{vm:l}));case u.TAX_NUMBER:return r.createElement(j,e({},n,{vm:l}));case u.TAX_OFFICE:return r.createElement(F,e({},n,{vm:l}));default:return null}}(t)}));return r.createElement(r.Fragment,null,1===t.length&&r.createElement("div",{className:m.RowPB},o),2===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},o,r.createElement("div",null)," "),3===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2,v.Grid3].join(" ")},o,r.createElement("div",null)," "))};return r.createElement("div",null,l.allowTitleChange&&r.createElement("div",{className:m.RowPB},r.createElement(C,e({},n,{vm:l}))),l.countryOptions.length<=1?null===(o=l.address.addressFormatIgnoreCountry)||void 0===o?void 0:o.map((function(e){return p(e)})):null===(i=l.address.addressFormat)||void 0===i?void 0:i.map((function(e){return p(e)})),!!l.allowCorporateInfo&&r.createElement("div",{style:{marginTop:"12px"}},r.createElement(s,{value:l.isCorporate,label:E("checkout-page:corporateInvoice"),onChange:l.onCorporateChange})),!!l.isCorporate&&(null===(a=l.address.billingFormat)||void 0===a?void 0:a.map((function(e){return h(e)}))))})),g=t((function(e){var t,o,n,l,s=e.vm,c=d().t,u=s.isShippingAddress?"shipping given-name":"given-name",v=null===(t=s.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.firstName;return r.createElement(i,{name:"firstName",type:a.TEXT,label:(null===(n=null===(o=s.address.fieldLabels)||void 0===o?void 0:o.firstName)||void 0===n?void 0:n.label)||c("checkout-page:firstName"),autocomplete:u,value:s.firstName||"",onChange:s.onFirstNameChange,hasError:s.isErrorsVisible&&((null===(l=s.address.validationResults)||void 0===l?void 0:l.firstName.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError":"checkout-page:firstNameError")})})),f=t((function(e){var t,o,n,l,s=e.vm,c=d().t,u=s.isShippingAddress?"shipping family-name":"family-name",v=null===(t=s.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.lastName;return r.createElement(i,{name:"lastName",type:a.TEXT,label:(null===(n=null===(o=s.address.fieldLabels)||void 0===o?void 0:o.lastName)||void 0===n?void 0:n.label)||c("checkout-page:lastName"),autocomplete:u,value:s.lastName||"",onChange:s.onLastNameChange,hasError:s.isErrorsVisible&&((null===(l=s.address.validationResults)||void 0===l?void 0:l.lastName.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError":"checkout-page:lastNameError")})})),b=t((function(e){var t,o,n,l=e.vm,s=d().t;return r.createElement(i,{name:"identityNumber",type:a.TEXT,label:(null===(o=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.identityNumber)||void 0===o?void 0:o.label)||s("checkout-page:identityNumber"),value:l.identityNumber||"",onChange:l.onIdentityNumberChange,hasError:l.isErrorsVisible&&(null===(n=l.address.validationResults)||void 0===n?void 0:n.identityNumber.hasError),errorText:s("checkout-page:identityNumberError")})})),C=t((function(e){var t=e.vm,o=d().t,n=t.address;return r.createElement(i,{type:a.TEXT,label:o("checkout-page:addressTitle"),value:n.title||"",onChange:t.onAddressTitleChange,hasError:t.isErrorsVisible&&!n.title,errorText:o("checkout-page:addressTitleError")})})),y=t((function(e){var t,o,n,l,s=e.vm,c=d().t,u=s.isShippingAddress?"shipping address-line1":"address-line1",v=null===(t=s.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.addressLine1;return r.createElement(i,{name:"addressLine1",type:a.TEXT,label:(null===(n=null===(o=s.address.fieldLabels)||void 0===o?void 0:o.addressLine1)||void 0===n?void 0:n.label)||c("checkout-page:addressLine1"),autocomplete:u,value:s.address.addressLine1||"",onChange:s.onAddressLine1Change,hasError:s.isErrorsVisible&&((null===(l=s.address.validationResults)||void 0===l?void 0:l.addressLine1.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError":"checkout-page:addressError")})})),T=t((function(e){var t,o,n,l=e.vm,s=d().t,c=l.isShippingAddress?"shipping address-line2":"address-line2",u=null===(t=l.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.addressLine2;return r.createElement(i,{name:"addressLine2",type:a.TEXT,autocomplete:c,label:(null===(n=null===(o=l.address.fieldLabels)||void 0===o?void 0:o.addressLine2)||void 0===n?void 0:n.label)||s("checkout-page:addressLine2"),value:l.address.addressLine2||"",onChange:l.onAddressLine2Change,hasError:l.isErrorsVisible&&u,errorText:u?s("checkout-page:fieldRestrictionError"):void 0})})),N=t((function(e){var t,o,n,l=e.vm,s=d().t,c=l.isShippingAddress?"shipping postal-code":"postal-code";return r.createElement(i,{name:"postalCode",type:a.TEXT,label:(null===(o=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.postalCode)||void 0===o?void 0:o.label)||s("checkout-page:postalCode"),autocomplete:c,value:l.address.postalCode||"",onChange:l.onAddressPostalCodeChange,hasError:l.isErrorsVisible&&(null===(n=l.address.validationResults)||void 0===n?void 0:n.postalCode.hasError),errorText:s("checkout-page:postalCodeError")})})),k=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return s.countryOptions.length<=1?null:r.createElement(i,{name:"country",type:a.SELECT,label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.country)||void 0===o?void 0:o.label)||c("checkout-page:country"),autocomplete:"country-name",value:(null===(n=s.country)||void 0===n?void 0:n.id)||"",onChange:s.onCountryChange,options:s.countryOptions,hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.country.hasError),errorText:c("checkout-page:countryError")})})),L=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return r.createElement(i,{name:"state",type:a.SELECT,label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.state)||void 0===o?void 0:o.label)||c("checkout-page:state"),value:(null===(n=s.state)||void 0===n?void 0:n.id)||"",onChange:s.onStateChange,options:s.stateOptions,hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.state.hasError),errorText:c("checkout-page:stateError")})})),x=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return r.createElement(i,{name:"city",type:a.SELECT,label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.city)||void 0===o?void 0:o.label)||c("checkout-page:city"),autocomplete:"off",value:(null===(n=s.city)||void 0===n?void 0:n.id)||"",onChange:s.onCityChange,options:s.cityOptions,disabled:!s.cityOptions.length,isLoading:s.isLoadingCities,hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.city.hasError),errorText:c("checkout-page:cityError")})})),R=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return r.createElement(i,{name:"city",type:a.TEXT,autocomplete:"address-level2",label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.city)||void 0===o?void 0:o.label)||c("checkout-page:city"),value:(null===(n=s.city)||void 0===n?void 0:n.name)||"",hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.city.hasError),onChange:s.onCityInputChange,errorText:c("checkout-page:cityError")})})),O=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return r.createElement(i,{name:"district",type:a.SELECT,label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.district)||void 0===o?void 0:o.label)||c("checkout-page:district"),autocomplete:"off",value:(null===(n=s.district)||void 0===n?void 0:n.id)||"",onChange:s.onDistrictChange,options:s.districtOptions,disabled:!s.districtOptions.length,isLoading:s.isLoadingDistricts,hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.district.hasError),errorText:c("checkout-page:districtError")})})),S=t((function(e){var t,o,n,l=e.vm,s=d().t;return r.createElement(i,{name:"district",type:a.TEXT,autocomplete:"address-level3",label:(null===(o=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.district)||void 0===o?void 0:o.label)||s("checkout-page:district"),value:(null===(n=l.district)||void 0===n?void 0:n.name)||"",onChange:l.onDistrictInputChange})})),A=t((function(e){var t,o,n=e.vm,l=d().t;return r.createElement(i,{name:"region",type:a.SELECT,label:l("checkout-page:region"),autocomplete:"off",value:(null===(t=n.region)||void 0===t?void 0:t.id)||"",onChange:n.onRegionChange,options:n.regionOptions,hasError:n.isErrorsVisible&&(null===(o=n.address.validationResults)||void 0===o?void 0:o.region.hasError),errorText:l("checkout-page:regionError")})})),I=t((function(e){var t,o,l,s,c=e.vm,u=d().t,v=c.isShippingAddress?"shipping tel":"tel";return r.createElement(i,{name:"phone",type:a.TEL,inputMode:n.TEL,label:(null===(o=null===(t=c.address.fieldLabels)||void 0===t?void 0:t.phone)||void 0===o?void 0:o.label)||u("checkout-page:phone"),autocomplete:v,value:c.phone||"",onChange:c.onPhoneChange,hasError:c.isErrorsVisible&&(null===(l=c.address.validationResults)||void 0===l?void 0:l.phone.hasError),currentCountryCode:(null===(s=c.address.country)||void 0===s?void 0:s.iso2)||c.myCountryCode,errorText:u("checkout-page:phoneError")})})),V=t((function(e){var t,o,n,l=e.vm,s=d().t,c=null===(t=l.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.companyName;return r.createElement(i,{name:"company",type:a.TEXT,label:(null===(n=null===(o=l.address.fieldLabels)||void 0===o?void 0:o.company)||void 0===n?void 0:n.label)||s("checkout-page:companyName"),value:l.address.company||"",onChange:l.onCompanyChange,hasError:l.isErrorsVisible&&c,errorText:c?s("checkout-page:fieldRestrictionError"):void 0})})),F=t((function(e){var t,o,n,l,s,c=e.vm,u=d().t,v=null===(t=c.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.taxOffice;return r.createElement(i,{name:"taxOffice",type:a.TEXT,label:(null===(n=null===(o=c.address.fieldLabels)||void 0===o?void 0:o.taxOffice)||void 0===n?void 0:n.label)||u("checkout-page:taxOffice"),value:(null===(l=c.address)||void 0===l?void 0:l.taxOffice)||"",onChange:c.onTaxOfficeChange,hasError:c.isErrorsVisible&&((null===(s=c.address.validationResults)||void 0===s?void 0:s.taxOffice.hasError)||v),errorText:u(v?"checkout-page:fieldRestrictionError":"checkout-page:taxOfficeError")})})),j=t((function(e){var t,o,n,l,s=e.vm,c=d().t;return r.createElement(i,{name:"taxNumber",type:a.TEXT,label:(null===(o=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.taxNumber)||void 0===o?void 0:o.label)||c("checkout-page:taxNumber"),value:(null===(n=s.address)||void 0===n?void 0:n.taxNumber)||"",onChange:s.onTaxNumberChange,hasError:s.isErrorsVisible&&(null===(l=s.address.validationResults)||void 0===l?void 0:l.taxNumber.hasError),errorText:c("checkout-page:taxNumberError")})}));export{E as AddressForm};
|
|
1
|
+
import{__assign as e}from'./../../../../ext/tslib/tslib.es6.js';import*as r from"react";import{observer as t}from"mobx-react-lite";import{IkasCheckoutRequirement as i}from"@ikas/storefront-models";import{FormItem as o}from"../form-item/index.js";import{FormItemType as a,FormItemInputMode as n}from"../form-item/model.js";import s from"./model.js";import{Checkbox as l}from"../checkbox/index.js";import"@ikas/storefront-config";import{useTranslation as d}from"../../../../utils/i18n.js";import{AddressFormItem as c,BillingFormItem as u}from"@ikas/localized-address";import v from"../../styles/common.module.scss.js";import m from"../../style.module.scss.js";var E=t((function(t){var i=r.useMemo((function(){return new s(e({},t))}),[]);return r.useEffect((function(){Object.entries(t).forEach((function(e){i[e[0]]=e[1]}))}),Object.values(t)),"in-store"===t.deliveryMethod?r.createElement(p,{props:t,vm:i}):r.createElement(h,{props:t,vm:i})})),p=t((function(t){var o=t.props,a=t.vm;return d().t,r.createElement("div",null,r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},r.createElement(g,e({},o,{vm:a})),r.createElement(f,e({},o,{vm:a})),r.createElement("div",null)," "),!!a.address.checkoutSettings&&a.address.checkoutSettings.phoneRequirement!==i.INVISIBLE&&r.createElement("div",{className:m.RowPB},r.createElement(I,e({},o,{vm:a})),r.createElement("div",null)," "))})),h=t((function(t){var i,o,a,n=t.props,s=t.vm,E=d().t,p=function(t){var i=t.map((function(t){return function(t){switch(t){case c.FIRSTNAME:return r.createElement(g,e({},n,{vm:s}));case c.LASTNAME:return r.createElement(f,e({},n,{vm:s}));case c.IDENTITY_NUMBER:return r.createElement(b,e({},n,{vm:s}));case c.ADDRESS_LINE_1:return r.createElement(y,e({},n,{vm:s}));case c.ADDRESS_LINE_2:return r.createElement(T,e({},n,{vm:s}));case c.POSTAL_CODE:return r.createElement(N,e({},n,{vm:s}));case c.COUNTRY:return r.createElement(L,e({},n,{vm:s}));case c.STATE:return r.createElement(k,e({},n,{vm:s}));case c.CITY:return s.address.isFreeTextCity?r.createElement(R,e({},n,{vm:s})):r.createElement(x,e({},n,{vm:s}));case c.DISTRICT:return s.address.isFreeTextDistrict?r.createElement(S,e({},n,{vm:s})):r.createElement(O,e({},n,{vm:s}));case c.REGION:return r.createElement(A,e({},n,{vm:s}));case c.PHONE:return r.createElement(I,e({},n,{vm:s}));default:return null}}(t)}));return r.createElement(r.Fragment,null,1===t.length&&r.createElement("div",{className:m.RowPB},i),2===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},i,r.createElement("div",null)," "),3===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2,v.Grid3].join(" ")},i,r.createElement("div",null)," "))},h=function(t){var i=t.map((function(t){return function(t){switch(t){case u.COMPANY:return r.createElement(V,e({},n,{vm:s}));case u.TAX_NUMBER:return r.createElement(j,e({},n,{vm:s}));case u.TAX_OFFICE:return r.createElement(F,e({},n,{vm:s}));default:return null}}(t)}));return r.createElement(r.Fragment,null,1===t.length&&r.createElement("div",{className:m.RowPB},i),2===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2].join(" ")},i,r.createElement("div",null)," "),3===t.length&&r.createElement("div",{className:[v.Grid,v.Grid2,v.Grid3].join(" ")},i,r.createElement("div",null)," "))};return r.createElement("div",null,s.allowTitleChange&&r.createElement("div",{className:m.RowPB},r.createElement(C,e({},n,{vm:s}))),s.countryOptions.length<=1?null===(i=s.address.addressFormatIgnoreCountry)||void 0===i?void 0:i.map((function(e){return p(e)})):null===(o=s.address.addressFormat)||void 0===o?void 0:o.map((function(e){return p(e)})),!!s.allowCorporateInfo&&r.createElement("div",{style:{marginTop:"12px"}},r.createElement(l,{value:s.isCorporate,label:E("checkout-page:corporateInvoice"),onChange:s.onCorporateChange})),!!s.isCorporate&&(null===(a=s.address.billingFormat)||void 0===a?void 0:a.map((function(e){return h(e)}))))})),g=t((function(e){var t,i,n,s,l=e.vm,c=d().t,u=l.isShippingAddress?"shipping given-name":"given-name",v=null===(t=l.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.firstName;return r.createElement(o,{name:"firstName",type:a.TEXT,label:(null===(n=null===(i=l.address.fieldLabels)||void 0===i?void 0:i.firstName)||void 0===n?void 0:n.label)||c("checkout-page:firstName"),autocomplete:u,value:l.firstName||"",onChange:l.onFirstNameChange,hasError:l.isErrorsVisible&&((null===(s=l.address.validationResults)||void 0===s?void 0:s.firstName.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError.firstName":"checkout-page:firstNameError")})})),f=t((function(e){var t,i,n,s,l=e.vm,c=d().t,u=l.isShippingAddress?"shipping family-name":"family-name",v=null===(t=l.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.lastName;return r.createElement(o,{name:"lastName",type:a.TEXT,label:(null===(n=null===(i=l.address.fieldLabels)||void 0===i?void 0:i.lastName)||void 0===n?void 0:n.label)||c("checkout-page:lastName"),autocomplete:u,value:l.lastName||"",onChange:l.onLastNameChange,hasError:l.isErrorsVisible&&((null===(s=l.address.validationResults)||void 0===s?void 0:s.lastName.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError.lastName":"checkout-page:lastNameError")})})),b=t((function(e){var t,i,n,s=e.vm,l=d().t;return r.createElement(o,{name:"identityNumber",type:a.TEXT,label:(null===(i=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.identityNumber)||void 0===i?void 0:i.label)||l("checkout-page:identityNumber"),value:s.identityNumber||"",onChange:s.onIdentityNumberChange,hasError:s.isErrorsVisible&&(null===(n=s.address.validationResults)||void 0===n?void 0:n.identityNumber.hasError),errorText:l("checkout-page:identityNumberError")})})),C=t((function(e){var t=e.vm,i=d().t,n=t.address;return r.createElement(o,{type:a.TEXT,label:i("checkout-page:addressTitle"),value:n.title||"",onChange:t.onAddressTitleChange,hasError:t.isErrorsVisible&&!n.title,errorText:i("checkout-page:addressTitleError")})})),y=t((function(e){var t,i,n,s,l=e.vm,c=d().t,u=l.isShippingAddress?"shipping address-line1":"address-line1",v=null===(t=l.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.addressLine1;return r.createElement(o,{name:"addressLine1",type:a.TEXT,label:(null===(n=null===(i=l.address.fieldLabels)||void 0===i?void 0:i.addressLine1)||void 0===n?void 0:n.label)||c("checkout-page:addressLine1"),autocomplete:u,value:l.address.addressLine1||"",onChange:l.onAddressLine1Change,hasError:l.isErrorsVisible&&((null===(s=l.address.validationResults)||void 0===s?void 0:s.addressLine1.hasError)||v),errorText:c(v?"checkout-page:fieldRestrictionError.addressLine1":"checkout-page:addressError")})})),T=t((function(e){var t,i,n,s=e.vm,l=d().t,c=s.isShippingAddress?"shipping address-line2":"address-line2",u=null===(t=s.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.addressLine2;return r.createElement(o,{name:"addressLine2",type:a.TEXT,autocomplete:c,label:(null===(n=null===(i=s.address.fieldLabels)||void 0===i?void 0:i.addressLine2)||void 0===n?void 0:n.label)||l("checkout-page:addressLine2"),value:s.address.addressLine2||"",onChange:s.onAddressLine2Change,hasError:s.isErrorsVisible&&u,errorText:u?l("checkout-page:fieldRestrictionError.addressLine2"):void 0})})),N=t((function(e){var t,i,n,s=e.vm,l=d().t,c=s.isShippingAddress?"shipping postal-code":"postal-code";return r.createElement(o,{name:"postalCode",type:a.TEXT,label:(null===(i=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.postalCode)||void 0===i?void 0:i.label)||l("checkout-page:postalCode"),autocomplete:c,value:s.address.postalCode||"",onChange:s.onAddressPostalCodeChange,hasError:s.isErrorsVisible&&(null===(n=s.address.validationResults)||void 0===n?void 0:n.postalCode.hasError),errorText:l("checkout-page:postalCodeError")})})),L=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return l.countryOptions.length<=1?null:r.createElement(o,{name:"country",type:a.SELECT,label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.country)||void 0===i?void 0:i.label)||c("checkout-page:country"),autocomplete:"country-name",value:(null===(n=l.country)||void 0===n?void 0:n.id)||"",onChange:l.onCountryChange,options:l.countryOptions,hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.country.hasError),errorText:c("checkout-page:countryError")})})),k=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return r.createElement(o,{name:"state",type:a.SELECT,label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.state)||void 0===i?void 0:i.label)||c("checkout-page:state"),value:(null===(n=l.state)||void 0===n?void 0:n.id)||"",onChange:l.onStateChange,options:l.stateOptions,hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.state.hasError),errorText:c("checkout-page:stateError")})})),x=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return r.createElement(o,{name:"city",type:a.SELECT,label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.city)||void 0===i?void 0:i.label)||c("checkout-page:city"),autocomplete:"off",value:(null===(n=l.city)||void 0===n?void 0:n.id)||"",onChange:l.onCityChange,options:l.cityOptions,disabled:!l.cityOptions.length,isLoading:l.isLoadingCities,hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.city.hasError),errorText:c("checkout-page:cityError")})})),R=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return r.createElement(o,{name:"city",type:a.TEXT,autocomplete:"address-level2",label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.city)||void 0===i?void 0:i.label)||c("checkout-page:city"),value:(null===(n=l.city)||void 0===n?void 0:n.name)||"",hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.city.hasError),onChange:l.onCityInputChange,errorText:c("checkout-page:cityError")})})),O=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return r.createElement(o,{name:"district",type:a.SELECT,label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.district)||void 0===i?void 0:i.label)||c("checkout-page:district"),autocomplete:"off",value:(null===(n=l.district)||void 0===n?void 0:n.id)||"",onChange:l.onDistrictChange,options:l.districtOptions,disabled:!l.districtOptions.length,isLoading:l.isLoadingDistricts,hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.district.hasError),errorText:c("checkout-page:districtError")})})),S=t((function(e){var t,i,n,s=e.vm,l=d().t;return r.createElement(o,{name:"district",type:a.TEXT,autocomplete:"address-level3",label:(null===(i=null===(t=s.address.fieldLabels)||void 0===t?void 0:t.district)||void 0===i?void 0:i.label)||l("checkout-page:district"),value:(null===(n=s.district)||void 0===n?void 0:n.name)||"",onChange:s.onDistrictInputChange})})),A=t((function(e){var t,i,n=e.vm,s=d().t;return r.createElement(o,{name:"region",type:a.SELECT,label:s("checkout-page:region"),autocomplete:"off",value:(null===(t=n.region)||void 0===t?void 0:t.id)||"",onChange:n.onRegionChange,options:n.regionOptions,hasError:n.isErrorsVisible&&(null===(i=n.address.validationResults)||void 0===i?void 0:i.region.hasError),errorText:s("checkout-page:regionError")})})),I=t((function(e){var t,i,s,l,c=e.vm,u=d().t,v=c.isShippingAddress?"shipping tel":"tel";return r.createElement(o,{name:"phone",type:a.TEL,inputMode:n.TEL,label:(null===(i=null===(t=c.address.fieldLabels)||void 0===t?void 0:t.phone)||void 0===i?void 0:i.label)||u("checkout-page:phone"),autocomplete:v,value:c.phone||"",onChange:c.onPhoneChange,hasError:c.isErrorsVisible&&(null===(s=c.address.validationResults)||void 0===s?void 0:s.phone.hasError),currentCountryCode:(null===(l=c.address.country)||void 0===l?void 0:l.iso2)||c.myCountryCode,errorText:u("checkout-page:phoneError")})})),V=t((function(e){var t,i,n,s=e.vm,l=d().t,c=null===(t=s.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.companyName;return r.createElement(o,{name:"company",type:a.TEXT,label:(null===(n=null===(i=s.address.fieldLabels)||void 0===i?void 0:i.company)||void 0===n?void 0:n.label)||l("checkout-page:companyName"),value:s.address.company||"",onChange:s.onCompanyChange,hasError:s.isErrorsVisible&&c,errorText:c?l("checkout-page:fieldRestrictionError.companyName"):void 0})})),F=t((function(e){var t,i,n,s,l,c=e.vm,u=d().t,v=null===(t=c.address.addressFieldRestrictionErrors)||void 0===t?void 0:t.taxOffice;return r.createElement(o,{name:"taxOffice",type:a.TEXT,label:(null===(n=null===(i=c.address.fieldLabels)||void 0===i?void 0:i.taxOffice)||void 0===n?void 0:n.label)||u("checkout-page:taxOffice"),value:(null===(s=c.address)||void 0===s?void 0:s.taxOffice)||"",onChange:c.onTaxOfficeChange,hasError:c.isErrorsVisible&&((null===(l=c.address.validationResults)||void 0===l?void 0:l.taxOffice.hasError)||v),errorText:u(v?"checkout-page:fieldRestrictionError.taxOffice":"checkout-page:taxOfficeError")})})),j=t((function(e){var t,i,n,s,l=e.vm,c=d().t;return r.createElement(o,{name:"taxNumber",type:a.TEXT,label:(null===(i=null===(t=l.address.fieldLabels)||void 0===t?void 0:t.taxNumber)||void 0===i?void 0:i.label)||c("checkout-page:taxNumber"),value:(null===(n=l.address)||void 0===n?void 0:n.taxNumber)||"",onChange:l.onTaxNumberChange,hasError:l.isErrorsVisible&&(null===(s=l.address.validationResults)||void 0===s?void 0:s.taxNumber.hasError),errorText:c("checkout-page:taxNumberError")})}));export{E as AddressForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as t}from"mobx-react-lite";import{IkasStorefrontConfig as o}from"@ikas/storefront-config";import{Checkbox as i}from"../../components/checkbox/index.js";import n from"../../components/error/index.js";import{PaymentGateways as r}from"./payment-gateways/index.js";import{BillingAddress as a}from"./billing-address/index.js";import{Button as c}from"../../components/button/index.js";import s from"../../components/master-pass/link-card-to-client/index.js";import{PayPal as m}from"../../components/paypal/index.js";import l from"../../components/notification-box/index.js";import{createTranslationInputData as p,useTranslation as d}from"../../../../utils/i18n.js";import y from"../../components/svg/lock.js";import u from"./style.module.scss.js";import{StoreCredit as k}from"./payment-gateways/store-credit/index.js";var f=t((function(t){var f=t.vm,g=d().t,v=e.useCallback((function(e){e.stopPropagation(),f.policyModalTitle=g("checkout-page:privacyPolicy"),f.policyModalText=f.privacyPolicy}),[f,f.privacyPolicy]),C=e.useCallback((function(e){e.stopPropagation(),f.policyModalTitle=g("checkout-page:termsOfService"),f.policyModalText=f.termsOfService}),[f,f.termsOfService]),E=o.getTranslations()["checkout-page"],P=p(E.ackPoliciesSentence).map((function(t){return t.isVariable?e.createElement("span",{className:[u.TermsLabelSpan,f.isErrorsVisible&&!f.isTermsAndConditionsChecked?u.Error:""].join(" "),onClick:"{{ ackPrivacyPolicy }}"===t.value?v:C},"{{ ackPrivacyPolicy }}"===t.value?g("checkout-page:ackPrivacyPolicy"):g("checkout-page:ackTermsOfService")):t.value}));return e.createElement("div",{className:[u.StepPayment,f.isPaymentMethodVisible?"":u.Disabled].join(" ")},e.createElement(n,{vm:f}),e.createElement(k,{vm:f}),f.isFree&&e.createElement(l,{type:"success",content:g("checkout-page:freeOrderDescription")}),!f.isFree&&e.createElement(e.Fragment,null,f.mpVM.isLinkCardToClientVisible&&e.createElement(s,{vm:f}),e.createElement(r,{vm:f})),e.createElement(a,{vm:f}),f.checkoutSettings.showTermsAndConditionsCheckbox
|
|
1
|
+
import*as e from"react";import{observer as t}from"mobx-react-lite";import{IkasStorefrontConfig as o}from"@ikas/storefront-config";import{Checkbox as i}from"../../components/checkbox/index.js";import n from"../../components/error/index.js";import{PaymentGateways as r}from"./payment-gateways/index.js";import{BillingAddress as a}from"./billing-address/index.js";import{Button as c}from"../../components/button/index.js";import s from"../../components/master-pass/link-card-to-client/index.js";import{PayPal as m}from"../../components/paypal/index.js";import l from"../../components/notification-box/index.js";import{createTranslationInputData as p,useTranslation as d}from"../../../../utils/i18n.js";import y from"../../components/svg/lock.js";import u from"./style.module.scss.js";import{StoreCredit as k}from"./payment-gateways/store-credit/index.js";var f=t((function(t){var f=t.vm,g=d().t,v=e.useCallback((function(e){e.stopPropagation(),f.policyModalTitle=g("checkout-page:privacyPolicy"),f.policyModalText=f.privacyPolicy}),[f,f.privacyPolicy]),C=e.useCallback((function(e){e.stopPropagation(),f.policyModalTitle=g("checkout-page:termsOfService"),f.policyModalText=f.termsOfService}),[f,f.termsOfService]),E=o.getTranslations()["checkout-page"],P=p(E.ackPoliciesSentence).map((function(t){return t.isVariable?e.createElement("span",{className:[u.TermsLabelSpan,f.isErrorsVisible&&!f.isTermsAndConditionsChecked?u.Error:""].join(" "),onClick:"{{ ackPrivacyPolicy }}"===t.value?v:C},"{{ ackPrivacyPolicy }}"===t.value?g("checkout-page:ackPrivacyPolicy"):g("checkout-page:ackTermsOfService")):t.value}));return e.createElement("div",{className:[u.StepPayment,f.isPaymentMethodVisible?"":u.Disabled].join(" ")},e.createElement(n,{vm:f}),e.createElement(k,{vm:f}),f.isFree&&e.createElement(l,{type:"success",content:g("checkout-page:freeOrderDescription")}),!f.isFree&&e.createElement(e.Fragment,null,f.mpVM.isLinkCardToClientVisible&&e.createElement(s,{vm:f}),e.createElement(r,{vm:f})),e.createElement(a,{vm:f}),f.checkoutSettings.showTermsAndConditionsCheckbox&&(!f.isIyzico||f.isFree)&&e.createElement("div",{style:{marginTop:f.useDifferentAddress?"12px":"0px"}},e.createElement(i,{value:f.isTermsAndConditionsChecked,hasError:f.isErrorsVisible&&!f.isTermsAndConditionsChecked,label:e.createElement(e.Fragment,null,P),onChange:f.onTermsAndConditionsCheckedChange})),!f.isFree&&f.isPayPal?e.createElement("div",{className:u.PayPalContainer},e.createElement(m,{vm:f})):f.isIyzico&&!f.isFree?null:e.createElement(c,{style:{width:"100%",marginTop:"24px"},text:g("checkout-page:actions.completeOrder"),isLoading:f.isStepLoading,onClick:f.isDigitalOnly?f.onCompleteDigitalOnlyPaymentClick:f.onCompletePaymentClick}),!!g("checkout-page:securePaymentTooltip")&&e.createElement("div",{className:u.SecurePaymentContainer},e.createElement("span",{className:u.Lock},e.createElement(y,null)),e.createElement("span",null,g("checkout-page:securePaymentTooltip"))))}));export{f as CheckoutStepPayment};
|
|
@@ -105,7 +105,7 @@ export declare class IkasCustomerStore {
|
|
|
105
105
|
createEmailSubscription: (email: string) => Promise<boolean>;
|
|
106
106
|
saveCustomerFormData: (input: SaveCustomerFormDataInput) => Promise<boolean>;
|
|
107
107
|
sendReview: (input: IkasCustomerReviewForm) => Promise<import("../../models/data").IkasCustomerReview | null | undefined>;
|
|
108
|
-
deactivateCustomer: (password
|
|
108
|
+
deactivateCustomer: (password?: string) => Promise<APIResponse<undefined> | APIResponse<boolean> | undefined>;
|
|
109
109
|
exportCustomerPersonalData: () => Promise<APIResponse<undefined> | APIResponse<string> | undefined>;
|
|
110
110
|
onCustomerConsentGrant: () => void;
|
|
111
111
|
waitUntilInitialized: () => Promise<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import i from"lodash/xorBy";import o from"lodash/cloneDeep";import n from"./api.js";import{IkasCustomer as a}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 c}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/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import{IkasRaffleParticipant as u}from"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import d from"../raffle/index.js";import{APIResponse as l}from'./../../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 h from"../product/index.js";import{Analytics as m}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";import{IkasLoginError as f,IkasRegisterError as v,SaveMyCustomerInput as g}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as w}from"@ikas/storefront-providers";import C from"../checkout/index.js";import{formatCurrency as b}from"../../utils/currency.js";var k="undefined"==typeof localStorage,S=function(){function S(i){var a=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._savedLastViewedProducts=[],this._savedLastViewedProductsResponse=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:a._customerConsentGranted})},this.login=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(i=t.data,this.setToken(i.token,i.tokenExpiry),i.customer&&this.setCustomer(i.customer),this.customer&&m.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.customerLogin=function(r,s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken,phone:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer?[4,m.customerLogin()]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,{isSuccess:!0,errorCodes:[]}];case 5:return t&&t.isSuccess&&(null===(c=t.data)||void 0===c?void 0:c.otpSend)?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]}}))}))},this.logout=function(){var t;a.clearLocalData(),null===(t=a.baseStore)||void 0===t||t.cartStore.removeCart(),m.customerLogout()},this.register=function(s,i,o,c,u,d,l,h){return t(a,void 0,void 0,(function(){var t,a,p,f;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.register({email:o,password:c,firstName:s,lastName:i,isAcceptMarketing:u,attributes:d,captchaToken:this._captchaToken,phone:l,flowId:h})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&(null===(p=t.data)||void 0===p?void 0:p.otpSend)?[2,{isSuccess:!0,flowId:null===(f=t.data)||void 0===f?void 0:f.flowId,otpSend:!0,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{email:o,firstName:s,lastName:i,notificationsAccepted:null,attributes:d}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}])}}))}))},this.activateCustomer=function(){return t(a,void 0,void 0,(function(){var t,r,s;return e(this,(function(e){switch(e.label){case 0:return t=new URLSearchParams(window.location.search),(r=t.get("token"))?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.activateCustomer({token:r,captchaToken:this._captchaToken})];case 2:return s=e.sent(),this.clearCaptchaToken(),[2,s.isSuccess];case 3:return[2,!1]}}))}))},this.resendCustomerActivationMail=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.resendCustomerActivationMail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess];case 3:return[2,!1]}}))}))},this.validateCustomerPhoneVerificationCode=function(r,s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateCustomerPhoneVerificationCode({verificationCode:r,captchaToken:this._captchaToken,otpInfo:s})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}];case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.validateOTPCode=function(s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return s?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateOTPCode({verificationCode:s,captchaToken:this._captchaToken,otpInfo:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&((null===(a=t.data)||void 0===a?void 0:a.otpSend)||(null===(c=t.data)||void 0===c?void 0:c.flowId))?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{notificationsAccepted:null}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]);case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.resendCustomerPhoneVerificationCode=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.resendCustomerPhoneVerificationCode()];case 1:return[2,(t=e.sent()).isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]}}))}))},this.saveContactForm=function(s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return m.contactForm(s),[4,this.getCaptcha()];case 1:return e.sent(),[4,n.sendContactFormToMerchant(r(r({},s),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&!!(null===(s=t.data)||void 0===s?void 0:s.exists)]}}))}))},this.forgotPassword=function(r){return t(a,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,n.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&t.data]}}))}))},this.recoverPassword=function(r,s,i){return t(a,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,n.recoverPassword({password:r,passwordAgain:s,token:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.saveCustomer({input:new g(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(a,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?(s=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),s.refundSettings=this._refundSettings,[2,s]}}))}))},this.getOrderByEmail=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrderByEmail({email:r,orderNumber:s})];case 1:return(t=e.sent()).isSuccess&&t.data?(i=t.data,[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getLoyaltyCustomerInfo=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.getLoyaltyCustomerInfo({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramPointHistory=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramPointHistory({orderId:{eq:r}})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramTiers=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramTiers()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getEarningMethods=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listEarningMethods()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getSpendingMethodsByCartId=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listSpendingMethodsByCartId({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.useLoyaltyPoints=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.useLoyaltyPoints({input:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactions({checkoutId:{eq:r.checkoutId},id:{eq:r.checkoutId},orderId:{eq:r.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrderTransactionsWithPrices=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactionsWithPrices({input:{orderId:r.orderId}})];case 1:return[2,t.sent().data]}}))}))},this.getFavoriteProductsIds=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(a,void 0,void 0,(function(){var t,r,s,i,o,a;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return(t=e.sent()).isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.length)?[4,h.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),perPage:100}})]:[2,[]];case 2:return r=e.sent(),null===(o=null===(i=r.data)||void 0===i?void 0:i.data)||void 0===o||o.forEach((function(t){t.selectedVariantValues=t.variants[0].variantValues})),[2,(null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r,!0),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(a,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,n.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(a,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,n.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.saveCustomerFormData=function(s){return t(a,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,n.saveCustomerFormData({input:r(r({},s),{captchaToken:this._captchaToken})})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(s.email)),[2,t.isSuccess]}}))}))},this.sendReview=function(s){return t(a,void 0,void 0,(function(){var t,i,o,a,c;return e(this,(function(e){switch(e.label){case 0:if(t=p.getCustomerReviewSettings(),i=p.getSalesChannelId(),o=p.getCurrentLocale(),!t)return[2];if(!(a=null===(c=this.customer)||void 0===c?void 0:c.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,n.createCustomerReview({input:r(r({},s),{customerId:t.customerLoginRequired?a:void 0,salesChannelId:i||"",locale:o})})];case 1:return[2,e.sent().data]}}))}))},this.deactivateCustomer=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.deactivateCustomer({password:r})]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.exportCustomerPersonalData=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.exportCustomerPersonelData()]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.onCustomerConsentGrant=function(){a.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,d.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,w(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new u(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,n.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,s,i;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(i=null===(s=e.customerAttribute)||void 0===s?void 0:s.options)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderProductFiles=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r.length?[4,C.listProductFile({id:{in:r}})]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getDigitalProductFileDownloadUrl=function(r,s){return t(a,void 0,void 0,(function(){var t,i,o,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),t=r.orderLineItems.find((function(t){return t.variant.id===s.variantId})),t?[4,C.getDigitalProductFileDownloadUrl({orderId:r.id,orderLineItemId:t.id})]:[3,2];case 1:i=e.sent(),(o=i.data)&&((n=document.createElement("a")).href=o,n.download=decodeURIComponent(s.name.split("/")[s.name.split("/").length-1])||"",n.click(),n.remove()),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.getOrderInvoicePdfUrl=function(r,s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,C.getOrderInvoicePdfUrl({input:{orderId:r,invoiceId:s}})];case 1:return t=e.sent(),[2,new l(t.data,t.graphQLErrors)]}}))}))},this.getStoreCreditBalance=function(){return t(a,void 0,void 0,(function(){var t,r,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,C.getStoreCreditBalance()];case 1:return t=e.sent(),r=p.getCurrentRouting(),[2,{amount:s=(null===(i=t.data)||void 0===i?void 0:i.amount)||0,formattedAmount:b(s,(null==r?void 0:r.currencyCode)||"",(null==r?void 0:r.currencySymbol)||"")}]}}))}))},this.getOrderRefundSettings=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,n.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)&&(this._refundSettings=t.data.find((function(t){return t.storefrontId===p.getStorefrontId()}))||t.data[0]),e.label=2;case 2:return[2]}}))}))},this.setSavedLastViewedProductsResponse=function(t){a._savedLastViewedProducts=o(a._lastViewedProducts),a._savedLastViewedProductsResponse=t},this.setCaptchaToken=function(t){a._captchaToken=t},this.baseStore=i,s(this)}return Object.defineProperty(S.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||k||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isCaptchaRequired",{get:function(){var t;return(null===(t=p.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"useLastViewedProductResponse",{get:function(){var t;return(null===(t=this._savedLastViewedProducts)||void 0===t?void 0:t.length)&&this._savedLastViewedProductsResponse&&0===i(this._lastViewedProducts,this._savedLastViewedProducts,"productId").length},enumerable:!1,configurable:!0}),S.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",s="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(s,{headers:{"x-api-key":p.getApiKey()||"","x-sfid":p.getStorefrontId()||"","x-sfrid":p.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return i=e.sent(),window.location.href=i.redirectUrl,[2]}}))}))},S.prototype.socialLoginToken=function(r){var s;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.socialLogin({code:r})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer?[4,m.customerLogin()]:[3,3]):[2,!1];case 2:e.sent(),e.label=3;case 3:return[2,!0]}}))}))},S.prototype.refundOrder=function(r,s){return t(this,void 0,void 0,(function(){var t,i,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],r.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,n.createOrderRefundRequest({input:{email:s,orderId:r.id,orderLineItems:t}})];case 1:return(i=e.sent()).isSuccess&&i.data?(Object.entries(i.data).forEach((function(t){var e=t[0],r=t[1];o[e]=r})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},S.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?[4,m.customerVisit()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},S.prototype.routeChangeInit=function(){this.loadToken(),!this.token&&this.customer&&this.clearLocalData(),this.token&&!this.customer&&this.getCustomer()},S.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return k||!this.token?[2]:[4,n.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},S.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,n.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]}}))}))},S.prototype.setCustomer=function(t){this.customer=new a(t)},S.prototype.getLastViewedProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=(null===(r=o(t.data))||void 0===r?void 0:r.reverse())||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},S.prototype.saveLastViewedProducts=function(){k||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},S.prototype.loadLastViewedProducts=function(){k||(this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=o(this._lastViewedProducts).reverse())},S.prototype.getLocalLastViewedProducts=function(){if(k)return[];try{var t=window.localStorage.getItem("lastViewedProducts");if(t)return JSON.parse(t)}catch(t){}return[]},S.prototype.removeLastViewedProducts=function(){k||window.localStorage.removeItem("lastViewedProducts")},S.prototype.onProductView=function(r,s){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===r}))?[2]:[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:r,variantId:s}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:s}),[3,3];case 2:this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=this._lastViewedProducts.filter((function(t){return t.productId!==r})),this._lastViewedProducts.push({productId:r,variantId:s}),this._lastViewedProducts=this._lastViewedProducts.slice(-20),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},S.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(k)return[2];e.label=1;case 1:return e.trys.push([1,4,,5]),(t=this.getLocalLastViewedProducts()).length?[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:t}})]:[3,3];case 2:e.sent()&&this.removeLastViewedProducts(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},S.prototype.saveCustomerConsent=function(){k||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},S.prototype.loadCustomerConsent=function(){k||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},S.prototype.removeCustomerConsent=function(){k||window.localStorage.removeItem("customerConsent")},S.prototype.setToken=function(t,e){k||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),p.init({customerToken:t}))},S.prototype.loadToken=function(){if(!k){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e?this.setToken(t,parseInt(e)):this.clearLocalTokenData()}},S.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},S.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,p.init({customerToken:""}),this.clearCaptchaToken()},S.prototype.clearCaptchaToken=function(){this._captchaToken=null},S.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]}}))}))},S}();export{S as IkasCustomerStore};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import i from"lodash/xorBy";import o from"lodash/cloneDeep";import n from"./api.js";import{IkasCustomer as a}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 c}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/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer-form-data-input/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import{IkasRaffleParticipant as u}from"../../models/data/raffle/index.js";import"../../models/data/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-filter/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import d from"../raffle/index.js";import{APIResponse as l}from'./../../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 h from"../product/index.js";import{Analytics as m}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as p}from"@ikas/storefront-config";import{IkasLoginError as f,IkasRegisterError as v,SaveMyCustomerInput as g}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as w}from"@ikas/storefront-providers";import C from"../checkout/index.js";import{formatCurrency as b}from"../../utils/currency.js";var k="undefined"==typeof localStorage,S=function(){function S(i){var a=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._savedLastViewedProducts=[],this._savedLastViewedProductsResponse=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:a._customerConsentGranted})},this.login=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(i=t.data,this.setToken(i.token,i.tokenExpiry),i.customer&&this.setCustomer(i.customer),this.customer&&m.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.customerLogin=function(r,s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:s,captchaToken:this._captchaToken,phone:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer?[4,m.customerLogin()]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,{isSuccess:!0,errorCodes:[]}];case 5:return t&&t.isSuccess&&(null===(c=t.data)||void 0===c?void 0:c.otpSend)?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]}}))}))},this.logout=function(){var t;a.clearLocalData(),null===(t=a.baseStore)||void 0===t||t.cartStore.removeCart(),m.customerLogout()},this.register=function(s,i,o,c,u,d,l,h){return t(a,void 0,void 0,(function(){var t,a,p,f;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.register({email:o,password:c,firstName:s,lastName:i,isAcceptMarketing:u,attributes:d,captchaToken:this._captchaToken,phone:l,flowId:h})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&(null===(p=t.data)||void 0===p?void 0:p.otpSend)?[2,{isSuccess:!0,flowId:null===(f=t.data)||void 0===f?void 0:f.flowId,otpSend:!0,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{email:o,firstName:s,lastName:i,notificationsAccepted:null,attributes:d}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}])}}))}))},this.activateCustomer=function(){return t(a,void 0,void 0,(function(){var t,r,s;return e(this,(function(e){switch(e.label){case 0:return t=new URLSearchParams(window.location.search),(r=t.get("token"))?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.activateCustomer({token:r,captchaToken:this._captchaToken})];case 2:return s=e.sent(),this.clearCaptchaToken(),[2,s.isSuccess];case 3:return[2,!1]}}))}))},this.resendCustomerActivationMail=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.resendCustomerActivationMail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess];case 3:return[2,!1]}}))}))},this.validateCustomerPhoneVerificationCode=function(r,s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateCustomerPhoneVerificationCode({verificationCode:r,captchaToken:this._captchaToken,otpInfo:s})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}];case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.validateOTPCode=function(s,i){return t(a,void 0,void 0,(function(){var t,o,a,c,u;return e(this,(function(e){switch(e.label){case 0:return s?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateOTPCode({verificationCode:s,captchaToken:this._captchaToken,otpInfo:i})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),m.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):t&&t.isSuccess&&((null===(a=t.data)||void 0===a?void 0:a.otpSend)||(null===(c=t.data)||void 0===c?void 0:c.flowId))?[2,{isSuccess:!0,otpSend:!0,flowId:null===(u=t.data)||void 0===u?void 0:u.flowId,errorCodes:[]}]:(t.errorCodes.some((function(t){return t===v.B2B_CUSTOMER_ACCOUNT_DISABLED}))&&m.completeRegistration(r(r({},this.toAnalyticsCustomer(this.customer)),{notificationsAccepted:null}),!0),[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]);case 3:return[2,{isSuccess:!1,errorCodes:[]}]}}))}))},this.resendCustomerPhoneVerificationCode=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.resendCustomerPhoneVerificationCode()];case 1:return[2,(t=e.sent()).isSuccess&&t.data?{isSuccess:!0,errorCodes:[]}:{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(v).includes(t)?t:v.UNKOWN}))}]}}))}))},this.saveContactForm=function(s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return m.contactForm(s),[4,this.getCaptcha()];case 1:return e.sent(),[4,n.sendContactFormToMerchant(r(r({},s),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&!!(null===(s=t.data)||void 0===s?void 0:s.exists)]}}))}))},this.forgotPassword=function(r){return t(a,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,n.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&t.data]}}))}))},this.recoverPassword=function(r,s,i){return t(a,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,n.recoverPassword({password:r,passwordAgain:s,token:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.saveCustomer({input:new g(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(a,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?(s=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),s.refundSettings=this._refundSettings,[2,s]}}))}))},this.getOrderByEmail=function(r,s){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrderByEmail({email:r,orderNumber:s})];case 1:return(t=e.sent()).isSuccess&&t.data?(i=t.data,[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getLoyaltyCustomerInfo=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.getLoyaltyCustomerInfo({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramPointHistory=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramPointHistory({orderId:{eq:r}})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getLoyaltyProgramTiers=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listLoyaltyProgramTiers()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getEarningMethods=function(){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listEarningMethods()];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getSpendingMethodsByCartId=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.listSpendingMethodsByCartId({cartId:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.useLoyaltyPoints=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.useLoyaltyPoints({input:r})];case 1:return(t=e.sent()).isSuccess&&t.data?[2,t.data]:[2,null]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactions({checkoutId:{eq:r.checkoutId},id:{eq:r.checkoutId},orderId:{eq:r.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrderTransactionsWithPrices=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.listOrderTransactionsWithPrices({input:{orderId:r.orderId}})];case 1:return[2,t.sent().data]}}))}))},this.getFavoriteProductsIds=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(a,void 0,void 0,(function(){var t,r,s,i,o,a;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return(t=e.sent()).isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.length)?[4,h.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:p.getPriceListId(),salesChannelId:p.getSalesChannelId(),perPage:100}})]:[2,[]];case 2:return r=e.sent(),null===(o=null===(i=r.data)||void 0===i?void 0:i.data)||void 0===o||o.forEach((function(t){t.selectedVariantValues=t.variants[0].variantValues})),[2,(null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:if(!(null===(s=this.customer)||void 0===s?void 0:s.id))throw Error("Unauthorized");return[4,n.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),m.addToWishlist(r,!0),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(a,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,n.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(a,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,n.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.saveCustomerFormData=function(s){return t(a,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,n.saveCustomerFormData({input:r(r({},s),{captchaToken:this._captchaToken})})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,m.createEmailSubscripition(s.email)),[2,t.isSuccess]}}))}))},this.sendReview=function(s){return t(a,void 0,void 0,(function(){var t,i,o,a,c;return e(this,(function(e){switch(e.label){case 0:if(t=p.getCustomerReviewSettings(),i=p.getSalesChannelId(),o=p.getCurrentLocale(),!t)return[2];if(!(a=null===(c=this.customer)||void 0===c?void 0:c.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,n.createCustomerReview({input:r(r({},s),{customerId:t.customerLoginRequired?a:void 0,salesChannelId:i||"",locale:o})})];case 1:return[2,e.sent().data]}}))}))},this.deactivateCustomer=function(s){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.deactivateCustomer(r({},s&&{password:s}))]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.exportCustomerPersonalData=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.exportCustomerPersonelData()]:[3,2];case 1:return[2,t.sent()];case 2:return[2]}}))}))},this.onCustomerConsentGrant=function(){a.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,d.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,w(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new u(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,n.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,s,i;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(i=null===(s=e.customerAttribute)||void 0===s?void 0:s.options)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderProductFiles=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r.length?[4,C.listProductFile({id:{in:r}})]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getDigitalProductFileDownloadUrl=function(r,s){return t(a,void 0,void 0,(function(){var t,i,o,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),t=r.orderLineItems.find((function(t){return t.variant.id===s.variantId})),t?[4,C.getDigitalProductFileDownloadUrl({orderId:r.id,orderLineItemId:t.id})]:[3,2];case 1:i=e.sent(),(o=i.data)&&((n=document.createElement("a")).href=o,n.download=decodeURIComponent(s.name.split("/")[s.name.split("/").length-1])||"",n.click(),n.remove()),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.getOrderInvoicePdfUrl=function(r,s){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,C.getOrderInvoicePdfUrl({input:{orderId:r,invoiceId:s}})];case 1:return t=e.sent(),[2,new l(t.data,t.graphQLErrors)]}}))}))},this.getStoreCreditBalance=function(){return t(a,void 0,void 0,(function(){var t,r,s,i;return e(this,(function(e){switch(e.label){case 0:return[4,C.getStoreCreditBalance()];case 1:return t=e.sent(),r=p.getCurrentRouting(),[2,{amount:s=(null===(i=t.data)||void 0===i?void 0:i.amount)||0,formattedAmount:b(s,(null==r?void 0:r.currencyCode)||"",(null==r?void 0:r.currencySymbol)||"")}]}}))}))},this.getOrderRefundSettings=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,n.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)&&(this._refundSettings=t.data.find((function(t){return t.storefrontId===p.getStorefrontId()}))||t.data[0]),e.label=2;case 2:return[2]}}))}))},this.setSavedLastViewedProductsResponse=function(t){a._savedLastViewedProducts=o(a._lastViewedProducts),a._savedLastViewedProductsResponse=t},this.setCaptchaToken=function(t){a._captchaToken=t},this.baseStore=i,s(this)}return Object.defineProperty(S.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||k||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isCaptchaRequired",{get:function(){var t;return(null===(t=p.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"useLastViewedProductResponse",{get:function(){var t;return(null===(t=this._savedLastViewedProducts)||void 0===t?void 0:t.length)&&this._savedLastViewedProductsResponse&&0===i(this._lastViewedProducts,this._savedLastViewedProducts,"productId").length},enumerable:!1,configurable:!0}),S.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,s,i;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",s="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(s,{headers:{"x-api-key":p.getApiKey()||"","x-sfid":p.getStorefrontId()||"","x-sfrid":p.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return i=e.sent(),window.location.href=i.redirectUrl,[2]}}))}))},S.prototype.socialLoginToken=function(r){var s;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.socialLogin({code:r})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer?[4,m.customerLogin()]:[3,3]):[2,!1];case 2:e.sent(),e.label=3;case 3:return[2,!0]}}))}))},S.prototype.refundOrder=function(r,s){return t(this,void 0,void 0,(function(){var t,i,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],r.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,n.createOrderRefundRequest({input:{email:s,orderId:r.id,orderLineItems:t}})];case 1:return(i=e.sent()).isSuccess&&i.data?(Object.entries(i.data).forEach((function(t){var e=t[0],r=t[1];o[e]=r})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},S.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?[4,m.customerVisit()]:[3,4];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},S.prototype.routeChangeInit=function(){this.loadToken(),!this.token&&this.customer&&this.clearLocalData(),this.token&&!this.customer&&this.getCustomer()},S.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return k||!this.token?[2]:[4,n.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},S.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,n.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]}}))}))},S.prototype.setCustomer=function(t){this.customer=new a(t)},S.prototype.getLastViewedProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=(null===(r=o(t.data))||void 0===r?void 0:r.reverse())||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},S.prototype.saveLastViewedProducts=function(){k||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},S.prototype.loadLastViewedProducts=function(){k||(this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=o(this._lastViewedProducts).reverse())},S.prototype.getLocalLastViewedProducts=function(){if(k)return[];try{var t=window.localStorage.getItem("lastViewedProducts");if(t)return JSON.parse(t)}catch(t){}return[]},S.prototype.removeLastViewedProducts=function(){k||window.localStorage.removeItem("lastViewedProducts")},S.prototype.onProductView=function(r,s){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===r}))?[2]:[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:r,variantId:s}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:s}),[3,3];case 2:this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=this._lastViewedProducts.filter((function(t){return t.productId!==r})),this._lastViewedProducts.push({productId:r,variantId:s}),this._lastViewedProducts=this._lastViewedProducts.slice(-20),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},S.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(k)return[2];e.label=1;case 1:return e.trys.push([1,4,,5]),(t=this.getLocalLastViewedProducts()).length?[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:t}})]:[3,3];case 2:e.sent()&&this.removeLastViewedProducts(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},S.prototype.saveCustomerConsent=function(){k||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},S.prototype.loadCustomerConsent=function(){k||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},S.prototype.removeCustomerConsent=function(){k||window.localStorage.removeItem("customerConsent")},S.prototype.setToken=function(t,e){k||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),p.init({customerToken:t}))},S.prototype.loadToken=function(){if(!k){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e?this.setToken(t,parseInt(e)):this.clearLocalTokenData()}},S.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},S.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,p.init({customerToken:""}),this.clearCaptchaToken()},S.prototype.clearCaptchaToken=function(){this._captchaToken=null},S.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]}}))}))},S}();export{S as IkasCustomerStore};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "6.1.0-beta.
|
|
3
|
+
"version": "6.1.0-beta.304",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"swiper": "11.0.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
27
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
28
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
29
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
30
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
26
|
+
"@ikas/storefront-api": "^6.1.0-beta.304",
|
|
27
|
+
"@ikas/storefront-config": "^6.1.0-beta.304",
|
|
28
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.304",
|
|
29
|
+
"@ikas/storefront-models": "^6.1.0-beta.304",
|
|
30
|
+
"@ikas/storefront-providers": "^6.1.0-beta.304",
|
|
31
31
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
32
32
|
"@adyen/adyen-web": "^5.57.0",
|
|
33
33
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -62,11 +62,11 @@
|
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
65
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
66
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
67
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
68
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
69
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
65
|
+
"@ikas/storefront-api": "^6.1.0-beta.304",
|
|
66
|
+
"@ikas/storefront-config": "^6.1.0-beta.304",
|
|
67
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.304",
|
|
68
|
+
"@ikas/storefront-models": "^6.1.0-beta.304",
|
|
69
|
+
"@ikas/storefront-providers": "^6.1.0-beta.304",
|
|
70
70
|
"mobx": "^6.1.3",
|
|
71
71
|
"mobx-react-lite": "^3.1.5",
|
|
72
72
|
"next": "12.2.0",
|