@ikas/storefront 0.0.115 → 0.0.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.es.js CHANGED
@@ -25842,7 +25842,9 @@ function simpleToProduct(simple) {
25842
25842
  ? p.priceListId === IkasStorefrontConfig.priceListId
25843
25843
  : p.priceListId === null;
25844
25844
  })),
25845
- stock: v.stocks.length ? v.stocks[0].stockCount : 0,
25845
+ stock: v.stocks
25846
+ .filter(function (s) { var _a; return (_a = IkasStorefrontConfig.stockLocationIds) === null || _a === void 0 ? void 0 : _a.includes(s.stockLocationId); })
25847
+ .reduce(function (total, current) { return current.stockCount + total; }, 0) || 0,
25846
25848
  variantValues: (_d = v.variantValues) === null || _d === void 0 ? void 0 : _d.map(function (vv) {
25847
25849
  var pvt = simple.productVariantTypes.find(function (pvt) { return pvt.variantType.id === vv.variantTypeId; });
25848
25850
  var variantValue = pvt === null || pvt === void 0 ? void 0 : pvt.variantType.values.find(function (_vv) { return _vv.id === vv.variantValueId; });
@@ -29403,7 +29405,7 @@ var IkasBaseStore = /** @class */ (function () {
29403
29405
  }
29404
29406
  IkasBaseStore.prototype.checkLocalization = function () {
29405
29407
  return __awaiter(this, void 0, void 0, function () {
29406
- var myCountryCode, currentRouting, otherCountriesRouting, correctRouting, isCorrectLocale, hasNoSpecificCountry, countries_1, localeOptions_1;
29408
+ var myCountryCode, currentRouting, isCorrectLocale, myCountryRouting, otherCountriesRouting, countries_1, localeOptions_1;
29407
29409
  return __generator(this, function (_a) {
29408
29410
  switch (_a.label) {
29409
29411
  case 0:
@@ -29418,14 +29420,21 @@ var IkasBaseStore = /** @class */ (function () {
29418
29420
  myCountryCode = _a.sent();
29419
29421
  currentRouting = IkasStorefrontConfig.routings.find(function (r) { return r.id === IkasStorefrontConfig.storefrontRoutingId; });
29420
29422
  if (!(currentRouting && myCountryCode)) return [3 /*break*/, 3];
29423
+ isCorrectLocale = true;
29424
+ myCountryRouting = IkasStorefrontConfig.routings.find(function (r) { var _a; return (_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode); });
29421
29425
  otherCountriesRouting = IkasStorefrontConfig.routings.find(function (r) { var _a; return !((_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.length); });
29422
- correctRouting = IkasStorefrontConfig.routings.find(function (r) { var _a; return (_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode); }) || otherCountriesRouting;
29423
- isCorrectLocale = IkasStorefrontConfig.storefrontRoutingId === (correctRouting === null || correctRouting === void 0 ? void 0 : correctRouting.id);
29424
- if (!isCorrectLocale) {
29425
- hasNoSpecificCountry = IkasStorefrontConfig.routings.length === 0 ||
29426
- IkasStorefrontConfig.routings.every(function (r) { var _a; return !((_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.length); });
29427
- if (hasNoSpecificCountry)
29428
- isCorrectLocale = true;
29426
+ // Current country has spefic routing
29427
+ if (myCountryRouting) {
29428
+ if (currentRouting.id !== myCountryRouting.id) {
29429
+ isCorrectLocale = false;
29430
+ }
29431
+ }
29432
+ // Current country does not have specific routing
29433
+ else {
29434
+ if (otherCountriesRouting &&
29435
+ currentRouting.id !== otherCountriesRouting.id) {
29436
+ isCorrectLocale = false;
29437
+ }
29429
29438
  }
29430
29439
  return [4 /*yield*/, IkasCountryAPI.listCountries()];
29431
29440
  case 2:
@@ -29453,7 +29462,7 @@ var IkasBaseStore = /** @class */ (function () {
29453
29462
  });
29454
29463
  }
29455
29464
  });
29456
- this.localeOptions = localeOptions_1;
29465
+ this.localeOptions = sortBy_1(localeOptions_1, "countryName");
29457
29466
  if (!isCorrectLocale) {
29458
29467
  this.showLocaleOptions = true;
29459
29468
  }
package/build/index.js CHANGED
@@ -25822,7 +25822,9 @@ function simpleToProduct(simple) {
25822
25822
  ? p.priceListId === IkasStorefrontConfig.priceListId
25823
25823
  : p.priceListId === null;
25824
25824
  })),
25825
- stock: v.stocks.length ? v.stocks[0].stockCount : 0,
25825
+ stock: v.stocks
25826
+ .filter(function (s) { var _a; return (_a = IkasStorefrontConfig.stockLocationIds) === null || _a === void 0 ? void 0 : _a.includes(s.stockLocationId); })
25827
+ .reduce(function (total, current) { return current.stockCount + total; }, 0) || 0,
25826
25828
  variantValues: (_d = v.variantValues) === null || _d === void 0 ? void 0 : _d.map(function (vv) {
25827
25829
  var pvt = simple.productVariantTypes.find(function (pvt) { return pvt.variantType.id === vv.variantTypeId; });
25828
25830
  var variantValue = pvt === null || pvt === void 0 ? void 0 : pvt.variantType.values.find(function (_vv) { return _vv.id === vv.variantValueId; });
@@ -29383,7 +29385,7 @@ var IkasBaseStore = /** @class */ (function () {
29383
29385
  }
29384
29386
  IkasBaseStore.prototype.checkLocalization = function () {
29385
29387
  return __awaiter(this, void 0, void 0, function () {
29386
- var myCountryCode, currentRouting, otherCountriesRouting, correctRouting, isCorrectLocale, hasNoSpecificCountry, countries_1, localeOptions_1;
29388
+ var myCountryCode, currentRouting, isCorrectLocale, myCountryRouting, otherCountriesRouting, countries_1, localeOptions_1;
29387
29389
  return __generator(this, function (_a) {
29388
29390
  switch (_a.label) {
29389
29391
  case 0:
@@ -29398,14 +29400,21 @@ var IkasBaseStore = /** @class */ (function () {
29398
29400
  myCountryCode = _a.sent();
29399
29401
  currentRouting = IkasStorefrontConfig.routings.find(function (r) { return r.id === IkasStorefrontConfig.storefrontRoutingId; });
29400
29402
  if (!(currentRouting && myCountryCode)) return [3 /*break*/, 3];
29403
+ isCorrectLocale = true;
29404
+ myCountryRouting = IkasStorefrontConfig.routings.find(function (r) { var _a; return (_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode); });
29401
29405
  otherCountriesRouting = IkasStorefrontConfig.routings.find(function (r) { var _a; return !((_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.length); });
29402
- correctRouting = IkasStorefrontConfig.routings.find(function (r) { var _a; return (_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.includes(myCountryCode); }) || otherCountriesRouting;
29403
- isCorrectLocale = IkasStorefrontConfig.storefrontRoutingId === (correctRouting === null || correctRouting === void 0 ? void 0 : correctRouting.id);
29404
- if (!isCorrectLocale) {
29405
- hasNoSpecificCountry = IkasStorefrontConfig.routings.length === 0 ||
29406
- IkasStorefrontConfig.routings.every(function (r) { var _a; return !((_a = r.countryCodes) === null || _a === void 0 ? void 0 : _a.length); });
29407
- if (hasNoSpecificCountry)
29408
- isCorrectLocale = true;
29406
+ // Current country has spefic routing
29407
+ if (myCountryRouting) {
29408
+ if (currentRouting.id !== myCountryRouting.id) {
29409
+ isCorrectLocale = false;
29410
+ }
29411
+ }
29412
+ // Current country does not have specific routing
29413
+ else {
29414
+ if (otherCountriesRouting &&
29415
+ currentRouting.id !== otherCountriesRouting.id) {
29416
+ isCorrectLocale = false;
29417
+ }
29409
29418
  }
29410
29419
  return [4 /*yield*/, IkasCountryAPI.listCountries()];
29411
29420
  case 2:
@@ -29433,7 +29442,7 @@ var IkasBaseStore = /** @class */ (function () {
29433
29442
  });
29434
29443
  }
29435
29444
  });
29436
- this.localeOptions = localeOptions_1;
29445
+ this.localeOptions = sortBy_1(localeOptions_1, "countryName");
29437
29446
  if (!isCorrectLocale) {
29438
29447
  this.showLocaleOptions = true;
29439
29448
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.115",
3
+ "version": "0.0.117",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",