@ikas/storefront 6.1.0-beta.232 → 6.1.0-beta.233
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{__awaiter as t,__generator as e}from'./../../../ext/tslib/tslib.es6.js';import*as n from"react";import{getStorefrontWidgetSettings as r,listEarningMethods as i,listLoyaltyProgramTiers as o,listSpendingMethodsByCartId as a,getLoyaltyCustomerInfo as s,listLoyaltyProgramPointHistory as c,useLoyaltyPoints as u,removeLoyaltyPointsFromCart as d}from"@ikas/storefront-api";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{IkasBaseStore as f}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import v from"../../../store/product/index.js";import g from"../../../store/category/index.js";import y from"../../../store/brand/index.js";import{resolveStoreUrl as h}from"./common.js";import{formatCurrency as m}from"../../../utils/currency.js";import"lodash/get";function p(n){var h,p=this,w=f.getInstance(),b=function(){var t;return null===(t=w.cartStore.cart)||void 0===t?void 0:t.id},
|
|
1
|
+
import{__awaiter as t,__generator as e}from'./../../../ext/tslib/tslib.es6.js';import*as n from"react";import{getStorefrontWidgetSettings as r,listEarningMethods as i,listLoyaltyProgramTiers as o,listSpendingMethodsByCartId as a,getLoyaltyCustomerInfo as s,listLoyaltyProgramPointHistory as c,useLoyaltyPoints as u,removeLoyaltyPointsFromCart as d}from"@ikas/storefront-api";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{IkasBaseStore as f}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import v from"../../../store/product/index.js";import g from"../../../store/category/index.js";import y from"../../../store/brand/index.js";import{resolveStoreUrl as h}from"./common.js";import{formatCurrency as m}from"../../../utils/currency.js";import"lodash/get";function p(n){var h,p=this,w=f.getInstance(),b=function(){var t;return null===(t=w.cartStore.cart)||void 0===t?void 0:t.id},S=function(t){var e,n=null!==(e=null==t?void 0:t.themeSettingsJson)&&void 0!==e?e:t;if(!n)throw new Error("Loyalty widget settings not found");if("string"==typeof n)try{return JSON.parse(n)}catch(t){throw new Error("Loyalty widget settings format is invalid")}return n};return{getLoyaltyWidget:function(){return t(p,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return n?[2,S(n)]:[4,r()];case 1:if((t=e.sent()).isSuccess&&t.data)return[2,S(t.data)];throw new Error("Loyalty widget settings not found")}}))}))},subscribeToMarketingNotifications:function(){return t(p,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,f.getInstance().customerStore.createEmailSubscription((null===(t=f.getInstance().customerStore.customer)||void 0===t?void 0:t.email)||"")];case 1:return[2,e.sent()]}}))}))},listEarningMethods:function(){return t(p,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,i()];case 1:return[2,t.sent().data||[]]}}))}))},listLoyaltyProgramTier:function(n){return t(p,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,o()];case 1:return[2,t.sent().data||[]]}}))}))},listSpendingMethodsByCartId:function(n){return t(p,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a({cartId:n||b()})];case 1:return[2,t.sent().data||[]]}}))}))},getLoyaltyCustomerInfo:function(){return t(p,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s({cartId:b()||null})];case 1:return[2,t.sent().data||null]}}))}))},listLoyaltyProgramPointHistory:function(n){return t(p,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return t={},(r=null==n?void 0:n.type)&&(t.type=Array.isArray(r)?{in:r}:{eq:r}),[4,c(t)];case 1:return[2,e.sent().data||[]]}}))}))},useLoyaltyPoints:function(n){return t(p,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u({input:n})];case 1:return(t=e.sent()).isSuccess?(h=n.loyaltySpendingMethodId,[4,w.cartStore.getCart()]):[3,3];case 2:e.sent(),e.label=3;case 3:return[2,!!t.isSuccess]}}))}))},removeLoyaltyPointsFromCart:function(){return t(p,void 0,void 0,(function(){var t,n,r,i,o;return e(this,(function(e){switch(e.label){case 0:return t=b(),n=h||(null===(o=null===(i=null===(r=w.cartStore.cart)||void 0===r?void 0:r.loyaltyLines)||void 0===i?void 0:i[0])||void 0===o?void 0:o.loyaltySpendingMethodId),t&&n?[4,d({cartId:t,loyaltySpendingMethodId:n})]:[2];case 1:return e.sent().isSuccess?[4,w.cartStore.getCart()]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},getProducts:function(n){return t(p,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return(null==n?void 0:n.length)?[4,v.searchProducts({input:{productIdList:n,page:1,perPage:n.length,priceListId:l.getPriceListId(),salesChannelId:l.getSalesChannelId()}},[])]:[2,[]];case 1:return t=e.sent(),[2,(null===(r=t.data)||void 0===r?void 0:r.data)||[]]}}))}))},getCategories:function(n){return t(p,void 0,void 0,(function(){var t,r,i;return e(this,(function(e){switch(e.label){case 0:return(null==n?void 0:n.length)?(t={id:{in:n},pagination:{limit:n.length,page:1}},[4,g.listCategory(t)]):[2,[]];case 1:return r=e.sent(),[2,(null===(i=r.data)||void 0===i?void 0:i.data)||[]]}}))}))},getBrands:function(n){return t(p,void 0,void 0,(function(){var t,r,i;return e(this,(function(e){switch(e.label){case 0:return(null==n?void 0:n.length)?(t={id:{in:n},pagination:{limit:n.length,page:1}},[4,y.listProductBrand(t)]):[2,[]];case 1:return r=e.sent(),[2,(null===(i=r.data)||void 0===i?void 0:i.data)||[]]}}))}))},getTags:function(n){return t(p,void 0,void 0,(function(){return e(this,(function(t){return[2,[]]}))}))},formatCurrency:function(t){return m(t,l.getDefaultCurrencyCode()||"TRY",l.getDefaultCurrencySymbol()||"TRY")}}}var w=function(){n.useEffect((function(){if("undefined"!=typeof window&&"undefined"!=typeof document){var n=!1,i=function(t){if("function"==typeof window.startIkasLoyaltyWidget)try{window.startIkasLoyaltyWidget(t)}catch(t){console.error("[@ikas/storefront] Failed to start loyalty widget",t)}},o=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:3000/storefront-widget-script-injector.iife.js":"/sf/assets/popup/storefront-widget-script-injector.iife.js";if(e){var r=document.querySelector('script[data-ikas-loyalty-widget="true"]');if(r)"true"===r.dataset.loaded?i(t):r.addEventListener("load",(function(){return i(t)}),{once:!0});else{var o=document.createElement("script");o.src=e,o.defer=!0,o.setAttribute("data-ikas-loyalty-widget","true"),o.addEventListener("load",(function(){o.dataset.loaded="true",n||i(t)}),{once:!0}),o.addEventListener("error",(function(t){console.error("[@ikas/storefront] Failed to load loyalty widget script",e,t)}),{once:!0}),document.body.appendChild(o)}}};return t(void 0,void 0,void 0,(function(){var n,i,a;return e(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),l.getLoyaltyPrograms().length?[4,r()]:[2];case 1:return(null==(n=s.sent())?void 0:n.isSuccess)&&n.data?[4,(c=n.data,t(void 0,void 0,void 0,(function(){var t,n,r,i;return e(this,(function(e){switch(e.label){case 0:return t={cdnURL:l.getCdnUrl()||"",merchantId:(null===(r=l.getMerchantSettings())||void 0===r?void 0:r.merchantId)||"",currency:l.getDefaultCurrencySymbol()||"TRY",callbacks:p(c),position:"fixed",storeURL:h()},[4,new Promise((function(t){var e=setInterval((function(){var n=l.getSessionId();n&&(clearInterval(e),t(n))}),100)}))];case 1:return e.sent(),(n=null===(i=f.getInstance().cartStore.cart)||void 0===i?void 0:i.id)&&(t.cartId=n),c&&(t.widgetSettings=c),[2,t]}}))})))]:[2];case 2:return i=s.sent(),window.ikasLoyaltyWidgetConfig=i,o(i),[3,4];case 3:return a=s.sent(),console.error("[@ikas/storefront] Failed to initialize loyalty widget",a),[3,4];case 4:return[2]}var c}))})),function(){n=!0}}}),[])};export{w as useLoyaltyWidget};
|
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.233",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"build": "rm -rf build && rollup -c"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ikas/loyalty-widget-renderer": "1.0.0-alpha.
|
|
20
|
+
"@ikas/loyalty-widget-renderer": "1.0.0-alpha.74",
|
|
21
21
|
"@ikas/popup-renderer": "1.0.227",
|
|
22
22
|
"@ikas/popup-script-injector": "1.0.0-alpha.21",
|
|
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.233",
|
|
27
|
+
"@ikas/storefront-config": "^6.1.0-beta.233",
|
|
28
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.233",
|
|
29
|
+
"@ikas/storefront-models": "^6.1.0-beta.233",
|
|
30
|
+
"@ikas/storefront-providers": "^6.1.0-beta.233",
|
|
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.233",
|
|
66
|
+
"@ikas/storefront-config": "^6.1.0-beta.233",
|
|
67
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.233",
|
|
68
|
+
"@ikas/storefront-models": "^6.1.0-beta.233",
|
|
69
|
+
"@ikas/storefront-providers": "^6.1.0-beta.233",
|
|
70
70
|
"mobx": "^6.1.3",
|
|
71
71
|
"mobx-react-lite": "^3.1.5",
|
|
72
72
|
"next": "12.2.0",
|