@ikas/storefront 4.0.0-alpha.39 → 4.0.0-alpha.4

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.
Files changed (62) hide show
  1. package/package.json +13 -13
  2. package/src/analytics/analytics.ts +1 -2
  3. package/src/analytics/googleUniversal.ts +2 -12
  4. package/src/analytics/head/index.tsx +2 -1
  5. package/src/analytics/ikas.ts +6 -24
  6. package/src/components/checkout/components/address-form/index.tsx +1 -1
  7. package/src/components/checkout/components/cart-summary/cart-item/index.tsx +9 -11
  8. package/src/components/checkout/components/cart-summary/cart-item/style.module.scss +10 -7
  9. package/src/components/checkout/components/cart-summary/index.tsx +17 -41
  10. package/src/components/checkout/components/customer-addresses/index.tsx +2 -6
  11. package/src/components/checkout/components/form-item/index.tsx +11 -9
  12. package/src/components/checkout/components/master-pass/credit-card-form/index.tsx +0 -2
  13. package/src/components/checkout/components/offer-product/index.tsx +19 -16
  14. package/src/components/checkout/components/offer-product/style.module.scss +3 -1
  15. package/src/components/checkout/components/phone-number-input/get-countries.ts +5 -37
  16. package/src/components/checkout/components/phone-number-input/index.tsx +10 -15
  17. package/src/components/checkout/components/phone-number-input/locale/en.ts +257 -0
  18. package/src/components/checkout/index.tsx +12 -14
  19. package/src/components/checkout/model.ts +61 -95
  20. package/src/components/checkout/modelMasterPass.ts +2 -2
  21. package/src/components/checkout/steps/step-payment/index.tsx +1 -6
  22. package/src/components/checkout/steps/step-payment/payment-gateways/index.tsx +3 -12
  23. package/src/components/checkout/steps/step-payment/payment-gateways/installments/index.tsx +3 -5
  24. package/src/components/checkout/steps/step-payment/style.module.scss +0 -5
  25. package/src/components/checkout/steps/step-shipping/index.tsx +4 -9
  26. package/src/components/checkout/steps/step-success/index.tsx +3 -4
  27. package/src/components/page/head.tsx +0 -12
  28. package/src/components/page/index.tsx +9 -10
  29. package/src/components/page-editor/ThemeComponentEditor.tsx +8 -15
  30. package/src/components/page-editor/model.ts +107 -44
  31. package/src/models/data/cart/campaign-offer/index.ts +2 -13
  32. package/src/models/data/cart/index.ts +1 -1
  33. package/src/models/data/category/path-item/index.ts +0 -4
  34. package/src/models/data/checkout/index.ts +3 -11
  35. package/src/models/data/checkout-settings/price/index.ts +0 -2
  36. package/src/models/data/merchant-settings/index.ts +0 -9
  37. package/src/models/data/order/index.ts +32 -51
  38. package/src/models/data/order/line-item/index.ts +13 -34
  39. package/src/models/data/order/line-item/variant/value/index.ts +1 -1
  40. package/src/models/data/order/transaction/index.ts +5 -2
  41. package/src/models/data/product/filter/index.ts +13 -4
  42. package/src/models/data/product/index.ts +3 -21
  43. package/src/models/data/product/option-set/index.ts +0 -4
  44. package/src/models/data/product/option-set/option/index.ts +10 -33
  45. package/src/models/data/product/variant/index.ts +1 -23
  46. package/src/models/data/product/variant/price/index.ts +9 -23
  47. package/src/models/data/product/variant-type/index.ts +0 -2
  48. package/src/models/data/raffle/index.ts +7 -9
  49. package/src/models/data/state/index.ts +2 -6
  50. package/src/models/data/storefront/index.ts +0 -2
  51. package/src/models/ui/product-list/index.ts +17 -26
  52. package/src/models/ui/raffle-list/index.ts +1 -1
  53. package/src/models/ui/validator/form/raffle-form.ts +3 -16
  54. package/src/models/ui/validator/rules/index.ts +13 -14
  55. package/src/page-data-init/index.ts +404 -159
  56. package/src/pages/checkout.tsx +1 -2
  57. package/src/pages/editor.tsx +2 -5
  58. package/src/store/cart/index.ts +2 -2
  59. package/src/store/customer/index.ts +17 -7
  60. package/src/store/raffle/index.ts +10 -7
  61. package/src/utils/constants.ts +1 -1
  62. package/src/utils/currency.ts +183 -9
@@ -6,7 +6,8 @@ import parsePhoneNumber, {
6
6
  getCountryCallingCode,
7
7
  parseIncompletePhoneNumber,
8
8
  } from "libphonenumber-js";
9
- import getCountries, { CountryType } from "./get-countries";
9
+
10
+ import getCountries from "./get-countries";
10
11
 
11
12
  import styles from "./style.module.scss";
12
13
 
@@ -18,20 +19,17 @@ type Props = {
18
19
  onChange: (value: string) => void;
19
20
  };
20
21
 
21
- const DEFAULT_COUNTRY = "TR";
22
+ const countries = getCountries();
22
23
 
23
24
  export const PhoneNumberInput: React.FC<Props> = observer(
24
25
  ({ defaultCountry, disabled = false, placeholder, value, onChange }) => {
25
- const [countries, setCountries] = React.useState<CountryType[]>([]);
26
26
  const [activeCountry, setActiveCountry] = React.useState(
27
- (defaultCountry as CountryCode) || DEFAULT_COUNTRY
27
+ defaultCountry as CountryCode
28
28
  );
29
29
  const [formatedValue, setFormatedValue] = React.useState("");
30
30
 
31
31
  React.useEffect(() => {
32
- fetchCountries();
33
-
34
- let countryCode = activeCountry;
32
+ let countryCode = (defaultCountry as CountryCode) || "TR";
35
33
 
36
34
  if (value) {
37
35
  const parsedPhoneNumber = parsePhoneNumber(value);
@@ -48,11 +46,6 @@ export const PhoneNumberInput: React.FC<Props> = observer(
48
46
  setActiveCountry(countryCode);
49
47
  }, []);
50
48
 
51
- const fetchCountries = async () => {
52
- const categories = await getCountries();
53
- setCountries(categories);
54
- };
55
-
56
49
  const onValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {
57
50
  const phoneNumber = formatPhoneNumber(event.target.value);
58
51
  setFormatedValue(phoneNumber);
@@ -83,7 +76,9 @@ export const PhoneNumberInput: React.FC<Props> = observer(
83
76
  };
84
77
 
85
78
  const getImageSrc = () => {
86
- return `https://cdn.myikas.com/sf/assets/flags/3x2/${activeCountry}.svg`;
79
+ return `https://cdn.myikas.com/sf/assets/flags/3x2/${
80
+ activeCountry || "TR"
81
+ }.svg`;
87
82
  };
88
83
 
89
84
  return (
@@ -93,14 +88,14 @@ export const PhoneNumberInput: React.FC<Props> = observer(
93
88
  <div className={styles.Flag}>
94
89
  <img
95
90
  className={styles.FlagImage}
96
- alt={activeCountry}
91
+ alt={activeCountry || ""}
97
92
  src={getImageSrc()}
98
93
  ></img>
99
94
  <div className={styles.Arrow}></div>
100
95
  </div>
101
96
  <select
102
97
  className={styles.Select}
103
- value={activeCountry}
98
+ value={activeCountry || ""}
104
99
  onChange={onCountryChange}
105
100
  disabled={disabled}
106
101
  >
@@ -0,0 +1,257 @@
1
+ export default {
2
+ "AB": "Abkhazia",
3
+ "AC": "Ascension Island",
4
+ "AD": "Andorra",
5
+ "AE": "United Arab Emirates",
6
+ "AF": "Afghanistan",
7
+ "AG": "Antigua and Barbuda",
8
+ "AI": "Anguilla",
9
+ "AL": "Albania",
10
+ "AM": "Armenia",
11
+ "AO": "Angola",
12
+ "AQ": "Antarctica",
13
+ "AR": "Argentina",
14
+ "AS": "American Samoa",
15
+ "AT": "Austria",
16
+ "AU": "Australia",
17
+ "AW": "Aruba",
18
+ "AX": "Åland Islands",
19
+ "AZ": "Azerbaijan",
20
+ "BA": "Bosnia and Herzegovina",
21
+ "BB": "Barbados",
22
+ "BD": "Bangladesh",
23
+ "BE": "Belgium",
24
+ "BF": "Burkina Faso",
25
+ "BG": "Bulgaria",
26
+ "BH": "Bahrain",
27
+ "BI": "Burundi",
28
+ "BJ": "Benin",
29
+ "BL": "Saint Barthélemy",
30
+ "BM": "Bermuda",
31
+ "BN": "Brunei Darussalam",
32
+ "BO": "Bolivia",
33
+ "BQ": "Bonaire, Sint Eustatius and Saba",
34
+ "BR": "Brazil",
35
+ "BS": "Bahamas",
36
+ "BT": "Bhutan",
37
+ "BV": "Bouvet Island",
38
+ "BW": "Botswana",
39
+ "BY": "Belarus",
40
+ "BZ": "Belize",
41
+ "CA": "Canada",
42
+ "CC": "Cocos (Keeling) Islands",
43
+ "CD": "Congo, Democratic Republic of the",
44
+ "CF": "Central African Republic",
45
+ "CG": "Congo",
46
+ "CH": "Switzerland",
47
+ "CI": "Cote d'Ivoire",
48
+ "CK": "Cook Islands",
49
+ "CL": "Chile",
50
+ "CM": "Cameroon",
51
+ "CN": "China",
52
+ "CO": "Colombia",
53
+ "CR": "Costa Rica",
54
+ "CU": "Cuba",
55
+ "CV": "Cape Verde",
56
+ "CW": "Curaçao",
57
+ "CX": "Christmas Island",
58
+ "CY": "Cyprus",
59
+ "CZ": "Czech Republic",
60
+ "DE": "Germany",
61
+ "DJ": "Djibouti",
62
+ "DK": "Denmark",
63
+ "DM": "Dominica",
64
+ "DO": "Dominican Republic",
65
+ "DZ": "Algeria",
66
+ "EC": "Ecuador",
67
+ "EE": "Estonia",
68
+ "EG": "Egypt",
69
+ "EH": "Western Sahara",
70
+ "ER": "Eritrea",
71
+ "ES": "Spain",
72
+ "ET": "Ethiopia",
73
+ "FI": "Finland",
74
+ "FJ": "Fiji",
75
+ "FK": "Falkland Islands",
76
+ "FM": "Federated States of Micronesia",
77
+ "FO": "Faroe Islands",
78
+ "FR": "France",
79
+ "GA": "Gabon",
80
+ "GB": "United Kingdom",
81
+ "GD": "Grenada",
82
+ "GE": "Georgia",
83
+ "GF": "French Guiana",
84
+ "GG": "Guernsey",
85
+ "GH": "Ghana",
86
+ "GI": "Gibraltar",
87
+ "GL": "Greenland",
88
+ "GM": "Gambia",
89
+ "GN": "Guinea",
90
+ "GP": "Guadeloupe",
91
+ "GQ": "Equatorial Guinea",
92
+ "GR": "Greece",
93
+ "GS": "South Georgia and the South Sandwich Islands",
94
+ "GT": "Guatemala",
95
+ "GU": "Guam",
96
+ "GW": "Guinea-Bissau",
97
+ "GY": "Guyana",
98
+ "HK": "Hong Kong",
99
+ "HM": "Heard Island and McDonald Islands",
100
+ "HN": "Honduras",
101
+ "HR": "Croatia",
102
+ "HT": "Haiti",
103
+ "HU": "Hungary",
104
+ "ID": "Indonesia",
105
+ "IE": "Ireland",
106
+ "IL": "Israel",
107
+ "IM": "Isle of Man",
108
+ "IN": "India",
109
+ "IO": "British Indian Ocean Territory",
110
+ "IQ": "Iraq",
111
+ "IR": "Iran",
112
+ "IS": "Iceland",
113
+ "IT": "Italy",
114
+ "JE": "Jersey",
115
+ "JM": "Jamaica",
116
+ "JO": "Jordan",
117
+ "JP": "Japan",
118
+ "KE": "Kenya",
119
+ "KG": "Kyrgyzstan",
120
+ "KH": "Cambodia",
121
+ "KI": "Kiribati",
122
+ "KM": "Comoros",
123
+ "KN": "Saint Kitts and Nevis",
124
+ "KP": "North Korea",
125
+ "KR": "South Korea",
126
+ "KW": "Kuwait",
127
+ "KY": "Cayman Islands",
128
+ "KZ": "Kazakhstan",
129
+ "LA": "Laos",
130
+ "LB": "Lebanon",
131
+ "LC": "Saint Lucia",
132
+ "LI": "Liechtenstein",
133
+ "LK": "Sri Lanka",
134
+ "LR": "Liberia",
135
+ "LS": "Lesotho",
136
+ "LT": "Lithuania",
137
+ "LU": "Luxembourg",
138
+ "LV": "Latvia",
139
+ "LY": "Libya",
140
+ "MA": "Morocco",
141
+ "MC": "Monaco",
142
+ "MD": "Moldova",
143
+ "ME": "Montenegro",
144
+ "MF": "Saint Martin (French Part)",
145
+ "MG": "Madagascar",
146
+ "MH": "Marshall Islands",
147
+ "MK": "North Macedonia",
148
+ "ML": "Mali",
149
+ "MM": "Burma",
150
+ "MN": "Mongolia",
151
+ "MO": "Macao",
152
+ "MP": "Northern Mariana Islands",
153
+ "MQ": "Martinique",
154
+ "MR": "Mauritania",
155
+ "MS": "Montserrat",
156
+ "MT": "Malta",
157
+ "MU": "Mauritius",
158
+ "MV": "Maldives",
159
+ "MW": "Malawi",
160
+ "MX": "Mexico",
161
+ "MY": "Malaysia",
162
+ "MZ": "Mozambique",
163
+ "NA": "Namibia",
164
+ "NC": "New Caledonia",
165
+ "NE": "Niger",
166
+ "NF": "Norfolk Island",
167
+ "NG": "Nigeria",
168
+ "NI": "Nicaragua",
169
+ "NL": "Netherlands",
170
+ "NO": "Norway",
171
+ "NP": "Nepal",
172
+ "NR": "Nauru",
173
+ "NU": "Niue",
174
+ "NZ": "New Zealand",
175
+ "OM": "Oman",
176
+ "OS": "South Ossetia",
177
+ "PA": "Panama",
178
+ "PE": "Peru",
179
+ "PF": "French Polynesia",
180
+ "PG": "Papua New Guinea",
181
+ "PH": "Philippines",
182
+ "PK": "Pakistan",
183
+ "PL": "Poland",
184
+ "PM": "Saint Pierre and Miquelon",
185
+ "PN": "Pitcairn",
186
+ "PR": "Puerto Rico",
187
+ "PS": "Palestine",
188
+ "PT": "Portugal",
189
+ "PW": "Palau",
190
+ "PY": "Paraguay",
191
+ "QA": "Qatar",
192
+ "RE": "Reunion",
193
+ "RO": "Romania",
194
+ "RS": "Serbia",
195
+ "RU": "Russia",
196
+ "RW": "Rwanda",
197
+ "SA": "Saudi Arabia",
198
+ "SB": "Solomon Islands",
199
+ "SC": "Seychelles",
200
+ "SD": "Sudan",
201
+ "SE": "Sweden",
202
+ "SG": "Singapore",
203
+ "SH": "Saint Helena",
204
+ "SI": "Slovenia",
205
+ "SJ": "Svalbard and Jan Mayen",
206
+ "SK": "Slovakia",
207
+ "SL": "Sierra Leone",
208
+ "SM": "San Marino",
209
+ "SN": "Senegal",
210
+ "SO": "Somalia",
211
+ "SR": "Suriname",
212
+ "SS": "South Sudan",
213
+ "ST": "Sao Tome and Principe",
214
+ "SV": "El Salvador",
215
+ "SX": "Sint Maarten",
216
+ "SY": "Syria",
217
+ "SZ": "Swaziland",
218
+ "TA": "Tristan da Cunha",
219
+ "TC": "Turks and Caicos Islands",
220
+ "TD": "Chad",
221
+ "TF": "French Southern Territories",
222
+ "TG": "Togo",
223
+ "TH": "Thailand",
224
+ "TJ": "Tajikistan",
225
+ "TK": "Tokelau",
226
+ "TL": "Timor-Leste",
227
+ "TM": "Turkmenistan",
228
+ "TN": "Tunisia",
229
+ "TO": "Tonga",
230
+ "TR": "Turkey",
231
+ "TT": "Trinidad and Tobago",
232
+ "TV": "Tuvalu",
233
+ "TW": "Taiwan",
234
+ "TZ": "Tanzania",
235
+ "UA": "Ukraine",
236
+ "UG": "Uganda",
237
+ "UM": "United States Minor Outlying Islands",
238
+ "US": "United States",
239
+ "UY": "Uruguay",
240
+ "UZ": "Uzbekistan",
241
+ "VA": "Holy See (Vatican City State)",
242
+ "VC": "Saint Vincent and the Grenadines",
243
+ "VE": "Venezuela",
244
+ "VG": "Virgin Islands, British",
245
+ "VI": "Virgin Islands, U.S.",
246
+ "VN": "Vietnam",
247
+ "VU": "Vanuatu",
248
+ "WF": "Wallis and Futuna",
249
+ "WS": "Samoa",
250
+ "XK": "Kosovo",
251
+ "YE": "Yemen",
252
+ "YT": "Mayotte",
253
+ "ZA": "South Africa",
254
+ "ZM": "Zambia",
255
+ "ZW": "Zimbabwe",
256
+ "ZZ": "International"
257
+ }
@@ -7,7 +7,7 @@ import ReactTooltip from "react-tooltip";
7
7
  import CheckoutViewModel, { CheckoutStep } from "./model";
8
8
  import { IkasCheckoutSettings } from "../../models/data/checkout-settings";
9
9
  import { IkasCheckout } from "../../models/data/checkout";
10
- import { formatCurrency, useTranslation } from "../../utils";
10
+ import { formatMoney, useTranslation } from "../../utils";
11
11
 
12
12
  import CheckoutStepInfo from "./steps/step-info";
13
13
  import { CheckoutStepShipping } from "./steps/step-shipping";
@@ -366,16 +366,15 @@ const Steps: React.FC<CommonProps> = observer(({ vm }) => {
366
366
  vm.step === CheckoutStep.PAYMENT ? (
367
367
  <div className={styles.AdressStepInfo}>
368
368
  <StepSummaryShipping vm={vm} />
369
- {((vm.checkout.availableShippingMethods &&
370
- vm.checkout.availableShippingMethods.length > 1) ||
371
- vm.checkoutSettings.isGiftPackageEnabled) && (
372
- <div
373
- className={styles.EditBtn}
374
- onClick={vm.onBackToShippingClick}
375
- >
376
- {t("checkout-page:actions.edit")}
377
- </div>
378
- )}
369
+ {vm.checkout.availableShippingMethods &&
370
+ vm.checkout.availableShippingMethods.length > 1 && (
371
+ <div
372
+ className={styles.EditBtn}
373
+ onClick={vm.onBackToShippingClick}
374
+ >
375
+ {t("checkout-page:actions.edit")}
376
+ </div>
377
+ )}
379
378
  </div>
380
379
  ) : undefined,
381
380
  vm.step === CheckoutStep.PAYMENT ? (
@@ -444,10 +443,9 @@ const StepSummaryShipping: React.FC<CommonProps> = observer(({ vm }) => {
444
443
  {" / " +
445
444
  (vm.checkout.shippingLines[0].price === 0
446
445
  ? t("checkout-page:free")
447
- : formatCurrency(
446
+ : formatMoney(
448
447
  vm.checkout.shippingLines[0].price,
449
- vm.checkout!.currencyCode,
450
- vm.checkout.currencySymbol
448
+ vm.checkout!.currencyCode
451
449
  ))}
452
450
  </span>
453
451
  </React.Fragment>
@@ -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,
@@ -92,8 +91,8 @@ export default class CheckoutViewModel {
92
91
 
93
92
  stripeResponse: CreateStripePaymentIntentResponse | null = null;
94
93
 
95
- checkoutCampaignOffer?: CampaignOfferType;
96
- postCheckoutCampaignOffer?: CampaignOfferType;
94
+ checkoutCampaignOffer: CampaignOfferType | undefined;
95
+ postCheckoutCampaignOffer: CampaignOfferType | undefined;
97
96
 
98
97
  returnPolicy: string;
99
98
  privacyPolicy: string;
@@ -253,9 +252,6 @@ export default class CheckoutViewModel {
253
252
  if (this.step === CheckoutStep.PAYMENT) {
254
253
  if (this.isInStoreDelivery) {
255
254
  this.checkout.billingAddress = new IkasOrderAddress();
256
- if (this.checkoutSettings) {
257
- this.checkout.billingAddress.checkoutSettings = this.checkoutSettings;
258
- }
259
255
  }
260
256
  }
261
257
 
@@ -444,10 +440,7 @@ export default class CheckoutViewModel {
444
440
  input = await this.inStockDeliveryInputData(input);
445
441
  }
446
442
 
447
- if (
448
- this.step === CheckoutStep.INFO ||
449
- this.step === CheckoutStep.SHIPPING
450
- ) {
443
+ if (this.step === CheckoutStep.INFO) {
451
444
  input.billingAddress = null;
452
445
  }
453
446
 
@@ -741,7 +734,7 @@ export default class CheckoutViewModel {
741
734
  this.checkout.billingAddress =
742
735
  this.checkout.billingAddress || new IkasOrderAddress();
743
736
  } else {
744
- if (this.isInStoreDelivery || this.checkout.billingAddress) {
737
+ if (this.isInStoreDelivery) {
745
738
  this.checkout.billingAddress = new IkasOrderAddress(
746
739
  _cloneDeep(this.checkout.billingAddress) || {}
747
740
  );
@@ -751,7 +744,6 @@ export default class CheckoutViewModel {
751
744
  );
752
745
  }
753
746
  }
754
-
755
747
  this.checkout.billingAddress.checkoutSettings = this.checkoutSettings;
756
748
  }
757
749
  };
@@ -767,8 +759,6 @@ export default class CheckoutViewModel {
767
759
  const newCart = await this.saveCart();
768
760
 
769
761
  if (newCart) this.checkout = new IkasCheckout(newCart);
770
- if (this.checkout.shippingAddress)
771
- this.checkout.shippingAddress.checkoutSettings = this.checkoutSettings;
772
762
  this.isChangingShippingMethod = false;
773
763
  };
774
764
 
@@ -993,9 +983,6 @@ export default class CheckoutViewModel {
993
983
  customer.addresses.push(newAddress);
994
984
 
995
985
  await this.store.customerStore.saveCustomer(customer);
996
- this.store.customerStore.customer.addresses?.forEach(
997
- (address) => (address.checkoutSettings = this.checkoutSettings)
998
- );
999
986
 
1000
987
  if (type === "shipping") {
1001
988
  this.checkout.shippingAddress!.id = newAddress.id;
@@ -1329,25 +1316,32 @@ export default class CheckoutViewModel {
1329
1316
  this.isContactModalVisible = value;
1330
1317
  };
1331
1318
 
1332
- getWaitingForActionCampaignOffers = (
1319
+ getWaitingForActionCampaignOffer = (
1333
1320
  targetPage: IkasCampaignOfferTargetPageType
1334
1321
  ) => {
1335
- if (!this.checkout.campaignOffers || !this.checkout.campaignOffers.length)
1336
- return;
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
+ );
1337
1328
 
1338
- const filteredCampaignOffers = this.checkout.campaignOffers.filter(
1339
- (co) =>
1340
- co.status === IkasCartCampaignOfferStatus.WAITING_FOR_ACTION &&
1341
- co.campaignOffer?.targetPageTypes.some((tpt) => tpt === targetPage)
1342
- );
1343
- return filteredCampaignOffers;
1329
+ if (filteredCampaignOffer.length) {
1330
+ return filteredCampaignOffer[0];
1331
+ }
1332
+ }
1333
+
1334
+ return null;
1344
1335
  };
1345
1336
 
1346
1337
  getOffer = (waitingForActionCampaignOffer: IkasCartCampaignOffer) => {
1347
- if (!waitingForActionCampaignOffer.campaignOffer) return null;
1348
- return waitingForActionCampaignOffer.campaignOffer.offers.find(
1349
- (o) => o.id === waitingForActionCampaignOffer.campaignOfferProductId
1350
- );
1338
+ if (waitingForActionCampaignOffer.campaignOffer) {
1339
+ return waitingForActionCampaignOffer.campaignOffer.offers.find(
1340
+ (o) => o.id === waitingForActionCampaignOffer.campaignOfferProductId
1341
+ );
1342
+ }
1343
+
1344
+ return null;
1351
1345
  };
1352
1346
 
1353
1347
  getProduct = async (productId: string) => {
@@ -1357,88 +1351,61 @@ export default class CheckoutViewModel {
1357
1351
  },
1358
1352
  });
1359
1353
 
1360
- if (!productsResponse.isSuccess || !productsResponse?.data?.data?.length)
1361
- return null;
1362
-
1363
- const product = productsResponse.data.data[0];
1364
- const selectedVariant = product.variants.find((v) => v.isActive);
1365
- const productDetail = new IkasProduct({
1366
- ...product,
1367
- selectedVariantValues: (selectedVariant || product.variants[0])
1368
- .variantValues,
1369
- });
1370
-
1371
- return productDetail;
1372
- };
1373
-
1374
- getOfferProductVariants = ({
1375
- offer,
1376
- product,
1377
- }: {
1378
- offer: IkasCampaignOfferProduct;
1379
- product: IkasProduct;
1380
- }) => {
1381
- const variants: IkasProductVariant[] = [];
1382
-
1383
- if (offer.excludedVariantIdList?.length) {
1384
- product.variants.forEach((v) => {
1385
- const isVariantExcluded = offer!.excludedVariantIdList?.some(
1386
- (ev) => ev === v.id
1387
- );
1388
- if (!v.hasStock || isVariantExcluded) return;
1389
-
1390
- 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,
1391
1366
  });
1392
- } else {
1393
- variants.push(...product.variants.filter((v) => v.hasStock));
1367
+
1368
+ return productDetail;
1394
1369
  }
1395
1370
 
1396
- return variants;
1371
+ return null;
1397
1372
  };
1398
1373
 
1399
1374
  getCampaignOfferProducts = async (
1400
1375
  targetPage: IkasCampaignOfferTargetPageType
1401
- ): Promise<CampaignOfferType | undefined> => {
1402
- const waitingForActionCampaignOffers =
1403
- this.getWaitingForActionCampaignOffers(targetPage);
1376
+ ) => {
1377
+ const waitingForActionCampaignOffer =
1378
+ this.getWaitingForActionCampaignOffer(targetPage);
1404
1379
 
1405
1380
  if (
1406
- !waitingForActionCampaignOffers ||
1407
- !waitingForActionCampaignOffers.length
1408
- )
1409
- return;
1410
-
1411
- for (let i = 0; i < waitingForActionCampaignOffers.length; i++) {
1412
- const waitingForActionCampaignOffer = waitingForActionCampaignOffers[i];
1413
-
1381
+ waitingForActionCampaignOffer &&
1382
+ waitingForActionCampaignOffer.campaignOffer
1383
+ ) {
1414
1384
  const offer = this.getOffer(waitingForActionCampaignOffer);
1415
- if (!offer) continue;
1416
1385
 
1417
- const product = await this.getProduct(offer.productId);
1418
- if (!product) continue;
1386
+ if (offer) {
1387
+ const productDetail = await this.getProduct(offer.productId);
1419
1388
 
1420
- const variants: IkasProductVariant[] = this.getOfferProductVariants({
1421
- offer,
1422
- product,
1423
- });
1424
- if (!variants.length) continue;
1425
-
1426
- return {
1427
- product,
1428
- variants,
1429
- campaignOffer: waitingForActionCampaignOffer,
1430
- offer,
1431
- };
1389
+ if (productDetail) {
1390
+ return {
1391
+ productDetail,
1392
+ campaignOffer: waitingForActionCampaignOffer,
1393
+ offer,
1394
+ };
1395
+ }
1396
+ }
1432
1397
  }
1398
+
1399
+ return undefined;
1433
1400
  };
1434
1401
 
1435
1402
  getCampaignOffer = async () => {
1436
- this.checkoutCampaignOffer = await this.getCampaignOfferProducts(
1403
+ this.checkoutCampaignOffer = (await this.getCampaignOfferProducts(
1437
1404
  IkasCampaignOfferTargetPageType.CHECKOUT
1438
- );
1439
- this.postCheckoutCampaignOffer = await this.getCampaignOfferProducts(
1405
+ )) as any;
1406
+ this.postCheckoutCampaignOffer = (await this.getCampaignOfferProducts(
1440
1407
  IkasCampaignOfferTargetPageType.POST_CHECKOUT
1441
- );
1408
+ )) as any;
1442
1409
  };
1443
1410
 
1444
1411
  updateCartCampaignOffer = async (props: UpdateCartCampaignOfferInput) => {
@@ -1494,7 +1461,6 @@ export type StockErrorData = {
1494
1461
 
1495
1462
  export type CampaignOfferType = {
1496
1463
  product: IkasProduct;
1497
- variants: IkasProductVariant[];
1498
1464
  campaignOffer: IkasCartCampaignOffer;
1499
1465
  offer: IkasCampaignOfferProduct;
1500
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 { getMasterPassRequestToken } from "@ikas/storefront-api";
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 getMasterPassRequestToken({
440
+ const response = await getMasterpassRequestToken({
441
441
  cartId,
442
442
  paymentGatewayId,
443
443
  operationType,
@@ -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