@ikas/storefront 0.1.24-alpha.1 → 0.1.24-alpha.3

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.
@@ -36,6 +36,8 @@ export default class AddressFormViewModel {
36
36
  id?: string | undefined;
37
37
  name?: string | undefined;
38
38
  code?: string | undefined;
39
+ iso2?: string | undefined;
40
+ iso3?: string | undefined;
39
41
  } | {
40
42
  id?: string | undefined;
41
43
  name?: string | undefined;
@@ -45,6 +47,8 @@ export default class AddressFormViewModel {
45
47
  id?: string | undefined;
46
48
  name?: string | undefined;
47
49
  code?: string | undefined;
50
+ iso2?: string | undefined;
51
+ iso3?: string | undefined;
48
52
  } | {
49
53
  id?: string | undefined;
50
54
  name?: string | undefined;
@@ -54,6 +58,8 @@ export default class AddressFormViewModel {
54
58
  id?: string | undefined;
55
59
  name?: string | undefined;
56
60
  code?: string | undefined;
61
+ iso2?: string | undefined;
62
+ iso3?: string | undefined;
57
63
  } | {
58
64
  id?: string | undefined;
59
65
  name?: string | undefined;
@@ -63,6 +69,8 @@ export default class AddressFormViewModel {
63
69
  id?: string | undefined;
64
70
  name?: string | undefined;
65
71
  code?: string | undefined;
72
+ iso2?: string | undefined;
73
+ iso3?: string | undefined;
66
74
  } | {
67
75
  id?: string | undefined;
68
76
  name?: string | undefined;
package/build/index.es.js CHANGED
@@ -19822,6 +19822,7 @@ var IkasPaymentGateway = /** @class */ (function () {
19822
19822
  function IkasPaymentGateway(data) {
19823
19823
  var _a;
19824
19824
  this.supportedCurrencies = [];
19825
+ this.availableCountries = [];
19825
19826
  this.paymentMethods = data.paymentMethods || [];
19826
19827
  this.paymentMethodType =
19827
19828
  data.paymentMethodType || IkasPaymentMethodType.OTHER;
@@ -19836,6 +19837,7 @@ var IkasPaymentGateway = /** @class */ (function () {
19836
19837
  ((_a = data.additionalPrices) === null || _a === void 0 ? void 0 : _a.map(function (ap) { return new IkasPaymentGatewayAdditionalPrice(ap); })) || null;
19837
19838
  this.translations = data.translations || null;
19838
19839
  this.supportedCurrencies = data.supportedCurrencies || [];
19840
+ this.availableCountries = data.availableCountries || [];
19839
19841
  this.setTranslations();
19840
19842
  makeAutoObservable(this);
19841
19843
  }
@@ -23117,13 +23119,11 @@ var CheckoutViewModel = /** @class */ (function () {
23117
23119
  if (queryStep) {
23118
23120
  this.step = queryStep;
23119
23121
  if (this.step === CheckoutStep.SHIPPING && !this.canProceedToShipping) {
23120
- this.changeStep(CheckoutStep.INFO);
23121
- return [2 /*return*/];
23122
+ return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
23122
23123
  }
23123
23124
  else if (this.step === CheckoutStep.PAYMENT &&
23124
23125
  !this.canProceedToPayment) {
23125
- this.changeStep(CheckoutStep.INFO);
23126
- return [2 /*return*/];
23126
+ return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
23127
23127
  }
23128
23128
  else if (![
23129
23129
  CheckoutStep.INFO,
@@ -23131,8 +23131,7 @@ var CheckoutViewModel = /** @class */ (function () {
23131
23131
  CheckoutStep.SHIPPING,
23132
23132
  CheckoutStep.PAYMENT,
23133
23133
  ].includes(this.step)) {
23134
- this.changeStep(CheckoutStep.INFO);
23135
- return [2 /*return*/];
23134
+ return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
23136
23135
  }
23137
23136
  }
23138
23137
  if (queryFailed) {
@@ -23162,12 +23161,18 @@ var CheckoutViewModel = /** @class */ (function () {
23162
23161
  return [4 /*yield*/, this.listPaymentGateways()];
23163
23162
  case 3:
23164
23163
  _b.sent();
23164
+ if (!this.paymentGateways.length) {
23165
+ this.error = {
23166
+ type: ErrorType.NO_SHIPPING_ERROR,
23167
+ };
23168
+ this.isCheckoutLoaded = true;
23169
+ return [2 /*return*/];
23170
+ }
23165
23171
  _b.label = 4;
23166
23172
  case 4:
23167
23173
  if (!(this.step !== CheckoutStep.SUCCESS)) return [3 /*break*/, 8];
23168
23174
  if (!this.checkout.isComplete) return [3 /*break*/, 5];
23169
- this.changeStep(CheckoutStep.SUCCESS);
23170
- return [2 /*return*/];
23175
+ return [2 /*return*/, this.changeStep(CheckoutStep.SUCCESS)];
23171
23176
  case 5: return [4 /*yield*/, this.initialStockCheck()];
23172
23177
  case 6:
23173
23178
  _b.sent();
@@ -23350,27 +23355,38 @@ var CheckoutViewModel = /** @class */ (function () {
23350
23355
  });
23351
23356
  }); };
23352
23357
  this.listPaymentGateways = function () { return __awaiter(_this, void 0, void 0, function () {
23353
- var isLocal, idList, paymentGateways, orderedPaymentGateways;
23358
+ var isLocal, idList, paymentGateways, shippingCountry_1, orderedPaymentGateways;
23354
23359
  var _this = this;
23355
- return __generator(this, function (_a) {
23356
- switch (_a.label) {
23360
+ var _a;
23361
+ return __generator(this, function (_b) {
23362
+ switch (_b.label) {
23357
23363
  case 0:
23358
23364
  isLocal = process.env.NEXT_PUBLIC_ENV === "local";
23359
23365
  idList = IkasStorefrontConfig.paymentGateways.map(function (pg) { return pg.id; });
23360
23366
  return [4 /*yield*/, IkasCheckoutAPI.listPaymentGateway(isLocal ? undefined : idList)];
23361
23367
  case 1:
23362
- paymentGateways = _a.sent();
23368
+ paymentGateways = _b.sent();
23363
23369
  if (!paymentGateways || !paymentGateways.length) {
23364
23370
  this.error = {
23365
23371
  type: ErrorType.API_ERROR,
23366
23372
  };
23367
23373
  return [2 /*return*/];
23368
23374
  }
23369
- paymentGateways = paymentGateways.filter(function (pg) {
23370
- return pg.supportedCurrencies.length
23371
- ? pg.supportedCurrencies.includes(_this.checkout.cart.currencyCode)
23372
- : true;
23373
- });
23375
+ if (this.step === CheckoutStep.PAYMENT) {
23376
+ paymentGateways = paymentGateways.filter(function (pg) {
23377
+ return pg.supportedCurrencies.length
23378
+ ? pg.supportedCurrencies.includes(_this.checkout.cart.currencyCode)
23379
+ : true;
23380
+ });
23381
+ shippingCountry_1 = (_a = this.checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.country;
23382
+ if (shippingCountry_1) {
23383
+ paymentGateways = paymentGateways.filter(function (pg) {
23384
+ return pg.availableCountries.length
23385
+ ? pg.availableCountries.includes(shippingCountry_1.iso2 || "")
23386
+ : true;
23387
+ });
23388
+ }
23389
+ }
23374
23390
  orderedPaymentGateways = [];
23375
23391
  sortBy_1(IkasStorefrontConfig.paymentGateways, "order").forEach(function (pg) {
23376
23392
  var _pg = paymentGateways === null || paymentGateways === void 0 ? void 0 : paymentGateways.find(function (p) { return p.id === pg.id; });
@@ -23885,6 +23901,8 @@ var CheckoutViewModel = /** @class */ (function () {
23885
23901
  _this.addressTitle = value;
23886
23902
  };
23887
23903
  this.setPaymentGateway = function (index) {
23904
+ if (!_this.paymentGateways.length)
23905
+ return;
23888
23906
  var paymentGateway = _this.paymentGateways[index];
23889
23907
  _this.checkout.selectedPaymentGateway = paymentGateway;
23890
23908
  if (_this.step !== CheckoutStep.SUCCESS) {
@@ -40969,7 +40987,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
40969
40987
  return __generator(this, function (_b) {
40970
40988
  switch (_b.label) {
40971
40989
  case 0:
40972
- QUERY = src(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\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 barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\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 adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "], ["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\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 barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\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 adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "])));
40990
+ QUERY = src(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n iso2\n iso3\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\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 barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\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 adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "], ["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n iso2\n iso3\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\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 barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\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 adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "])));
40973
40991
  _b.label = 1;
40974
40992
  case 1:
40975
40993
  _b.trys.push([1, 3, , 4]);
@@ -41174,7 +41192,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
41174
41192
  return __generator(this, function (_b) {
41175
41193
  switch (_b.label) {
41176
41194
  case 0:
41177
- QUERY = src(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n }\n }\n "], ["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n }\n }\n "])));
41195
+ QUERY = src(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n availableCountries\n }\n }\n "], ["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n availableCountries\n }\n }\n "])));
41178
41196
  _b.label = 1;
41179
41197
  case 1:
41180
41198
  _b.trys.push([1, 3, , 4]);
@@ -68291,6 +68309,7 @@ var CustomerLoginRequiredError = observer(function (_a) {
68291
68309
  var Errors = function (_a) {
68292
68310
  var _b;
68293
68311
  var vm = _a.vm;
68312
+ var ref = useRef(null);
68294
68313
  var onErrorClose = useCallback(function () {
68295
68314
  vm.error = undefined;
68296
68315
  }, [vm]);
@@ -68314,7 +68333,10 @@ var Errors = function (_a) {
68314
68333
  }
68315
68334
  if (!error)
68316
68335
  return null;
68317
- return createElement("div", { style: { marginBottom: "24px" } }, error);
68336
+ if (ref.current) {
68337
+ ref.current.scrollIntoView();
68338
+ }
68339
+ return (createElement("div", { ref: ref, style: { marginBottom: "24px" } }, error));
68318
68340
  };
68319
68341
  var Errors$1 = observer(Errors);
68320
68342
 
@@ -68568,6 +68590,8 @@ var AddressFormViewModel = /** @class */ (function () {
68568
68590
  id: country === null || country === void 0 ? void 0 : country.id,
68569
68591
  name: country === null || country === void 0 ? void 0 : country.name,
68570
68592
  code: country === null || country === void 0 ? void 0 : country.iso3,
68593
+ iso2: country === null || country === void 0 ? void 0 : country.iso2,
68594
+ iso3: country === null || country === void 0 ? void 0 : country.iso3,
68571
68595
  };
68572
68596
  _this.address.state = undefined;
68573
68597
  _this.address.city = undefined;
package/build/index.js CHANGED
@@ -19837,6 +19837,7 @@ var IkasPaymentGateway = /** @class */ (function () {
19837
19837
  function IkasPaymentGateway(data) {
19838
19838
  var _a;
19839
19839
  this.supportedCurrencies = [];
19840
+ this.availableCountries = [];
19840
19841
  this.paymentMethods = data.paymentMethods || [];
19841
19842
  this.paymentMethodType =
19842
19843
  data.paymentMethodType || IkasPaymentMethodType.OTHER;
@@ -19851,6 +19852,7 @@ var IkasPaymentGateway = /** @class */ (function () {
19851
19852
  ((_a = data.additionalPrices) === null || _a === void 0 ? void 0 : _a.map(function (ap) { return new IkasPaymentGatewayAdditionalPrice(ap); })) || null;
19852
19853
  this.translations = data.translations || null;
19853
19854
  this.supportedCurrencies = data.supportedCurrencies || [];
19855
+ this.availableCountries = data.availableCountries || [];
19854
19856
  this.setTranslations();
19855
19857
  mobx.makeAutoObservable(this);
19856
19858
  }
@@ -23124,13 +23126,11 @@ var CheckoutViewModel = /** @class */ (function () {
23124
23126
  if (queryStep) {
23125
23127
  this.step = queryStep;
23126
23128
  if (this.step === CheckoutStep.SHIPPING && !this.canProceedToShipping) {
23127
- this.changeStep(CheckoutStep.INFO);
23128
- return [2 /*return*/];
23129
+ return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
23129
23130
  }
23130
23131
  else if (this.step === CheckoutStep.PAYMENT &&
23131
23132
  !this.canProceedToPayment) {
23132
- this.changeStep(CheckoutStep.INFO);
23133
- return [2 /*return*/];
23133
+ return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
23134
23134
  }
23135
23135
  else if (![
23136
23136
  CheckoutStep.INFO,
@@ -23138,8 +23138,7 @@ var CheckoutViewModel = /** @class */ (function () {
23138
23138
  CheckoutStep.SHIPPING,
23139
23139
  CheckoutStep.PAYMENT,
23140
23140
  ].includes(this.step)) {
23141
- this.changeStep(CheckoutStep.INFO);
23142
- return [2 /*return*/];
23141
+ return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
23143
23142
  }
23144
23143
  }
23145
23144
  if (queryFailed) {
@@ -23169,12 +23168,18 @@ var CheckoutViewModel = /** @class */ (function () {
23169
23168
  return [4 /*yield*/, this.listPaymentGateways()];
23170
23169
  case 3:
23171
23170
  _b.sent();
23171
+ if (!this.paymentGateways.length) {
23172
+ this.error = {
23173
+ type: ErrorType.NO_SHIPPING_ERROR,
23174
+ };
23175
+ this.isCheckoutLoaded = true;
23176
+ return [2 /*return*/];
23177
+ }
23172
23178
  _b.label = 4;
23173
23179
  case 4:
23174
23180
  if (!(this.step !== CheckoutStep.SUCCESS)) return [3 /*break*/, 8];
23175
23181
  if (!this.checkout.isComplete) return [3 /*break*/, 5];
23176
- this.changeStep(CheckoutStep.SUCCESS);
23177
- return [2 /*return*/];
23182
+ return [2 /*return*/, this.changeStep(CheckoutStep.SUCCESS)];
23178
23183
  case 5: return [4 /*yield*/, this.initialStockCheck()];
23179
23184
  case 6:
23180
23185
  _b.sent();
@@ -23357,27 +23362,38 @@ var CheckoutViewModel = /** @class */ (function () {
23357
23362
  });
23358
23363
  }); };
23359
23364
  this.listPaymentGateways = function () { return __awaiter(_this, void 0, void 0, function () {
23360
- var isLocal, idList, paymentGateways, orderedPaymentGateways;
23365
+ var isLocal, idList, paymentGateways, shippingCountry_1, orderedPaymentGateways;
23361
23366
  var _this = this;
23362
- return __generator(this, function (_a) {
23363
- switch (_a.label) {
23367
+ var _a;
23368
+ return __generator(this, function (_b) {
23369
+ switch (_b.label) {
23364
23370
  case 0:
23365
23371
  isLocal = process.env.NEXT_PUBLIC_ENV === "local";
23366
23372
  idList = IkasStorefrontConfig.paymentGateways.map(function (pg) { return pg.id; });
23367
23373
  return [4 /*yield*/, IkasCheckoutAPI.listPaymentGateway(isLocal ? undefined : idList)];
23368
23374
  case 1:
23369
- paymentGateways = _a.sent();
23375
+ paymentGateways = _b.sent();
23370
23376
  if (!paymentGateways || !paymentGateways.length) {
23371
23377
  this.error = {
23372
23378
  type: ErrorType.API_ERROR,
23373
23379
  };
23374
23380
  return [2 /*return*/];
23375
23381
  }
23376
- paymentGateways = paymentGateways.filter(function (pg) {
23377
- return pg.supportedCurrencies.length
23378
- ? pg.supportedCurrencies.includes(_this.checkout.cart.currencyCode)
23379
- : true;
23380
- });
23382
+ if (this.step === CheckoutStep.PAYMENT) {
23383
+ paymentGateways = paymentGateways.filter(function (pg) {
23384
+ return pg.supportedCurrencies.length
23385
+ ? pg.supportedCurrencies.includes(_this.checkout.cart.currencyCode)
23386
+ : true;
23387
+ });
23388
+ shippingCountry_1 = (_a = this.checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.country;
23389
+ if (shippingCountry_1) {
23390
+ paymentGateways = paymentGateways.filter(function (pg) {
23391
+ return pg.availableCountries.length
23392
+ ? pg.availableCountries.includes(shippingCountry_1.iso2 || "")
23393
+ : true;
23394
+ });
23395
+ }
23396
+ }
23381
23397
  orderedPaymentGateways = [];
23382
23398
  sortBy_1(IkasStorefrontConfig.paymentGateways, "order").forEach(function (pg) {
23383
23399
  var _pg = paymentGateways === null || paymentGateways === void 0 ? void 0 : paymentGateways.find(function (p) { return p.id === pg.id; });
@@ -23892,6 +23908,8 @@ var CheckoutViewModel = /** @class */ (function () {
23892
23908
  _this.addressTitle = value;
23893
23909
  };
23894
23910
  this.setPaymentGateway = function (index) {
23911
+ if (!_this.paymentGateways.length)
23912
+ return;
23895
23913
  var paymentGateway = _this.paymentGateways[index];
23896
23914
  _this.checkout.selectedPaymentGateway = paymentGateway;
23897
23915
  if (_this.step !== CheckoutStep.SUCCESS) {
@@ -40948,7 +40966,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
40948
40966
  return __generator(this, function (_b) {
40949
40967
  switch (_b.label) {
40950
40968
  case 0:
40951
- QUERY = src(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\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 barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\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 adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "], ["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\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 barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\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 adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "])));
40969
+ QUERY = src(templateObject_2$3 || (templateObject_2$3 = __makeTemplateObject(["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n iso2\n iso3\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\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 barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\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 adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "], ["\n query getCheckoutById($id: String!) {\n getCheckoutById(id: $id) {\n totalFinalPrice\n note\n availableShippingMethods {\n price\n rateName\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n }\n billingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n code\n id\n name\n iso2\n iso3\n }\n district {\n code\n id\n name\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n code\n id\n name\n }\n taxNumber\n taxOffice\n }\n cartId\n couponCode\n createdAt\n customer {\n email\n firstName\n id\n lastName\n notificationsAccepted\n }\n deleted\n id\n merchantId\n orderId\n orderNumber\n recoverEmailStatus\n recoveryStatus\n shippingAddress {\n id\n addressLine1\n addressLine2\n city {\n code\n id\n name\n }\n company\n country {\n id\n code\n name\n }\n district {\n name\n id\n code\n }\n firstName\n identityNumber\n isDefault\n lastName\n phone\n postalCode\n state {\n name\n id\n code\n }\n taxNumber\n taxOffice\n }\n shippingLines {\n title\n taxValue\n price\n shippingSettingsId\n shippingZoneRateId\n }\n shippingMethod\n shippingSettingsId\n shippingZoneRateId\n status\n updatedAt\n cart {\n createdAt\n currencyCode\n customerId\n dueDate\n id\n itemCount\n taxLines {\n price\n rate\n }\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 barcodeList\n id\n mainImageId\n name\n productId\n sku\n slug\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 adjustments {\n amount\n amountType\n name\n order\n type\n couponId\n appliedOrderLines {\n amount\n appliedQuantity\n orderLineId\n }\n }\n giftPackageLines {\n price\n taxValue\n }\n isGiftPackage\n giftPackageNote\n }\n }\n "])));
40952
40970
  _b.label = 1;
40953
40971
  case 1:
40954
40972
  _b.trys.push([1, 3, , 4]);
@@ -41153,7 +41171,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
41153
41171
  return __generator(this, function (_b) {
41154
41172
  switch (_b.label) {
41155
41173
  case 0:
41156
- QUERY = src(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n }\n }\n "], ["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n }\n }\n "])));
41174
+ QUERY = src(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n availableCountries\n }\n }\n "], ["\n query listPaymentGateway($id: StringFilterInput, $locale: String) {\n listPaymentGateway(id: $id, locale: $locale) {\n paymentMethods {\n name\n logoUrl\n }\n paymentMethodType\n id\n name\n description\n testMode\n code\n type\n logoUrl\n additionalPrices {\n amount\n amountType\n name\n type\n }\n translations {\n description\n locale\n name\n }\n supportedCurrencies\n availableCountries\n }\n }\n "])));
41157
41175
  _b.label = 1;
41158
41176
  case 1:
41159
41177
  _b.trys.push([1, 3, , 4]);
@@ -68270,6 +68288,7 @@ var CustomerLoginRequiredError = mobxReactLite.observer(function (_a) {
68270
68288
  var Errors = function (_a) {
68271
68289
  var _b;
68272
68290
  var vm = _a.vm;
68291
+ var ref = React.useRef(null);
68273
68292
  var onErrorClose = React.useCallback(function () {
68274
68293
  vm.error = undefined;
68275
68294
  }, [vm]);
@@ -68293,7 +68312,10 @@ var Errors = function (_a) {
68293
68312
  }
68294
68313
  if (!error)
68295
68314
  return null;
68296
- return React.createElement("div", { style: { marginBottom: "24px" } }, error);
68315
+ if (ref.current) {
68316
+ ref.current.scrollIntoView();
68317
+ }
68318
+ return (React.createElement("div", { ref: ref, style: { marginBottom: "24px" } }, error));
68297
68319
  };
68298
68320
  var Errors$1 = mobxReactLite.observer(Errors);
68299
68321
 
@@ -68547,6 +68569,8 @@ var AddressFormViewModel = /** @class */ (function () {
68547
68569
  id: country === null || country === void 0 ? void 0 : country.id,
68548
68570
  name: country === null || country === void 0 ? void 0 : country.name,
68549
68571
  code: country === null || country === void 0 ? void 0 : country.iso3,
68572
+ iso2: country === null || country === void 0 ? void 0 : country.iso2,
68573
+ iso3: country === null || country === void 0 ? void 0 : country.iso3,
68550
68574
  };
68551
68575
  _this.address.state = undefined;
68552
68576
  _this.address.city = undefined;
@@ -29,6 +29,8 @@ declare type IkasOrderAddressLocation = {
29
29
  id?: string;
30
30
  name?: string;
31
31
  code?: string;
32
+ iso2?: string;
33
+ iso3?: string;
32
34
  };
33
35
  export declare type IkasOrderAddressCountry = IkasOrderAddressLocation;
34
36
  export declare type IkasOrderAddressCity = IkasOrderAddressLocation;
@@ -12,6 +12,7 @@ export declare class IkasPaymentGateway {
12
12
  additionalPrices: IkasPaymentGatewayAdditionalPrice[] | null;
13
13
  translations: IkasPaymentGatewayTranslation[] | null;
14
14
  supportedCurrencies: string[];
15
+ availableCountries: string[];
15
16
  constructor(data: Partial<IkasPaymentGateway>);
16
17
  getCalculatedAdditionalPrices(totalFinalPrice: number, shippingLines: IkasOrderShippingLine[] | null): {
17
18
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.1.24-alpha.1",
3
+ "version": "0.1.24-alpha.3",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",