@ikas/storefront 0.1.24-alpha.1 → 0.1.24-alpha.2
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 +34 -14
- package/build/index.js +34 -14
- package/build/models/data/payment-gateway/index.d.ts +1 -0
- package/package.json +1 -1
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,16 +23355,17 @@ 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, orderedPaymentGateways;
|
|
23354
23359
|
var _this = this;
|
|
23355
|
-
|
|
23356
|
-
|
|
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 =
|
|
23368
|
+
paymentGateways = _b.sent();
|
|
23363
23369
|
if (!paymentGateways || !paymentGateways.length) {
|
|
23364
23370
|
this.error = {
|
|
23365
23371
|
type: ErrorType.API_ERROR,
|
|
@@ -23371,6 +23377,14 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23371
23377
|
? pg.supportedCurrencies.includes(_this.checkout.cart.currencyCode)
|
|
23372
23378
|
: true;
|
|
23373
23379
|
});
|
|
23380
|
+
shippingCountry = (_a = this.checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.country;
|
|
23381
|
+
if (shippingCountry) {
|
|
23382
|
+
paymentGateways = paymentGateways.filter(function (pg) {
|
|
23383
|
+
return pg.availableCountries.length
|
|
23384
|
+
? pg.availableCountries.includes(shippingCountry.code || "")
|
|
23385
|
+
: true;
|
|
23386
|
+
});
|
|
23387
|
+
}
|
|
23374
23388
|
orderedPaymentGateways = [];
|
|
23375
23389
|
sortBy_1(IkasStorefrontConfig.paymentGateways, "order").forEach(function (pg) {
|
|
23376
23390
|
var _pg = paymentGateways === null || paymentGateways === void 0 ? void 0 : paymentGateways.find(function (p) { return p.id === pg.id; });
|
|
@@ -23885,6 +23899,8 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23885
23899
|
_this.addressTitle = value;
|
|
23886
23900
|
};
|
|
23887
23901
|
this.setPaymentGateway = function (index) {
|
|
23902
|
+
if (!_this.paymentGateways.length)
|
|
23903
|
+
return;
|
|
23888
23904
|
var paymentGateway = _this.paymentGateways[index];
|
|
23889
23905
|
_this.checkout.selectedPaymentGateway = paymentGateway;
|
|
23890
23906
|
if (_this.step !== CheckoutStep.SUCCESS) {
|
|
@@ -41174,7 +41190,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
|
|
|
41174
41190
|
return __generator(this, function (_b) {
|
|
41175
41191
|
switch (_b.label) {
|
|
41176
41192
|
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 "])));
|
|
41193
|
+
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
41194
|
_b.label = 1;
|
|
41179
41195
|
case 1:
|
|
41180
41196
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -68291,6 +68307,7 @@ var CustomerLoginRequiredError = observer(function (_a) {
|
|
|
68291
68307
|
var Errors = function (_a) {
|
|
68292
68308
|
var _b;
|
|
68293
68309
|
var vm = _a.vm;
|
|
68310
|
+
var ref = useRef(null);
|
|
68294
68311
|
var onErrorClose = useCallback(function () {
|
|
68295
68312
|
vm.error = undefined;
|
|
68296
68313
|
}, [vm]);
|
|
@@ -68314,7 +68331,10 @@ var Errors = function (_a) {
|
|
|
68314
68331
|
}
|
|
68315
68332
|
if (!error)
|
|
68316
68333
|
return null;
|
|
68317
|
-
|
|
68334
|
+
if (ref.current) {
|
|
68335
|
+
ref.current.scrollIntoView();
|
|
68336
|
+
}
|
|
68337
|
+
return (createElement("div", { ref: ref, style: { marginBottom: "24px" } }, error));
|
|
68318
68338
|
};
|
|
68319
68339
|
var Errors$1 = observer(Errors);
|
|
68320
68340
|
|
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,16 +23362,17 @@ 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, orderedPaymentGateways;
|
|
23361
23366
|
var _this = this;
|
|
23362
|
-
|
|
23363
|
-
|
|
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 =
|
|
23375
|
+
paymentGateways = _b.sent();
|
|
23370
23376
|
if (!paymentGateways || !paymentGateways.length) {
|
|
23371
23377
|
this.error = {
|
|
23372
23378
|
type: ErrorType.API_ERROR,
|
|
@@ -23378,6 +23384,14 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23378
23384
|
? pg.supportedCurrencies.includes(_this.checkout.cart.currencyCode)
|
|
23379
23385
|
: true;
|
|
23380
23386
|
});
|
|
23387
|
+
shippingCountry = (_a = this.checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.country;
|
|
23388
|
+
if (shippingCountry) {
|
|
23389
|
+
paymentGateways = paymentGateways.filter(function (pg) {
|
|
23390
|
+
return pg.availableCountries.length
|
|
23391
|
+
? pg.availableCountries.includes(shippingCountry.code || "")
|
|
23392
|
+
: true;
|
|
23393
|
+
});
|
|
23394
|
+
}
|
|
23381
23395
|
orderedPaymentGateways = [];
|
|
23382
23396
|
sortBy_1(IkasStorefrontConfig.paymentGateways, "order").forEach(function (pg) {
|
|
23383
23397
|
var _pg = paymentGateways === null || paymentGateways === void 0 ? void 0 : paymentGateways.find(function (p) { return p.id === pg.id; });
|
|
@@ -23892,6 +23906,8 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23892
23906
|
_this.addressTitle = value;
|
|
23893
23907
|
};
|
|
23894
23908
|
this.setPaymentGateway = function (index) {
|
|
23909
|
+
if (!_this.paymentGateways.length)
|
|
23910
|
+
return;
|
|
23895
23911
|
var paymentGateway = _this.paymentGateways[index];
|
|
23896
23912
|
_this.checkout.selectedPaymentGateway = paymentGateway;
|
|
23897
23913
|
if (_this.step !== CheckoutStep.SUCCESS) {
|
|
@@ -41153,7 +41169,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
|
|
|
41153
41169
|
return __generator(this, function (_b) {
|
|
41154
41170
|
switch (_b.label) {
|
|
41155
41171
|
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 "])));
|
|
41172
|
+
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
41173
|
_b.label = 1;
|
|
41158
41174
|
case 1:
|
|
41159
41175
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -68270,6 +68286,7 @@ var CustomerLoginRequiredError = mobxReactLite.observer(function (_a) {
|
|
|
68270
68286
|
var Errors = function (_a) {
|
|
68271
68287
|
var _b;
|
|
68272
68288
|
var vm = _a.vm;
|
|
68289
|
+
var ref = React.useRef(null);
|
|
68273
68290
|
var onErrorClose = React.useCallback(function () {
|
|
68274
68291
|
vm.error = undefined;
|
|
68275
68292
|
}, [vm]);
|
|
@@ -68293,7 +68310,10 @@ var Errors = function (_a) {
|
|
|
68293
68310
|
}
|
|
68294
68311
|
if (!error)
|
|
68295
68312
|
return null;
|
|
68296
|
-
|
|
68313
|
+
if (ref.current) {
|
|
68314
|
+
ref.current.scrollIntoView();
|
|
68315
|
+
}
|
|
68316
|
+
return (React.createElement("div", { ref: ref, style: { marginBottom: "24px" } }, error));
|
|
68297
68317
|
};
|
|
68298
68318
|
var Errors$1 = mobxReactLite.observer(Errors);
|
|
68299
68319
|
|
|
@@ -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;
|