@ikas/storefront 4.0.0-alpha.74 → 4.0.0-alpha.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/checkout/components/klarna/index.js +1 -1
- package/build/components/checkout/steps/step-success/index.js +1 -1
- package/build/store/customer/api.d.ts +2 -2
- package/build/store/customer/api.js +1 -1
- package/build/store/customer/index.d.ts +1 -2
- package/build/store/customer/index.js +1 -1
- package/build/store/raffle/index.d.ts +1 -1
- package/build/store/raffle/index.js +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as n from"react";import{observer as e}from"mobx-react-lite";import t from"next/script";import"@ikas/storefront-config";import{useTranslation as a}from"../../../../utils/i18n.js";var r=e((function(e){var r=e.vm;return a().t,n.useEffect((function(){window.handleKlarna=function(n){var e;n&&
|
|
1
|
+
import*as n from"react";import{observer as e}from"mobx-react-lite";import t from"next/script";import"@ikas/storefront-config";import{useTranslation as a}from"../../../../utils/i18n.js";var r=e((function(e){var r=e.vm;return a().t,n.useEffect((function(){window.handleKlarna=function(n){var e;n&&fetch((null===(e=r.klarnaResponse)||void 0===e?void 0:e.authorizeUrl)+"&data="+n).then((function(n){})).then((function(n){})).catch((function(n){}))}}),[]),r.klarnaResponse?n.createElement(n.Fragment,null,n.createElement("div",{id:"klarna-payments-container"}),n.createElement(t,{dangerouslySetInnerHTML:{__html:'window.klarnaAsyncCallback = function () {\n try {\n Klarna.Payments.init({\n client_token: "'.concat(r.klarnaResponse.clientToken,'",\n });\n Klarna.Payments.load({\n container: "#klarna-payments-container",\n },\n function (res) {\n }\n );\n } catch (e) {\n console.log("error", e);\n }\n };')}}),n.createElement(t,{dangerouslySetInnerHTML:{__html:"".concat(r.isKlarnaPaymentCompleted&&"Klarna.Payments.authorize({ auto_finalize: true }, function (res) {\n if (res.approved && !!res.authorization_token) {\n window.handleKlarna(JSON.stringify(res))\n } else{\n ".concat(setTimeout((function(){r.setIsKlarnaPaymentCompleted(!1)}),2e3),"\n }\n });"))}}),n.createElement(t,{src:"https://x.klarnacdn.net/kp/lib/v1/api.js"})):null}));export{r as Klarna};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as t}from"mobx-react-lite";import{Button as a}from"../../components/button/index.js";import{CART_LS_KEY as o}from"../../../../store/cart/index.js";import i from"./style.module.scss.js";import s from"../../components/svg/success-circle.js";import r from"../../components/expandable-section/index.js";import n from"../../components/credit-card-form/svg/amex.js";import d from"../../components/credit-card-form/svg/master-card.js";import c from"../../components/credit-card-form/svg/troy.js";import l from"../../components/credit-card-form/svg/visa.js";import"@ikas/storefront-config";import{formatCurrency as m}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.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"mobx";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import{IkasPaymentMethodType as p,IkasPaymentGatewayType as v,IkasOrderPackageStatus as E,IkasTransactionCardAssociation as f}from"@ikas/storefront-models";import"../../../../models/data/campaign-offer/index.js";import"../../../../models/data/cart/campaign-offer/index.js";import"../../../../models/data/cart/index.js";import"../../../../models/data/category/path-item/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/checkout/index.js";import"../../../../models/data/checkout-settings/index.js";import"../../../../models/data/city/index.js";import"../../../../models/data/country/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/attribute/index.js";import"../../../../models/data/customer/review/summary/index.js";import"../../../../models/data/customer/review/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/filter-category/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/line-item/variant/value/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/payment-gateway/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product/filter/index.js";import"../../../../models/data/product/option-set/option/index.js";import"../../../../models/data/product/option-set/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../models/data/product/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/data/state/index.js";import"../../../../models/data/theme-json/index.js";import"../../../../models/data/theme-json/custom-data/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import"../../../../models/ui/product-attribute-detail/index.js";import"../../../../models/ui/product-attribute-list/index.js";import"../../../../models/ui/customer-review-list/index.js";import"../../../../models/ui/customer-review-summary-list/index.js";import"../../../../models/ui/validator/index.js";import"../../../../models/ui/validator/rules/index.js";import"../../../../models/ui/validator/form/login.js";import"../../../../models/ui/validator/form/address.js";import"../../../../models/ui/validator/form/register.js";import"../../../../models/ui/validator/form/contact-form.js";import"../../../../models/ui/validator/form/forgot-password.js";import"../../../../models/ui/validator/form/recover-password.js";import"../../../../models/ui/validator/form/account-info.js";import"../../../../models/ui/validator/form/raffle-form.js";import"../../../../models/ui/validator/form/customer-review.js";import"../../../../models/ui/raffle-list/index.js";import g from"../../components/offer-product/index.js";import{Analytics as x}from"../../../../analytics/analytics.js";import"../../../../analytics/head/index.js";var h=t((function(t){var E,h,k,T,y,N,I=t.vm,L=u().t;e.useEffect((function(){if("undefined"!=typeof localStorage){var e=localStorage.getItem(o);e&&e===I.checkout.id&&(I.successTransaction&&x.purchase(I.checkout,I.successTransaction),localStorage.removeItem(o)),window.handleKlarna(void 0)}}),[]);var A=((null===(E=I.checkout.customer)||void 0===E?void 0:E.firstName)||"")+" "+((null===(h=I.checkout.customer)||void 0===h?void 0:h.lastName)||""),C=((null===(k=I.checkout.shippingAddress)||void 0===k?void 0:k.firstName)||"")+" "+((null===(T=I.checkout.shippingAddress)||void 0===T?void 0:T.lastName)||""),D=I.paymentGateways.find((function(e){var t;return e.id===(null===(t=I.successTransaction)||void 0===t?void 0:t.paymentGatewayId)})),S=null===(y=I.successTransaction)||void 0===y?void 0:y.paymentMethodDetail,R=e.useMemo((function(){var t,a,o,s;return e.createElement("div",{className:[i.InfoGrid].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:paymentMethod")),D&&e.createElement(e.Fragment,null,!!D.logoUrl&&e.createElement("div",{className:i.PaymentLogoContainer},e.createElement("img",{src:D.logoUrl})),!D.logoUrl&&e.createElement("div",{className:i.InfoText},D.paymentMethodType===p.CREDIT_CARD&&D.type===v.INTERNAL?L("checkout-page:creditCard"):D.name),!!D.description&&D.type!==v.EXTERNAL&&e.createElement("div",{className:i.InfoText},e.createElement("div",{dangerouslySetInnerHTML:{__html:D.description}}))),"CREDIT_CARD"===(null===(t=I.successTransaction)||void 0===t?void 0:t.paymentMethod)&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoText},e.createElement("div",{className:i.CardLogoContainer},function(){var t,a;switch(null===(a=null===(t=I.successTransaction)||void 0===t?void 0:t.paymentMethodDetail)||void 0===a?void 0:a.cardAssociation){case f.AMERICAN_EXPRESS:return e.createElement(n,null);case f.MASTER_CARD:return e.createElement(d,null);case f.TROY:return e.createElement(c,null);case f.VISA:return e.createElement(l,null);default:return e.createElement("div",null)}}()),e.createElement("span",null,"**** ".concat((null==S?void 0:S.lastFourDigits)||""))),(null===(a=null==S?void 0:S.installment)||void 0===a?void 0:a.installmentCount)&&S.installment.installmentCount>1&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoText},"".concat(S.installment.installmentCount," ").concat(L("checkout-page:installments"))),null!==S.installment.installmentPrice&&e.createElement("div",{className:i.InfoText},"".concat(S.installment.installmentCount," x ").concat(m(S.installment.installmentPrice,I.checkout.currencyCode,I.checkout.currencySymbol)))))),e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:billingAddress")),!!(null===(o=I.checkout.billingAddress)||void 0===o?void 0:o.company)&&e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},I.checkout.billingAddress.company),e.createElement("div",{className:i.InfoText},null===(s=I.checkout.billingAddress)||void 0===s?void 0:s.addressText)))}),[]),b=e.useMemo((function(){var t,a,o,s,r;return e.createElement("div",{className:[i.InfoGrid].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:contactInfo")),e.createElement("div",{className:i.InfoText},null===(t=I.checkout.customer)||void 0===t?void 0:t.email),e.createElement("div",{className:i.InfoText},A),!!(null===(a=I.checkout.shippingAddress)||void 0===a?void 0:a.phone)&&e.createElement("div",{className:i.InfoText},null===(o=I.checkout.shippingAddress)||void 0===o?void 0:o.phone)),e.createElement("div",null,"in-store"===I.deliveryMethod&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:receiver")),e.createElement("div",{className:[i.InfoText,i.withMBottom].join(" ")},C)),e.createElement("div",{className:i.InfoTitle},"address"===I.deliveryMethod?L("checkout-page:shippingAddress"):L("checkout-page:pickUpLocation")),!!(null===(s=I.checkout.shippingAddress)||void 0===s?void 0:s.company)&&e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},I.checkout.shippingAddress.company),e.createElement("div",{className:i.InfoText},null===(r=I.checkout.shippingAddress)||void 0===r?void 0:r.addressText)))}),[]);return e.createElement("div",{className:i.StepSuccess},e.createElement("div",{className:i.SuccessTitleContainer},e.createElement(s,null),e.createElement("span",{className:i.SuccessTitle},L("checkout-page:orderSuccessTitle"))),e.createElement("div",{className:i.SuccessSubTitle},L("address"===I.deliveryMethod?"checkout-page:orderSuccessDescription":"checkout-page:orderSuccessInStoreDeliveryDescription",{customerName:A})),e.createElement("div",{className:[i.InfoGrid,i.WithBorder].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:orderNoAndDate")),e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},"#"+(I.checkout.orderNumber||"")),e.createElement("div",{className:i.InfoText},I.checkout.dateStr),e.createElement(j,{vm:I})),e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:contactInfo")),e.createElement("div",{className:i.InfoText},null===(N=I.checkout.customer)||void 0===N?void 0:N.email),e.createElement("div",{className:i.InfoText},A))),I.postCheckoutCampaignOffer&&e.createElement(g,{vm:I,campaignOffer:I.postCheckoutCampaignOffer}),e.createElement(r,{title:L("checkout-page:paymentSummary")},R),!I.isDigitalOnly&&e.createElement(r,{title:L("checkout-page:shippingSummary")},b),e.createElement("div",{className:i.Actions},e.createElement("div",{className:i.HelpText},e.createElement("span",null,L("checkout-page:helpCtaQuestion")),e.createElement("span",{className:i.Cta,onClick:function(){return I.setContactModalVisible(!0)}},L("checkout-page:helpCta"))),e.createElement(a,{text:L("checkout-page:actions.backToShopping"),onClick:I.onBackToShoppingClick,style:{flex:"0 0 auto"}})))})),j=t((function(t){var a,o=t.vm,s=u().t,r=i.Yellow;switch(o.checkout.orderPackageStatus){case E.FULFILLED:case E.PARTIALLY_FULFILLED:case E.DELIVERED:case E.PARTIALLY_DELIVERED:r=i.Green;break;case E.CANCELLED:case E.PARTIALLY_CANCELLED:case E.CANCEL_REJECTED:case E.CANCEL_REQUESTED:r=i.Red}return e.createElement("div",{className:[i.OrderStatus,r].join(" ")},o.checkout.orderPackageStatus?null===(a=[{types:[E.UNFULFILLED],text:s("checkout-page:orderPackageStatus.unfulfilled")},{types:[E.READY_FOR_SHIPMENT],text:s("checkout-page:orderPackageStatus.readyForShipment")},{types:[E.PARTIALLY_FULFILLED],text:s("checkout-page:orderPackageStatus.partiallyFulfilled")},{types:[E.FULFILLED],text:s("checkout-page:orderPackageStatus.fulfilled")},{types:[E.DELIVERED,E.PARTIALLY_DELIVERED],text:s("checkout-page:orderPackageStatus.delivered")},{types:[E.UNABLE_TO_DELIVER],text:s("checkout-page:orderPackageStatus.unableToDeliver")},{types:[E.CANCELLED,E.PARTIALLY_CANCELLED],text:s("checkout-page:orderPackageStatus.cancelled")},{types:[E.CANCEL_REJECTED],text:s("checkout-page:orderPackageStatus.cancelRejected")},{types:[E.REFUNDED,E.PARTIALLY_REFUNDED],text:s("checkout-page:orderPackageStatus.refunded")},{types:[E.REFUND_REQUEST_ACCEPTED],text:s("checkout-page:orderPackageStatus.refundRequestAccepted")},{types:[E.REFUND_REJECTED],text:s("checkout-page:orderPackageStatus.refundRejected")},{types:[E.REFUND_REQUESTED],text:s("checkout-page:orderPackageStatus.refundRequested")}].find((function(e){return e.types.includes(o.checkout.orderPackageStatus)})))||void 0===a?void 0:a.text:"")}));export{h as StepSuccess};
|
|
1
|
+
import*as e from"react";import{observer as t}from"mobx-react-lite";import{Button as a}from"../../components/button/index.js";import{CART_LS_KEY as o}from"../../../../store/cart/index.js";import i from"./style.module.scss.js";import s from"../../components/svg/success-circle.js";import r from"../../components/expandable-section/index.js";import n from"../../components/credit-card-form/svg/amex.js";import d from"../../components/credit-card-form/svg/master-card.js";import c from"../../components/credit-card-form/svg/troy.js";import l from"../../components/credit-card-form/svg/visa.js";import"@ikas/storefront-config";import{formatCurrency as m}from"../../../../utils/currency.js";import{useTranslation as u}from"../../../../utils/i18n.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"mobx";import"../../../../models/data/blog/index.js";import"../../../../models/data/brand/index.js";import{IkasPaymentMethodType as p,IkasPaymentGatewayType as v,IkasOrderPackageStatus as E,IkasTransactionCardAssociation as f}from"@ikas/storefront-models";import"../../../../models/data/campaign-offer/index.js";import"../../../../models/data/cart/campaign-offer/index.js";import"../../../../models/data/cart/index.js";import"../../../../models/data/category/path-item/index.js";import"../../../../models/data/category/index.js";import"../../../../models/data/checkout/index.js";import"../../../../models/data/checkout-settings/index.js";import"../../../../models/data/city/index.js";import"../../../../models/data/country/index.js";import"../../../../models/data/customer/address/index.js";import"../../../../models/data/customer/attribute/index.js";import"../../../../models/data/customer/review/summary/index.js";import"../../../../models/data/customer/review/index.js";import"../../../../models/data/customer/index.js";import"../../../../models/data/district/index.js";import"../../../../models/data/favorite-product/index.js";import"../../../../models/data/filter-category/index.js";import"../../../../models/data/html-meta-data/index.js";import"../../../../models/data/image/index.js";import"../../../../models/data/order/address/index.js";import"../../../../models/data/order/line-item/variant/value/index.js";import"../../../../models/data/order/line-item/variant/index.js";import"../../../../models/data/order/line-item/index.js";import"../../../../models/data/order/package/index.js";import"../../../../models/data/order/index.js";import"../../../../models/data/payment-gateway/index.js";import"../../../../models/data/product/attribute-value/index.js";import"../../../../models/data/product/filter/index.js";import"../../../../models/data/product/option-set/option/index.js";import"../../../../models/data/product/option-set/index.js";import"../../../../models/data/product/variant/price/index.js";import"../../../../models/data/product/variant/index.js";import"../../../../models/data/variant-type/index.js";import"../../../../models/data/product/index.js";import"../../../../models/data/raffle/index.js";import"../../../../models/data/state/index.js";import"../../../../models/data/theme-json/index.js";import"../../../../models/data/theme-json/custom-data/index.js";import"../../../../models/data/variant-type/variant-value/index.js";import"../../../../models/ui/blog-list/index.js";import"../../../../models/ui/blog-category-list/index.js";import"../../../../models/ui/brand-list/index.js";import"../../../../models/ui/category-list/index.js";import"../../../../models/ui/product-list/index.js";import"../../../../models/ui/product-attribute-detail/index.js";import"../../../../models/ui/product-attribute-list/index.js";import"../../../../models/ui/customer-review-list/index.js";import"../../../../models/ui/customer-review-summary-list/index.js";import"../../../../models/ui/validator/index.js";import"../../../../models/ui/validator/rules/index.js";import"../../../../models/ui/validator/form/login.js";import"../../../../models/ui/validator/form/address.js";import"../../../../models/ui/validator/form/register.js";import"../../../../models/ui/validator/form/contact-form.js";import"../../../../models/ui/validator/form/forgot-password.js";import"../../../../models/ui/validator/form/recover-password.js";import"../../../../models/ui/validator/form/account-info.js";import"../../../../models/ui/validator/form/raffle-form.js";import"../../../../models/ui/validator/form/customer-review.js";import"../../../../models/ui/raffle-list/index.js";import g from"../../components/offer-product/index.js";import{Analytics as x}from"../../../../analytics/analytics.js";import"../../../../analytics/head/index.js";var h=t((function(t){var E,h,k,T,y,N,I=t.vm,L=u().t;e.useEffect((function(){if("undefined"!=typeof localStorage){var e=localStorage.getItem(o);e&&e===I.checkout.id&&(I.successTransaction&&x.purchase(I.checkout,I.successTransaction),localStorage.removeItem(o)),window&&window.handleKlarna(void 0)}}),[]);var A=((null===(E=I.checkout.customer)||void 0===E?void 0:E.firstName)||"")+" "+((null===(h=I.checkout.customer)||void 0===h?void 0:h.lastName)||""),C=((null===(k=I.checkout.shippingAddress)||void 0===k?void 0:k.firstName)||"")+" "+((null===(T=I.checkout.shippingAddress)||void 0===T?void 0:T.lastName)||""),D=I.paymentGateways.find((function(e){var t;return e.id===(null===(t=I.successTransaction)||void 0===t?void 0:t.paymentGatewayId)})),S=null===(y=I.successTransaction)||void 0===y?void 0:y.paymentMethodDetail,R=e.useMemo((function(){var t,a,o,s;return e.createElement("div",{className:[i.InfoGrid].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:paymentMethod")),D&&e.createElement(e.Fragment,null,!!D.logoUrl&&e.createElement("div",{className:i.PaymentLogoContainer},e.createElement("img",{src:D.logoUrl})),!D.logoUrl&&e.createElement("div",{className:i.InfoText},D.paymentMethodType===p.CREDIT_CARD&&D.type===v.INTERNAL?L("checkout-page:creditCard"):D.name),!!D.description&&D.type!==v.EXTERNAL&&e.createElement("div",{className:i.InfoText},e.createElement("div",{dangerouslySetInnerHTML:{__html:D.description}}))),"CREDIT_CARD"===(null===(t=I.successTransaction)||void 0===t?void 0:t.paymentMethod)&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoText},e.createElement("div",{className:i.CardLogoContainer},function(){var t,a;switch(null===(a=null===(t=I.successTransaction)||void 0===t?void 0:t.paymentMethodDetail)||void 0===a?void 0:a.cardAssociation){case f.AMERICAN_EXPRESS:return e.createElement(n,null);case f.MASTER_CARD:return e.createElement(d,null);case f.TROY:return e.createElement(c,null);case f.VISA:return e.createElement(l,null);default:return e.createElement("div",null)}}()),e.createElement("span",null,"**** ".concat((null==S?void 0:S.lastFourDigits)||""))),(null===(a=null==S?void 0:S.installment)||void 0===a?void 0:a.installmentCount)&&S.installment.installmentCount>1&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoText},"".concat(S.installment.installmentCount," ").concat(L("checkout-page:installments"))),null!==S.installment.installmentPrice&&e.createElement("div",{className:i.InfoText},"".concat(S.installment.installmentCount," x ").concat(m(S.installment.installmentPrice,I.checkout.currencyCode,I.checkout.currencySymbol)))))),e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:billingAddress")),!!(null===(o=I.checkout.billingAddress)||void 0===o?void 0:o.company)&&e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},I.checkout.billingAddress.company),e.createElement("div",{className:i.InfoText},null===(s=I.checkout.billingAddress)||void 0===s?void 0:s.addressText)))}),[]),b=e.useMemo((function(){var t,a,o,s,r;return e.createElement("div",{className:[i.InfoGrid].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:contactInfo")),e.createElement("div",{className:i.InfoText},null===(t=I.checkout.customer)||void 0===t?void 0:t.email),e.createElement("div",{className:i.InfoText},A),!!(null===(a=I.checkout.shippingAddress)||void 0===a?void 0:a.phone)&&e.createElement("div",{className:i.InfoText},null===(o=I.checkout.shippingAddress)||void 0===o?void 0:o.phone)),e.createElement("div",null,"in-store"===I.deliveryMethod&&e.createElement(e.Fragment,null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:receiver")),e.createElement("div",{className:[i.InfoText,i.withMBottom].join(" ")},C)),e.createElement("div",{className:i.InfoTitle},"address"===I.deliveryMethod?L("checkout-page:shippingAddress"):L("checkout-page:pickUpLocation")),!!(null===(s=I.checkout.shippingAddress)||void 0===s?void 0:s.company)&&e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},I.checkout.shippingAddress.company),e.createElement("div",{className:i.InfoText},null===(r=I.checkout.shippingAddress)||void 0===r?void 0:r.addressText)))}),[]);return e.createElement("div",{className:i.StepSuccess},e.createElement("div",{className:i.SuccessTitleContainer},e.createElement(s,null),e.createElement("span",{className:i.SuccessTitle},L("checkout-page:orderSuccessTitle"))),e.createElement("div",{className:i.SuccessSubTitle},L("address"===I.deliveryMethod?"checkout-page:orderSuccessDescription":"checkout-page:orderSuccessInStoreDeliveryDescription",{customerName:A})),e.createElement("div",{className:[i.InfoGrid,i.WithBorder].join(" ")},e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:orderNoAndDate")),e.createElement("div",{className:[i.InfoText,i.InfoTextBold].join(" ")},"#"+(I.checkout.orderNumber||"")),e.createElement("div",{className:i.InfoText},I.checkout.dateStr),e.createElement(j,{vm:I})),e.createElement("div",null,e.createElement("div",{className:i.InfoTitle},L("checkout-page:contactInfo")),e.createElement("div",{className:i.InfoText},null===(N=I.checkout.customer)||void 0===N?void 0:N.email),e.createElement("div",{className:i.InfoText},A))),I.postCheckoutCampaignOffer&&e.createElement(g,{vm:I,campaignOffer:I.postCheckoutCampaignOffer}),e.createElement(r,{title:L("checkout-page:paymentSummary")},R),!I.isDigitalOnly&&e.createElement(r,{title:L("checkout-page:shippingSummary")},b),e.createElement("div",{className:i.Actions},e.createElement("div",{className:i.HelpText},e.createElement("span",null,L("checkout-page:helpCtaQuestion")),e.createElement("span",{className:i.Cta,onClick:function(){return I.setContactModalVisible(!0)}},L("checkout-page:helpCta"))),e.createElement(a,{text:L("checkout-page:actions.backToShopping"),onClick:I.onBackToShoppingClick,style:{flex:"0 0 auto"}})))})),j=t((function(t){var a,o=t.vm,s=u().t,r=i.Yellow;switch(o.checkout.orderPackageStatus){case E.FULFILLED:case E.PARTIALLY_FULFILLED:case E.DELIVERED:case E.PARTIALLY_DELIVERED:r=i.Green;break;case E.CANCELLED:case E.PARTIALLY_CANCELLED:case E.CANCEL_REJECTED:case E.CANCEL_REQUESTED:r=i.Red}return e.createElement("div",{className:[i.OrderStatus,r].join(" ")},o.checkout.orderPackageStatus?null===(a=[{types:[E.UNFULFILLED],text:s("checkout-page:orderPackageStatus.unfulfilled")},{types:[E.READY_FOR_SHIPMENT],text:s("checkout-page:orderPackageStatus.readyForShipment")},{types:[E.PARTIALLY_FULFILLED],text:s("checkout-page:orderPackageStatus.partiallyFulfilled")},{types:[E.FULFILLED],text:s("checkout-page:orderPackageStatus.fulfilled")},{types:[E.DELIVERED,E.PARTIALLY_DELIVERED],text:s("checkout-page:orderPackageStatus.delivered")},{types:[E.UNABLE_TO_DELIVER],text:s("checkout-page:orderPackageStatus.unableToDeliver")},{types:[E.CANCELLED,E.PARTIALLY_CANCELLED],text:s("checkout-page:orderPackageStatus.cancelled")},{types:[E.CANCEL_REJECTED],text:s("checkout-page:orderPackageStatus.cancelRejected")},{types:[E.REFUNDED,E.PARTIALLY_REFUNDED],text:s("checkout-page:orderPackageStatus.refunded")},{types:[E.REFUND_REQUEST_ACCEPTED],text:s("checkout-page:orderPackageStatus.refundRequestAccepted")},{types:[E.REFUND_REJECTED],text:s("checkout-page:orderPackageStatus.refundRejected")},{types:[E.REFUND_REQUESTED],text:s("checkout-page:orderPackageStatus.refundRequested")}].find((function(e){return e.types.includes(o.checkout.orderPackageStatus)})))||void 0===a?void 0:a.text:"")}));export{h as StepSuccess};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIResponse } from "@ikas/fe-api-client";
|
|
2
|
-
import { CheckCustomerEmailQueryParams,
|
|
2
|
+
import { CheckCustomerEmailQueryParams, SubscribeToMarketingNotificationsQueryParams, CreateCustomerReviewQueryParams, CreateOrderRefundRequestQueryParams, CustomerForgotPasswordQueryParams, CustomerLoginQueryParams, CustomerRecoverPasswordQueryParams, CustomerRefreshTokenQueryParams, CustomerSocialLoginQueryParams, GetCustomerOrdersQueryParams, GetLastViewedProductsQueryParams, GetOrderByEmailQueryParams, IsFavoriteProductQueryParams, ListCustomerReviewsQueryParams, ListCustomerReviewSummaryQueryParams, ListOrderRefundSettingsQueryParams, ListOrderTransactionsQueryParams, RegisterCustomerQueryParams, SaveFavoriteProductQueryParams, SaveLastViewedProductsQueryParams, SaveMyCustomerQueryParams, SendContactFormToMerchantQueryParams } from "@ikas/storefront-api";
|
|
3
3
|
import { IkasCustomer, IkasCustomerAttribute, IkasCustomerReview, IkasCustomerReviewSummary, IkasFavoriteProduct, IkasLastViewedProduct, IkasOrder, IkasOrderRefundSettings, IkasOrderTransaction } from "../../models/data";
|
|
4
4
|
export default class CustomerStoreAPI {
|
|
5
5
|
static login(params: CustomerLoginQueryParams): Promise<APIResponse<{
|
|
@@ -27,7 +27,7 @@ export default class CustomerStoreAPI {
|
|
|
27
27
|
static getOrderByEmail(params: GetOrderByEmailQueryParams): Promise<APIResponse<IkasOrder | null>>;
|
|
28
28
|
static listOrderTransactions(params: ListOrderTransactionsQueryParams): Promise<APIResponse<IkasOrderTransaction[]>>;
|
|
29
29
|
static createOrderRefundRequest(params: CreateOrderRefundRequestQueryParams): Promise<APIResponse<IkasOrder | null>>;
|
|
30
|
-
static
|
|
30
|
+
static subscribeToMarketingNotifications(params: SubscribeToMarketingNotificationsQueryParams): Promise<APIResponse<undefined> | APIResponse<boolean>>;
|
|
31
31
|
static getLastViewedProducts(params: GetLastViewedProductsQueryParams): Promise<APIResponse<IkasLastViewedProduct[]>>;
|
|
32
32
|
static saveLastViewedProducts(params: SaveLastViewedProductsQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/build/__api/types").ProductLastViewed>>;
|
|
33
33
|
static listOrderRefundSettings(params: ListOrderRefundSettingsQueryParams): Promise<APIResponse<IkasOrderRefundSettings[]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as n}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{login as i,socialLogin as o,register as a,refreshToken as s,forgotPassword as d,recoverPassword as u,checkEmail as c,getCustomer as l,saveCustomer as m,getOrders as f,getOrderByEmail as p,listOrderTransactions as v,createOrderRefundRequest as h,
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as n}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{login as i,socialLogin as o,register as a,refreshToken as s,forgotPassword as d,recoverPassword as u,checkEmail as c,getCustomer as l,saveCustomer as m,getOrders as f,getOrderByEmail as p,listOrderTransactions as v,createOrderRefundRequest as h,subscribeToMarketingNotifications as w,getLastViewedProducts as j,saveLastViewedProducts as x,listOrderRefundSettings as b,sendContactFormToMerchant as g,listFavoriteProducts as L,saveFavoriteProduct as E,isFavoriteProduct as Q,createCustomerReview as y,listCustomerReviews as k,listCustomerReviewSummary as _,listCustomerAttribute as P}from"@ikas/storefront-api";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"mobx";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import{IkasCustomerAttribute as C}from"../../models/data/customer/attribute/index.js";import{IkasCustomerReviewSummary as R}from"../../models/data/customer/review/summary/index.js";import{IkasCustomerReview as T}from"../../models/data/customer/review/index.js";import{IkasCustomer as O}from"../../models/data/customer/index.js";import"../../models/data/district/index.js";import{IkasFavoriteProduct as F}from"../../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{IkasLastViewedProduct as I}from"../../models/data/last-viewed-product/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import{IkasOrderRefundSettings as S}from"../../models/data/order/refund/settings/index.js";import{IkasOrderTransaction as A}from"../../models/data/order/transaction/index.js";import{IkasOrder as M}from"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";var V=function(){function V(){}return V.login=function(o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,i(o)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{customer:t.data.customer?new O(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},V.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,o(i)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{customer:t.data.customer?new O(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},V.register=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a(i)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{customer:t.data.customer?new O(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},V.refreshToken=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s(r)];case 1:return[2,t.sent()]}}))}))},V.forgotPassword=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,d(r)];case 1:return[2,t.sent()]}}))}))},V.recoverPassword=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u(r)];case 1:return[2,t.sent()]}}))}))},V.checkEmail=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,c(r)];case 1:return[2,t.sent()]}}))}))},V.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,l()];case 1:return t=e.sent(),[2,new n(t.data?new O(t.data):null,t.graphQLErrors)]}}))}))},V.saveCustomer=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,m(r)];case 1:return t=e.sent(),[2,new n(t.data?new O(t.data):null,t.graphQLErrors)]}}))}))},V.getOrders=function(r){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,f(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new M(t)})),t.graphQLErrors)]}}))}))},V.getOrderByEmail=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p(r)];case 1:return t=e.sent(),[2,new n(t.data?new M(t.data):null,t.graphQLErrors)]}}))}))},V.listOrderTransactions=function(r){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,v(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new A(t)})),t.graphQLErrors)]}}))}))},V.createOrderRefundRequest=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,h(r)];case 1:return t=e.sent(),[2,new n(t.data?new M(t.data):null,t.graphQLErrors)]}}))}))},V.subscribeToMarketingNotifications=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,w(r)];case 1:return[2,t.sent()]}}))}))},V.getLastViewedProducts=function(r){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,j(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new I(t)})),t.graphQLErrors)]}}))}))},V.saveLastViewedProducts=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,x(r)];case 1:return[2,t.sent()]}}))}))},V.listOrderRefundSettings=function(r){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,b(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new S(t)})),t.graphQLErrors)]}}))}))},V.sendContactFormToMerchant=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,g(r)];case 1:return[2,t.sent()]}}))}))},V.listFavoriteProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,L()];case 1:return t=e.sent(),[2,new n(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new F(t)})),t.graphQLErrors)]}}))}))},V.saveFavoriteProduct=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,E(r)];case 1:return[2,t.sent()]}}))}))},V.isFavoriteProduct=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,Q({productId:r.productId})];case 1:return[2,t.sent()]}}))}))},V.createCustomerReview=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,y(r)];case 1:return t=e.sent(),[2,new n(t.data?new T(t.data):null,t.graphQLErrors)]}}))}))},V.listCustomerReviews=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,k(i)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{data:t.data.data.map((function(t){return new T(t)}))}):null,t.graphQLErrors)]}}))}))},V.listCustomerReviewSummary=function(i){var o;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,_(i)];case 1:return t=e.sent(),[2,new n(r(r({},t.data),{data:null===(o=t.data)||void 0===o?void 0:o.data.map((function(t){return new R(t)}))}),t.graphQLErrors)]}}))}))},V.listCustomerAttribute=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,P()];case 1:return t=e.sent(),[2,new n(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new C(t)}),t.graphQLErrors))]}}))}))},V}();export{V as default};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IkasContactForm, IkasCustomer, IkasCustomerAttributeValue, IkasFavoriteProduct, IkasOrderTransaction, IkasProduct, IkasOrder } from "../../models/data";
|
|
2
2
|
import { IkasBaseStore } from "../base";
|
|
3
|
-
import { IkasRaffle } from "@ikas/storefront-models";
|
|
4
3
|
export declare class IkasCustomerStore {
|
|
5
4
|
customer?: IkasCustomer | null;
|
|
6
5
|
token?: string | null;
|
|
@@ -48,7 +47,7 @@ export declare class IkasCustomerStore {
|
|
|
48
47
|
waitUntilCaptchaTokenInitialized: () => Promise<unknown>;
|
|
49
48
|
setCaptchaToken: (token: string) => void;
|
|
50
49
|
getCaptcha(): Promise<void>;
|
|
51
|
-
getRaffles: () => Promise<
|
|
50
|
+
getRaffles: () => Promise<import("@ikas/fe-api-client").APIResponse<import("../../models/data").IkasRaffleParticipant[]>>;
|
|
52
51
|
getCustomerAttributes: () => Promise<import("../../models/data").IkasCustomerAttribute[]>;
|
|
53
52
|
getOrderByEmail: (email: string, orderNumber: string) => Promise<IkasOrder | null>;
|
|
54
53
|
private init;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import o from"lodash/uniqBy";import s from"./api.js";import{IkasCustomer as n}from"../../models/data/customer/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as a}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import c from"../raffle/index.js";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import u from"../product/index.js";import{Analytics as d}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{SaveMyCustomerInput as h}from"@ikas/storefront-api";import{populateRaffleProducts as m}from"@ikas/storefront-providers";var p="undefined"==typeof localStorage,f=function(){function f(o){var n=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this.toAnalyticsCustomer=function(t){return i(i({},t),{consentGranted:n._customerConsentGranted})},this.login=function(i,r){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.login({email:i,password:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&d.customerLogin(),(n=null===(a=this.baseStore)||void 0===a?void 0:a.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(n.orderLineItems[0],n.orderLineItems[0].quantity)]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,!0];case 5:return[2,!1]}}))}))},this.logout=function(){var t;n.clearLocalData(),null===(t=n.baseStore)||void 0===t||t.cartStore.removeCart(),d.customerLogout()},this.register=function(i,r,o,a,c,u){return t(n,void 0,void 0,(function(){var t,n;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.register({email:o,password:a,firstName:i,lastName:r,isAcceptMarketing:c,attributes:u,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(n=t.data)||void 0===n?void 0:n.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),d.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return d.contactForm(r),[4,this.getCaptcha()];case 1:return e.sent(),[4,s.sendContactFormToMerchant(i(i({},r),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.checkEmail({email:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.forgotPassword=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.forgotPassword({email:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.recoverPassword=function(i,r,o){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.recoverPassword({password:i,passwordAgain:r,token:o,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.saveCustomer({input:new h(i)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(i){return t(n,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.getOrders({orderId:i})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?(r=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),r.refundSettings=this._refundSettings,[2,r]}}))}))},this.getOrderTransactions=function(i){return void 0===i&&(i={}),t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listOrderTransactions({checkoutId:{eq:i.checkoutId},id:{eq:i.checkoutId},orderId:{eq:i.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProductsIds=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listFavoriteProducts()];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(n,void 0,void 0,(function(){var t,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.listFavoriteProducts()];case 1:return(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)?[4,u.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:l.getPriceListId(),salesChannelId:l.getSalesChannelId()}})]:[2,[]];case 2:return i=e.sent(),[2,(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.data)||[]]}}))}))},this.addProductToFavorites=function(i){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!0,productId:i})];case 1:return t=e.sent(),d.addToWishlist(i),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(i){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!1,productId:i})];case 1:return t=e.sent(),d.addToWishlist(i),[2,t.data||!1]}}))}))},this.isProductFavorite=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,s.isFavoriteProduct({productId:i})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.createCustomerEmailSubscription({input:{email:i,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,a.SUBSCRIBED):this._visitorSubscribedEmail=!0,d.createEmailSubscripition(i)),[2,t.isSuccess]}}))}))},this.sendReview=function(r){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:if(t=l.getCustomerReviewSettings(),o=l.getSalesChannelId(),!t)return[2];if(!(n=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,s.createCustomerReview({input:i(i({},r),{customerId:t.customerLoginRequired?n:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},this.onCustomerConsentGrant=function(){n.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.setCaptchaToken=function(t){n._captchaToken=t},this.getRaffles=function(){return t(n,void 0,void 0,(function(){var t,i,r;return e(this,(function(e){switch(e.label){case 0:return[4,c.listRaffleParticipants()];case 1:return t=e.sent(),i=[],(null===(r=t.data)||void 0===r?void 0:r.length)?(i=t.data).length?[4,m(i)]:[3,3]:[2,i];case 2:e.sent(),e.label=3;case 3:return[2,i||[]]}}))}))},this.getCustomerAttributes=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,s.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(i=this.customer.attributes)||void 0===i||i.forEach((function(e){var i,r,o;e.customerAttribute=(null===(i=t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(r=e.customerAttribute)||void 0===r?void 0:r.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderByEmail=function(i,r){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrderByEmail({email:i,orderNumber:r})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderRefundSettings=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,s.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.baseStore=o,r(this)}return Object.defineProperty(f.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||p||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"isCaptchaRequired",{get:function(){var t;return null===(t=l.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation},enumerable:!1,configurable:!0}),f.prototype.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",r="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(i,"/login/authenticate?redirect=").concat(t),[4,fetch(r,{headers:{"x-api-key":l.getApiKey()||"","x-sfid":l.getStorefrontId()||"","x-sfrid":l.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),window.location.href=o.redirectUrl,[2]}}))}))},f.prototype.socialLoginToken=function(i){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.socialLogin({code:i})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(r=t.data)||void 0===r?void 0:r.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer&&d.customerLogin(),[2,!0]):[2,!1]}}))}))},f.prototype.refundOrder=function(i){return t(this,void 0,void 0,(function(){var t,r,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],i.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,s.createOrderRefundRequest({input:{orderId:i.id,orderLineItems:t}})];case 1:return(r=e.sent()).isSuccess&&r.data?(Object.entries(r.data).forEach((function(t){var e=t[0],i=t[1];o[e]=i})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},f.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]}}))}))},f.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&&d.customerVisit(),[2]}}))}))},f.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},f.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return p||!this.token?[2]:[4,s.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},f.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,s.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},f.prototype.setCustomer=function(t){this.customer=new n(t)},f.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,s.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=t.data||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},f.prototype.saveLastViewedProducts=function(){p||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},f.prototype.loadLastViewedProducts=function(){if(!p)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"))}catch(t){}},f.prototype.removeLastViewedProducts=function(){p||window.localStorage.removeItem("lastViewedProducts")},f.prototype.onProductView=function(i,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===i}))?[2]:[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:i,variantId:r}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:i,variantId:r}),[3,3];case 2:this._lastViewedProducts.push({productId:i,variantId:r}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},f.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(p)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:this._lastViewedProducts}})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},f.prototype.saveCustomerConsent=function(){p||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},f.prototype.loadCustomerConsent=function(){p||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},f.prototype.removeCustomerConsent=function(){p||window.localStorage.removeItem("customerConsent")},f.prototype.setToken=function(t,e){p||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),l.init({customerToken:t}))},f.prototype.loadToken=function(){if(!p){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},f.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},f.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,l.init({customerToken:""}),this.clearCaptchaToken()},f.prototype.clearCaptchaToken=function(){this._captchaToken=null},f}();export{f as IkasCustomerStore};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import o from"lodash/uniqBy";import s from"./api.js";import{IkasCustomer as n}from"../../models/data/customer/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as a}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import c from"../raffle/index.js";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import u from"../product/index.js";import{Analytics as d}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{SaveMyCustomerInput as h}from"@ikas/storefront-api";import{populateRaffleProducts as m}from"@ikas/storefront-providers";var p="undefined"==typeof localStorage,f=function(){function f(o){var n=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:n._customerConsentGranted})},this.login=function(r,i){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.login({email:r,password:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&d.customerLogin(),(n=null===(a=this.baseStore)||void 0===a?void 0:a.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(n.orderLineItems[0],n.orderLineItems[0].quantity)]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,!0];case 5:return[2,!1]}}))}))},this.logout=function(){var t;n.clearLocalData(),null===(t=n.baseStore)||void 0===t||t.cartStore.removeCart(),d.customerLogout()},this.register=function(r,i,o,a,c,u){return t(n,void 0,void 0,(function(){var t,n;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.register({email:o,password:a,firstName:r,lastName:i,isAcceptMarketing:c,attributes:u,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(n=t.data)||void 0===n?void 0:n.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),d.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return d.contactForm(i),[4,this.getCaptcha()];case 1:return e.sent(),[4,s.sendContactFormToMerchant(r(r({},i),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.forgotPassword=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.recoverPassword=function(r,i,o){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.recoverPassword({password:r,passwordAgain:i,token:o,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.saveCustomer({input:new h(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(n,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?(i=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listOrderTransactions({checkoutId:{eq:r.checkoutId},id:{eq:r.checkoutId},orderId:{eq:r.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProductsIds=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listFavoriteProducts()];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(n,void 0,void 0,(function(){var t,r,i,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.listFavoriteProducts()];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?[4,u.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:l.getPriceListId(),salesChannelId:l.getSalesChannelId()}})]:[2,[]];case 2:return r=e.sent(),[2,(null===(o=null==r?void 0:r.data)||void 0===o?void 0:o.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),d.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),d.addToWishlist(r),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,s.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,a.SUBSCRIBED):this._visitorSubscribedEmail=!0,d.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.sendReview=function(i){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:if(t=l.getCustomerReviewSettings(),o=l.getSalesChannelId(),!t)return[2];if(!(n=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,s.createCustomerReview({input:r(r({},i),{customerId:t.customerLoginRequired?n:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},this.onCustomerConsentGrant=function(){n.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.setCaptchaToken=function(t){n._captchaToken=t},this.getRaffles=function(){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,c.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,m(t.data.filter((function(t){return!!t.raffle})).map((function(t){return t.raffle})))]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,t]}}))}))},this.getCustomerAttributes=function(){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,s.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,i,o;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===(o=null===(i=e.customerAttribute)||void 0===i?void 0:i.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderByEmail=function(r,i){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrderByEmail({email:r,orderNumber:i})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderRefundSettings=function(){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,s.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.baseStore=o,i(this)}return Object.defineProperty(f.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||p||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"isCaptchaRequired",{get:function(){var t;return null===(t=l.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation},enumerable:!1,configurable:!0}),f.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",i="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(i,{headers:{"x-api-key":l.getApiKey()||"","x-sfid":l.getStorefrontId()||"","x-sfrid":l.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),window.location.href=o.redirectUrl,[2]}}))}))},f.prototype.socialLoginToken=function(r){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.socialLogin({code:r})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(i=t.data)||void 0===i?void 0:i.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer&&d.customerLogin(),[2,!0]):[2,!1]}}))}))},f.prototype.refundOrder=function(r){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,s.createOrderRefundRequest({input:{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]}}))}))},f.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]}}))}))},f.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&&d.customerVisit(),[2]}}))}))},f.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},f.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return p||!this.token?[2]:[4,s.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},f.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,s.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},f.prototype.setCustomer=function(t){this.customer=new n(t)},f.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,s.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=t.data||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},f.prototype.saveLastViewedProducts=function(){p||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},f.prototype.loadLastViewedProducts=function(){if(!p)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"))}catch(t){}},f.prototype.removeLastViewedProducts=function(){p||window.localStorage.removeItem("lastViewedProducts")},f.prototype.onProductView=function(r,i){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,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:r,variantId:i}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:i}),[3,3];case 2:this._lastViewedProducts.push({productId:r,variantId:i}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},f.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(p)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:this._lastViewedProducts}})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},f.prototype.saveCustomerConsent=function(){p||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},f.prototype.loadCustomerConsent=function(){p||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},f.prototype.removeCustomerConsent=function(){p||window.localStorage.removeItem("customerConsent")},f.prototype.setToken=function(t,e){p||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),l.init({customerToken:t}))},f.prototype.loadToken=function(){if(!p){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},f.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},f.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,l.init({customerToken:""}),this.clearCaptchaToken()},f.prototype.clearCaptchaToken=function(){this._captchaToken=null},f}();export{f as IkasCustomerStore};
|
|
@@ -11,5 +11,5 @@ export default class RaffleStore {
|
|
|
11
11
|
}>>;
|
|
12
12
|
static saveRaffleParticipant(params: SaveRaffleParticipantQueryParams): Promise<APIResponse<IkasRaffleParticipant | null>>;
|
|
13
13
|
static listRaffleMetaData(params: ListRaffleMetadataQueryParams): Promise<APIResponse<IkasRaffleMetaData[]>>;
|
|
14
|
-
static listRaffleParticipants(): Promise<APIResponse<
|
|
14
|
+
static listRaffleParticipants(): Promise<APIResponse<IkasRaffleParticipant[]>>;
|
|
15
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as n}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{listStorefrontRaffle as r,saveRaffleParticipant as a,listRaffleMetaData as o,listRaffleParticipants as s}from"@ikas/storefront-api";import{IkasRaffle as u,IkasRaffleParticipant as d,IkasRaffleMetaData as l}from"../../models/data/raffle/index.js";var f=function(){function f(){}return f.listStorefrontRaffle=function(a){var o,s;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,r(a)];case 1:return t=e.sent(),[2,new n(i(i({},t.data),{data:null===(s=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map((function(t){return new u(t)}))}))]}}))}))},f.saveRaffleParticipant=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a(i)];case 1:return t=e.sent(),[2,new n(t.data?new d(t.data):null,t.graphQLErrors)]}}))}))},f.listRaffleMetaData=function(i){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,o(i)];case 1:return t=e.sent(),[2,new n(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new l(t)})),t.graphQLErrors)]}}))}))},f.listRaffleParticipants=function(){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s()];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as n}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{listStorefrontRaffle as r,saveRaffleParticipant as a,listRaffleMetaData as o,listRaffleParticipants as s}from"@ikas/storefront-api";import{IkasRaffle as u,IkasRaffleParticipant as d,IkasRaffleMetaData as l}from"../../models/data/raffle/index.js";var f=function(){function f(){}return f.listStorefrontRaffle=function(a){var o,s;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,r(a)];case 1:return t=e.sent(),[2,new n(i(i({},t.data),{data:null===(s=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map((function(t){return new u(t)}))}))]}}))}))},f.saveRaffleParticipant=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a(i)];case 1:return t=e.sent(),[2,new n(t.data?new d(t.data):null,t.graphQLErrors)]}}))}))},f.listRaffleMetaData=function(i){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,o(i)];case 1:return t=e.sent(),[2,new n(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new l(t)})),t.graphQLErrors)]}}))}))},f.listRaffleParticipants=function(){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s()];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new d(t)})),t.graphQLErrors)]}}))}))},f}();export{f as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.76",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "Umut Ozan Yıldırım",
|
|
6
6
|
"license": "ISC",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"libphonenumber-js": "^1.10.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ikas/storefront-api": "^4.0.0-alpha.
|
|
27
|
-
"@ikas/storefront-config": "^4.0.0-alpha.
|
|
28
|
-
"@ikas/storefront-model-functions": "^4.0.0-alpha.
|
|
29
|
-
"@ikas/storefront-models": "^4.0.0-alpha.
|
|
30
|
-
"@ikas/storefront-providers": "^4.0.0-alpha.
|
|
26
|
+
"@ikas/storefront-api": "^4.0.0-alpha.76",
|
|
27
|
+
"@ikas/storefront-config": "^4.0.0-alpha.76",
|
|
28
|
+
"@ikas/storefront-model-functions": "^4.0.0-alpha.76",
|
|
29
|
+
"@ikas/storefront-models": "^4.0.0-alpha.76",
|
|
30
|
+
"@ikas/storefront-providers": "^4.0.0-alpha.76",
|
|
31
31
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
32
32
|
"@rollup/plugin-json": "^4.1.0",
|
|
33
33
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"query-string": "^6.13.8"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@ikas/storefront-api": "^4.0.0-alpha.
|
|
57
|
-
"@ikas/storefront-config": "^4.0.0-alpha.
|
|
58
|
-
"@ikas/storefront-model-functions": "^4.0.0-alpha.
|
|
59
|
-
"@ikas/storefront-models": "^4.0.0-alpha.
|
|
60
|
-
"@ikas/storefront-providers": "^4.0.0-alpha.
|
|
56
|
+
"@ikas/storefront-api": "^4.0.0-alpha.76",
|
|
57
|
+
"@ikas/storefront-config": "^4.0.0-alpha.76",
|
|
58
|
+
"@ikas/storefront-model-functions": "^4.0.0-alpha.76",
|
|
59
|
+
"@ikas/storefront-models": "^4.0.0-alpha.76",
|
|
60
|
+
"@ikas/storefront-providers": "^4.0.0-alpha.76",
|
|
61
61
|
"mobx": "^6.1.3",
|
|
62
62
|
"mobx-react-lite": "^3.1.5",
|
|
63
63
|
"next": "12.2.0",
|