@ikas/storefront 4.0.0-alpha.49 → 4.0.0-alpha.5
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/package.json +13 -13
- package/src/analytics/analytics.ts +1 -2
- package/src/analytics/googleUniversal.ts +2 -12
- package/src/analytics/head/index.tsx +2 -1
- package/src/analytics/ikas.ts +7 -25
- package/src/components/checkout/components/address-form/index.tsx +1 -1
- package/src/components/checkout/components/address-form/model.ts +0 -1
- package/src/components/checkout/components/button/style.module.scss +2 -2
- package/src/components/checkout/components/cart-summary/cart-item/index.tsx +29 -16
- package/src/components/checkout/components/cart-summary/cart-item/style.module.scss +23 -60
- package/src/components/checkout/components/cart-summary/index.tsx +27 -58
- package/src/components/checkout/components/cart-summary/style.module.scss +3 -48
- package/src/components/checkout/components/customer-addresses/index.tsx +2 -7
- package/src/components/checkout/components/customer-addresses/model.ts +8 -16
- package/src/components/checkout/components/error/index.tsx +1 -1
- package/src/components/checkout/components/error/unknown-error/index.tsx +2 -4
- package/src/components/checkout/components/form-item/index.tsx +11 -9
- package/src/components/checkout/components/master-pass/credit-card-form/index.tsx +0 -2
- package/src/components/checkout/components/offer-product/index.tsx +19 -16
- package/src/components/checkout/components/offer-product/style.module.scss +3 -1
- package/src/components/checkout/components/phone-number-input/get-countries.ts +5 -37
- package/src/components/checkout/components/phone-number-input/index.tsx +10 -15
- package/src/components/checkout/components/phone-number-input/locale/en.ts +257 -0
- package/src/components/checkout/index.tsx +19 -28
- package/src/components/checkout/model.ts +91 -214
- package/src/components/checkout/modelMasterPass.ts +2 -2
- package/src/components/checkout/steps/step-info/index.tsx +3 -9
- package/src/components/checkout/steps/step-payment/billing-address/index.tsx +1 -1
- package/src/components/checkout/steps/step-payment/index.tsx +2 -11
- package/src/components/checkout/steps/step-payment/payment-gateways/index.tsx +3 -12
- package/src/components/checkout/steps/step-payment/payment-gateways/installments/index.tsx +3 -5
- package/src/components/checkout/steps/step-payment/style.module.scss +0 -5
- package/src/components/checkout/steps/step-shipping/index.tsx +4 -9
- package/src/components/checkout/steps/step-success/index.tsx +7 -15
- package/src/components/page/head.tsx +0 -12
- package/src/components/page/index.tsx +9 -10
- package/src/components/page-editor/ThemeComponentEditor.tsx +8 -19
- package/src/components/page-editor/model.ts +107 -44
- package/src/models/data/cart/campaign-offer/index.ts +2 -13
- package/src/models/data/cart/index.ts +1 -1
- package/src/models/data/category/init.ts +33 -0
- package/src/models/data/category/path-item/index.ts +0 -4
- package/src/models/data/checkout/index.ts +4 -36
- package/src/models/data/checkout-settings/price/index.ts +0 -2
- package/src/models/data/country/index.ts +0 -4
- package/src/models/data/index.ts +0 -3
- package/src/models/data/merchant-settings/index.ts +0 -9
- package/src/models/data/order/index.ts +32 -51
- package/src/models/data/order/line-item/index.ts +18 -76
- package/src/models/data/order/line-item/variant/index.ts +0 -8
- package/src/models/data/order/line-item/variant/price/index.ts +0 -2
- package/src/models/data/order/line-item/variant/value/index.ts +1 -1
- package/src/models/data/order/transaction/index.ts +5 -2
- package/src/models/data/product/attribute-value/index.ts +0 -40
- package/src/models/data/product/filter/index.ts +13 -4
- package/src/models/data/product/index.ts +7 -45
- package/src/models/data/product/option-set/index.ts +3 -8
- package/src/models/data/product/option-set/option/index.ts +13 -36
- package/src/models/data/product/variant/index.ts +1 -26
- package/src/models/data/product/variant/price/index.ts +9 -25
- package/src/models/data/product/variant-type/index.ts +0 -2
- package/src/models/data/raffle/index.ts +7 -9
- package/src/models/data/state/index.ts +2 -6
- package/src/models/data/storefront/index.ts +0 -2
- package/src/models/data/storefront/routing/index.tsx +0 -4
- package/src/models/ui/product-list/index.ts +17 -26
- package/src/models/ui/raffle-list/index.ts +1 -1
- package/src/models/ui/validator/form/raffle-form.ts +3 -16
- package/src/models/ui/validator/rules/index.ts +13 -14
- package/src/page-data-init/index.ts +404 -159
- package/src/pages/checkout.tsx +1 -2
- package/src/pages/editor.tsx +2 -5
- package/src/store/base.ts +2 -2
- package/src/store/cart/index.ts +2 -2
- package/src/store/customer/index.ts +17 -7
- package/src/store/index.ts +0 -2
- package/src/store/raffle/index.ts +10 -7
- package/src/utils/constants.ts +1 -1
- package/src/utils/currency.ts +183 -9
- package/src/models/data/country/location-translations/index.ts +0 -15
- package/src/models/data/order/line-item/base-unit/index.ts +0 -22
- package/src/models/data/order/line-item/base-unit/unit-type/index.ts +0 -14
- package/src/models/data/order/line-item/variant/unit/index.ts +0 -17
- package/src/models/data/product/base-unit/index.ts +0 -32
- package/src/models/data/product/variant/unit/index.ts +0 -17
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
IkasOrderCustomer,
|
|
13
13
|
IkasCartCampaignOfferStatus,
|
|
14
14
|
IkasProduct,
|
|
15
|
-
IkasProductVariant,
|
|
16
15
|
IkasCartCampaignOffer,
|
|
17
16
|
IkasCheckout,
|
|
18
17
|
IkasStockLocation,
|
|
@@ -20,7 +19,6 @@ import {
|
|
|
20
19
|
IkasTransactionStatus,
|
|
21
20
|
IkasCampaignOfferTargetPageType,
|
|
22
21
|
IkasCampaignOfferProduct,
|
|
23
|
-
IkasOrderShippingMethod,
|
|
24
22
|
} from "../../models";
|
|
25
23
|
import { IkasOrderAddress } from "../../models/data/order/address";
|
|
26
24
|
import {
|
|
@@ -93,8 +91,8 @@ export default class CheckoutViewModel {
|
|
|
93
91
|
|
|
94
92
|
stripeResponse: CreateStripePaymentIntentResponse | null = null;
|
|
95
93
|
|
|
96
|
-
checkoutCampaignOffer
|
|
97
|
-
postCheckoutCampaignOffer
|
|
94
|
+
checkoutCampaignOffer: CampaignOfferType | undefined;
|
|
95
|
+
postCheckoutCampaignOffer: CampaignOfferType | undefined;
|
|
98
96
|
|
|
99
97
|
returnPolicy: string;
|
|
100
98
|
privacyPolicy: string;
|
|
@@ -175,11 +173,6 @@ export default class CheckoutViewModel {
|
|
|
175
173
|
} else {
|
|
176
174
|
return this.changeStep(CheckoutStep.INFO);
|
|
177
175
|
}
|
|
178
|
-
} else if (
|
|
179
|
-
this.step === CheckoutStep.SUCCESS &&
|
|
180
|
-
!this.canProceedToPayment
|
|
181
|
-
) {
|
|
182
|
-
return this.changeStep(CheckoutStep.INFO);
|
|
183
176
|
} else if (
|
|
184
177
|
![
|
|
185
178
|
CheckoutStep.INFO,
|
|
@@ -256,6 +249,12 @@ export default class CheckoutViewModel {
|
|
|
256
249
|
}
|
|
257
250
|
}
|
|
258
251
|
|
|
252
|
+
if (this.step === CheckoutStep.PAYMENT) {
|
|
253
|
+
if (this.isInStoreDelivery) {
|
|
254
|
+
this.checkout.billingAddress = new IkasOrderAddress();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
259
258
|
if (this.step !== CheckoutStep.SUCCESS) {
|
|
260
259
|
if (this.checkout.isComplete) {
|
|
261
260
|
return this.changeStep(CheckoutStep.SUCCESS);
|
|
@@ -366,9 +365,7 @@ export default class CheckoutViewModel {
|
|
|
366
365
|
|
|
367
366
|
get canProceedToShipping() {
|
|
368
367
|
return (
|
|
369
|
-
|
|
370
|
-
? this.checkout.billingAddress?.isValid
|
|
371
|
-
: this.checkout.shippingAddress?.isValid) &&
|
|
368
|
+
this.checkout.shippingAddress?.isValid &&
|
|
372
369
|
this.checkout.hasValidCustomerEmail &&
|
|
373
370
|
this.error?.type !== ErrorType.NO_SHIPPING_ERROR
|
|
374
371
|
);
|
|
@@ -434,12 +431,6 @@ export default class CheckoutViewModel {
|
|
|
434
431
|
);
|
|
435
432
|
}
|
|
436
433
|
|
|
437
|
-
get isDigitalOnly() {
|
|
438
|
-
return (
|
|
439
|
-
this.checkout.shippingMethod === IkasOrderShippingMethod.DIGITAL_DELIVERY
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
434
|
// VALIDATIONS END
|
|
444
435
|
|
|
445
436
|
saveCart = async () => {
|
|
@@ -449,18 +440,10 @@ export default class CheckoutViewModel {
|
|
|
449
440
|
input = await this.inStockDeliveryInputData(input);
|
|
450
441
|
}
|
|
451
442
|
|
|
452
|
-
if (
|
|
453
|
-
(this.step === CheckoutStep.INFO ||
|
|
454
|
-
this.step === CheckoutStep.SHIPPING) &&
|
|
455
|
-
!this.isDigitalOnly
|
|
456
|
-
) {
|
|
443
|
+
if (this.step === CheckoutStep.INFO) {
|
|
457
444
|
input.billingAddress = null;
|
|
458
445
|
}
|
|
459
446
|
|
|
460
|
-
if (this.isDigitalOnly) {
|
|
461
|
-
input.shippingAddress = null;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
447
|
const response = await CartStoreAPI.saveCart({ input });
|
|
465
448
|
|
|
466
449
|
if (response?.graphQLErrors && response.graphQLErrors.length) {
|
|
@@ -473,7 +456,6 @@ export default class CheckoutViewModel {
|
|
|
473
456
|
} else {
|
|
474
457
|
throw {
|
|
475
458
|
type: ErrorType.API_ERROR,
|
|
476
|
-
data: response.firstErrorMessage,
|
|
477
459
|
};
|
|
478
460
|
}
|
|
479
461
|
}
|
|
@@ -528,7 +510,6 @@ export default class CheckoutViewModel {
|
|
|
528
510
|
if (!checkStocksResponse.isSuccess) {
|
|
529
511
|
throw {
|
|
530
512
|
type: ErrorType.API_ERROR,
|
|
531
|
-
data: checkStocksResponse.firstErrorMessage,
|
|
532
513
|
};
|
|
533
514
|
}
|
|
534
515
|
|
|
@@ -574,7 +555,6 @@ export default class CheckoutViewModel {
|
|
|
574
555
|
if (!response.isSuccess || !response.data?.length) {
|
|
575
556
|
this.error = {
|
|
576
557
|
type: ErrorType.API_ERROR,
|
|
577
|
-
data: response.firstErrorMessage,
|
|
578
558
|
};
|
|
579
559
|
return;
|
|
580
560
|
}
|
|
@@ -628,7 +608,7 @@ export default class CheckoutViewModel {
|
|
|
628
608
|
try {
|
|
629
609
|
await this.checkStocks();
|
|
630
610
|
} catch (err) {
|
|
631
|
-
if (
|
|
611
|
+
if (err.type) {
|
|
632
612
|
this.error = err;
|
|
633
613
|
} else {
|
|
634
614
|
console.log(err);
|
|
@@ -652,7 +632,6 @@ export default class CheckoutViewModel {
|
|
|
652
632
|
) {
|
|
653
633
|
this.error = {
|
|
654
634
|
type: ErrorType.API_ERROR,
|
|
655
|
-
data: paymentGatewaysResponse.firstErrorMessage,
|
|
656
635
|
};
|
|
657
636
|
return;
|
|
658
637
|
}
|
|
@@ -725,29 +704,18 @@ export default class CheckoutViewModel {
|
|
|
725
704
|
this.checkout.customer = new IkasOrderCustomer(
|
|
726
705
|
this.store.customerStore.customer as any
|
|
727
706
|
);
|
|
728
|
-
} else
|
|
729
|
-
this.checkout.customer = new IkasOrderCustomer(
|
|
730
|
-
this.checkout.customer || {}
|
|
731
|
-
);
|
|
732
|
-
}
|
|
707
|
+
} else if (!this.checkout.customer)
|
|
708
|
+
this.checkout.customer = new IkasOrderCustomer({});
|
|
733
709
|
};
|
|
734
710
|
|
|
735
711
|
createShippingAddress = () => {
|
|
736
|
-
if (this.isDigitalOnly) return;
|
|
737
|
-
|
|
738
712
|
if (!this.checkout.shippingAddress) {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
customerAddresses?.length ? customerAddresses[0].id! : "-1"
|
|
743
|
-
);
|
|
744
|
-
} else {
|
|
745
|
-
this.onSelectedShippingAddressIdChange("-1");
|
|
746
|
-
}
|
|
747
|
-
} else {
|
|
748
|
-
this.checkout.shippingAddress = new IkasOrderAddress(
|
|
749
|
-
_cloneDeep(this.checkout.shippingAddress) || {}
|
|
713
|
+
const customerAddresses = this.store.customerStore.customer?.addresses;
|
|
714
|
+
this.onSelectedShippingAddressIdChange(
|
|
715
|
+
customerAddresses?.length ? customerAddresses[0].id! : "-1"
|
|
750
716
|
);
|
|
717
|
+
} else {
|
|
718
|
+
this.selectedShippingAddressId = this.checkout.shippingAddress.id || "-1";
|
|
751
719
|
this.checkout.shippingAddress.checkoutSettings = this.checkoutSettings;
|
|
752
720
|
}
|
|
753
721
|
};
|
|
@@ -758,21 +726,25 @@ export default class CheckoutViewModel {
|
|
|
758
726
|
USE_DIFFERENT_ADDRESS_KEY
|
|
759
727
|
);
|
|
760
728
|
|
|
761
|
-
if (
|
|
762
|
-
if (
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
729
|
+
if (this.useDifferentAddress) {
|
|
730
|
+
if (this.checkout.billingAddress) {
|
|
731
|
+
this.selectedBillingAddressId =
|
|
732
|
+
this.checkout.billingAddress.id || "-1";
|
|
733
|
+
}
|
|
734
|
+
this.checkout.billingAddress =
|
|
735
|
+
this.checkout.billingAddress || new IkasOrderAddress();
|
|
736
|
+
} else {
|
|
737
|
+
if (this.isInStoreDelivery) {
|
|
738
|
+
this.checkout.billingAddress = new IkasOrderAddress(
|
|
739
|
+
_cloneDeep(this.checkout.billingAddress) || {}
|
|
766
740
|
);
|
|
767
741
|
} else {
|
|
768
|
-
this.
|
|
742
|
+
this.checkout.billingAddress = new IkasOrderAddress(
|
|
743
|
+
_cloneDeep(this.checkout.shippingAddress) || {}
|
|
744
|
+
);
|
|
769
745
|
}
|
|
770
|
-
} else {
|
|
771
|
-
this.checkout.billingAddress = new IkasOrderAddress(
|
|
772
|
-
_cloneDeep(this.checkout.billingAddress) || {}
|
|
773
|
-
);
|
|
774
|
-
this.checkout.billingAddress.checkoutSettings = this.checkoutSettings;
|
|
775
746
|
}
|
|
747
|
+
this.checkout.billingAddress.checkoutSettings = this.checkoutSettings;
|
|
776
748
|
}
|
|
777
749
|
};
|
|
778
750
|
|
|
@@ -787,8 +759,6 @@ export default class CheckoutViewModel {
|
|
|
787
759
|
const newCart = await this.saveCart();
|
|
788
760
|
|
|
789
761
|
if (newCart) this.checkout = new IkasCheckout(newCart);
|
|
790
|
-
if (this.checkout.shippingAddress)
|
|
791
|
-
this.checkout.shippingAddress.checkoutSettings = this.checkoutSettings;
|
|
792
762
|
this.isChangingShippingMethod = false;
|
|
793
763
|
};
|
|
794
764
|
|
|
@@ -1013,9 +983,6 @@ export default class CheckoutViewModel {
|
|
|
1013
983
|
customer.addresses.push(newAddress);
|
|
1014
984
|
|
|
1015
985
|
await this.store.customerStore.saveCustomer(customer);
|
|
1016
|
-
this.store.customerStore.customer.addresses?.forEach(
|
|
1017
|
-
(address) => (address.checkoutSettings = this.checkoutSettings)
|
|
1018
|
-
);
|
|
1019
986
|
|
|
1020
987
|
if (type === "shipping") {
|
|
1021
988
|
this.checkout.shippingAddress!.id = newAddress.id;
|
|
@@ -1068,34 +1035,6 @@ export default class CheckoutViewModel {
|
|
|
1068
1035
|
} else {
|
|
1069
1036
|
this.changeStep(CheckoutStep.PAYMENT);
|
|
1070
1037
|
}
|
|
1071
|
-
} catch (err) {
|
|
1072
|
-
if (typeof err.type !== undefined) {
|
|
1073
|
-
this.error = err;
|
|
1074
|
-
} else {
|
|
1075
|
-
console.log(err);
|
|
1076
|
-
this.error = {
|
|
1077
|
-
type: ErrorType.UNKNOWN,
|
|
1078
|
-
};
|
|
1079
|
-
}
|
|
1080
|
-
this.isStepLoading = false;
|
|
1081
|
-
}
|
|
1082
|
-
};
|
|
1083
|
-
|
|
1084
|
-
onProceedToDigitalOnlyPaymentClick = async () => {
|
|
1085
|
-
if (!this.canProceedToPayment) {
|
|
1086
|
-
this.isErrorsVisible = true;
|
|
1087
|
-
return;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
this.isErrorsVisible = false;
|
|
1091
|
-
|
|
1092
|
-
try {
|
|
1093
|
-
this.isStepLoading = true;
|
|
1094
|
-
|
|
1095
|
-
await this.checkStocks();
|
|
1096
|
-
await this.saveCart();
|
|
1097
|
-
|
|
1098
|
-
this.changeStep(CheckoutStep.PAYMENT);
|
|
1099
1038
|
} catch (err) {
|
|
1100
1039
|
if (err.type) {
|
|
1101
1040
|
this.error = err;
|
|
@@ -1124,7 +1063,7 @@ export default class CheckoutViewModel {
|
|
|
1124
1063
|
this.error = undefined;
|
|
1125
1064
|
this.changeStep(CheckoutStep.PAYMENT);
|
|
1126
1065
|
} catch (err) {
|
|
1127
|
-
if (
|
|
1066
|
+
if (err.type) {
|
|
1128
1067
|
this.error = err;
|
|
1129
1068
|
} else {
|
|
1130
1069
|
console.log(err);
|
|
@@ -1166,46 +1105,6 @@ export default class CheckoutViewModel {
|
|
|
1166
1105
|
return;
|
|
1167
1106
|
}
|
|
1168
1107
|
|
|
1169
|
-
await this.createSaleTransaction();
|
|
1170
|
-
} catch (err) {
|
|
1171
|
-
if (typeof err.type !== undefined) {
|
|
1172
|
-
this.error = err;
|
|
1173
|
-
} else {
|
|
1174
|
-
this.error = {
|
|
1175
|
-
type: ErrorType.UNKNOWN,
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
this.isStepLoading = false;
|
|
1179
|
-
}
|
|
1180
|
-
};
|
|
1181
|
-
|
|
1182
|
-
onCompleteDigitalOnlyPaymentClick = async () => {
|
|
1183
|
-
if (
|
|
1184
|
-
!this.canProceedToPayment ||
|
|
1185
|
-
(this.checkoutSettings.showTermsAndConditionsCheckbox &&
|
|
1186
|
-
!this.isTermsAndConditionsChecked)
|
|
1187
|
-
) {
|
|
1188
|
-
this.isErrorsVisible = true;
|
|
1189
|
-
return;
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
try {
|
|
1193
|
-
this.isErrorsVisible = false;
|
|
1194
|
-
this.isStepLoading = true;
|
|
1195
|
-
|
|
1196
|
-
await this.checkStocks();
|
|
1197
|
-
await this.saveCart();
|
|
1198
|
-
|
|
1199
|
-
if (this.isCustomFlowStripe) {
|
|
1200
|
-
const stripeFromBtn = document.querySelector("#stripe-form-btn");
|
|
1201
|
-
if (stripeFromBtn) {
|
|
1202
|
-
//@ts-ignore
|
|
1203
|
-
stripeFromBtn.click();
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
return;
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
1108
|
await this.createSaleTransaction();
|
|
1210
1109
|
} catch (err) {
|
|
1211
1110
|
if (err.type) {
|
|
@@ -1295,7 +1194,6 @@ export default class CheckoutViewModel {
|
|
|
1295
1194
|
process.env.NEXT_PUBLIC_BASE_URL + response.data.returnSlug;
|
|
1296
1195
|
} else {
|
|
1297
1196
|
throw {
|
|
1298
|
-
data: response.firstErrorMessage,
|
|
1299
1197
|
type: ErrorType.UNKNOWN,
|
|
1300
1198
|
};
|
|
1301
1199
|
}
|
|
@@ -1418,25 +1316,32 @@ export default class CheckoutViewModel {
|
|
|
1418
1316
|
this.isContactModalVisible = value;
|
|
1419
1317
|
};
|
|
1420
1318
|
|
|
1421
|
-
|
|
1319
|
+
getWaitingForActionCampaignOffer = (
|
|
1422
1320
|
targetPage: IkasCampaignOfferTargetPageType
|
|
1423
1321
|
) => {
|
|
1424
|
-
if (
|
|
1425
|
-
|
|
1322
|
+
if (this.checkout.campaignOffers && this.checkout.campaignOffers.length) {
|
|
1323
|
+
const filteredCampaignOffer = this.checkout.campaignOffers.filter(
|
|
1324
|
+
(co) =>
|
|
1325
|
+
co.status === IkasCartCampaignOfferStatus.WAITING_FOR_ACTION &&
|
|
1326
|
+
co.campaignOffer?.targetPageTypes.some((tpt) => tpt === targetPage)
|
|
1327
|
+
);
|
|
1426
1328
|
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
return
|
|
1329
|
+
if (filteredCampaignOffer.length) {
|
|
1330
|
+
return filteredCampaignOffer[0];
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
return null;
|
|
1433
1335
|
};
|
|
1434
1336
|
|
|
1435
1337
|
getOffer = (waitingForActionCampaignOffer: IkasCartCampaignOffer) => {
|
|
1436
|
-
if (
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1338
|
+
if (waitingForActionCampaignOffer.campaignOffer) {
|
|
1339
|
+
return waitingForActionCampaignOffer.campaignOffer.offers.find(
|
|
1340
|
+
(o) => o.id === waitingForActionCampaignOffer.campaignOfferProductId
|
|
1341
|
+
);
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
return null;
|
|
1440
1345
|
};
|
|
1441
1346
|
|
|
1442
1347
|
getProduct = async (productId: string) => {
|
|
@@ -1446,88 +1351,61 @@ export default class CheckoutViewModel {
|
|
|
1446
1351
|
},
|
|
1447
1352
|
});
|
|
1448
1353
|
|
|
1449
|
-
if (
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
};
|
|
1462
|
-
|
|
1463
|
-
getOfferProductVariants = ({
|
|
1464
|
-
offer,
|
|
1465
|
-
product,
|
|
1466
|
-
}: {
|
|
1467
|
-
offer: IkasCampaignOfferProduct;
|
|
1468
|
-
product: IkasProduct;
|
|
1469
|
-
}) => {
|
|
1470
|
-
const variants: IkasProductVariant[] = [];
|
|
1471
|
-
|
|
1472
|
-
if (offer.excludedVariantIdList?.length) {
|
|
1473
|
-
product.variants.forEach((v) => {
|
|
1474
|
-
const isVariantExcluded = offer!.excludedVariantIdList?.some(
|
|
1475
|
-
(ev) => ev === v.id
|
|
1476
|
-
);
|
|
1477
|
-
if (!v.hasStock || isVariantExcluded) return;
|
|
1478
|
-
|
|
1479
|
-
variants.push(v);
|
|
1354
|
+
if (
|
|
1355
|
+
productsResponse.isSuccess &&
|
|
1356
|
+
productsResponse.data &&
|
|
1357
|
+
productsResponse.data.data &&
|
|
1358
|
+
productsResponse.data.data.length
|
|
1359
|
+
) {
|
|
1360
|
+
const product = productsResponse.data.data[0];
|
|
1361
|
+
const selectedVariant = product.variants.find((v) => v.isActive);
|
|
1362
|
+
const productDetail = new IkasProduct({
|
|
1363
|
+
...product,
|
|
1364
|
+
selectedVariantValues: (selectedVariant || product.variants[0])
|
|
1365
|
+
.variantValues,
|
|
1480
1366
|
});
|
|
1481
|
-
|
|
1482
|
-
|
|
1367
|
+
|
|
1368
|
+
return productDetail;
|
|
1483
1369
|
}
|
|
1484
1370
|
|
|
1485
|
-
return
|
|
1371
|
+
return null;
|
|
1486
1372
|
};
|
|
1487
1373
|
|
|
1488
1374
|
getCampaignOfferProducts = async (
|
|
1489
1375
|
targetPage: IkasCampaignOfferTargetPageType
|
|
1490
|
-
)
|
|
1491
|
-
const
|
|
1492
|
-
this.
|
|
1376
|
+
) => {
|
|
1377
|
+
const waitingForActionCampaignOffer =
|
|
1378
|
+
this.getWaitingForActionCampaignOffer(targetPage);
|
|
1493
1379
|
|
|
1494
1380
|
if (
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
)
|
|
1498
|
-
return;
|
|
1499
|
-
|
|
1500
|
-
for (let i = 0; i < waitingForActionCampaignOffers.length; i++) {
|
|
1501
|
-
const waitingForActionCampaignOffer = waitingForActionCampaignOffers[i];
|
|
1502
|
-
|
|
1381
|
+
waitingForActionCampaignOffer &&
|
|
1382
|
+
waitingForActionCampaignOffer.campaignOffer
|
|
1383
|
+
) {
|
|
1503
1384
|
const offer = this.getOffer(waitingForActionCampaignOffer);
|
|
1504
|
-
if (!offer) continue;
|
|
1505
1385
|
|
|
1506
|
-
|
|
1507
|
-
|
|
1386
|
+
if (offer) {
|
|
1387
|
+
const productDetail = await this.getProduct(offer.productId);
|
|
1508
1388
|
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
variants,
|
|
1518
|
-
campaignOffer: waitingForActionCampaignOffer,
|
|
1519
|
-
offer,
|
|
1520
|
-
};
|
|
1389
|
+
if (productDetail) {
|
|
1390
|
+
return {
|
|
1391
|
+
productDetail,
|
|
1392
|
+
campaignOffer: waitingForActionCampaignOffer,
|
|
1393
|
+
offer,
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1521
1397
|
}
|
|
1398
|
+
|
|
1399
|
+
return undefined;
|
|
1522
1400
|
};
|
|
1523
1401
|
|
|
1524
1402
|
getCampaignOffer = async () => {
|
|
1525
|
-
this.checkoutCampaignOffer = await this.getCampaignOfferProducts(
|
|
1403
|
+
this.checkoutCampaignOffer = (await this.getCampaignOfferProducts(
|
|
1526
1404
|
IkasCampaignOfferTargetPageType.CHECKOUT
|
|
1527
|
-
);
|
|
1528
|
-
this.postCheckoutCampaignOffer = await this.getCampaignOfferProducts(
|
|
1405
|
+
)) as any;
|
|
1406
|
+
this.postCheckoutCampaignOffer = (await this.getCampaignOfferProducts(
|
|
1529
1407
|
IkasCampaignOfferTargetPageType.POST_CHECKOUT
|
|
1530
|
-
);
|
|
1408
|
+
)) as any;
|
|
1531
1409
|
};
|
|
1532
1410
|
|
|
1533
1411
|
updateCartCampaignOffer = async (props: UpdateCartCampaignOfferInput) => {
|
|
@@ -1583,7 +1461,6 @@ export type StockErrorData = {
|
|
|
1583
1461
|
|
|
1584
1462
|
export type CampaignOfferType = {
|
|
1585
1463
|
product: IkasProduct;
|
|
1586
|
-
variants: IkasProductVariant[];
|
|
1587
1464
|
campaignOffer: IkasCartCampaignOffer;
|
|
1588
1465
|
offer: IkasCampaignOfferProduct;
|
|
1589
1466
|
};
|
|
@@ -6,7 +6,7 @@ import { useTranslation } from "../../utils/i18n";
|
|
|
6
6
|
import { IkasBaseStore } from "../../store";
|
|
7
7
|
import { IkasCheckout, IkasPaymentGateway } from "../../models";
|
|
8
8
|
import { MasterPassOperationTypeEnum } from "@ikas/storefront-api";
|
|
9
|
-
import {
|
|
9
|
+
import { getMasterpassRequestToken } from "@ikas/storefront-api";
|
|
10
10
|
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
11
11
|
|
|
12
12
|
const isServer = typeof localStorage === "undefined";
|
|
@@ -437,7 +437,7 @@ export default class MasterPassModel {
|
|
|
437
437
|
operationType: MasterPassOperationTypeEnum;
|
|
438
438
|
phoneNumber: string;
|
|
439
439
|
}) => {
|
|
440
|
-
const response = await
|
|
440
|
+
const response = await getMasterpassRequestToken({
|
|
441
441
|
cartId,
|
|
442
442
|
paymentGatewayId,
|
|
443
443
|
operationType,
|
|
@@ -31,9 +31,7 @@ const CheckoutStepInfo: React.FC<Props> = ({ vm }) => {
|
|
|
31
31
|
);
|
|
32
32
|
|
|
33
33
|
const customerAddressesViewModel = React.useMemo(() => {
|
|
34
|
-
return vm
|
|
35
|
-
? new CustomerAddressesViewModel(vm, "billing")
|
|
36
|
-
: new CustomerAddressesViewModel(vm, "shipping");
|
|
34
|
+
return new CustomerAddressesViewModel(vm, "shipping");
|
|
37
35
|
}, [vm]);
|
|
38
36
|
|
|
39
37
|
return (
|
|
@@ -72,16 +70,12 @@ const CheckoutStepInfo: React.FC<Props> = ({ vm }) => {
|
|
|
72
70
|
marginTop: vm.store.customerStore.customer ? "0px" : "32px",
|
|
73
71
|
}}
|
|
74
72
|
text={
|
|
75
|
-
vm.deliveryMethod === "address"
|
|
73
|
+
vm.deliveryMethod === "address"
|
|
76
74
|
? t("checkout-page:actions.continueWithShipping")
|
|
77
75
|
: t("checkout-page:actions.continueWithPayment")
|
|
78
76
|
}
|
|
79
77
|
isLoading={vm.isStepLoading}
|
|
80
|
-
onClick={
|
|
81
|
-
vm.isDigitalOnly
|
|
82
|
-
? vm.onProceedToDigitalOnlyPaymentClick
|
|
83
|
-
: vm.onProceedToShippingClick
|
|
84
|
-
}
|
|
78
|
+
onClick={vm.onProceedToShippingClick}
|
|
85
79
|
/>
|
|
86
80
|
)}
|
|
87
81
|
</div>
|
|
@@ -31,7 +31,7 @@ export const BillingAddress: React.FC<Props> = observer(({ vm }) => {
|
|
|
31
31
|
marginBottom: vm.useDifferentAddress ? "24px" : "0px",
|
|
32
32
|
}}
|
|
33
33
|
>
|
|
34
|
-
{vm.deliveryMethod === "address" &&
|
|
34
|
+
{vm.deliveryMethod === "address" && (
|
|
35
35
|
<Checkbox
|
|
36
36
|
value={!vm.useDifferentAddress}
|
|
37
37
|
hasError={vm.isErrorsVisible && !vm.isTermsAndConditionsChecked}
|
|
@@ -48,12 +48,7 @@ export const CheckoutStepPayment: React.FC<Props> = observer(({ vm }) => {
|
|
|
48
48
|
const policyLabel = policyInputData.map((p) =>
|
|
49
49
|
p.isVariable ? (
|
|
50
50
|
<span
|
|
51
|
-
className={
|
|
52
|
-
styles.TermsLabelSpan,
|
|
53
|
-
vm.isErrorsVisible && !vm.isTermsAndConditionsChecked
|
|
54
|
-
? styles.Error
|
|
55
|
-
: "",
|
|
56
|
-
].join(" ")}
|
|
51
|
+
className={styles.TermsLabelSpan}
|
|
57
52
|
onClick={
|
|
58
53
|
p.value === "{{ ackPrivacyPolicy }}"
|
|
59
54
|
? onShowPrivacyPolicyClick
|
|
@@ -93,11 +88,7 @@ export const CheckoutStepPayment: React.FC<Props> = observer(({ vm }) => {
|
|
|
93
88
|
}}
|
|
94
89
|
text={t("checkout-page:actions.completeOrder")}
|
|
95
90
|
isLoading={vm.isStepLoading}
|
|
96
|
-
onClick={
|
|
97
|
-
vm.isDigitalOnly
|
|
98
|
-
? vm.onCompleteDigitalOnlyPaymentClick
|
|
99
|
-
: vm.onCompletePaymentClick
|
|
100
|
-
}
|
|
91
|
+
onClick={vm.onCompletePaymentClick}
|
|
101
92
|
/>
|
|
102
93
|
|
|
103
94
|
{!!t("checkout-page:securePaymentTooltip") && (
|
|
@@ -12,20 +12,15 @@ import { CreditCardForm } from "../../../components/credit-card-form";
|
|
|
12
12
|
import { Installments } from "./installments";
|
|
13
13
|
import SelectBox from "../../../components/select-box";
|
|
14
14
|
import styles from "./style.module.scss";
|
|
15
|
-
import {
|
|
15
|
+
import { formatMoney, useTranslation } from "../../../../../utils";
|
|
16
16
|
import SVGExternal from "../../../components/svg/external";
|
|
17
17
|
import SVGMasterCard from "../../../components/master-pass/payment-gateway/svg/master-card";
|
|
18
18
|
import { IkasPaymentGatewayAdditionalPrice } from "../../../../../models/data/payment-gateway/additional-price";
|
|
19
|
-
import
|
|
19
|
+
import { StripeForm } from "../../../components/stripe";
|
|
20
20
|
import { Card as MasterPassCard } from "../../../modelMasterPass";
|
|
21
21
|
import CreditCardData from "../../../components/credit-card-form/model";
|
|
22
22
|
import CreditCardFormMasterPass from "../../../components/master-pass/credit-card-form";
|
|
23
23
|
|
|
24
|
-
//@ts-ignore
|
|
25
|
-
const StripeForm = dynamic(() =>
|
|
26
|
-
import("../../../components/stripe").then((mod) => mod.StripeForm)
|
|
27
|
-
);
|
|
28
|
-
|
|
29
24
|
type Props = {
|
|
30
25
|
vm: CheckoutViewModel;
|
|
31
26
|
};
|
|
@@ -55,11 +50,7 @@ export const PaymentGateways: React.FC<Props> = observer(({ vm }) => {
|
|
|
55
50
|
|
|
56
51
|
return `${
|
|
57
52
|
ap.amountType === IkasPaymentGatewayTransactionFeeType.AMOUNT
|
|
58
|
-
?
|
|
59
|
-
ap.amount,
|
|
60
|
-
vm.checkout.currencyCode,
|
|
61
|
-
vm.checkout.currencySymbol
|
|
62
|
-
)
|
|
53
|
+
? formatMoney(ap.amount, vm.checkout.currencyCode)
|
|
63
54
|
: " %" + ap.amount
|
|
64
55
|
}${
|
|
65
56
|
ap.type === IkasPaymentGatewayAdditionalPriceType.DECREMENT
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
3
|
import CheckoutViewModel from "../../../../model";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { formatMoney, useTranslation } from "../../../../../../utils";
|
|
6
6
|
import styles from "./style.module.scss";
|
|
7
7
|
import { Toggle } from "../../../../../../components/checkout/components/toggle";
|
|
8
8
|
|
|
@@ -33,19 +33,17 @@ export const Installments: React.FC<Props> = observer(({ vm }) => {
|
|
|
33
33
|
</div>
|
|
34
34
|
{ip.installmentCount !== 1 && (
|
|
35
35
|
<div className={styles.InstallmentPrice}>
|
|
36
|
-
{
|
|
36
|
+
{formatMoney(
|
|
37
37
|
ip.installmentPrice!,
|
|
38
38
|
vm.checkout!.currencyCode,
|
|
39
|
-
vm.checkout!.currencySymbol
|
|
40
39
|
)}
|
|
41
40
|
</div>
|
|
42
41
|
)}
|
|
43
42
|
</div>
|
|
44
43
|
<div className={styles.Price}>
|
|
45
|
-
{
|
|
44
|
+
{formatMoney(
|
|
46
45
|
ip.totalPrice!,
|
|
47
46
|
vm.checkout!.currencyCode,
|
|
48
|
-
vm.checkout!.currencySymbol
|
|
49
47
|
)}
|
|
50
48
|
</div>
|
|
51
49
|
</div>
|