@ikas/storefront 4.0.0-alpha.38 → 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 (61) 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 +8 -9
  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 +18 -37
  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 +0 -20
  43. package/src/models/data/product/option-set/option/index.ts +6 -25
  44. package/src/models/data/product/variant/index.ts +1 -23
  45. package/src/models/data/product/variant/price/index.ts +9 -23
  46. package/src/models/data/product/variant-type/index.ts +0 -2
  47. package/src/models/data/raffle/index.ts +7 -9
  48. package/src/models/data/state/index.ts +2 -6
  49. package/src/models/data/storefront/index.ts +0 -2
  50. package/src/models/ui/product-list/index.ts +17 -26
  51. package/src/models/ui/raffle-list/index.ts +1 -1
  52. package/src/models/ui/validator/form/raffle-form.ts +3 -16
  53. package/src/models/ui/validator/rules/index.ts +13 -14
  54. package/src/page-data-init/index.ts +404 -159
  55. package/src/pages/checkout.tsx +1 -2
  56. package/src/pages/editor.tsx +2 -5
  57. package/src/store/cart/index.ts +2 -2
  58. package/src/store/customer/index.ts +17 -7
  59. package/src/store/raffle/index.ts +10 -7
  60. package/src/utils/constants.ts +1 -1
  61. package/src/utils/currency.ts +183 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.0.0-alpha.38",
3
+ "version": "4.0.0-alpha.4",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "Umut Ozan Yıldırım",
6
6
  "license": "ISC",
@@ -24,18 +24,18 @@
24
24
  "libphonenumber-js": "^1.10.6"
25
25
  },
26
26
  "devDependencies": {
27
- "@ikas/storefront-api": "^4.0.0-alpha.38",
28
- "@ikas/storefront-config": "^4.0.0-alpha.38",
29
- "@ikas/storefront-model-functions": "^4.0.0-alpha.38",
30
- "@ikas/storefront-models": "^4.0.0-alpha.38",
31
- "@ikas/storefront-providers": "^4.0.0-alpha.38",
27
+ "@ikas/storefront-api": "^4.0.0-alpha.4",
28
+ "@ikas/storefront-config": "^4.0.0-alpha.4",
29
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.4",
30
+ "@ikas/storefront-models": "^4.0.0-alpha.4",
31
+ "@ikas/storefront-providers": "^4.0.0-alpha.4",
32
32
  "@rollup/plugin-commonjs": "^22.0.0",
33
33
  "@rollup/plugin-json": "^4.1.0",
34
34
  "@rollup/plugin-node-resolve": "^13.3.0",
35
35
  "@types/react-phone-number-input": "^3.0.10",
36
36
  "mobx": "^6.1.3",
37
37
  "mobx-react-lite": "^3.1.5",
38
- "next": "12.2.0",
38
+ "next": "canary",
39
39
  "prettier": "^2.2.1",
40
40
  "react": "17.0.2",
41
41
  "react-dom": "17.0.2",
@@ -52,14 +52,14 @@
52
52
  "html-react-parser": "^1.4.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@ikas/storefront-api": "^4.0.0-alpha.38",
56
- "@ikas/storefront-config": "^4.0.0-alpha.38",
57
- "@ikas/storefront-model-functions": "^4.0.0-alpha.38",
58
- "@ikas/storefront-models": "^4.0.0-alpha.38",
59
- "@ikas/storefront-providers": "^4.0.0-alpha.38",
55
+ "@ikas/storefront-api": "^4.0.0-alpha.4",
56
+ "@ikas/storefront-config": "^4.0.0-alpha.4",
57
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.4",
58
+ "@ikas/storefront-models": "^4.0.0-alpha.4",
59
+ "@ikas/storefront-providers": "^4.0.0-alpha.4",
60
60
  "mobx": "^6.1.3",
61
61
  "mobx-react-lite": "^3.1.5",
62
- "next": "12.2.0",
62
+ "next": "canary",
63
63
  "react": "17.0.2",
64
64
  "react-dom": "17.0.2",
65
65
  "lodash": "^4.17.20",
@@ -54,7 +54,6 @@ export class Analytics {
54
54
  const customerInfo = await Analytics.getCustomerInfo();
55
55
 
56
56
  GoogleTagManager.pageView(url);
57
- GoogleUniversal.pageView(window.location.pathname);
58
57
  IkasAnalytics.pageView(pageType);
59
58
 
60
59
  tryForEach(Analytics.subscribers, (s) => {
@@ -195,7 +194,7 @@ export class Analytics {
195
194
  try {
196
195
  localStorage.removeItem(LS_BEGIN_CHECKOUT_KEY);
197
196
 
198
- FacebookPixel.purchase(checkout, transaction.id || "");
197
+ FacebookPixel.purchase(checkout, checkout.orderNumber || "");
199
198
  GoogleTagManager.purchase(checkout, checkout.orderNumber || "");
200
199
  IkasAnalytics.orderSuccess(checkout);
201
200
  GoogleAnalytics.purchase(checkout, checkout.orderNumber || "");
@@ -8,23 +8,12 @@ export class GoogleUniversal {
8
8
  makeAutoObservable(this);
9
9
  }
10
10
 
11
- static pageView(url: string) {
12
- try {
13
- if (!isServer && (window as any).ga) {
14
- (window as any).ga("set", "page", url);
15
- (window as any).ga("send", "pageview");
16
- }
17
- return;
18
- } catch (err) {
19
- console.error(err);
20
- }
21
- }
22
-
23
11
  static productView(productDetail: IkasProduct) {
24
12
  try {
25
13
  if (!isServer && (window as any).ga) {
26
14
  (window as any).ga("ec:addProduct", productToGUItem(productDetail));
27
15
  (window as any).ga("ec:setAction", "detail");
16
+ (window as any).ga("send", "pageview");
28
17
  }
29
18
  return;
30
19
  } catch (err) {
@@ -90,6 +79,7 @@ export class GoogleUniversal {
90
79
  shipping: "" + checkout.shippingTotal,
91
80
  coupon: checkout.couponCode,
92
81
  });
82
+ (window as any).ga("send", "pageview");
93
83
  }
94
84
  return;
95
85
  } catch (err) {
@@ -79,7 +79,8 @@ export const AnalyticsHead: React.FC<HeadProps> = observer(({ blockHTML }) => {
79
79
  dangerouslySetInnerHTML={{
80
80
  __html: `window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
81
81
  ga('create', '${universalAnalyticsId}', 'auto');
82
- ga('require', 'ec');`,
82
+ ga('require', 'ec');
83
+ ga('send', 'pageview');`,
83
84
  }}
84
85
  />
85
86
  <script
@@ -144,18 +144,10 @@ export default class IkasAnalytics {
144
144
  static sessionId?: string | null;
145
145
  static visitorId?: string | null;
146
146
 
147
- static async createUUID() {
148
- const response = await fetch(
149
- `${process.env.NEXT_PUBLIC_BASE_URL}/generate-id/1`
150
- );
151
- const responseJson = await response.json();
152
- return responseJson.data[0] as string;
153
- }
154
-
155
147
  static async createSessionId() {
156
148
  try {
157
149
  const idWithExpiry: IdWithExpiry = {
158
- id: await this.createUUID(),
150
+ id: Date.now() + "",
159
151
  expiry: Date.now() + this.EXPIRY_LENGTH,
160
152
  };
161
153
 
@@ -175,8 +167,7 @@ export default class IkasAnalytics {
175
167
  if (existingSessionIdData) {
176
168
  const idWithExpiry = JSON.parse(existingSessionIdData) as IdWithExpiry;
177
169
 
178
- // Remove old ids so that they can be replaced with UUIDs (length 13 check)
179
- if (idWithExpiry.expiry < Date.now() || idWithExpiry.id.length <= 13) {
170
+ if (idWithExpiry.expiry < Date.now()) {
180
171
  await this.createSessionId();
181
172
  } else {
182
173
  // Extend the duration of the sessionId
@@ -190,30 +181,21 @@ export default class IkasAnalytics {
190
181
  } else {
191
182
  await this.createSessionId();
192
183
  }
193
-
194
- IkasStorefrontConfig.init({
195
- sessionId: this.sessionId || "",
196
- });
197
184
  } catch (err) {
198
185
  console.error(err);
199
186
  }
200
187
  }
201
188
 
202
- static async checkVisitorId() {
189
+ static checkVisitorId() {
203
190
  try {
204
191
  const existingVisitorId = localStorage.getItem(this.VISITOR_ID_KEY);
205
192
 
206
- // Remove old ids so that they can be replaced with UUIDs (length 13 check)
207
- if (existingVisitorId && existingVisitorId.length > 13) {
193
+ if (existingVisitorId) {
208
194
  this.visitorId = existingVisitorId;
209
195
  } else {
210
- this.visitorId = await this.createUUID();
196
+ this.visitorId = Date.now() + "";
211
197
  localStorage.setItem(this.VISITOR_ID_KEY, this.visitorId);
212
198
  }
213
-
214
- IkasStorefrontConfig.init({
215
- visitorId: this.visitorId,
216
- });
217
199
  } catch (err) {
218
200
  console.error(err);
219
201
  }
@@ -317,7 +299,7 @@ export default class IkasAnalytics {
317
299
  static async sendEvents(events: Event[]) {
318
300
  try {
319
301
  await this.checkSessionId();
320
- await this.checkVisitorId();
302
+ this.checkVisitorId();
321
303
 
322
304
  const store = IkasBaseStore.getInstance();
323
305
  const cloudFrontEvent: CloudFrontEvent = {
@@ -315,7 +315,7 @@ const CityInput: React.FC<FormItemProps> = observer(({ vm }) => {
315
315
  return (
316
316
  <FormItem
317
317
  type={FormItemType.TEXT}
318
- autocomplete="address-level2"
318
+ autocomplete="address-level3"
319
319
  label={t("checkout-page:city")}
320
320
  value={vm.city?.name || ""}
321
321
  onChange={vm.onCityInputChange}
@@ -4,11 +4,7 @@ import {
4
4
  IkasOrderLineItem,
5
5
  IkasProductOptionType,
6
6
  } from "../../../../../models";
7
- import {
8
- formatDate,
9
- formatCurrency,
10
- useTranslation,
11
- } from "../../../../../utils";
7
+ import { formatDate, formatMoney, useTranslation } from "../../../../../utils";
12
8
  import CheckoutViewModel from "../../../../../components/checkout/model";
13
9
  import { Modal } from "../../modal";
14
10
 
@@ -163,17 +159,19 @@ export const CartItem: React.FC<Props> = observer(
163
159
  {!!cartItem.overridenPriceWithQuantity && (
164
160
  <span className={styles.GrayPrice}>
165
161
  {!!adjustmentTotal
166
- ? cartItem.formattedFinalPriceWithQuantity
167
- : cartItem.formattedOverridenPriceWithQuantity}
162
+ ? formatMoney(cartItem.finalPriceWithQuantity, currencyCode)
163
+ : formatMoney(
164
+ cartItem.overridenPriceWithQuantity,
165
+ currencyCode
166
+ )}
168
167
  </span>
169
168
  )}
170
169
  {!!adjustmentTotal
171
- ? formatCurrency(
170
+ ? formatMoney(
172
171
  cartItem.finalPriceWithQuantity - adjustmentTotal,
173
- currencyCode,
174
- cartItem.currencySymbol
172
+ currencyCode
175
173
  )
176
- : cartItem.formattedFinalPriceWithQuantity}
174
+ : formatMoney(cartItem.finalPriceWithQuantity, currencyCode)}
177
175
  </div>
178
176
  </div>
179
177
  </div>
@@ -8,12 +8,14 @@
8
8
  .ImageContainer {
9
9
  flex: 0 0 auto;
10
10
  width: 114px;
11
+ height: 114px;
11
12
  position: relative;
12
13
  margin-right: 16px;
13
14
 
14
15
  .Image {
15
16
  width: 100%;
16
- object-fit: contain;
17
+ height: 100%;
18
+ object-fit: cover;
17
19
  border-radius: 8px;
18
20
  }
19
21
  }
@@ -53,6 +55,7 @@
53
55
  cursor: pointer;
54
56
  text-decoration: underline;
55
57
  }
58
+
56
59
  }
57
60
  }
58
61
 
@@ -61,7 +64,7 @@
61
64
  display: flex;
62
65
  align-items: center;
63
66
  color: $primaryTextColor;
64
-
67
+
65
68
  .GrayPrice {
66
69
  font-size: 14px;
67
70
  color: $secondaryTextColor;
@@ -75,25 +78,25 @@
75
78
  flex-direction: column;
76
79
  margin-bottom: 24px;
77
80
  max-width: 400px;
78
-
81
+
79
82
  .OptionName {
80
83
  font-size: 14px;
81
84
  color: $primaryTextColor;
82
85
  margin-right: 8px;
83
86
  font-weight: 500;
84
87
  }
85
-
88
+
86
89
  .OptionValue {
87
90
  font-size: 14px;
88
91
  color: $secondaryTextColor;
89
92
  }
90
-
93
+
91
94
  .OptionsHorContainer {
92
95
  display: flex;
93
96
  align-items: center;
94
97
  flex-wrap: wrap;
95
98
  }
96
-
99
+
97
100
  .OptionColorValue {
98
101
  width: 24px;
99
102
  height: 24px;
@@ -101,4 +104,4 @@
101
104
  margin-right: 4px;
102
105
  }
103
106
  }
104
- }
107
+ }
@@ -5,7 +5,7 @@ import _sortBy from "lodash/sortBy";
5
5
  import InputWithButton from "../input-with-button";
6
6
  import NotificationBox from "../notification-box";
7
7
  import CheckoutViewModel, { CheckoutStep } from "../../model";
8
- import { formatCurrency, useTranslation } from "../../../../utils";
8
+ import { formatMoney, useTranslation } from "../../../../utils";
9
9
  import { CartItem } from "./cart-item";
10
10
  import { FormItem } from "../form-item";
11
11
  import { FormItemType } from "../form-item/model";
@@ -95,13 +95,9 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
95
95
  <div className={styles.Left}>{t("checkout-page:summary")}</div>
96
96
  <div className={styles.Price}>
97
97
  <span className={styles.PriceText}>
98
- {`${formatCurrency(
99
- vm.finalPrice || 0,
100
- checkout.currencyCode,
101
- checkout.currencySymbol
102
- )} (${checkout.items.length} ${t(
103
- "checkout-page:cartItemProduct"
104
- )})`}
98
+ {`${formatMoney(vm.finalPrice || 0, checkout.currencyCode)} (${
99
+ checkout.items.length
100
+ } ${t("checkout-page:cartItemProduct")})`}
105
101
  </span>
106
102
  <span className={arrowDownClasses}>
107
103
  <SVGArrowDown />
@@ -136,7 +132,7 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
136
132
  )}
137
133
  <InfoRow
138
134
  label={t("checkout-page:subtotal")}
139
- value={checkout.formattedTotalPrice}
135
+ value={formatMoney(checkout.totalPrice, checkout.currencyCode)}
140
136
  tooltipText={t("checkout-page:subtotalTooltip")}
141
137
  />
142
138
  {!!checkout.shippingLines?.length && (
@@ -144,7 +140,10 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
144
140
  label={t("checkout-page:cartShippingTitle")}
145
141
  value={
146
142
  checkout.shippingTotal
147
- ? checkout.formattedShippingTotal
143
+ ? formatMoney(
144
+ checkout.shippingTotal,
145
+ checkout.currencyCode
146
+ )
148
147
  : t("checkout-page:free")
149
148
  }
150
149
  />
@@ -152,16 +151,15 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
152
151
  {!!checkout.totalTax && !!vm.customizationProps?.showTax && (
153
152
  <InfoRow
154
153
  label={t("checkout-page:cartTaxTitle")}
155
- value={checkout.formattedTotalTax}
154
+ value={formatMoney(checkout.totalTax, checkout.currencyCode)}
156
155
  />
157
156
  )}
158
157
  {!!vm.installmentExtraPrice && (
159
158
  <InfoRow
160
159
  label={t("checkout-page:cartInterest")}
161
- value={formatCurrency(
160
+ value={formatMoney(
162
161
  vm.installmentExtraPrice,
163
- checkout.currencyCode,
164
- checkout.currencySymbol
162
+ checkout.currencyCode
165
163
  )}
166
164
  />
167
165
  )}
@@ -195,11 +193,7 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
195
193
  <div className={styles.Title}>{t("checkout-page:total")}</div>
196
194
  </div>
197
195
  <div className={styles.TotalPrice}>
198
- {formatCurrency(
199
- vm.finalPrice || 0,
200
- checkout.currencyCode,
201
- checkout.currencySymbol
202
- )}
196
+ {formatMoney(vm.finalPrice || 0, checkout.currencyCode)}
203
197
  </div>
204
198
  </div>
205
199
 
@@ -279,11 +273,7 @@ const Adjustments: React.FC<CommonProps> = observer(({ vm }) => {
279
273
  <div className={styles.Value}>
280
274
  <span>{adjustment.type === "DECREMENT" ? "- " : ""}</span>{" "}
281
275
  <span>
282
- {formatCurrency(
283
- adjustment.amount,
284
- vm.checkout.currencyCode,
285
- vm.checkout.currencySymbol
286
- )}
276
+ {formatMoney(adjustment.amount, vm.checkout.currencyCode)}
287
277
  </span>
288
278
  </div>
289
279
  </div>
@@ -314,11 +304,7 @@ const CalculatedAdditionalPrices: React.FC<CommonProps> = observer(({ vm }) => {
314
304
  <div className={styles.Value}>
315
305
  <span>{adjustment.type === "DECREMENT" ? "- " : ""}</span>{" "}
316
306
  <span>
317
- {formatCurrency(
318
- adjustment.amount,
319
- vm.checkout!.currencyCode,
320
- vm.checkout!.currencySymbol
321
- )}
307
+ {formatMoney(adjustment.amount, vm.checkout!.currencyCode)}
322
308
  </span>
323
309
  </div>
324
310
  </div>
@@ -332,13 +318,7 @@ const CalculatedAdditionalPrices: React.FC<CommonProps> = observer(({ vm }) => {
332
318
  </div>
333
319
  </div>
334
320
  <div className={styles.Value}>
335
- <span>
336
- {formatCurrency(
337
- gpl.price,
338
- vm.checkout.currencyCode,
339
- vm.checkout!.currencySymbol
340
- )}
341
- </span>
321
+ <span>{formatMoney(gpl.price, vm.checkout.currencyCode)}</span>
342
322
  </div>
343
323
  </div>
344
324
  ))}
@@ -430,11 +410,7 @@ const Coupon: React.FC<CouponProps> = observer(
430
410
  <div className={styles.Value}>
431
411
  <span>{adjustment?.type === "DECREMENT" ? "- " : ""}</span>{" "}
432
412
  <span>
433
- {formatCurrency(
434
- adjustment?.amount || 0,
435
- vm.checkout.currencyCode,
436
- vm.checkout.currencySymbol
437
- )}
413
+ {formatMoney(adjustment?.amount || 0, vm.checkout.currencyCode)}
438
414
  </span>
439
415
  </div>
440
416
  )}
@@ -143,9 +143,7 @@ const CustomerAddresses: React.FC<Props> = ({ vm }) => {
143
143
 
144
144
  {!!vm.vm.store.customerStore.customer &&
145
145
  !vm.editingCustomerAddress &&
146
- (vm.vm.deliveryMethod === "address" ||
147
- (vm.vm.step === CheckoutStep.PAYMENT &&
148
- vm.vm.deliveryMethod === "in-store")) && (
146
+ vm.vm.deliveryMethod === "address" && (
149
147
  <div className={checkoutStyles.RowPB}>
150
148
  {vm.vm.store.customerStore.customer.addresses?.map((address) => (
151
149
  <SelectBox
@@ -185,9 +183,7 @@ const CustomerAddresses: React.FC<Props> = ({ vm }) => {
185
183
  vm.vm.step === CheckoutStep.INFO &&
186
184
  vm.vm.deliveryMethod === "address"
187
185
  ? addressForm
188
- : vm.vm.step === CheckoutStep.PAYMENT &&
189
- !vm.vm.store.customerStore.customer &&
190
- addressForm}
186
+ : vm.vm.step === CheckoutStep.PAYMENT && addressForm}
191
187
 
192
188
  {vm.vm.deliveryMethod === "in-store" && (
193
189
  <div className={checkoutStyles.RowPB}>
@@ -7,7 +7,6 @@ import styles from "./style.module.scss";
7
7
 
8
8
  import { useTranslation } from "../../../../utils";
9
9
  import ReactTooltip from "react-tooltip";
10
- import { PhoneNumberInput } from "../phone-number-input";
11
10
 
12
11
  export const FormItem: React.FC<Props> = observer((props) => {
13
12
  const { t } = useTranslation();
@@ -109,14 +108,17 @@ export const FormItem: React.FC<Props> = observer((props) => {
109
108
  />
110
109
  )}
111
110
  {vm.type === FormItemType.TEL && (
112
- <PhoneNumberInput
113
- key={props.currentCountryCode || "1"}
114
- disabled={vm.disabled}
115
- defaultCountry={props.currentCountryCode}
116
- placeholder={t("checkout-page:enterPhoneNumber")}
117
- value={vm.value ? vm.value : ""}
118
- onChange={vm.onPhoneChange}
119
- />
111
+ <div></div>
112
+ // <PhoneInput
113
+ // key={props.currentCountryCode || "1"}
114
+ // disabled={vm.disabled}
115
+ // defaultCountry={props.currentCountryCode}
116
+ // placeholder={t("checkout-page:enterPhoneNumber")}
117
+ // value={vm.value ? vm.value : ""}
118
+ // onChange={vm.onPhoneChange}
119
+ // international={true}
120
+ // addInternationalOption={false}
121
+ // />
120
122
  )}
121
123
  {vm.type === FormItemType.TEXT_AREA && <TextArea vm={vm} />}
122
124
  {vm.type === FormItemType.SELECT && (
@@ -132,9 +132,7 @@ const CreditCardFormMasterPass = observer(({ vm }: Props) => {
132
132
  <div className={checkoutStyles.RowPB}>
133
133
  <FormItem
134
134
  name="masterPassPhoneNumber"
135
- autocomplete="tel"
136
135
  type={FormItemType.TEL}
137
- currentCountryCode={vm.store.currentCountryCode}
138
136
  disabled={
139
137
  vm.mpVM.isSaveCardToMasterPassPhoneNumberInputDisabled
140
138
  }
@@ -8,7 +8,7 @@ import SVGCross from "../svg/cross";
8
8
  import styles from "./style.module.scss";
9
9
  import { useTranslation } from "../../../../utils/i18n";
10
10
  import { IkasProductVariant } from "../../../../models";
11
- import { formatCurrency } from "../../../../utils/currency";
11
+ import { formatMoney } from "../../../../utils/currency";
12
12
 
13
13
  type Props = {
14
14
  vm: CheckoutViewModel;
@@ -18,7 +18,7 @@ type Props = {
18
18
  const OfferProduct: React.FC<Props> = ({ vm, campaignOffer }) => {
19
19
  const { t } = useTranslation();
20
20
  const [selectedVariant, setSelectedVariant] =
21
- React.useState<IkasProductVariant>(campaignOffer.variants[0]);
21
+ React.useState<IkasProductVariant>(campaignOffer!.product.selectedVariant);
22
22
 
23
23
  const acceptOffer = () => {
24
24
  vm.updateCartCampaignOffer({
@@ -43,7 +43,7 @@ const OfferProduct: React.FC<Props> = ({ vm, campaignOffer }) => {
43
43
  };
44
44
 
45
45
  const onVariantChange = (value: string) => {
46
- const variant = campaignOffer.variants.find((v) => v.id === value);
46
+ const variant = campaignOffer.product.variants.find((v) => v.id === value);
47
47
 
48
48
  if (variant) {
49
49
  setSelectedVariant(variant);
@@ -95,32 +95,35 @@ const OfferProduct: React.FC<Props> = ({ vm, campaignOffer }) => {
95
95
  <span className={styles.Discount}>
96
96
  {selectedVariant.price.formattedFinalPrice}
97
97
  </span>{" "}
98
- {formatCurrency(
98
+ {formatMoney(
99
99
  selectedVariant.price.finalPrice -
100
100
  (selectedVariant.price.finalPrice *
101
101
  (campaignOffer.offer.discountAmount || 100)) /
102
102
  100,
103
- vm.checkout!.currencyCode,
104
- vm.checkout!.currencySymbol
103
+ vm.checkout!.currencyCode
105
104
  )}
106
105
  </div>
107
106
  <div className={styles.Actions}>
108
- {campaignOffer.variants.length > 1 && (
109
- <Select
110
- value={selectedVariant.id}
111
- onSelectChange={onVariantChange}
112
- options={campaignOffer.variants.map((v) => ({
113
- label: v.variantValues.map((vv) => vv.name).join(", "),
114
- value: v.id,
115
- }))}
116
- />
117
- )}
107
+ {campaignOffer.product.hasVariant &&
108
+ campaignOffer.product.hasStock && (
109
+ <Select
110
+ value={selectedVariant.id}
111
+ onSelectChange={onVariantChange}
112
+ options={campaignOffer.product.variants
113
+ .filter((v) => v.hasStock)
114
+ .map((v) => ({
115
+ label: v.variantValues.map((vv) => vv.name).join(", "),
116
+ value: v.id,
117
+ }))}
118
+ />
119
+ )}
118
120
  <Button
119
121
  style={{
120
122
  width: "100%",
121
123
  height: 44,
122
124
  fontSize: 14,
123
125
  }}
126
+ isDisabled={!campaignOffer.product.hasStock}
124
127
  text={t("checkout-page:actions.addToCart")}
125
128
  onClick={acceptOffer}
126
129
  />
@@ -62,6 +62,7 @@
62
62
  }
63
63
 
64
64
  .ImageContainer {
65
+ height: 136px;
65
66
  width: 136px;
66
67
  position: relative;
67
68
  background-color: #fff;
@@ -72,7 +73,8 @@
72
73
 
73
74
  .Image {
74
75
  width: 100%;
75
- object-fit: contain;
76
+ height: 100%;
77
+ object-fit: cover;
76
78
  border-radius: 8px;
77
79
  }
78
80
 
@@ -1,50 +1,18 @@
1
- import { IkasStorefrontConfig } from "@ikas/storefront-config";
2
1
  import { CountryCode, getCountries as categories } from "libphonenumber-js";
3
2
  import compareStrings from "./compare-strings";
4
3
 
5
- export type CountryType = {
4
+ import en from "./locale/en";
5
+
6
+ type CountryType = {
6
7
  value: CountryCode;
7
8
  label: string | undefined;
8
9
  };
9
10
 
10
- const getUrl = () => {
11
- const languages = [
12
- "de",
13
- "el",
14
- "en",
15
- "es",
16
- "fi",
17
- "fr",
18
- "it",
19
- "nb",
20
- "pl",
21
- "pt-BR",
22
- "pt",
23
- "ru",
24
- "sv",
25
- "tr",
26
- "ua",
27
- "vi",
28
- ];
29
-
30
- let locale = IkasStorefrontConfig.getCurrentLocale();
31
-
32
- if (!languages.some((language) => language === locale)) {
33
- locale = "en";
34
- }
35
-
36
- return `https://cdn.myikas.com/sf/static/locale/country/${locale}.json`;
37
- };
38
-
39
- const getCountries = async (): Promise<CountryType[]> => {
40
- const url = getUrl();
41
- const response = await fetch(url);
42
- const lang = await response.json();
43
-
11
+ const getCountries = (): CountryType[] => {
44
12
  return categories()
45
13
  .map((country) => ({
46
14
  value: country,
47
- label: lang[country],
15
+ label: en[country],
48
16
  }))
49
17
  .sort((a, b) => compareStrings(a.label, b.label));
50
18
  };