@ikas/storefront 0.0.102 → 0.0.104

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.
Files changed (53) hide show
  1. package/build/__generated__/global-types.d.ts +22 -1
  2. package/build/api/cart/__generated__/getCart.d.ts +4 -0
  3. package/build/api/cart/__generated__/saveItemToCart.d.ts +4 -0
  4. package/build/api/checkout/__generated__/checkStocks.d.ts +3 -3
  5. package/build/api/checkout/index.d.ts +1 -1
  6. package/build/api/country/__generated__/getAvailableShippingCountries.d.ts +3 -0
  7. package/build/api/country/__generated__/getMyCountry.d.ts +3 -0
  8. package/build/api/country/__generated__/listCountry.d.ts +2 -0
  9. package/build/api/country/index.d.ts +2 -1
  10. package/build/api/index.d.ts +0 -2
  11. package/build/api/storefront/__generated__/getStorefront.d.ts +39 -10
  12. package/build/api/storefront/index.d.ts +1 -1
  13. package/build/components/checkout/index.d.ts +3 -0
  14. package/build/components/checkout/model.d.ts +4 -3
  15. package/build/index.es.js +727 -429
  16. package/build/index.js +729 -432
  17. package/build/models/data/cart/index.d.ts +9 -0
  18. package/build/models/data/country/index.d.ts +2 -0
  19. package/build/models/data/sales-channel/index.d.ts +12 -0
  20. package/build/models/data/storefront/{storefront-domain → domain}/index.d.ts +1 -0
  21. package/build/models/data/storefront/index.d.ts +17 -6
  22. package/build/models/data/storefront/localization/index.d.ts +7 -0
  23. package/build/models/data/storefront/routing/index.d.ts +9 -0
  24. package/build/models/data/storefront/theme/index.d.ts +13 -0
  25. package/build/models/data/storefront/theme-localization/index.d.ts +12 -0
  26. package/build/models/ui/product-list/index.d.ts +1 -1
  27. package/build/pages/404.d.ts +1 -0
  28. package/build/pages/[slug]/index.d.ts +1 -0
  29. package/build/pages/account/addresses.d.ts +1 -0
  30. package/build/pages/account/favorite-products.d.ts +1 -0
  31. package/build/pages/account/forgot-password.d.ts +1 -0
  32. package/build/pages/account/index.d.ts +1 -0
  33. package/build/pages/account/login.d.ts +1 -0
  34. package/build/pages/account/orders/[id].d.ts +1 -0
  35. package/build/pages/account/orders/index.d.ts +1 -0
  36. package/build/pages/account/recover-password.d.ts +1 -0
  37. package/build/pages/account/register.d.ts +1 -0
  38. package/build/pages/cart.d.ts +1 -0
  39. package/build/pages/checkout/[id].d.ts +4 -0
  40. package/build/pages/home.d.ts +1 -0
  41. package/build/pages/pages/[slug].d.ts +1 -0
  42. package/build/pages/search.d.ts +1 -0
  43. package/build/store/base.d.ts +13 -0
  44. package/build/storefront/index.d.ts +18 -0
  45. package/build/utils/providers/page-data.d.ts +10 -0
  46. package/build/utils/settings.d.ts +142 -0
  47. package/package.json +1 -1
  48. package/build/api/product-stock-location/__generated__/listProductStockLocation.d.ts +0 -13
  49. package/build/api/product-stock-location/index.d.ts +0 -4
  50. package/build/api/theme/index.d.ts +0 -4
  51. package/build/models/data/storefront/stockfront-location/index.d.ts +0 -5
  52. package/build/models/data/storefront/stockfront-route/index.d.ts +0 -5
  53. package/build/models/data/storefront/storefront-region/index.d.ts +0 -18
package/build/index.js CHANGED
@@ -3,25 +3,27 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var mobx = require('mobx');
6
- var fs = require('fs');
7
- var getConfig = require('next/config');
8
6
  var React = require('react');
7
+ var getConfig = require('next/config');
9
8
  var mobxReactLite = require('mobx-react-lite');
10
9
  var router = require('next/router');
11
10
  var Image$1 = require('next/image');
12
11
  var Link = require('next/link');
13
12
  var Head = require('next/head');
13
+ var fs = require('fs');
14
14
  var dynamic = require('next/dynamic');
15
+ var Error$1 = require('next/error');
15
16
 
16
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
18
 
18
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
19
- var getConfig__default = /*#__PURE__*/_interopDefaultLegacy(getConfig);
20
19
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
20
+ var getConfig__default = /*#__PURE__*/_interopDefaultLegacy(getConfig);
21
21
  var Image__default = /*#__PURE__*/_interopDefaultLegacy(Image$1);
22
22
  var Link__default = /*#__PURE__*/_interopDefaultLegacy(Link);
23
23
  var Head__default = /*#__PURE__*/_interopDefaultLegacy(Head);
24
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
24
25
  var dynamic__default = /*#__PURE__*/_interopDefaultLegacy(dynamic);
26
+ var Error__default = /*#__PURE__*/_interopDefaultLegacy(Error$1);
25
27
 
26
28
  /*! *****************************************************************************
27
29
  Copyright (c) Microsoft Corporation.
@@ -10885,10 +10887,37 @@ var IkasStorefrontConfig = /** @class */ (function () {
10885
10887
  IkasStorefrontConfig.components = components;
10886
10888
  IkasStorefrontConfig.config = config;
10887
10889
  IkasStorefrontConfig.apiUrlOverride = apiUrlOverride || null;
10890
+ if (process.env.NEXT_PUBLIC_ENV === "local") {
10891
+ this.storefrontId = config.storefrontId;
10892
+ }
10893
+ };
10894
+ IkasStorefrontConfig.initWithJson = function (json) {
10895
+ try {
10896
+ Object.entries(json).forEach(function (_a) {
10897
+ var key = _a[0], value = _a[1];
10898
+ //@ts-ignore
10899
+ IkasStorefrontConfig[key] = value;
10900
+ });
10901
+ }
10902
+ catch (err) {
10903
+ console.log(err);
10904
+ }
10905
+ };
10906
+ IkasStorefrontConfig.getJson = function () {
10907
+ return {
10908
+ storefrontId: IkasStorefrontConfig.storefrontId || null,
10909
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId || null,
10910
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId || null,
10911
+ salesChannelId: IkasStorefrontConfig.salesChannelId || null,
10912
+ priceListId: IkasStorefrontConfig.priceListId || null,
10913
+ stockLocationIds: IkasStorefrontConfig.stockLocationIds || null,
10914
+ routings: JSON.parse(JSON.stringify(IkasStorefrontConfig.routings)) || null,
10915
+ };
10888
10916
  };
10889
10917
  IkasStorefrontConfig.components = {};
10890
10918
  IkasStorefrontConfig.config = {};
10891
10919
  IkasStorefrontConfig.apiUrlOverride = null;
10920
+ IkasStorefrontConfig.routings = [];
10892
10921
  return IkasStorefrontConfig;
10893
10922
  }());
10894
10923
 
@@ -11017,6 +11046,7 @@ var IkasProductDetailPropValueProvider = /** @class */ (function () {
11017
11046
  return [2 /*return*/, null];
11018
11047
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
11019
11048
  productIdList: [this.productDetailPropValue.productId],
11049
+ priceListId: IkasStorefrontConfig.priceListId,
11020
11050
  })];
11021
11051
  case 1:
11022
11052
  productSearchResponse = _b.sent();
@@ -11825,11 +11855,15 @@ var IkasPageDataProvider = /** @class */ (function () {
11825
11855
  return {
11826
11856
  props: {
11827
11857
  propValuesStr: JSON.stringify(this.pageComponentPropValues),
11858
+ pageSpecificDataStr: this.pageSpecificData
11859
+ ? JSON.stringify(this.pageSpecificData || {})
11860
+ : "",
11828
11861
  page: mobx.toJS(this.page) || null,
11829
11862
  settingsStr: JSON.stringify(this.theme.settings || {}),
11830
11863
  merchantSettings: this.merchantSettings
11831
11864
  ? JSON.stringify(this.merchantSettings)
11832
11865
  : null,
11866
+ configJson: IkasStorefrontConfig.getJson(),
11833
11867
  },
11834
11868
  };
11835
11869
  },
@@ -12046,6 +12080,7 @@ var IkasPageDataProvider = /** @class */ (function () {
12046
12080
  return [2 /*return*/];
12047
12081
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
12048
12082
  productIdList: [metaDataResponse.metaData.targetId],
12083
+ priceListId: IkasStorefrontConfig.priceListId,
12049
12084
  })];
12050
12085
  case 2:
12051
12086
  productsResponse = _b.sent();
@@ -12803,6 +12838,10 @@ var IkasCart = /** @class */ (function () {
12803
12838
  : [];
12804
12839
  this.merchantId = data.merchantId || "";
12805
12840
  this.totalPrice = data.totalPrice || 0;
12841
+ this.salesChannelId = data.salesChannelId || "";
12842
+ this.storefrontId = data.storefrontId || null;
12843
+ this.storefrontRoutingId = data.storefrontRoutingId || null;
12844
+ this.storefrontThemeId = data.storefrontThemeId || null;
12806
12845
  mobx.makeAutoObservable(this);
12807
12846
  }
12808
12847
  Object.defineProperty(IkasCart.prototype, "totalTax", {
@@ -15822,7 +15861,7 @@ var MAX_CVC_LENGTH = 4;
15822
15861
  var USE_DIFFERENT_ADDRESS_KEY = "sAddr";
15823
15862
  var isServer$1 = typeof localStorage === "undefined";
15824
15863
  var CheckoutViewModel = /** @class */ (function () {
15825
- function CheckoutViewModel(checkout, queryParams, router) {
15864
+ function CheckoutViewModel(checkout, queryParams, router, returnPolicy, privacyPolicy, termsOfService) {
15826
15865
  var _this = this;
15827
15866
  this.checkout = new IkasCheckout();
15828
15867
  this.storefront = null;
@@ -15928,7 +15967,7 @@ var CheckoutViewModel = /** @class */ (function () {
15928
15967
  variantId: i.variant.id,
15929
15968
  productId: i.variant.productId,
15930
15969
  }); });
15931
- return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines)];
15970
+ return [4 /*yield*/, IkasCheckoutAPI.checkStocks(lines, IkasStorefrontConfig.stockLocationIds || [])];
15932
15971
  case 1:
15933
15972
  result = _b.sent();
15934
15973
  if (!result) {
@@ -15941,7 +15980,7 @@ var CheckoutViewModel = /** @class */ (function () {
15941
15980
  data = unavailableItems.map(function (item) { return ({
15942
15981
  variant: _this.cart.items.find(function (i) { return i.variant.id === item.variantId; })
15943
15982
  .variant,
15944
- availableQuantity: item.availableQuantity,
15983
+ availableQuantity: item.stockCount,
15945
15984
  }); });
15946
15985
  throw {
15947
15986
  type: ErrorType.STOCK_ERROR,
@@ -15958,7 +15997,7 @@ var CheckoutViewModel = /** @class */ (function () {
15958
15997
  switch (_b.label) {
15959
15998
  case 0:
15960
15999
  _a = this;
15961
- return [4 /*yield*/, IkasCountryAPI.listShippingCountries()];
16000
+ return [4 /*yield*/, IkasCountryAPI.listShippingCountries(IkasStorefrontConfig.storefrontId)];
15962
16001
  case 1:
15963
16002
  _a.shippingCountryIds = _b.sent();
15964
16003
  return [2 /*return*/];
@@ -16034,30 +16073,6 @@ var CheckoutViewModel = /** @class */ (function () {
16034
16073
  }
16035
16074
  });
16036
16075
  }); };
16037
- this.getStorefront = function () { return __awaiter(_this, void 0, void 0, function () {
16038
- var storefront;
16039
- return __generator(this, function (_a) {
16040
- switch (_a.label) {
16041
- case 0:
16042
- if (!IkasStorefrontConfig.config.storefrontId || !!this.storefront)
16043
- return [2 /*return*/];
16044
- _a.label = 1;
16045
- case 1:
16046
- _a.trys.push([1, 3, , 4]);
16047
- return [4 /*yield*/, IkasStorefrontAPI.getStorefront(IkasStorefrontConfig.config.storefrontId)];
16048
- case 2:
16049
- storefront = _a.sent();
16050
- if (storefront) {
16051
- this.storefront = storefront;
16052
- }
16053
- return [3 /*break*/, 4];
16054
- case 3:
16055
- _a.sent();
16056
- return [3 /*break*/, 4];
16057
- case 4: return [2 /*return*/];
16058
- }
16059
- });
16060
- }); };
16061
16076
  this.createCustomer = function () {
16062
16077
  if (_this.customerStore.customer) {
16063
16078
  _this.checkout.customer = _this.customerStore.customer;
@@ -16189,7 +16204,7 @@ var CheckoutViewModel = /** @class */ (function () {
16189
16204
  _this.router.push("/");
16190
16205
  };
16191
16206
  this.onProceedToShippingClick = function () { return __awaiter(_this, void 0, void 0, function () {
16192
- var newAddress, customer, err_3;
16207
+ var newAddress, customer, err_2;
16193
16208
  return __generator(this, function (_a) {
16194
16209
  switch (_a.label) {
16195
16210
  case 0:
@@ -16219,12 +16234,12 @@ var CheckoutViewModel = /** @class */ (function () {
16219
16234
  this.changeStep(CheckoutStep.SHIPPING);
16220
16235
  return [3 /*break*/, 7];
16221
16236
  case 6:
16222
- err_3 = _a.sent();
16223
- if (err_3.type) {
16224
- this.error = err_3;
16237
+ err_2 = _a.sent();
16238
+ if (err_2.type) {
16239
+ this.error = err_2;
16225
16240
  }
16226
16241
  else {
16227
- console.log(err_3);
16242
+ console.log(err_2);
16228
16243
  this.error = {
16229
16244
  type: ErrorType.UNKNOWN,
16230
16245
  };
@@ -16236,7 +16251,7 @@ var CheckoutViewModel = /** @class */ (function () {
16236
16251
  });
16237
16252
  }); };
16238
16253
  this.onProceedToPaymentClick = function () { return __awaiter(_this, void 0, void 0, function () {
16239
- var err_4;
16254
+ var err_3;
16240
16255
  return __generator(this, function (_a) {
16241
16256
  switch (_a.label) {
16242
16257
  case 0:
@@ -16256,12 +16271,12 @@ var CheckoutViewModel = /** @class */ (function () {
16256
16271
  this.changeStep(CheckoutStep.PAYMENT);
16257
16272
  return [3 /*break*/, 4];
16258
16273
  case 3:
16259
- err_4 = _a.sent();
16260
- if (err_4.type) {
16261
- this.error = err_4;
16274
+ err_3 = _a.sent();
16275
+ if (err_3.type) {
16276
+ this.error = err_3;
16262
16277
  }
16263
16278
  else {
16264
- console.log(err_4);
16279
+ console.log(err_3);
16265
16280
  this.error = {
16266
16281
  type: ErrorType.UNKNOWN,
16267
16282
  };
@@ -16273,7 +16288,7 @@ var CheckoutViewModel = /** @class */ (function () {
16273
16288
  });
16274
16289
  }); };
16275
16290
  this.performPayment = function () { return __awaiter(_this, void 0, void 0, function () {
16276
- var response, transactionStatus, err_5;
16291
+ var response, transactionStatus, err_4;
16277
16292
  return __generator(this, function (_a) {
16278
16293
  switch (_a.label) {
16279
16294
  case 0:
@@ -16320,10 +16335,10 @@ var CheckoutViewModel = /** @class */ (function () {
16320
16335
  }
16321
16336
  return [3 /*break*/, 6];
16322
16337
  case 5:
16323
- err_5 = _a.sent();
16324
- if (err_5.type) {
16325
- console.log(err_5);
16326
- this.error = err_5;
16338
+ err_4 = _a.sent();
16339
+ if (err_4.type) {
16340
+ console.log(err_4);
16341
+ this.error = err_4;
16327
16342
  }
16328
16343
  else {
16329
16344
  this.error = {
@@ -16402,6 +16417,9 @@ var CheckoutViewModel = /** @class */ (function () {
16402
16417
  }); };
16403
16418
  this.checkout = checkout;
16404
16419
  this.router = router;
16420
+ this.returnPolicy = returnPolicy;
16421
+ this.privacyPolicy = privacyPolicy;
16422
+ this.termsOfService = termsOfService;
16405
16423
  this.init(queryParams);
16406
16424
  mobx.makeAutoObservable(this);
16407
16425
  }
@@ -16412,15 +16430,6 @@ var CheckoutViewModel = /** @class */ (function () {
16412
16430
  enumerable: false,
16413
16431
  configurable: true
16414
16432
  });
16415
- Object.defineProperty(CheckoutViewModel.prototype, "storefrontRegion", {
16416
- get: function () {
16417
- var _a;
16418
- return ((_a = this.storefront) === null || _a === void 0 ? void 0 : _a.regions.length) ? this.storefront.regions[0]
16419
- : undefined;
16420
- },
16421
- enumerable: false,
16422
- configurable: true
16423
- });
16424
16433
  Object.defineProperty(CheckoutViewModel.prototype, "selectedPaymentGatewayIndex", {
16425
16434
  get: function () {
16426
16435
  var _this = this;
@@ -17084,6 +17093,7 @@ var IkasCustomerStore = /** @class */ (function () {
17084
17093
  return [2 /*return*/, []];
17085
17094
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
17086
17095
  productIdList: favoriteProductsResult.map(function (fP) { return fP.productId; }),
17096
+ priceListId: IkasStorefrontConfig.priceListId,
17087
17097
  })];
17088
17098
  case 2:
17089
17099
  productsResult = _b.sent();
@@ -21918,7 +21928,10 @@ var IkasProductList = /** @class */ (function () {
21918
21928
  Object.defineProperty(IkasProductList.prototype, "isFiltered", {
21919
21929
  get: function () {
21920
21930
  var _a;
21921
- return (((_a = this.filters) === null || _a === void 0 ? void 0 : _a.some(function (f) { return !!f.valueList.length; })) || !!this._searchKeyword);
21931
+ return (((_a = this.filters) === null || _a === void 0 ? void 0 : _a.some(function (f) { return !!f.valueList.length; })) ||
21932
+ !!this._searchKeyword ||
21933
+ (this._pageType !== exports.IkasThemePageType.CATEGORY &&
21934
+ !!this._filterCategoryId));
21922
21935
  },
21923
21936
  enumerable: false,
21924
21937
  configurable: true
@@ -21981,13 +21994,20 @@ var IkasProductList = /** @class */ (function () {
21981
21994
  });
21982
21995
  Object.defineProperty(IkasProductList.prototype, "filterQueryParams", {
21983
21996
  get: function () {
21984
- var _a;
21997
+ var _this = this;
21998
+ var _a, _b, _c;
21985
21999
  var queryParams = {};
21986
22000
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (f) {
21987
22001
  queryParams[f.key] = f.keyList;
21988
22002
  });
21989
22003
  if (this._searchKeyword)
21990
22004
  queryParams.s = this._searchKeyword;
22005
+ if (this._pageType !== exports.IkasThemePageType.CATEGORY &&
22006
+ this._filterCategoryId) {
22007
+ var slug = (_c = (_b = this.filterCategories) === null || _b === void 0 ? void 0 : _b.find(function (fc) { return fc.id === _this._filterCategoryId; })) === null || _c === void 0 ? void 0 : _c.slug;
22008
+ if (slug)
22009
+ queryParams.c = slug;
22010
+ }
21991
22011
  return queryString.stringify(queryParams, { arrayFormat: "comma" });
21992
22012
  },
21993
22013
  enumerable: false,
@@ -22042,6 +22062,7 @@ var IkasProductList = /** @class */ (function () {
22042
22062
  categoryIdList: this._filterCategoryId
22043
22063
  ? [this._filterCategoryId]
22044
22064
  : undefined,
22065
+ priceListId: IkasStorefrontConfig.priceListId,
22045
22066
  query: this._searchKeyword,
22046
22067
  })];
22047
22068
  case 1: return [2 /*return*/, _c.sent()];
@@ -22069,6 +22090,7 @@ var IkasProductList = /** @class */ (function () {
22069
22090
  };
22070
22091
  IkasProductList.prototype.applyQueryParamFilters = function (queryParams) {
22071
22092
  var _this = this;
22093
+ var _a;
22072
22094
  try {
22073
22095
  queryParams === null || queryParams === void 0 ? void 0 : queryParams.forEach(function (value, key) {
22074
22096
  var _a;
@@ -22080,6 +22102,15 @@ var IkasProductList = /** @class */ (function () {
22080
22102
  var querySearch = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("s");
22081
22103
  if (querySearch)
22082
22104
  this._searchKeyword = querySearch;
22105
+ if (this._pageType !== exports.IkasThemePageType.CATEGORY) {
22106
+ var queryCategory_1 = queryParams === null || queryParams === void 0 ? void 0 : queryParams.get("c");
22107
+ if (queryCategory_1) {
22108
+ var filterCategory = (_a = this.filterCategories) === null || _a === void 0 ? void 0 : _a.find(function (fc) { return fc.slug === queryCategory_1; });
22109
+ if (filterCategory) {
22110
+ this._filterCategoryId = filterCategory.id;
22111
+ }
22112
+ }
22113
+ }
22083
22114
  }
22084
22115
  catch (err) {
22085
22116
  console.log(err);
@@ -22126,12 +22157,32 @@ var IkasProductList = /** @class */ (function () {
22126
22157
  var _a;
22127
22158
  (_a = this.filters) === null || _a === void 0 ? void 0 : _a.forEach(function (filter) { return filter.clear(); });
22128
22159
  this._searchKeyword = "";
22160
+ if (this._pageType !== exports.IkasThemePageType.CATEGORY) {
22161
+ this._filterCategoryId = undefined;
22162
+ }
22129
22163
  this.applyFilters();
22130
22164
  };
22131
- IkasProductList.prototype.onFilterCategoryClick = function (filterCategory) {
22165
+ IkasProductList.prototype.onFilterCategoryClick = function (filterCategory, disableRoute) {
22132
22166
  var _a;
22133
- (_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href +
22134
- (this.filterQueryParams ? "?" + this.filterQueryParams : ""));
22167
+ if (disableRoute === void 0) { disableRoute = false; }
22168
+ return __awaiter(this, void 0, void 0, function () {
22169
+ return __generator(this, function (_b) {
22170
+ switch (_b.label) {
22171
+ case 0:
22172
+ if (!disableRoute) return [3 /*break*/, 2];
22173
+ this._filterCategoryId = filterCategory.id;
22174
+ return [4 /*yield*/, this.applyFilters()];
22175
+ case 1:
22176
+ _b.sent();
22177
+ return [3 /*break*/, 3];
22178
+ case 2:
22179
+ (_a = this.router) === null || _a === void 0 ? void 0 : _a.push(filterCategory.href +
22180
+ (this.filterQueryParams ? "?" + this.filterQueryParams : ""));
22181
+ _b.label = 3;
22182
+ case 3: return [2 /*return*/];
22183
+ }
22184
+ });
22185
+ });
22135
22186
  };
22136
22187
  IkasProductList.prototype.toJSON = function () {
22137
22188
  return {
@@ -24216,7 +24267,7 @@ var IkasCartAPI = /** @class */ (function () {
24216
24267
  return __generator(this, function (_b) {
24217
24268
  switch (_b.label) {
24218
24269
  case 0:
24219
- MUTATION = src(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "], ["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "])));
24270
+ MUTATION = src(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "], ["\n mutation saveItemToCart($input: SaveItemToCartInput!) {\n saveItemToCart(input: $input) {\n id\n createdAt\n updatedAt\n dueDate\n currencyCode\n customerId\n merchantId\n itemCount\n totalPrice\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n deleted\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n id\n name\n sku\n slug\n barcodeList\n mainImageId\n productId\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n }\n }\n "])));
24220
24271
  _b.label = 1;
24221
24272
  case 1:
24222
24273
  _b.trys.push([1, 3, , 4]);
@@ -24251,7 +24302,7 @@ var IkasCartAPI = /** @class */ (function () {
24251
24302
  return __generator(this, function (_b) {
24252
24303
  switch (_b.label) {
24253
24304
  case 0:
24254
- QUERY = src(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "], ["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "])));
24305
+ QUERY = src(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "], ["\n query getCart($cartId: String, $customerId: String) {\n getCart(id: $cartId, customerId: $customerId) {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n salesChannelId\n storefrontId\n storefrontRoutingId\n storefrontThemeId\n items {\n createdAt\n currencyCode\n discount {\n amount\n amountType\n reason\n }\n discountPrice\n finalPrice\n id\n originalOrderLineItemId\n price\n quantity\n status\n deleted\n statusUpdatedAt\n stockLocationId\n taxValue\n updatedAt\n variant {\n slug\n barcodeList\n id\n mainImageId\n name\n productId\n sku\n variantValues {\n order\n variantTypeId\n variantTypeName\n variantValueId\n variantValueName\n }\n }\n }\n merchantId\n status\n totalPrice\n updatedAt\n }\n }\n "])));
24255
24306
  _b.label = 1;
24256
24307
  case 1:
24257
24308
  _b.trys.push([1, 3, , 4]);
@@ -24723,13 +24774,13 @@ var IkasCheckoutAPI = /** @class */ (function () {
24723
24774
  });
24724
24775
  });
24725
24776
  };
24726
- IkasCheckoutAPI.checkStocks = function (lines) {
24777
+ IkasCheckoutAPI.checkStocks = function (lines, stockLocationIdList) {
24727
24778
  return __awaiter(this, void 0, void 0, function () {
24728
24779
  var QUERY, _a, data, errors, err_7;
24729
24780
  return __generator(this, function (_b) {
24730
24781
  switch (_b.label) {
24731
24782
  case 0:
24732
- QUERY = src(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n query checkStocks($lines: [CheckStocksLineInput!]!) {\n checkStocks(lines: $lines) {\n lines {\n availableQuantity\n isAvailable\n stockLocationId\n variantId\n }\n }\n }\n "], ["\n query checkStocks($lines: [CheckStocksLineInput!]!) {\n checkStocks(lines: $lines) {\n lines {\n availableQuantity\n isAvailable\n stockLocationId\n variantId\n }\n }\n }\n "])));
24783
+ QUERY = src(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n query checkStocks(\n $lines: [CheckStocksLineInput!]!\n $stockLocationIdList: [String!]\n ) {\n checkStocks(lines: $lines, stockLocationIdList: $stockLocationIdList) {\n lines {\n stockCount\n isAvailable\n variantId\n }\n }\n }\n "], ["\n query checkStocks(\n $lines: [CheckStocksLineInput!]!\n $stockLocationIdList: [String!]\n ) {\n checkStocks(lines: $lines, stockLocationIdList: $stockLocationIdList) {\n lines {\n stockCount\n isAvailable\n variantId\n }\n }\n }\n "])));
24733
24784
  _b.label = 1;
24734
24785
  case 1:
24735
24786
  _b.trys.push([1, 3, , 4]);
@@ -24739,6 +24790,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
24739
24790
  query: QUERY,
24740
24791
  variables: {
24741
24792
  lines: lines,
24793
+ stockLocationIdList: stockLocationIdList,
24742
24794
  },
24743
24795
  })];
24744
24796
  case 2:
@@ -24821,7 +24873,7 @@ var IkasCountryAPI = /** @class */ (function () {
24821
24873
  return __generator(this, function (_b) {
24822
24874
  switch (_b.label) {
24823
24875
  case 0:
24824
- QUERY = src(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n query listCountry {\n listCountry {\n id\n name\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "], ["\n query listCountry {\n listCountry {\n id\n name\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "])));
24876
+ QUERY = src(templateObject_1$5 || (templateObject_1$5 = __makeTemplateObject(["\n query listCountry {\n listCountry {\n id\n name\n native\n iso2\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "], ["\n query listCountry {\n listCountry {\n id\n name\n native\n iso2\n iso3\n phoneCode\n locationTranslations {\n tr\n en\n }\n }\n }\n "])));
24825
24877
  _b.label = 1;
24826
24878
  case 1:
24827
24879
  _b.trys.push([1, 3, , 4]);
@@ -24837,6 +24889,8 @@ var IkasCountryAPI = /** @class */ (function () {
24837
24889
  return [2 /*return*/, data.listCountry.map(function (c) { return ({
24838
24890
  id: c.id,
24839
24891
  name: pascalCase(c.locationTranslations.tr),
24892
+ native: c.native || "",
24893
+ iso2: c.iso2 || undefined,
24840
24894
  iso3: c.iso3 || undefined,
24841
24895
  phoneCode: c.phoneCode || undefined,
24842
24896
  }); })];
@@ -24850,13 +24904,13 @@ var IkasCountryAPI = /** @class */ (function () {
24850
24904
  });
24851
24905
  });
24852
24906
  };
24853
- IkasCountryAPI.listShippingCountries = function () {
24907
+ IkasCountryAPI.listShippingCountries = function (storefrontId) {
24854
24908
  return __awaiter(this, void 0, void 0, function () {
24855
24909
  var QUERY, _a, data, errors, err_2;
24856
24910
  return __generator(this, function (_b) {
24857
24911
  switch (_b.label) {
24858
24912
  case 0:
24859
- QUERY = src(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query getAvailableShippingCountries {\n getAvailableShippingCountries\n }\n "], ["\n query getAvailableShippingCountries {\n getAvailableShippingCountries\n }\n "])));
24913
+ QUERY = src(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query getAvailableShippingCountries($storefrontId: String!) {\n getAvailableShippingCountries(storefrontId: $storefrontId)\n }\n "], ["\n query getAvailableShippingCountries($storefrontId: String!) {\n getAvailableShippingCountries(storefrontId: $storefrontId)\n }\n "])));
24860
24914
  _b.label = 1;
24861
24915
  case 1:
24862
24916
  _b.trys.push([1, 3, , 4]);
@@ -24864,6 +24918,9 @@ var IkasCountryAPI = /** @class */ (function () {
24864
24918
  .getClient()
24865
24919
  .query({
24866
24920
  query: QUERY,
24921
+ variables: {
24922
+ storefrontId: storefrontId,
24923
+ },
24867
24924
  })];
24868
24925
  case 2:
24869
24926
  _a = _b.sent(), data = _a.data, errors = _a.errors;
@@ -24882,9 +24939,34 @@ var IkasCountryAPI = /** @class */ (function () {
24882
24939
  });
24883
24940
  });
24884
24941
  };
24942
+ IkasCountryAPI.getMyCountry = function () {
24943
+ return __awaiter(this, void 0, void 0, function () {
24944
+ var QUERY, data, err_3;
24945
+ return __generator(this, function (_a) {
24946
+ switch (_a.label) {
24947
+ case 0:
24948
+ QUERY = src(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject(["\n query getMyCountry {\n getMyCountry\n }\n "], ["\n query getMyCountry {\n getMyCountry\n }\n "])));
24949
+ _a.label = 1;
24950
+ case 1:
24951
+ _a.trys.push([1, 3, , 4]);
24952
+ return [4 /*yield*/, apollo.getClient().query({
24953
+ query: QUERY,
24954
+ })];
24955
+ case 2:
24956
+ data = (_a.sent()).data;
24957
+ return [2 /*return*/, data.getMyCountry];
24958
+ case 3:
24959
+ err_3 = _a.sent();
24960
+ console.log(err_3);
24961
+ return [3 /*break*/, 4];
24962
+ case 4: return [2 /*return*/];
24963
+ }
24964
+ });
24965
+ });
24966
+ };
24885
24967
  return IkasCountryAPI;
24886
24968
  }());
24887
- var templateObject_1$5, templateObject_2$3;
24969
+ var templateObject_1$5, templateObject_2$3, templateObject_3$1;
24888
24970
 
24889
24971
  var IkasCustomerAPI = /** @class */ (function () {
24890
24972
  function IkasCustomerAPI() {
@@ -24969,7 +25051,7 @@ var IkasCustomerAPI = /** @class */ (function () {
24969
25051
  return __generator(this, function (_b) {
24970
25052
  switch (_b.label) {
24971
25053
  case 0:
24972
- MUTATION = src(templateObject_3$1 || (templateObject_3$1 = __makeTemplateObject(["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "], ["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "])));
25054
+ MUTATION = src(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "], ["\n mutation customerRefreshToken($token: String!) {\n customerRefreshToken(token: $token) {\n token\n tokenExpiry\n }\n }\n "])));
24973
25055
  _b.label = 1;
24974
25056
  case 1:
24975
25057
  _b.trys.push([1, 3, , 4]);
@@ -25285,7 +25367,7 @@ var IkasCustomerAPI = /** @class */ (function () {
25285
25367
  };
25286
25368
  return IkasCustomerAPI;
25287
25369
  }());
25288
- var templateObject_1$6, templateObject_2$4, templateObject_3$1, templateObject_4$1, templateObject_5$1, templateObject_6$1, templateObject_7$1, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
25370
+ var templateObject_1$6, templateObject_2$4, templateObject_3$2, templateObject_4$1, templateObject_5$1, templateObject_6$1, templateObject_7$1, templateObject_8, templateObject_9, templateObject_10, templateObject_11;
25289
25371
 
25290
25372
  var IkasDistrictAPI = /** @class */ (function () {
25291
25373
  function IkasDistrictAPI() {
@@ -25738,7 +25820,7 @@ var IkasFavoriteProductAPI = /** @class */ (function () {
25738
25820
  return __generator(this, function (_b) {
25739
25821
  switch (_b.label) {
25740
25822
  case 0:
25741
- SAVE_FAVORITE_PRODUCT = src(templateObject_3$2 || (templateObject_3$2 = __makeTemplateObject(["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "], ["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "])));
25823
+ SAVE_FAVORITE_PRODUCT = src(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "], ["\n mutation saveFavoriteProduct($isFavorite: Boolean!, $productId: String!) {\n saveFavoriteProduct(isFavorite: $isFavorite, productId: $productId)\n }\n "])));
25742
25824
  _b.label = 1;
25743
25825
  case 1:
25744
25826
  _b.trys.push([1, 3, , 4]);
@@ -25764,7 +25846,7 @@ var IkasFavoriteProductAPI = /** @class */ (function () {
25764
25846
  };
25765
25847
  return IkasFavoriteProductAPI;
25766
25848
  }());
25767
- var templateObject_1$c, templateObject_2$6, templateObject_3$2;
25849
+ var templateObject_1$c, templateObject_2$6, templateObject_3$3;
25768
25850
 
25769
25851
  var IkasContactFormAPI = /** @class */ (function () {
25770
25852
  function IkasContactFormAPI() {
@@ -25857,150 +25939,6 @@ var IkasStateAPI = /** @class */ (function () {
25857
25939
  }());
25858
25940
  var templateObject_1$e;
25859
25941
 
25860
- var IkasStorefrontDomain = /** @class */ (function () {
25861
- function IkasStorefrontDomain(data) {
25862
- if (data === void 0) { data = {}; }
25863
- this.id = data.id || "";
25864
- this.merchantDomainId = data.merchantDomainId || "";
25865
- this.name = data.name || "";
25866
- this.redirectDomainName = data.redirectDomainName || null;
25867
- mobx.makeAutoObservable(this);
25868
- }
25869
- return IkasStorefrontDomain;
25870
- }());
25871
-
25872
- var IkasStorefrontLocation = /** @class */ (function () {
25873
- function IkasStorefrontLocation(data) {
25874
- if (data === void 0) { data = {}; }
25875
- this.countryId = data.countryId || "";
25876
- this.stateId = data.stateId || null;
25877
- mobx.makeAutoObservable(this);
25878
- }
25879
- return IkasStorefrontLocation;
25880
- }());
25881
-
25882
- var IkasStorefrontRoute = /** @class */ (function () {
25883
- function IkasStorefrontRoute(data) {
25884
- if (data === void 0) { data = {}; }
25885
- this.domainId = data.domainId || "";
25886
- this.useSubPath = data.useSubPath || false;
25887
- mobx.makeAutoObservable(this);
25888
- }
25889
- return IkasStorefrontRoute;
25890
- }());
25891
-
25892
- var IkasStorefrontRegion = /** @class */ (function () {
25893
- function IkasStorefrontRegion(data) {
25894
- if (data === void 0) { data = {}; }
25895
- // Extra
25896
- this.theme = new IkasTheme();
25897
- this.id = data.id || "";
25898
- this.locale = data.locale || "";
25899
- this.themeJSON = data.themeJSON || "";
25900
- this.shipping = data.shipping || null;
25901
- this.paymentSettingsId = data.paymentSettingsId || null;
25902
- this.priceListId = data.priceListId || null;
25903
- this.locations = data.locations
25904
- ? data.locations.map(function (o) { return new IkasStorefrontLocation(o); })
25905
- : [];
25906
- this.routes = data.routes
25907
- ? data.routes.map(function (o) { return new IkasStorefrontRoute(o); })
25908
- : null;
25909
- this.termsOfService = data.termsOfService || "";
25910
- this.privacyPolicy = data.privacyPolicy || "";
25911
- this.returnPolicy = data.returnPolicy || "";
25912
- try {
25913
- this.theme = this.themeJSON
25914
- ? new IkasTheme(JSON.parse(this.themeJSON))
25915
- : new IkasTheme();
25916
- }
25917
- catch (err) { }
25918
- mobx.makeAutoObservable(this);
25919
- }
25920
- return IkasStorefrontRegion;
25921
- }());
25922
-
25923
- var IkasStorefront = /** @class */ (function () {
25924
- function IkasStorefront(data) {
25925
- if (data === void 0) { data = {}; }
25926
- this.id = data.id || "";
25927
- this.name = data.name || "";
25928
- this.themeId = data.themeId || "";
25929
- this.themeVersionId = data.themeVersionId || "";
25930
- this.userId = data.userId || "";
25931
- this.domains = data.domains
25932
- ? data.domains.map(function (o) { return new IkasStorefrontDomain(o); })
25933
- : [];
25934
- this.regions = data.regions
25935
- ? data.regions.map(function (o) { return new IkasStorefrontRegion(o); })
25936
- : [];
25937
- mobx.makeAutoObservable(this);
25938
- }
25939
- return IkasStorefront;
25940
- }());
25941
-
25942
- var IkasStorefrontAPI = /** @class */ (function () {
25943
- function IkasStorefrontAPI() {
25944
- }
25945
- IkasStorefrontAPI.getStorefront = function (storefrontId) {
25946
- return __awaiter(this, void 0, void 0, function () {
25947
- var QUERY, _a, data, errors;
25948
- return __generator(this, function (_b) {
25949
- switch (_b.label) {
25950
- case 0:
25951
- QUERY = src(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n query getStorefront($storefrontId: String!) {\n getStorefront(id: $storefrontId) {\n id\n name\n themeId\n themeVersionId\n userId\n # domains {\n # id\n # merchantDomainId\n # name\n # redirectDomainName\n # }\n regions {\n id\n locale\n # themeJSON\n privacyPolicy\n returnPolicy\n termsOfService\n }\n }\n }\n "], ["\n query getStorefront($storefrontId: String!) {\n getStorefront(id: $storefrontId) {\n id\n name\n themeId\n themeVersionId\n userId\n # domains {\n # id\n # merchantDomainId\n # name\n # redirectDomainName\n # }\n regions {\n id\n locale\n # themeJSON\n privacyPolicy\n returnPolicy\n termsOfService\n }\n }\n }\n "])));
25952
- _b.label = 1;
25953
- case 1:
25954
- _b.trys.push([1, 3, , 4]);
25955
- return [4 /*yield*/, apollo
25956
- .getClient()
25957
- .query({
25958
- query: QUERY,
25959
- variables: {
25960
- storefrontId: storefrontId,
25961
- },
25962
- })];
25963
- case 2:
25964
- _a = _b.sent(), data = _a.data, errors = _a.errors;
25965
- if (errors && errors.length) {
25966
- console.log(errors);
25967
- }
25968
- if (data)
25969
- return [2 /*return*/, new IkasStorefront(data.getStorefront)];
25970
- return [3 /*break*/, 4];
25971
- case 3:
25972
- _b.sent();
25973
- return [3 /*break*/, 4];
25974
- case 4: return [2 /*return*/, new IkasStorefront()];
25975
- }
25976
- });
25977
- });
25978
- };
25979
- return IkasStorefrontAPI;
25980
- }());
25981
- var templateObject_1$f;
25982
-
25983
- var IkasThemeAPI = /** @class */ (function () {
25984
- function IkasThemeAPI() {
25985
- }
25986
- IkasThemeAPI.fetchTheme = function () {
25987
- return new Promise(function (resolve, reject) {
25988
- var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
25989
- var themeJSONPath = serverRuntimeConfig.THEME_JSON_PATH || "./src/theme.json";
25990
- fs__default['default'].readFile(themeJSONPath, {
25991
- flag: "a+",
25992
- }, function (err, file) {
25993
- if (err) {
25994
- return reject(err);
25995
- }
25996
- var result = file.length ? JSON.parse(file.toString()) : {};
25997
- resolve(new IkasTheme(result));
25998
- });
25999
- });
26000
- };
26001
- return IkasThemeAPI;
26002
- }());
26003
-
26004
25942
  var IkasVariantTypeAPI = /** @class */ (function () {
26005
25943
  function IkasVariantTypeAPI() {
26006
25944
  }
@@ -26010,7 +25948,7 @@ var IkasVariantTypeAPI = /** @class */ (function () {
26010
25948
  return __generator(this, function (_b) {
26011
25949
  switch (_b.label) {
26012
25950
  case 0:
26013
- LIST_VARIANT_TYPE = src(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "], ["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "])));
25951
+ LIST_VARIANT_TYPE = src(templateObject_1$f || (templateObject_1$f = __makeTemplateObject(["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "], ["\n query listVariantType($id: StringFilterInput!) {\n listVariantType(id: $id) {\n id\n createdAt\n updatedAt\n deleted\n name\n selectionType\n values {\n id\n createdAt\n updatedAt\n deleted\n name\n thumbnailImageId\n colorCode\n }\n }\n }\n "])));
26014
25952
  _b.label = 1;
26015
25953
  case 1:
26016
25954
  _b.trys.push([1, 3, , 4]);
@@ -26056,7 +25994,7 @@ var IkasVariantTypeAPI = /** @class */ (function () {
26056
25994
  };
26057
25995
  return IkasVariantTypeAPI;
26058
25996
  }());
26059
- var templateObject_1$g;
25997
+ var templateObject_1$f;
26060
25998
 
26061
25999
  function styleInject(css, ref) {
26062
26000
  if ( ref === void 0 ) ref = {};
@@ -27246,6 +27184,11 @@ var IkasCartStore = /** @class */ (function () {
27246
27184
  name: product.name,
27247
27185
  },
27248
27186
  },
27187
+ priceListId: IkasStorefrontConfig.priceListId || null,
27188
+ salesChannelId: IkasStorefrontConfig.salesChannelId,
27189
+ storefrontId: IkasStorefrontConfig.storefrontId,
27190
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId,
27191
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId,
27249
27192
  };
27250
27193
  return [4 /*yield*/, IkasCartAPI.saveItemToCart(input)];
27251
27194
  case 1:
@@ -27286,6 +27229,11 @@ var IkasCartStore = /** @class */ (function () {
27286
27229
  name: item.variant.name,
27287
27230
  },
27288
27231
  },
27232
+ priceListId: IkasStorefrontConfig.priceListId || null,
27233
+ salesChannelId: IkasStorefrontConfig.salesChannelId,
27234
+ storefrontId: IkasStorefrontConfig.storefrontId,
27235
+ storefrontRoutingId: IkasStorefrontConfig.storefrontRoutingId,
27236
+ storefrontThemeId: IkasStorefrontConfig.storefrontThemeId,
27289
27237
  };
27290
27238
  return [4 /*yield*/, IkasCartAPI.saveItemToCart(input)];
27291
27239
  case 1:
@@ -27648,9 +27596,11 @@ function createCategoryBreadcrumbSchema(pageSpecificDataStr) {
27648
27596
 
27649
27597
  var IkasCheckoutPage = mobxReactLite.observer(function (_a) {
27650
27598
  var _b, _c, _d;
27651
- var checkout = _a.checkout, queryParams = _a.queryParams;
27599
+ var checkout = _a.checkout, returnPolicy = _a.returnPolicy, privacyPolicy = _a.privacyPolicy, termsOfService = _a.termsOfService, queryParams = _a.queryParams;
27652
27600
  var router$1 = router.useRouter();
27653
- var vm = React.useState(function () { return new CheckoutViewModel(checkout, queryParams, router$1); })[0];
27601
+ var vm = React.useState(function () {
27602
+ return new CheckoutViewModel(checkout, queryParams, router$1, returnPolicy, privacyPolicy, termsOfService);
27603
+ })[0];
27654
27604
  React.useEffect(function () {
27655
27605
  Analytics.beginCheckout(vm.checkout);
27656
27606
  Analytics.checkoutStep(vm.checkout, vm.step);
@@ -27675,46 +27625,18 @@ var IkasCheckoutPage = mobxReactLite.observer(function (_a) {
27675
27625
  var onPolicyModalClose = function () {
27676
27626
  setPolicyModalText("");
27677
27627
  };
27678
- var onReturnPolicyClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27679
- var _a, _b;
27680
- return __generator(this, function (_c) {
27681
- switch (_c.label) {
27682
- case 0: return [4 /*yield*/, vm.getStorefront()];
27683
- case 1:
27684
- _c.sent();
27685
- console.log((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.returnPolicy);
27686
- setPolicyModalTitle("Para İade Politikası");
27687
- setPolicyModalText(((_b = vm.storefrontRegion) === null || _b === void 0 ? void 0 : _b.returnPolicy) || "");
27688
- return [2 /*return*/];
27689
- }
27690
- });
27691
- }); };
27692
- var onPrivacyPolicyClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27693
- var _a;
27694
- return __generator(this, function (_b) {
27695
- switch (_b.label) {
27696
- case 0: return [4 /*yield*/, vm.getStorefront()];
27697
- case 1:
27698
- _b.sent();
27699
- setPolicyModalTitle("Gizlilik Politikası");
27700
- setPolicyModalText(((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.privacyPolicy) || "");
27701
- return [2 /*return*/];
27702
- }
27703
- });
27704
- }); };
27705
- var onTermsOfServiceClick = function () { return __awaiter(void 0, void 0, void 0, function () {
27706
- var _a;
27707
- return __generator(this, function (_b) {
27708
- switch (_b.label) {
27709
- case 0: return [4 /*yield*/, vm.getStorefront()];
27710
- case 1:
27711
- _b.sent();
27712
- setPolicyModalTitle("Hizmet Şartları");
27713
- setPolicyModalText(((_a = vm.storefrontRegion) === null || _a === void 0 ? void 0 : _a.termsOfService) || "");
27714
- return [2 /*return*/];
27715
- }
27716
- });
27717
- }); };
27628
+ var onReturnPolicyClick = function () {
27629
+ setPolicyModalTitle("Para İade Politikası");
27630
+ setPolicyModalText(vm.returnPolicy);
27631
+ };
27632
+ var onPrivacyPolicyClick = function () {
27633
+ setPolicyModalTitle("Gizlilik Politikası");
27634
+ setPolicyModalText(vm.privacyPolicy);
27635
+ };
27636
+ var onTermsOfServiceClick = function () {
27637
+ setPolicyModalTitle("Hizmet Şartları");
27638
+ setPolicyModalText(vm.termsOfService);
27639
+ };
27718
27640
  var onErrorClose = function () {
27719
27641
  vm.error = undefined;
27720
27642
  };
@@ -27817,6 +27739,9 @@ var IkasPage = mobxReactLite.observer(function (_a) {
27817
27739
  if (page) {
27818
27740
  store.currentPageType = page.type;
27819
27741
  }
27742
+ React.useEffect(function () {
27743
+ store.checkLocalization();
27744
+ }, []);
27820
27745
  var renderComponent = function (pageComponent, index) {
27821
27746
  var pageComponentPropValue = propValues.find(function (pv) { return pv.pageComponent.id === pageComponent.id; });
27822
27747
  return (React.createElement(ThemeComponent, { key: pageComponent.id, index: index, pageComponentPropValue: pageComponentPropValue, pageComponent: pageComponent, settingsStr: settingsStr }));
@@ -28334,24 +28259,358 @@ var index = /*#__PURE__*/Object.freeze({
28334
28259
  Image: Image
28335
28260
  });
28336
28261
 
28262
+ var IkasStorefrontLocalization = /** @class */ (function () {
28263
+ function IkasStorefrontLocalization(data) {
28264
+ this.id = data.id || "";
28265
+ this.isDefault = data.isDefault || false;
28266
+ this.locale = data.locale || "";
28267
+ this.name = data.name || "";
28268
+ }
28269
+ return IkasStorefrontLocalization;
28270
+ }());
28271
+
28272
+ var IkasStorefrontDomain = /** @class */ (function () {
28273
+ function IkasStorefrontDomain(data) {
28274
+ if (data === void 0) { data = {}; }
28275
+ this.id = data.id || "";
28276
+ this.merchantDomainId = data.merchantDomainId || "";
28277
+ this.name = data.name || "";
28278
+ this.redirectDomainName = data.redirectDomainName || null;
28279
+ this.isDefault = data.isDefault || false;
28280
+ mobx.makeAutoObservable(this);
28281
+ }
28282
+ return IkasStorefrontDomain;
28283
+ }());
28284
+
28285
+ var IkasStorefrontRouting = /** @class */ (function () {
28286
+ function IkasStorefrontRouting(data) {
28287
+ this.id = data.id || "";
28288
+ this.countryCodes = data.countryCodes || null;
28289
+ this.domain = data.domain || null;
28290
+ this.locale = data.locale || "";
28291
+ this.path = data.path || null;
28292
+ this.priceListId = data.priceListId || null;
28293
+ }
28294
+ return IkasStorefrontRouting;
28295
+ }());
28296
+
28297
+ var IkasStorefrontThemeStatus;
28298
+ (function (IkasStorefrontThemeStatus) {
28299
+ IkasStorefrontThemeStatus["WAITING"] = "WAITING";
28300
+ IkasStorefrontThemeStatus["READY"] = "READY";
28301
+ })(IkasStorefrontThemeStatus || (IkasStorefrontThemeStatus = {}));
28302
+ var IkasStorefrontTheme = /** @class */ (function () {
28303
+ function IkasStorefrontTheme(data) {
28304
+ this.id = data.id || "";
28305
+ this.isMainTheme = data.isMainTheme || false;
28306
+ this.name = data.name || "";
28307
+ this.status = data.status || IkasStorefrontThemeStatus.WAITING;
28308
+ this.themeId = data.themeId || "";
28309
+ this.themeVersionId = data.themeVersionId || "";
28310
+ }
28311
+ return IkasStorefrontTheme;
28312
+ }());
28313
+
28314
+ var StorefrontStatus;
28315
+ (function (StorefrontStatus) {
28316
+ StorefrontStatus["WAITING"] = "WAITING";
28317
+ StorefrontStatus["READY"] = "READY";
28318
+ })(StorefrontStatus || (StorefrontStatus = {}));
28319
+ var IkasStorefront = /** @class */ (function () {
28320
+ function IkasStorefront(data) {
28321
+ if (data === void 0) { data = {}; }
28322
+ this.id = data.id || "";
28323
+ this.name = data.name || "";
28324
+ this.status = data.status || StorefrontStatus.WAITING;
28325
+ this.mainStorefrontThemeId = data.mainStorefrontThemeId || null;
28326
+ this.emailSettingsId = data.emailSettingsId || null;
28327
+ this.salesChannelId = data.salesChannelId || null;
28328
+ this.gtmId = data.gtmId || null;
28329
+ this.fbpId = data.fbpId || null;
28330
+ // Sub Models
28331
+ this.localizations = data.localizations
28332
+ ? data.localizations.map(function (l) { return new IkasStorefrontLocalization(l); })
28333
+ : [];
28334
+ this.routings = data.routings
28335
+ ? data.routings.map(function (r) { return new IkasStorefrontRouting(r); })
28336
+ : [];
28337
+ this.domains = data.domains
28338
+ ? data.domains.map(function (o) { return new IkasStorefrontDomain(o); })
28339
+ : [];
28340
+ this.themes = data.themes
28341
+ ? data.themes.map(function (t) { return new IkasStorefrontTheme(t); })
28342
+ : [];
28343
+ }
28344
+ return IkasStorefront;
28345
+ }());
28346
+
28347
+ var IkasSalesChannel = /** @class */ (function () {
28348
+ function IkasSalesChannel(data) {
28349
+ if (data === void 0) { data = {}; }
28350
+ var _a;
28351
+ this.id = data.id || "";
28352
+ this.name = data.name || "";
28353
+ this.priceListId = data.priceListId || "";
28354
+ this.stockLocations =
28355
+ ((_a = data.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return new IkasSalesChannelStockLocation(sl); })) ||
28356
+ [];
28357
+ }
28358
+ return IkasSalesChannel;
28359
+ }());
28360
+ var IkasSalesChannelStockLocation = /** @class */ (function () {
28361
+ function IkasSalesChannelStockLocation(data) {
28362
+ this.id = data.id || "";
28363
+ this.order = data.order || 0;
28364
+ }
28365
+ return IkasSalesChannelStockLocation;
28366
+ }());
28367
+
28368
+ var IkasStorefrontThemeLocalization = /** @class */ (function () {
28369
+ function IkasStorefrontThemeLocalization(data) {
28370
+ this.id = data.id || "";
28371
+ this.locale = data.locale || "";
28372
+ this.storefrontId = data.storefrontId || "";
28373
+ this.storefrontThemeId = data.storefrontThemeId || "";
28374
+ this.themeJson = data.themeJson
28375
+ ? new IkasTheme(data.themeJson)
28376
+ : new IkasTheme();
28377
+ this.privacyPolicy = data.privacyPolicy || null;
28378
+ this.returnPolicy = data.returnPolicy || null;
28379
+ this.termsOfService = data.termsOfService || null;
28380
+ }
28381
+ return IkasStorefrontThemeLocalization;
28382
+ }());
28383
+
28384
+ var IkasStorefrontAPI = /** @class */ (function () {
28385
+ function IkasStorefrontAPI() {
28386
+ }
28387
+ IkasStorefrontAPI.getStorefront = function (id) {
28388
+ return __awaiter(this, void 0, void 0, function () {
28389
+ var QUERY, _a, data, errors, err_1;
28390
+ return __generator(this, function (_b) {
28391
+ switch (_b.label) {
28392
+ case 0:
28393
+ QUERY = src(templateObject_1$g || (templateObject_1$g = __makeTemplateObject(["\n query getStorefront($id: String!) {\n getStorefront(id: $id) {\n createdAt\n emailSettingsId\n fbpId\n gtmId\n id\n localizations {\n createdAt\n id\n isDefault\n locale\n name\n }\n mainStorefrontThemeId\n name\n salesChannelId\n routings {\n countryCodes\n createdAt\n domain\n id\n locale\n path\n priceListId\n updatedAt\n }\n status\n themes {\n createdAt\n id\n isMainTheme\n name\n status\n themeId\n themeVersionId\n updatedAt\n }\n }\n }\n "], ["\n query getStorefront($id: String!) {\n getStorefront(id: $id) {\n createdAt\n emailSettingsId\n fbpId\n gtmId\n id\n localizations {\n createdAt\n id\n isDefault\n locale\n name\n }\n mainStorefrontThemeId\n name\n salesChannelId\n routings {\n countryCodes\n createdAt\n domain\n id\n locale\n path\n priceListId\n updatedAt\n }\n status\n themes {\n createdAt\n id\n isMainTheme\n name\n status\n themeId\n themeVersionId\n updatedAt\n }\n }\n }\n "])));
28394
+ _b.label = 1;
28395
+ case 1:
28396
+ _b.trys.push([1, 3, , 4]);
28397
+ return [4 /*yield*/, apollo
28398
+ .getClient()
28399
+ .query({
28400
+ query: QUERY,
28401
+ variables: {
28402
+ id: id,
28403
+ },
28404
+ })];
28405
+ case 2:
28406
+ _a = _b.sent(), data = _a.data, errors = _a.errors;
28407
+ if (errors && errors.length) {
28408
+ console.log(errors);
28409
+ }
28410
+ if (data)
28411
+ return [2 /*return*/, new IkasStorefront(data.getStorefront)];
28412
+ return [3 /*break*/, 4];
28413
+ case 3:
28414
+ err_1 = _b.sent();
28415
+ console.log(err_1);
28416
+ return [3 /*break*/, 4];
28417
+ case 4: return [2 /*return*/];
28418
+ }
28419
+ });
28420
+ });
28421
+ };
28422
+ return IkasStorefrontAPI;
28423
+ }());
28424
+ var templateObject_1$g;
28425
+
28426
+ var SettingsHelper = /** @class */ (function () {
28427
+ function SettingsHelper() {
28428
+ }
28429
+ SettingsHelper.readLocalTheme = function () {
28430
+ return new Promise(function (resolve, reject) {
28431
+ var themeJSONPath = "./src/theme.json";
28432
+ fs__default['default'].readFile(themeJSONPath, {
28433
+ flag: "a+",
28434
+ }, function (err, file) {
28435
+ if (err) {
28436
+ return reject(err);
28437
+ }
28438
+ var result = file.length ? JSON.parse(file.toString()) : {};
28439
+ resolve(new IkasTheme(result));
28440
+ });
28441
+ });
28442
+ };
28443
+ SettingsHelper.readSettingsFile = function () {
28444
+ return new Promise(function (resolve) {
28445
+ var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
28446
+ var settingsPath = serverRuntimeConfig.SETTINGS;
28447
+ fs__default['default'].readFile(settingsPath, {
28448
+ flag: "a+",
28449
+ }, function (err, file) {
28450
+ if (err) {
28451
+ console.error("SETTINGS FILE READ ERROR!!!");
28452
+ console.error(err);
28453
+ return resolve(null);
28454
+ }
28455
+ var result = file.length ? JSON.parse(file.toString()) : {};
28456
+ resolve(result);
28457
+ });
28458
+ });
28459
+ };
28460
+ SettingsHelper.getSettings = function (locale) {
28461
+ var _this = this;
28462
+ return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
28463
+ var isLocal, storefrontResponse, storefront, localTheme, settings, storefront_1, salesChannel_1, localizationMap, themeLocalizationPath, routing_1;
28464
+ return __generator(this, function (_a) {
28465
+ switch (_a.label) {
28466
+ case 0:
28467
+ isLocal = process.env.NEXT_PUBLIC_ENV === "local";
28468
+ if (!isLocal) return [3 /*break*/, 3];
28469
+ if (!IkasStorefrontConfig.storefrontId) {
28470
+ console.error("Missing storefrontId in the config.json file!");
28471
+ return [2 /*return*/, resolve(null)];
28472
+ }
28473
+ return [4 /*yield*/, IkasStorefrontAPI.getStorefront(IkasStorefrontConfig.storefrontId)];
28474
+ case 1:
28475
+ storefrontResponse = _a.sent();
28476
+ if (!storefrontResponse)
28477
+ return [2 /*return*/, resolve(null)];
28478
+ storefront = storefrontResponse;
28479
+ return [4 /*yield*/, SettingsHelper.readLocalTheme()];
28480
+ case 2:
28481
+ localTheme = _a.sent();
28482
+ resolve({
28483
+ storefront: storefront,
28484
+ themeLocalization: new IkasStorefrontThemeLocalization({
28485
+ themeJson: localTheme,
28486
+ }),
28487
+ salesChannel: new IkasSalesChannel({
28488
+ id: storefront.salesChannelId,
28489
+ }),
28490
+ routing: storefront.routings.length
28491
+ ? storefront.routings[0]
28492
+ : new IkasStorefrontRouting({}),
28493
+ });
28494
+ return [3 /*break*/, 5];
28495
+ case 3: return [4 /*yield*/, SettingsHelper.readSettingsFile()];
28496
+ case 4:
28497
+ settings = _a.sent();
28498
+ if (!settings)
28499
+ return [2 /*return*/, resolve(null)];
28500
+ storefront_1 = new IkasStorefront(settings.storefront);
28501
+ salesChannel_1 = new IkasSalesChannel(settings.salesChannel);
28502
+ localizationMap = settings.localizationMap;
28503
+ themeLocalizationPath = localizationMap[locale];
28504
+ routing_1 = storefront_1.routings.find(function (r) { return r.id === locale || r.path === locale; });
28505
+ if (!themeLocalizationPath || !routing_1) {
28506
+ console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!");
28507
+ return [2 /*return*/, resolve(null)];
28508
+ }
28509
+ fs__default['default'].readFile(themeLocalizationPath, {
28510
+ flag: "a+",
28511
+ }, function (err, file) {
28512
+ if (err) {
28513
+ console.error("THEME LOCALZIATION FILE READ ERROR!!!");
28514
+ console.error(err);
28515
+ return resolve(null);
28516
+ }
28517
+ var result = file.length ? JSON.parse(file.toString()) : {};
28518
+ resolve({
28519
+ storefront: storefront_1,
28520
+ themeLocalization: new IkasStorefrontThemeLocalization(result),
28521
+ salesChannel: salesChannel_1,
28522
+ routing: routing_1,
28523
+ });
28524
+ });
28525
+ _a.label = 5;
28526
+ case 5: return [2 /*return*/];
28527
+ }
28528
+ });
28529
+ }); });
28530
+ };
28531
+ SettingsHelper.getPageData = function (context, isServer, pageType) {
28532
+ var _a;
28533
+ return __awaiter(this, void 0, void 0, function () {
28534
+ var locale, settings, storefront, themeLocalization, salesChannel, routing, provider;
28535
+ return __generator(this, function (_b) {
28536
+ switch (_b.label) {
28537
+ case 0:
28538
+ locale = context.locale || context.defaultLocale || "en";
28539
+ return [4 /*yield*/, SettingsHelper.getSettings(locale)];
28540
+ case 1:
28541
+ settings = _b.sent();
28542
+ if (!settings ||
28543
+ !settings.storefront.mainStorefrontThemeId ||
28544
+ !settings.storefront.salesChannelId) {
28545
+ return [2 /*return*/, {
28546
+ props: {},
28547
+ notFound: true,
28548
+ }];
28549
+ }
28550
+ storefront = settings.storefront, themeLocalization = settings.themeLocalization, salesChannel = settings.salesChannel, routing = settings.routing;
28551
+ IkasStorefrontConfig.storefrontId = storefront.id;
28552
+ IkasStorefrontConfig.storefrontRoutingId = routing.id;
28553
+ IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
28554
+ IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
28555
+ IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
28556
+ IkasStorefrontConfig.stockLocationIds = (_a = salesChannel.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return sl.id; });
28557
+ IkasStorefrontConfig.routings = storefront.routings;
28558
+ provider = new IkasPageDataProvider(themeLocalization.themeJson, context.params, pageType);
28559
+ return [4 /*yield*/, provider.getPageData()];
28560
+ case 2:
28561
+ _b.sent();
28562
+ if (!provider.page) {
28563
+ return [2 /*return*/, {
28564
+ props: {},
28565
+ notFound: true,
28566
+ }];
28567
+ }
28568
+ if (isServer)
28569
+ return [2 /*return*/, provider.nextPageData];
28570
+ else
28571
+ return [2 /*return*/, {
28572
+ props: provider.nextPageData.props,
28573
+ revalidate: 60,
28574
+ }];
28575
+ }
28576
+ });
28577
+ });
28578
+ };
28579
+ SettingsHelper.getStaticProps = function (context, pageType) {
28580
+ return __awaiter(this, void 0, void 0, function () {
28581
+ return __generator(this, function (_a) {
28582
+ switch (_a.label) {
28583
+ case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType)];
28584
+ case 1: return [2 /*return*/, _a.sent()];
28585
+ }
28586
+ });
28587
+ });
28588
+ };
28589
+ SettingsHelper.getServerSideProps = function (context, pageType) {
28590
+ return __awaiter(this, void 0, void 0, function () {
28591
+ return __generator(this, function (_a) {
28592
+ switch (_a.label) {
28593
+ case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType)];
28594
+ case 1: return [2 /*return*/, _a.sent()];
28595
+ }
28596
+ });
28597
+ });
28598
+ };
28599
+ return SettingsHelper;
28600
+ }());
28601
+
28337
28602
  var Page = function (_a) {
28338
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
28603
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
28604
+ IkasStorefrontConfig.initWithJson(configJson);
28339
28605
  var router$1 = router.useRouter();
28340
28606
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28341
28607
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
28342
28608
  };
28343
28609
  var getStaticProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28344
- var theme, provider;
28345
28610
  return __generator(this, function (_a) {
28346
28611
  switch (_a.label) {
28347
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28348
- case 1:
28349
- theme = _a.sent();
28350
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.INDEX);
28351
- return [4 /*yield*/, provider.getPageData()];
28352
- case 2:
28353
- _a.sent();
28354
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28612
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.INDEX)];
28613
+ case 1: return [2 /*return*/, _a.sent()];
28355
28614
  }
28356
28615
  });
28357
28616
  }); };
@@ -28363,7 +28622,8 @@ var home = /*#__PURE__*/Object.freeze({
28363
28622
  });
28364
28623
 
28365
28624
  var Page$1 = function (_a) {
28366
- var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
28625
+ var page = _a.page, pageSpecificDataStr = _a.pageSpecificDataStr, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
28626
+ IkasStorefrontConfig.initWithJson(configJson);
28367
28627
  var router$1 = router.useRouter();
28368
28628
  var _b = React.useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
28369
28629
  var initialPropValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
@@ -28393,6 +28653,7 @@ var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void
28393
28653
  productMetaData = metaData.filter(function (m) { return m.targetType && m.targetType === exports.IkasHTMLMetaDataTargetType.PRODUCT; });
28394
28654
  return [4 /*yield*/, IkasProductSearchAPI.searchProducts({
28395
28655
  productIdList: productMetaData.map(function (p) { return p.targetId; }),
28656
+ priceListId: IkasStorefrontConfig.priceListId,
28396
28657
  })];
28397
28658
  case 2:
28398
28659
  productsResponse = _b.sent();
@@ -28439,25 +28700,10 @@ var getStaticPaths = function (context) { return __awaiter(void 0, void 0, void
28439
28700
  });
28440
28701
  }); };
28441
28702
  var getStaticProps$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28442
- var theme, provider;
28443
28703
  return __generator(this, function (_a) {
28444
28704
  switch (_a.label) {
28445
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28446
- case 1:
28447
- theme = _a.sent();
28448
- provider = new IkasPageDataProvider(theme, context.params, undefined);
28449
- return [4 /*yield*/, provider.getPageData()];
28450
- case 2:
28451
- _a.sent();
28452
- if (!provider.page) {
28453
- return [2 /*return*/, {
28454
- notFound: true,
28455
- }];
28456
- }
28457
- return [2 /*return*/, {
28458
- props: __assign(__assign({}, provider.nextPageData.props), { pageSpecificDataStr: JSON.stringify(provider.pageSpecificData || {}) }),
28459
- revalidate: 60,
28460
- }];
28705
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context)];
28706
+ case 1: return [2 /*return*/, _a.sent()];
28461
28707
  }
28462
28708
  });
28463
28709
  }); };
@@ -28496,25 +28742,52 @@ var index$2 = /*#__PURE__*/Object.freeze({
28496
28742
  });
28497
28743
 
28498
28744
  var Page$2 = function (_a) {
28499
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28745
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28746
+ IkasStorefrontConfig.initWithJson(configJson);
28500
28747
  var router$1 = router.useRouter();
28501
28748
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28502
28749
  return (React.createElement(IkasPage, { page: page, settingsStr: settingsStr, propValues: propValues }));
28503
28750
  };
28504
28751
  var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28505
- var theme, customPages, customPagePaths;
28752
+ var allSettings, customPagePaths;
28506
28753
  return __generator(this, function (_a) {
28507
28754
  switch (_a.label) {
28508
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28755
+ case 0:
28756
+ if (!context.locales)
28757
+ return [2 /*return*/, {
28758
+ paths: [],
28759
+ fallback: "blocking",
28760
+ }];
28761
+ return [4 /*yield*/, Promise.all(context.locales.map(function (locale) { return SettingsHelper.getSettings(locale); }))];
28509
28762
  case 1:
28510
- theme = _a.sent();
28511
- customPages = theme.pages.filter(function (p) { return p.type === exports.IkasThemePageType.CUSTOM; });
28512
- customPagePaths = customPages.map(function (p) { return ({
28513
- slug: p.slug,
28514
- }); });
28763
+ allSettings = (_a.sent());
28764
+ customPagePaths = [];
28765
+ allSettings.forEach(function (_a) {
28766
+ var themeLocalization = _a.themeLocalization, routing = _a.routing;
28767
+ if (!themeLocalization)
28768
+ return;
28769
+ var customPages = themeLocalization.themeJson.pages.filter(function (p) { return p.type === exports.IkasThemePageType.CUSTOM; });
28770
+ customPages.forEach(function (customPage) {
28771
+ if (customPage.slug &&
28772
+ !customPagePaths.some(function (p) { return p.params.slug === customPage.slug; })) {
28773
+ if (process.env.NEXT_PUBLIC_ENV === "local") {
28774
+ customPagePaths.push({
28775
+ params: { slug: customPage.slug },
28776
+ });
28777
+ }
28778
+ else {
28779
+ customPagePaths.push({
28780
+ params: { slug: customPage.slug },
28781
+ locale: routing.path || routing.id,
28782
+ });
28783
+ }
28784
+ }
28785
+ });
28786
+ });
28515
28787
  return [2 /*return*/, {
28516
28788
  paths: customPagePaths.map(function (p) { return ({
28517
- params: p,
28789
+ params: p.params,
28790
+ locale: p.locale,
28518
28791
  }); }),
28519
28792
  fallback: "blocking",
28520
28793
  }];
@@ -28522,17 +28795,10 @@ var getStaticPaths$1 = function (context) { return __awaiter(void 0, void 0, voi
28522
28795
  });
28523
28796
  }); };
28524
28797
  var getStaticProps$2 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28525
- var theme, provider;
28526
28798
  return __generator(this, function (_a) {
28527
28799
  switch (_a.label) {
28528
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28529
- case 1:
28530
- theme = _a.sent();
28531
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.CUSTOM);
28532
- return [4 /*yield*/, provider.getPageData()];
28533
- case 2:
28534
- _a.sent();
28535
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28800
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.CUSTOM)];
28801
+ case 1: return [2 /*return*/, _a.sent()];
28536
28802
  }
28537
28803
  });
28538
28804
  }); };
@@ -28545,18 +28811,37 @@ var _slug_ = /*#__PURE__*/Object.freeze({
28545
28811
  });
28546
28812
 
28547
28813
  var CheckoutPage = function (_a) {
28548
- var checkoutStr = _a.checkoutStr, queryParams = _a.queryParams;
28814
+ var checkoutStr = _a.checkoutStr, configJson = _a.configJson, others = __rest(_a, ["checkoutStr", "configJson"]);
28815
+ IkasStorefrontConfig.initWithJson(configJson);
28549
28816
  Analytics.disableHTML();
28550
28817
  var checkout = new IkasCheckout(JSON.parse(checkoutStr));
28551
- return React.createElement(IkasCheckoutPage, { checkout: checkout, queryParams: queryParams });
28818
+ return React.createElement(IkasCheckoutPage, __assign({ checkout: checkout }, others));
28552
28819
  };
28553
28820
  var _id_ = mobxReactLite.observer(CheckoutPage);
28554
28821
  var getServerSideProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28555
- var id, redirect, checkout;
28822
+ var id, locale, settings, storefront, themeLocalization, routing, redirect, checkout;
28556
28823
  return __generator(this, function (_a) {
28557
28824
  switch (_a.label) {
28558
28825
  case 0:
28559
28826
  id = context.query.id;
28827
+ locale = context.locale || context.defaultLocale || "en";
28828
+ return [4 /*yield*/, SettingsHelper.getSettings(locale)];
28829
+ case 1:
28830
+ settings = _a.sent();
28831
+ // TODO maybe remove this and convert this page to static
28832
+ if (!settings ||
28833
+ !settings.storefront.mainStorefrontThemeId ||
28834
+ !settings.storefront.salesChannelId) {
28835
+ return [2 /*return*/, {
28836
+ props: {},
28837
+ notFound: true,
28838
+ }];
28839
+ }
28840
+ storefront = settings.storefront, themeLocalization = settings.themeLocalization, routing = settings.routing;
28841
+ IkasStorefrontConfig.storefrontId = storefront.id;
28842
+ IkasStorefrontConfig.storefrontRoutingId = routing.id;
28843
+ IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
28844
+ IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
28560
28845
  redirect = function () {
28561
28846
  context.res.writeHead(302, { Location: "/" });
28562
28847
  context.res.end();
@@ -28566,12 +28851,15 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
28566
28851
  return [2 /*return*/, redirect()];
28567
28852
  }
28568
28853
  return [4 /*yield*/, IkasCheckoutAPI.getCheckoutById(id)];
28569
- case 1:
28854
+ case 2:
28570
28855
  checkout = _a.sent();
28571
28856
  if (checkout) {
28572
28857
  return [2 /*return*/, {
28573
28858
  props: {
28574
28859
  checkoutStr: JSON.stringify(checkout),
28860
+ returnPolicy: themeLocalization.returnPolicy || "",
28861
+ privacyPolicy: themeLocalization.privacyPolicy || "",
28862
+ termsOfService: themeLocalization.termsOfService || "",
28575
28863
  queryParams: context.query,
28576
28864
  },
28577
28865
  }];
@@ -28590,23 +28878,17 @@ var _id_$1 = /*#__PURE__*/Object.freeze({
28590
28878
  });
28591
28879
 
28592
28880
  var Page$3 = function (_a) {
28593
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28881
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28882
+ IkasStorefrontConfig.initWithJson(configJson);
28594
28883
  var router$1 = router.useRouter();
28595
28884
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28596
28885
  return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28597
28886
  };
28598
28887
  var getStaticProps$3 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28599
- var theme, provider;
28600
28888
  return __generator(this, function (_a) {
28601
28889
  switch (_a.label) {
28602
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28603
- case 1:
28604
- theme = _a.sent();
28605
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.ACCOUNT);
28606
- return [4 /*yield*/, provider.getPageData()];
28607
- case 2:
28608
- _a.sent();
28609
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28890
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.ACCOUNT)];
28891
+ case 1: return [2 /*return*/, _a.sent()];
28610
28892
  }
28611
28893
  });
28612
28894
  }); };
@@ -28618,23 +28900,17 @@ var index$3 = /*#__PURE__*/Object.freeze({
28618
28900
  });
28619
28901
 
28620
28902
  var Page$4 = function (_a) {
28621
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28903
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28904
+ IkasStorefrontConfig.initWithJson(configJson);
28622
28905
  var router$1 = router.useRouter();
28623
28906
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28624
28907
  return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28625
28908
  };
28626
28909
  var getStaticProps$4 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28627
- var theme, provider;
28628
28910
  return __generator(this, function (_a) {
28629
28911
  switch (_a.label) {
28630
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28631
- case 1:
28632
- theme = _a.sent();
28633
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.ADDRESSES);
28634
- return [4 /*yield*/, provider.getPageData()];
28635
- case 2:
28636
- _a.sent();
28637
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28912
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.ADDRESSES)];
28913
+ case 1: return [2 /*return*/, _a.sent()];
28638
28914
  }
28639
28915
  });
28640
28916
  }); };
@@ -28646,23 +28922,17 @@ var addresses = /*#__PURE__*/Object.freeze({
28646
28922
  });
28647
28923
 
28648
28924
  var Page$5 = function (_a) {
28649
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28925
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28926
+ IkasStorefrontConfig.initWithJson(configJson);
28650
28927
  var router$1 = router.useRouter();
28651
28928
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28652
28929
  return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28653
28930
  };
28654
28931
  var getStaticProps$5 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28655
- var theme, provider;
28656
28932
  return __generator(this, function (_a) {
28657
28933
  switch (_a.label) {
28658
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28659
- case 1:
28660
- theme = _a.sent();
28661
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.ORDERS);
28662
- return [4 /*yield*/, provider.getPageData()];
28663
- case 2:
28664
- _a.sent();
28665
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28934
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.ORDERS)];
28935
+ case 1: return [2 /*return*/, _a.sent()];
28666
28936
  }
28667
28937
  });
28668
28938
  }); };
@@ -28674,23 +28944,17 @@ var index$4 = /*#__PURE__*/Object.freeze({
28674
28944
  });
28675
28945
 
28676
28946
  var Page$6 = function (_a) {
28677
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
28947
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
28948
+ IkasStorefrontConfig.initWithJson(configJson);
28678
28949
  var router$1 = router.useRouter();
28679
28950
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28680
28951
  return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28681
28952
  };
28682
28953
  var getServerSideProps$1 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28683
- var theme, provider;
28684
28954
  return __generator(this, function (_a) {
28685
28955
  switch (_a.label) {
28686
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28687
- case 1:
28688
- theme = _a.sent();
28689
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.ORDER_DETAIL);
28690
- return [4 /*yield*/, provider.getPageData()];
28691
- case 2:
28692
- _a.sent();
28693
- return [2 /*return*/, provider.nextPageData];
28956
+ case 0: return [4 /*yield*/, SettingsHelper.getServerSideProps(context, exports.IkasThemePageType.ORDER_DETAIL)];
28957
+ case 1: return [2 /*return*/, _a.sent()];
28694
28958
  }
28695
28959
  });
28696
28960
  }); };
@@ -28702,23 +28966,17 @@ var _id_$2 = /*#__PURE__*/Object.freeze({
28702
28966
  });
28703
28967
 
28704
28968
  var Page$7 = function (_a) {
28705
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
28969
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
28970
+ IkasStorefrontConfig.initWithJson(configJson);
28706
28971
  var router$1 = router.useRouter();
28707
28972
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28708
28973
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28709
28974
  };
28710
28975
  var getStaticProps$6 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28711
- var theme, provider;
28712
28976
  return __generator(this, function (_a) {
28713
28977
  switch (_a.label) {
28714
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28715
- case 1:
28716
- theme = _a.sent();
28717
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.LOGIN);
28718
- return [4 /*yield*/, provider.getPageData()];
28719
- case 2:
28720
- _a.sent();
28721
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
28978
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.LOGIN)];
28979
+ case 1: return [2 /*return*/, _a.sent()];
28722
28980
  }
28723
28981
  });
28724
28982
  }); };
@@ -28730,23 +28988,17 @@ var login = /*#__PURE__*/Object.freeze({
28730
28988
  });
28731
28989
 
28732
28990
  var Page$8 = function (_a) {
28733
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
28991
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
28992
+ IkasStorefrontConfig.initWithJson(configJson);
28734
28993
  var router$1 = router.useRouter();
28735
28994
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28736
28995
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28737
28996
  };
28738
28997
  var getStaticProps$7 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28739
- var theme, provider;
28740
28998
  return __generator(this, function (_a) {
28741
28999
  switch (_a.label) {
28742
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28743
- case 1:
28744
- theme = _a.sent();
28745
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.REGISTER);
28746
- return [4 /*yield*/, provider.getPageData()];
28747
- case 2:
28748
- _a.sent();
28749
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29000
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.REGISTER)];
29001
+ case 1: return [2 /*return*/, _a.sent()];
28750
29002
  }
28751
29003
  });
28752
29004
  }); };
@@ -28758,23 +29010,17 @@ var register = /*#__PURE__*/Object.freeze({
28758
29010
  });
28759
29011
 
28760
29012
  var Page$9 = function (_a) {
28761
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29013
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29014
+ IkasStorefrontConfig.initWithJson(configJson);
28762
29015
  var router$1 = router.useRouter();
28763
29016
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28764
29017
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28765
29018
  };
28766
29019
  var getStaticProps$8 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28767
- var theme, provider;
28768
29020
  return __generator(this, function (_a) {
28769
29021
  switch (_a.label) {
28770
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28771
- case 1:
28772
- theme = _a.sent();
28773
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.FORGOT_PASSWORD);
28774
- return [4 /*yield*/, provider.getPageData()];
28775
- case 2:
28776
- _a.sent();
28777
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29022
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.FORGOT_PASSWORD)];
29023
+ case 1: return [2 /*return*/, _a.sent()];
28778
29024
  }
28779
29025
  });
28780
29026
  }); };
@@ -28786,23 +29032,17 @@ var forgotPassword = /*#__PURE__*/Object.freeze({
28786
29032
  });
28787
29033
 
28788
29034
  var Page$a = function (_a) {
28789
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29035
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29036
+ IkasStorefrontConfig.initWithJson(configJson);
28790
29037
  var router$1 = router.useRouter();
28791
29038
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28792
29039
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28793
29040
  };
28794
29041
  var getStaticProps$9 = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28795
- var theme, provider;
28796
29042
  return __generator(this, function (_a) {
28797
29043
  switch (_a.label) {
28798
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28799
- case 1:
28800
- theme = _a.sent();
28801
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.RECOVER_PASSWORD);
28802
- return [4 /*yield*/, provider.getPageData()];
28803
- case 2:
28804
- _a.sent();
28805
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29044
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.RECOVER_PASSWORD)];
29045
+ case 1: return [2 /*return*/, _a.sent()];
28806
29046
  }
28807
29047
  });
28808
29048
  }); };
@@ -28814,7 +29054,8 @@ var recoverPassword = /*#__PURE__*/Object.freeze({
28814
29054
  });
28815
29055
 
28816
29056
  var Page$b = function (_a) {
28817
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
29057
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
29058
+ IkasStorefrontConfig.initWithJson(configJson);
28818
29059
  var router$1 = router.useRouter();
28819
29060
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28820
29061
  var store = IkasStorefrontConfig.store;
@@ -28824,17 +29065,10 @@ var Page$b = function (_a) {
28824
29065
  return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28825
29066
  };
28826
29067
  var getStaticProps$a = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28827
- var theme, provider;
28828
29068
  return __generator(this, function (_a) {
28829
29069
  switch (_a.label) {
28830
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28831
- case 1:
28832
- theme = _a.sent();
28833
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.CART);
28834
- return [4 /*yield*/, provider.getPageData()];
28835
- case 2:
28836
- _a.sent();
28837
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29070
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.CART)];
29071
+ case 1: return [2 /*return*/, _a.sent()];
28838
29072
  }
28839
29073
  });
28840
29074
  }); };
@@ -28857,23 +29091,17 @@ var editor$1 = /*#__PURE__*/Object.freeze({
28857
29091
  });
28858
29092
 
28859
29093
  var Page$d = function (_a) {
28860
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr;
29094
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, configJson = _a.configJson;
29095
+ IkasStorefrontConfig.initWithJson(configJson);
28861
29096
  var router$1 = router.useRouter();
28862
29097
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28863
29098
  return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
28864
29099
  };
28865
29100
  var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28866
- var theme, provider;
28867
29101
  return __generator(this, function (_a) {
28868
29102
  switch (_a.label) {
28869
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28870
- case 1:
28871
- theme = _a.sent();
28872
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.FAVORITE_PRODUCTS);
28873
- return [4 /*yield*/, provider.getPageData()];
28874
- case 2:
28875
- _a.sent();
28876
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29103
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.FAVORITE_PRODUCTS)];
29104
+ case 1: return [2 /*return*/, _a.sent()];
28877
29105
  }
28878
29106
  });
28879
29107
  }); };
@@ -28885,7 +29113,8 @@ var favoriteProducts = /*#__PURE__*/Object.freeze({
28885
29113
  });
28886
29114
 
28887
29115
  var Page$e = function (_a) {
28888
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29116
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29117
+ IkasStorefrontConfig.initWithJson(configJson);
28889
29118
  var router$1 = router.useRouter();
28890
29119
  var _b = React.useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
28891
29120
  var initialPropValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
@@ -28899,17 +29128,10 @@ var Page$e = function (_a) {
28899
29128
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
28900
29129
  };
28901
29130
  var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28902
- var theme, provider;
28903
29131
  return __generator(this, function (_a) {
28904
29132
  switch (_a.label) {
28905
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
28906
- case 1:
28907
- theme = _a.sent();
28908
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.SEARCH);
28909
- return [4 /*yield*/, provider.getPageData()];
28910
- case 2:
28911
- _a.sent();
28912
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29133
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.SEARCH)];
29134
+ case 1: return [2 /*return*/, _a.sent()];
28913
29135
  }
28914
29136
  });
28915
29137
  }); };
@@ -28921,23 +29143,29 @@ var search = /*#__PURE__*/Object.freeze({
28921
29143
  });
28922
29144
 
28923
29145
  var Page$f = function (_a) {
28924
- var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings;
29146
+ var page = _a.page, propValuesStr = _a.propValuesStr, settingsStr = _a.settingsStr, merchantSettings = _a.merchantSettings, configJson = _a.configJson;
29147
+ if (!propValuesStr || !page)
29148
+ return React.createElement(Error__default['default'], { statusCode: 404 });
29149
+ IkasStorefrontConfig.initWithJson(configJson);
28925
29150
  var router$1 = router.useRouter();
28926
29151
  var propValues = React.useMemo(function () { return IkasPageDataProvider.initPropValues(propValuesStr, router$1); }, [propValuesStr]);
28927
29152
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
28928
29153
  };
28929
29154
  var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, void 0, function () {
28930
- var theme, provider;
29155
+ var props;
28931
29156
  return __generator(this, function (_a) {
28932
29157
  switch (_a.label) {
28933
- case 0: return [4 /*yield*/, IkasThemeAPI.fetchTheme()];
29158
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.NOT_FOUND)];
28934
29159
  case 1:
28935
- theme = _a.sent();
28936
- provider = new IkasPageDataProvider(theme, context.params, exports.IkasThemePageType.NOT_FOUND);
28937
- return [4 /*yield*/, provider.getPageData()];
28938
- case 2:
28939
- _a.sent();
28940
- return [2 /*return*/, __assign(__assign({}, provider.nextPageData), { revalidate: 60 })];
29160
+ props = _a.sent();
29161
+ //@ts-ignore
29162
+ if (props.notFound)
29163
+ return [2 /*return*/, {
29164
+ props: {},
29165
+ revalidate: 60,
29166
+ }];
29167
+ else
29168
+ return [2 /*return*/, props];
28941
29169
  }
28942
29170
  });
28943
29171
  }); };
@@ -28954,12 +29182,83 @@ mobx.configure({
28954
29182
  var IkasBaseStore = /** @class */ (function () {
28955
29183
  function IkasBaseStore() {
28956
29184
  this.currentPageType = null;
29185
+ this.localeOptions = [];
29186
+ this.showLocaleOptions = false;
29187
+ this.localeChecked = false;
28957
29188
  this.customerStore = new IkasCustomerStore(this);
28958
29189
  this.cartStore = new IkasCartStore(this);
28959
29190
  mobx.makeObservable(this, {
28960
29191
  currentPageType: mobx.observable,
29192
+ localeOptions: mobx.observable,
29193
+ showLocaleOptions: mobx.observable,
28961
29194
  });
28962
29195
  }
29196
+ IkasBaseStore.prototype.checkLocalization = function () {
29197
+ return __awaiter(this, void 0, void 0, function () {
29198
+ var myCountryCode, currentRouting, correctRouting, isCorrectLocale, countries_1, localeOptions_1;
29199
+ return __generator(this, function (_a) {
29200
+ switch (_a.label) {
29201
+ case 0:
29202
+ if (this.localeChecked)
29203
+ return [2 /*return*/];
29204
+ if (typeof window === undefined) {
29205
+ console.warn("checkRegion should be called on the client side!");
29206
+ return [2 /*return*/];
29207
+ }
29208
+ return [4 /*yield*/, IkasCountryAPI.getMyCountry()];
29209
+ case 1:
29210
+ myCountryCode = _a.sent();
29211
+ currentRouting = IkasStorefrontConfig.routings.find(function (r) { return r.id === IkasStorefrontConfig.storefrontRoutingId; });
29212
+ if (!(currentRouting && myCountryCode)) return [3 /*break*/, 3];
29213
+ correctRouting = IkasStorefrontConfig.routings.find(function (r) { var _a; return (_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode); });
29214
+ isCorrectLocale = IkasStorefrontConfig.storefrontRoutingId === (correctRouting === null || correctRouting === void 0 ? void 0 : correctRouting.id);
29215
+ return [4 /*yield*/, IkasCountryAPI.listCountries()];
29216
+ case 2:
29217
+ countries_1 = _a.sent();
29218
+ localeOptions_1 = [];
29219
+ IkasStorefrontConfig.routings.map(function (r) {
29220
+ var _a;
29221
+ if ((_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.length) {
29222
+ r.countryCodes.forEach(function (countryCode) {
29223
+ var _a;
29224
+ var country = countries_1.find(function (c) { return c.iso2 === countryCode; });
29225
+ localeOptions_1.push({
29226
+ id: v4(),
29227
+ countryName: (country === null || country === void 0 ? void 0 : country.native) || (country === null || country === void 0 ? void 0 : country.name) || "",
29228
+ routing: r,
29229
+ isRecommended: ((_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode)) || false,
29230
+ });
29231
+ });
29232
+ }
29233
+ else {
29234
+ localeOptions_1.push({
29235
+ id: v4(),
29236
+ routing: r,
29237
+ isRecommended: !IkasStorefrontConfig.routings.some(function (r) { var _a; return (_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode); }),
29238
+ });
29239
+ }
29240
+ });
29241
+ this.localeOptions = localeOptions_1;
29242
+ if (!isCorrectLocale) {
29243
+ this.showLocaleOptions = true;
29244
+ }
29245
+ this.localeChecked = true;
29246
+ _a.label = 3;
29247
+ case 3: return [2 /*return*/];
29248
+ }
29249
+ });
29250
+ });
29251
+ };
29252
+ IkasBaseStore.prototype.setLocalization = function (localeOption) {
29253
+ document.cookie = "NEXT_LOCALE=" + (localeOption.routing.path || localeOption.routing.id) + "; expires=Thu, 1 Dec 2050 12:00:00 UTC";
29254
+ if (localeOption.routing.domain) {
29255
+ window.location.replace("https://" + localeOption.routing.domain);
29256
+ }
29257
+ else {
29258
+ window.location.replace(window.location.origin +
29259
+ (localeOption.routing.path ? "/" + localeOption.routing.path : ""));
29260
+ }
29261
+ };
28963
29262
  return IkasBaseStore;
28964
29263
  }());
28965
29264
 
@@ -29037,10 +29336,8 @@ exports.IkasProductSearchAPI = IkasProductSearchAPI;
29037
29336
  exports.IkasProductVariant = IkasProductVariant;
29038
29337
  exports.IkasProductVariantType = IkasProductVariantType;
29039
29338
  exports.IkasStateAPI = IkasStateAPI;
29040
- exports.IkasStorefrontAPI = IkasStorefrontAPI;
29041
29339
  exports.IkasStorefrontConfig = IkasStorefrontConfig;
29042
29340
  exports.IkasTheme = IkasTheme;
29043
- exports.IkasThemeAPI = IkasThemeAPI;
29044
29341
  exports.IkasThemeComponent = IkasThemeComponent;
29045
29342
  exports.IkasThemeComponentProp = IkasThemeComponentProp;
29046
29343
  exports.IkasThemeCustomData = IkasThemeCustomData;