@ikas/storefront 0.1.23 → 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 +43 -15
- package/build/index.js +43 -15
- package/build/models/data/payment-gateway/index.d.ts +2 -0
- package/package.json +1 -1
package/build/index.es.js
CHANGED
|
@@ -19821,6 +19821,8 @@ var IkasCart = /** @class */ (function () {
|
|
|
19821
19821
|
var IkasPaymentGateway = /** @class */ (function () {
|
|
19822
19822
|
function IkasPaymentGateway(data) {
|
|
19823
19823
|
var _a;
|
|
19824
|
+
this.supportedCurrencies = [];
|
|
19825
|
+
this.availableCountries = [];
|
|
19824
19826
|
this.paymentMethods = data.paymentMethods || [];
|
|
19825
19827
|
this.paymentMethodType =
|
|
19826
19828
|
data.paymentMethodType || IkasPaymentMethodType.OTHER;
|
|
@@ -19834,6 +19836,8 @@ var IkasPaymentGateway = /** @class */ (function () {
|
|
|
19834
19836
|
this.additionalPrices =
|
|
19835
19837
|
((_a = data.additionalPrices) === null || _a === void 0 ? void 0 : _a.map(function (ap) { return new IkasPaymentGatewayAdditionalPrice(ap); })) || null;
|
|
19836
19838
|
this.translations = data.translations || null;
|
|
19839
|
+
this.supportedCurrencies = data.supportedCurrencies || [];
|
|
19840
|
+
this.availableCountries = data.availableCountries || [];
|
|
19837
19841
|
this.setTranslations();
|
|
19838
19842
|
makeAutoObservable(this);
|
|
19839
19843
|
}
|
|
@@ -23115,13 +23119,11 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23115
23119
|
if (queryStep) {
|
|
23116
23120
|
this.step = queryStep;
|
|
23117
23121
|
if (this.step === CheckoutStep.SHIPPING && !this.canProceedToShipping) {
|
|
23118
|
-
this.changeStep(CheckoutStep.INFO);
|
|
23119
|
-
return [2 /*return*/];
|
|
23122
|
+
return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
|
|
23120
23123
|
}
|
|
23121
23124
|
else if (this.step === CheckoutStep.PAYMENT &&
|
|
23122
23125
|
!this.canProceedToPayment) {
|
|
23123
|
-
this.changeStep(CheckoutStep.INFO);
|
|
23124
|
-
return [2 /*return*/];
|
|
23126
|
+
return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
|
|
23125
23127
|
}
|
|
23126
23128
|
else if (![
|
|
23127
23129
|
CheckoutStep.INFO,
|
|
@@ -23129,8 +23131,7 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23129
23131
|
CheckoutStep.SHIPPING,
|
|
23130
23132
|
CheckoutStep.PAYMENT,
|
|
23131
23133
|
].includes(this.step)) {
|
|
23132
|
-
this.changeStep(CheckoutStep.INFO);
|
|
23133
|
-
return [2 /*return*/];
|
|
23134
|
+
return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
|
|
23134
23135
|
}
|
|
23135
23136
|
}
|
|
23136
23137
|
if (queryFailed) {
|
|
@@ -23160,12 +23161,18 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23160
23161
|
return [4 /*yield*/, this.listPaymentGateways()];
|
|
23161
23162
|
case 3:
|
|
23162
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
|
+
}
|
|
23163
23171
|
_b.label = 4;
|
|
23164
23172
|
case 4:
|
|
23165
23173
|
if (!(this.step !== CheckoutStep.SUCCESS)) return [3 /*break*/, 8];
|
|
23166
23174
|
if (!this.checkout.isComplete) return [3 /*break*/, 5];
|
|
23167
|
-
this.changeStep(CheckoutStep.SUCCESS);
|
|
23168
|
-
return [2 /*return*/];
|
|
23175
|
+
return [2 /*return*/, this.changeStep(CheckoutStep.SUCCESS)];
|
|
23169
23176
|
case 5: return [4 /*yield*/, this.initialStockCheck()];
|
|
23170
23177
|
case 6:
|
|
23171
23178
|
_b.sent();
|
|
@@ -23348,24 +23355,39 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23348
23355
|
});
|
|
23349
23356
|
}); };
|
|
23350
23357
|
this.listPaymentGateways = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
23351
|
-
var isLocal, idList, paymentGateways, orderedPaymentGateways;
|
|
23352
|
-
|
|
23353
|
-
|
|
23358
|
+
var isLocal, idList, paymentGateways, shippingCountry, orderedPaymentGateways;
|
|
23359
|
+
var _this = this;
|
|
23360
|
+
var _a;
|
|
23361
|
+
return __generator(this, function (_b) {
|
|
23362
|
+
switch (_b.label) {
|
|
23354
23363
|
case 0:
|
|
23355
23364
|
isLocal = process.env.NEXT_PUBLIC_ENV === "local";
|
|
23356
23365
|
idList = IkasStorefrontConfig.paymentGateways.map(function (pg) { return pg.id; });
|
|
23357
23366
|
return [4 /*yield*/, IkasCheckoutAPI.listPaymentGateway(isLocal ? undefined : idList)];
|
|
23358
23367
|
case 1:
|
|
23359
|
-
paymentGateways =
|
|
23368
|
+
paymentGateways = _b.sent();
|
|
23360
23369
|
if (!paymentGateways || !paymentGateways.length) {
|
|
23361
23370
|
this.error = {
|
|
23362
23371
|
type: ErrorType.API_ERROR,
|
|
23363
23372
|
};
|
|
23364
23373
|
return [2 /*return*/];
|
|
23365
23374
|
}
|
|
23375
|
+
paymentGateways = paymentGateways.filter(function (pg) {
|
|
23376
|
+
return pg.supportedCurrencies.length
|
|
23377
|
+
? pg.supportedCurrencies.includes(_this.checkout.cart.currencyCode)
|
|
23378
|
+
: true;
|
|
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
|
+
}
|
|
23366
23388
|
orderedPaymentGateways = [];
|
|
23367
23389
|
sortBy_1(IkasStorefrontConfig.paymentGateways, "order").forEach(function (pg) {
|
|
23368
|
-
var _pg = paymentGateways.find(function (p) { return p.id === pg.id; });
|
|
23390
|
+
var _pg = paymentGateways === null || paymentGateways === void 0 ? void 0 : paymentGateways.find(function (p) { return p.id === pg.id; });
|
|
23369
23391
|
if (_pg)
|
|
23370
23392
|
orderedPaymentGateways.push(_pg);
|
|
23371
23393
|
});
|
|
@@ -23877,6 +23899,8 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23877
23899
|
_this.addressTitle = value;
|
|
23878
23900
|
};
|
|
23879
23901
|
this.setPaymentGateway = function (index) {
|
|
23902
|
+
if (!_this.paymentGateways.length)
|
|
23903
|
+
return;
|
|
23880
23904
|
var paymentGateway = _this.paymentGateways[index];
|
|
23881
23905
|
_this.checkout.selectedPaymentGateway = paymentGateway;
|
|
23882
23906
|
if (_this.step !== CheckoutStep.SUCCESS) {
|
|
@@ -41166,7 +41190,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
|
|
|
41166
41190
|
return __generator(this, function (_b) {
|
|
41167
41191
|
switch (_b.label) {
|
|
41168
41192
|
case 0:
|
|
41169
|
-
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 }\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 }\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 "])));
|
|
41170
41194
|
_b.label = 1;
|
|
41171
41195
|
case 1:
|
|
41172
41196
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -68283,6 +68307,7 @@ var CustomerLoginRequiredError = observer(function (_a) {
|
|
|
68283
68307
|
var Errors = function (_a) {
|
|
68284
68308
|
var _b;
|
|
68285
68309
|
var vm = _a.vm;
|
|
68310
|
+
var ref = useRef(null);
|
|
68286
68311
|
var onErrorClose = useCallback(function () {
|
|
68287
68312
|
vm.error = undefined;
|
|
68288
68313
|
}, [vm]);
|
|
@@ -68306,7 +68331,10 @@ var Errors = function (_a) {
|
|
|
68306
68331
|
}
|
|
68307
68332
|
if (!error)
|
|
68308
68333
|
return null;
|
|
68309
|
-
|
|
68334
|
+
if (ref.current) {
|
|
68335
|
+
ref.current.scrollIntoView();
|
|
68336
|
+
}
|
|
68337
|
+
return (createElement("div", { ref: ref, style: { marginBottom: "24px" } }, error));
|
|
68310
68338
|
};
|
|
68311
68339
|
var Errors$1 = observer(Errors);
|
|
68312
68340
|
|
package/build/index.js
CHANGED
|
@@ -19836,6 +19836,8 @@ var IkasCart = /** @class */ (function () {
|
|
|
19836
19836
|
var IkasPaymentGateway = /** @class */ (function () {
|
|
19837
19837
|
function IkasPaymentGateway(data) {
|
|
19838
19838
|
var _a;
|
|
19839
|
+
this.supportedCurrencies = [];
|
|
19840
|
+
this.availableCountries = [];
|
|
19839
19841
|
this.paymentMethods = data.paymentMethods || [];
|
|
19840
19842
|
this.paymentMethodType =
|
|
19841
19843
|
data.paymentMethodType || IkasPaymentMethodType.OTHER;
|
|
@@ -19849,6 +19851,8 @@ var IkasPaymentGateway = /** @class */ (function () {
|
|
|
19849
19851
|
this.additionalPrices =
|
|
19850
19852
|
((_a = data.additionalPrices) === null || _a === void 0 ? void 0 : _a.map(function (ap) { return new IkasPaymentGatewayAdditionalPrice(ap); })) || null;
|
|
19851
19853
|
this.translations = data.translations || null;
|
|
19854
|
+
this.supportedCurrencies = data.supportedCurrencies || [];
|
|
19855
|
+
this.availableCountries = data.availableCountries || [];
|
|
19852
19856
|
this.setTranslations();
|
|
19853
19857
|
mobx.makeAutoObservable(this);
|
|
19854
19858
|
}
|
|
@@ -23122,13 +23126,11 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23122
23126
|
if (queryStep) {
|
|
23123
23127
|
this.step = queryStep;
|
|
23124
23128
|
if (this.step === CheckoutStep.SHIPPING && !this.canProceedToShipping) {
|
|
23125
|
-
this.changeStep(CheckoutStep.INFO);
|
|
23126
|
-
return [2 /*return*/];
|
|
23129
|
+
return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
|
|
23127
23130
|
}
|
|
23128
23131
|
else if (this.step === CheckoutStep.PAYMENT &&
|
|
23129
23132
|
!this.canProceedToPayment) {
|
|
23130
|
-
this.changeStep(CheckoutStep.INFO);
|
|
23131
|
-
return [2 /*return*/];
|
|
23133
|
+
return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
|
|
23132
23134
|
}
|
|
23133
23135
|
else if (![
|
|
23134
23136
|
CheckoutStep.INFO,
|
|
@@ -23136,8 +23138,7 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23136
23138
|
CheckoutStep.SHIPPING,
|
|
23137
23139
|
CheckoutStep.PAYMENT,
|
|
23138
23140
|
].includes(this.step)) {
|
|
23139
|
-
this.changeStep(CheckoutStep.INFO);
|
|
23140
|
-
return [2 /*return*/];
|
|
23141
|
+
return [2 /*return*/, this.changeStep(CheckoutStep.INFO)];
|
|
23141
23142
|
}
|
|
23142
23143
|
}
|
|
23143
23144
|
if (queryFailed) {
|
|
@@ -23167,12 +23168,18 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23167
23168
|
return [4 /*yield*/, this.listPaymentGateways()];
|
|
23168
23169
|
case 3:
|
|
23169
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
|
+
}
|
|
23170
23178
|
_b.label = 4;
|
|
23171
23179
|
case 4:
|
|
23172
23180
|
if (!(this.step !== CheckoutStep.SUCCESS)) return [3 /*break*/, 8];
|
|
23173
23181
|
if (!this.checkout.isComplete) return [3 /*break*/, 5];
|
|
23174
|
-
this.changeStep(CheckoutStep.SUCCESS);
|
|
23175
|
-
return [2 /*return*/];
|
|
23182
|
+
return [2 /*return*/, this.changeStep(CheckoutStep.SUCCESS)];
|
|
23176
23183
|
case 5: return [4 /*yield*/, this.initialStockCheck()];
|
|
23177
23184
|
case 6:
|
|
23178
23185
|
_b.sent();
|
|
@@ -23355,24 +23362,39 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23355
23362
|
});
|
|
23356
23363
|
}); };
|
|
23357
23364
|
this.listPaymentGateways = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
23358
|
-
var isLocal, idList, paymentGateways, orderedPaymentGateways;
|
|
23359
|
-
|
|
23360
|
-
|
|
23365
|
+
var isLocal, idList, paymentGateways, shippingCountry, orderedPaymentGateways;
|
|
23366
|
+
var _this = this;
|
|
23367
|
+
var _a;
|
|
23368
|
+
return __generator(this, function (_b) {
|
|
23369
|
+
switch (_b.label) {
|
|
23361
23370
|
case 0:
|
|
23362
23371
|
isLocal = process.env.NEXT_PUBLIC_ENV === "local";
|
|
23363
23372
|
idList = IkasStorefrontConfig.paymentGateways.map(function (pg) { return pg.id; });
|
|
23364
23373
|
return [4 /*yield*/, IkasCheckoutAPI.listPaymentGateway(isLocal ? undefined : idList)];
|
|
23365
23374
|
case 1:
|
|
23366
|
-
paymentGateways =
|
|
23375
|
+
paymentGateways = _b.sent();
|
|
23367
23376
|
if (!paymentGateways || !paymentGateways.length) {
|
|
23368
23377
|
this.error = {
|
|
23369
23378
|
type: ErrorType.API_ERROR,
|
|
23370
23379
|
};
|
|
23371
23380
|
return [2 /*return*/];
|
|
23372
23381
|
}
|
|
23382
|
+
paymentGateways = paymentGateways.filter(function (pg) {
|
|
23383
|
+
return pg.supportedCurrencies.length
|
|
23384
|
+
? pg.supportedCurrencies.includes(_this.checkout.cart.currencyCode)
|
|
23385
|
+
: true;
|
|
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
|
+
}
|
|
23373
23395
|
orderedPaymentGateways = [];
|
|
23374
23396
|
sortBy_1(IkasStorefrontConfig.paymentGateways, "order").forEach(function (pg) {
|
|
23375
|
-
var _pg = paymentGateways.find(function (p) { return p.id === pg.id; });
|
|
23397
|
+
var _pg = paymentGateways === null || paymentGateways === void 0 ? void 0 : paymentGateways.find(function (p) { return p.id === pg.id; });
|
|
23376
23398
|
if (_pg)
|
|
23377
23399
|
orderedPaymentGateways.push(_pg);
|
|
23378
23400
|
});
|
|
@@ -23884,6 +23906,8 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
23884
23906
|
_this.addressTitle = value;
|
|
23885
23907
|
};
|
|
23886
23908
|
this.setPaymentGateway = function (index) {
|
|
23909
|
+
if (!_this.paymentGateways.length)
|
|
23910
|
+
return;
|
|
23887
23911
|
var paymentGateway = _this.paymentGateways[index];
|
|
23888
23912
|
_this.checkout.selectedPaymentGateway = paymentGateway;
|
|
23889
23913
|
if (_this.step !== CheckoutStep.SUCCESS) {
|
|
@@ -41145,7 +41169,7 @@ var IkasCheckoutAPI = /** @class */ (function () {
|
|
|
41145
41169
|
return __generator(this, function (_b) {
|
|
41146
41170
|
switch (_b.label) {
|
|
41147
41171
|
case 0:
|
|
41148
|
-
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 }\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 }\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 "])));
|
|
41149
41173
|
_b.label = 1;
|
|
41150
41174
|
case 1:
|
|
41151
41175
|
_b.trys.push([1, 3, , 4]);
|
|
@@ -68262,6 +68286,7 @@ var CustomerLoginRequiredError = mobxReactLite.observer(function (_a) {
|
|
|
68262
68286
|
var Errors = function (_a) {
|
|
68263
68287
|
var _b;
|
|
68264
68288
|
var vm = _a.vm;
|
|
68289
|
+
var ref = React.useRef(null);
|
|
68265
68290
|
var onErrorClose = React.useCallback(function () {
|
|
68266
68291
|
vm.error = undefined;
|
|
68267
68292
|
}, [vm]);
|
|
@@ -68285,7 +68310,10 @@ var Errors = function (_a) {
|
|
|
68285
68310
|
}
|
|
68286
68311
|
if (!error)
|
|
68287
68312
|
return null;
|
|
68288
|
-
|
|
68313
|
+
if (ref.current) {
|
|
68314
|
+
ref.current.scrollIntoView();
|
|
68315
|
+
}
|
|
68316
|
+
return (React.createElement("div", { ref: ref, style: { marginBottom: "24px" } }, error));
|
|
68289
68317
|
};
|
|
68290
68318
|
var Errors$1 = mobxReactLite.observer(Errors);
|
|
68291
68319
|
|
|
@@ -11,6 +11,8 @@ export declare class IkasPaymentGateway {
|
|
|
11
11
|
description: string | null;
|
|
12
12
|
additionalPrices: IkasPaymentGatewayAdditionalPrice[] | null;
|
|
13
13
|
translations: IkasPaymentGatewayTranslation[] | null;
|
|
14
|
+
supportedCurrencies: string[];
|
|
15
|
+
availableCountries: string[];
|
|
14
16
|
constructor(data: Partial<IkasPaymentGateway>);
|
|
15
17
|
getCalculatedAdditionalPrices(totalFinalPrice: number, shippingLines: IkasOrderShippingLine[] | null): {
|
|
16
18
|
name: string;
|