@ikas/storefront 4.0.0-alpha.5 → 4.0.0-alpha.50

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 (85) hide show
  1. package/package.json +13 -13
  2. package/src/analytics/analytics.ts +2 -1
  3. package/src/analytics/googleUniversal.ts +12 -2
  4. package/src/analytics/head/index.tsx +1 -2
  5. package/src/analytics/ikas.ts +25 -7
  6. package/src/components/checkout/components/address-form/index.tsx +1 -1
  7. package/src/components/checkout/components/address-form/model.ts +1 -0
  8. package/src/components/checkout/components/button/style.module.scss +2 -2
  9. package/src/components/checkout/components/cart-summary/cart-item/index.tsx +16 -29
  10. package/src/components/checkout/components/cart-summary/cart-item/style.module.scss +60 -23
  11. package/src/components/checkout/components/cart-summary/index.tsx +58 -27
  12. package/src/components/checkout/components/cart-summary/style.module.scss +48 -3
  13. package/src/components/checkout/components/customer-addresses/index.tsx +7 -2
  14. package/src/components/checkout/components/customer-addresses/model.ts +16 -8
  15. package/src/components/checkout/components/error/index.tsx +1 -1
  16. package/src/components/checkout/components/error/unknown-error/index.tsx +4 -2
  17. package/src/components/checkout/components/form-item/index.tsx +9 -11
  18. package/src/components/checkout/components/master-pass/credit-card-form/index.tsx +2 -0
  19. package/src/components/checkout/components/offer-product/index.tsx +16 -19
  20. package/src/components/checkout/components/offer-product/style.module.scss +1 -3
  21. package/src/components/checkout/components/phone-number-input/get-countries.ts +37 -5
  22. package/src/components/checkout/components/phone-number-input/index.tsx +15 -10
  23. package/src/components/checkout/index.tsx +28 -19
  24. package/src/components/checkout/model.ts +214 -91
  25. package/src/components/checkout/modelMasterPass.ts +2 -2
  26. package/src/components/checkout/steps/step-info/index.tsx +9 -3
  27. package/src/components/checkout/steps/step-payment/billing-address/index.tsx +1 -1
  28. package/src/components/checkout/steps/step-payment/index.tsx +11 -2
  29. package/src/components/checkout/steps/step-payment/payment-gateways/index.tsx +12 -3
  30. package/src/components/checkout/steps/step-payment/payment-gateways/installments/index.tsx +5 -3
  31. package/src/components/checkout/steps/step-payment/style.module.scss +5 -0
  32. package/src/components/checkout/steps/step-shipping/index.tsx +9 -4
  33. package/src/components/checkout/steps/step-success/index.tsx +15 -7
  34. package/src/components/page/head.tsx +12 -0
  35. package/src/components/page/index.tsx +10 -9
  36. package/src/components/page-editor/ThemeComponentEditor.tsx +19 -8
  37. package/src/components/page-editor/model.ts +44 -107
  38. package/src/models/data/cart/campaign-offer/index.ts +13 -2
  39. package/src/models/data/cart/index.ts +1 -1
  40. package/src/models/data/category/path-item/index.ts +4 -0
  41. package/src/models/data/checkout/index.ts +36 -4
  42. package/src/models/data/checkout-settings/price/index.ts +2 -0
  43. package/src/models/data/country/index.ts +4 -0
  44. package/src/models/data/country/location-translations/index.ts +15 -0
  45. package/src/models/data/index.ts +3 -0
  46. package/src/models/data/merchant-settings/index.ts +9 -0
  47. package/src/models/data/order/index.ts +51 -32
  48. package/src/models/data/order/line-item/base-unit/index.ts +22 -0
  49. package/src/models/data/order/line-item/base-unit/unit-type/index.ts +14 -0
  50. package/src/models/data/order/line-item/index.ts +76 -18
  51. package/src/models/data/order/line-item/variant/index.ts +8 -0
  52. package/src/models/data/order/line-item/variant/price/index.ts +2 -0
  53. package/src/models/data/order/line-item/variant/unit/index.ts +17 -0
  54. package/src/models/data/order/line-item/variant/value/index.ts +1 -1
  55. package/src/models/data/order/transaction/index.ts +2 -5
  56. package/src/models/data/product/attribute-value/index.ts +40 -0
  57. package/src/models/data/product/base-unit/index.ts +32 -0
  58. package/src/models/data/product/filter/index.ts +4 -13
  59. package/src/models/data/product/index.ts +45 -7
  60. package/src/models/data/product/option-set/index.ts +8 -3
  61. package/src/models/data/product/option-set/option/index.ts +36 -13
  62. package/src/models/data/product/variant/index.ts +26 -1
  63. package/src/models/data/product/variant/price/index.ts +25 -9
  64. package/src/models/data/product/variant/unit/index.ts +17 -0
  65. package/src/models/data/product/variant-type/index.ts +2 -0
  66. package/src/models/data/raffle/index.ts +9 -7
  67. package/src/models/data/state/index.ts +6 -2
  68. package/src/models/data/storefront/index.ts +2 -0
  69. package/src/models/data/storefront/routing/index.tsx +4 -0
  70. package/src/models/ui/product-list/index.ts +26 -17
  71. package/src/models/ui/raffle-list/index.ts +1 -1
  72. package/src/models/ui/validator/form/raffle-form.ts +16 -3
  73. package/src/models/ui/validator/rules/index.ts +14 -13
  74. package/src/page-data-init/index.ts +159 -404
  75. package/src/pages/checkout.tsx +2 -1
  76. package/src/pages/editor.tsx +5 -2
  77. package/src/store/base.ts +2 -2
  78. package/src/store/cart/index.ts +2 -2
  79. package/src/store/customer/index.ts +7 -17
  80. package/src/store/index.ts +2 -0
  81. package/src/store/raffle/index.ts +7 -10
  82. package/src/utils/constants.ts +1 -1
  83. package/src/utils/currency.ts +9 -183
  84. package/src/components/checkout/components/phone-number-input/locale/en.ts +0 -257
  85. package/src/models/data/category/init.ts +0 -33
@@ -1,15 +1,18 @@
1
1
  import {
2
2
  IkasMerchantSettingsCurrencyFormat,
3
3
  IkasMerchantSettings as IMerchantSettings,
4
+ IkasMerchantAddress,
4
5
  } from "@ikas/storefront-models";
5
6
  import { makeAutoObservable } from "mobx";
6
7
  import { IkasImage } from "../image";
7
8
 
8
9
  export class IkasMerchantSettings implements IMerchantSettings {
9
10
  currencyFormats: IkasMerchantSettingsCurrencyFormat[] | null;
11
+ address: IkasMerchantAddress | null;
10
12
  logoId: string | null;
11
13
  merchantId: string;
12
14
  merchantName: string;
15
+ phone: string | null;
13
16
 
14
17
  // Extra
15
18
  logo?: IkasImage | null;
@@ -19,7 +22,13 @@ export class IkasMerchantSettings implements IMerchantSettings {
19
22
  this.logoId = data.logoId;
20
23
  this.merchantId = data.merchantId;
21
24
  this.merchantName = data.merchantName;
25
+ this.phone = data.phone || null;
26
+ this.address = data.address || null;
27
+
22
28
  this.logo = data.logo ? new IkasImage(data.logo) : null;
29
+ if (!this.logo && this.logoId) {
30
+ this.logo = new IkasImage({ id: this.logoId, isVideo: false });
31
+ }
23
32
 
24
33
  makeAutoObservable(this);
25
34
  }
@@ -20,7 +20,7 @@ import {
20
20
  import { IkasOrder as IOrder } from "@ikas/storefront-models";
21
21
  import { computed, makeObservable, observable } from "mobx";
22
22
  import { IkasOrderFunctions } from "@ikas/storefront-model-functions";
23
- import { formatMoney, getCurrencySymbol } from "../../../utils/currency";
23
+ import { formatCurrency } from "../../../utils/currency";
24
24
 
25
25
  type IOrderConstructorData = {
26
26
  refundSettings?: IkasOrderRefundSettings | null;
@@ -31,6 +31,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
31
31
  cancelReason: IkasOrderCancelReason | null = null;
32
32
  cancelledAt: number | null = null;
33
33
  currencyCode: string;
34
+ currencySymbol: string | null = null;
34
35
  customer: IkasOrderCustomer | null = null;
35
36
  customerId: string | null = null;
36
37
  giftPackageLines: IkasOrderGiftPackageLine[] | null = null;
@@ -57,15 +58,16 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
57
58
  // Extra
58
59
  refundSettings?: IkasOrderRefundSettings | null;
59
60
 
60
- constructor(data: IOrderConstructorData) {
61
- super(data);
61
+ constructor(data: Partial<IOrderConstructorData>) {
62
+ super(data as any);
62
63
 
63
64
  this.billingAddress = data.billingAddress
64
65
  ? new IkasOrderAddress(data.billingAddress)
65
66
  : null;
66
67
  this.cancelReason = data.cancelReason || null;
67
68
  this.cancelledAt = data.cancelledAt || null;
68
- this.currencyCode = data.currencyCode;
69
+ this.currencyCode = data.currencyCode || "";
70
+ this.currencySymbol = data.currencySymbol || null;
69
71
  this.customer = data.customer ? new IkasOrderCustomer(data.customer) : null;
70
72
  this.customerId = data.customerId || null;
71
73
  this.giftPackageLines =
@@ -78,7 +80,9 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
78
80
  this.orderAdjustments =
79
81
  data.orderAdjustments?.map((oa) => new IkasOrderAdjustment(oa)) || null;
80
82
  this.orderLineItems =
81
- data.orderLineItems.map((oli) => new IkasOrderLineItem(oli)) || null;
83
+ data.orderLineItems
84
+ ?.map((oli) => new IkasOrderLineItem(oli))
85
+ .filter((i) => !i.deleted) || [];
82
86
  this.orderNumber = data.orderNumber || null;
83
87
  this.orderPackageStatus = data.orderPackageStatus || null;
84
88
  this.orderPackages =
@@ -90,12 +94,15 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
90
94
  this.shippingAddress = data.shippingAddress
91
95
  ? new IkasOrderAddress(data.shippingAddress)
92
96
  : null;
93
- this.shippingMethod = data.shippingMethod;
94
- this.status = data.status;
97
+ this.shippingLines =
98
+ data.shippingLines?.map((sl) => new IkasOrderShippingLine(sl)) || null;
99
+ this.shippingMethod =
100
+ data.shippingMethod || IkasOrderShippingMethod.SHIPMENT;
101
+ this.status = data.status || IkasOrderStatus.CREATED;
95
102
  this.taxLines =
96
103
  data.taxLines?.map((tl) => new IkasOrderTaxLine(tl)) || null;
97
- this.totalFinalPrice = data.totalFinalPrice;
98
- this.totalPrice = data.totalPrice;
104
+ this.totalFinalPrice = data.totalFinalPrice ?? 0;
105
+ this.totalPrice = data.totalPrice ?? 0;
99
106
 
100
107
  this.refundSettings = data.refundSettings;
101
108
 
@@ -104,6 +111,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
104
111
  cancelReason: observable,
105
112
  cancelledAt: observable,
106
113
  currencyCode: observable,
114
+ currencySymbol: observable,
107
115
  customer: observable,
108
116
  customerId: observable,
109
117
  giftPackageLines: observable,
@@ -130,7 +138,6 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
130
138
 
131
139
  items: computed,
132
140
  itemCount: computed,
133
- currencySymbol: computed,
134
141
  refundableItems: computed,
135
142
  unfullfilledItems: computed,
136
143
  refundedItems: computed,
@@ -157,27 +164,20 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
157
164
  return this.items?.length || 0;
158
165
  }
159
166
 
160
- get currencySymbol() {
161
- return getCurrencySymbol(this.currencyCode);
162
- }
163
-
164
167
  get refundableItems() {
165
168
  if (!this.refundSettings) return [];
166
- return IkasOrderFunctions.getRefundableItems(this, this.refundSettings).map(
167
- (i) => new IkasOrderLineItem(i)
168
- );
169
+ return IkasOrderFunctions.getRefundableItems(
170
+ this,
171
+ this.refundSettings
172
+ ) as IkasOrderLineItem[];
169
173
  }
170
174
 
171
175
  get unfullfilledItems() {
172
- return IkasOrderFunctions.getUnfullfilledItems(this).map(
173
- (i) => new IkasOrderLineItem(i)
174
- );
176
+ return IkasOrderFunctions.getUnfullfilledItems(this) as IkasOrderLineItem[];
175
177
  }
176
178
 
177
179
  get refundedItems() {
178
- return IkasOrderFunctions.getRefundedItems(this).map(
179
- (i) => new IkasOrderLineItem(i)
180
- );
180
+ return IkasOrderFunctions.getRefundedItems(this) as IkasOrderLineItem[];
181
181
  }
182
182
 
183
183
  get totalTax() {
@@ -185,7 +185,11 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
185
185
  }
186
186
 
187
187
  get formattedTotalTax() {
188
- return formatMoney(this.totalTax, this.currencySymbol);
188
+ return formatCurrency(
189
+ this.totalTax,
190
+ this.currencyCode,
191
+ this.currencySymbol || ""
192
+ );
189
193
  }
190
194
 
191
195
  get shippingTotal() {
@@ -193,15 +197,27 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
193
197
  }
194
198
 
195
199
  get formattedShippingTotal() {
196
- return formatMoney(this.shippingTotal, this.currencySymbol);
200
+ return formatCurrency(
201
+ this.shippingTotal,
202
+ this.currencyCode,
203
+ this.currencySymbol || ""
204
+ );
197
205
  }
198
206
 
199
207
  get formattedTotalFinalPrice() {
200
- return formatMoney(this.totalFinalPrice, this.currencySymbol);
208
+ return formatCurrency(
209
+ this.totalFinalPrice,
210
+ this.currencyCode,
211
+ this.currencySymbol || ""
212
+ );
201
213
  }
202
214
 
203
215
  get formattedTotalPrice() {
204
- return formatMoney(this.totalPrice, this.currencySymbol);
216
+ return formatCurrency(
217
+ this.totalPrice,
218
+ this.currencyCode,
219
+ this.currencySymbol || ""
220
+ );
205
221
  }
206
222
 
207
223
  get hasCustomer() {
@@ -221,14 +237,17 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
221
237
  }
222
238
 
223
239
  get couponAdjustment() {
224
- const adjustment = IkasOrderFunctions.getCouponAdjustment(this);
225
- return adjustment ? new IkasOrderAdjustment(adjustment) : undefined;
240
+ return IkasOrderFunctions.getCouponAdjustment(this) as IkasOrderAdjustment;
226
241
  }
227
242
 
228
243
  get nonCouponAdjustments() {
229
- return IkasOrderFunctions.getNonCouponAdjustments(this)?.map(
230
- (a) => new IkasOrderAdjustment(a)
231
- );
244
+ return IkasOrderFunctions.getNonCouponAdjustments(
245
+ this
246
+ ) as IkasOrderAdjustment[];
247
+ }
248
+
249
+ get isRefundEnabled() {
250
+ return !this.refundableItems.some((item) => item.refundQuantity === null);
232
251
  }
233
252
  }
234
253
 
@@ -0,0 +1,22 @@
1
+ import {
2
+ IkasProductUnitType,
3
+ IkasOrderLineBaseUnit as IOrderLineBaseUnit,
4
+ } from "@ikas/storefront-models";
5
+ import { makeAutoObservable } from "mobx";
6
+ import { IkasOrderLineVariantUnitType } from "./unit-type";
7
+
8
+ export class IkasOrderLineBaseUnit implements IOrderLineBaseUnit {
9
+ baseAmount: number;
10
+ type: IkasProductUnitType;
11
+ unit: IkasOrderLineVariantUnitType | null;
12
+
13
+ constructor(data: IOrderLineBaseUnit) {
14
+ this.baseAmount = data.baseAmount;
15
+ this.type = data.type;
16
+ this.unit = data.unit ? new IkasOrderLineVariantUnitType(data.unit) : null;
17
+
18
+ makeAutoObservable(this);
19
+ }
20
+ }
21
+
22
+ export { IkasProductUnitType };
@@ -0,0 +1,14 @@
1
+ import { IkasOrderLineVariantUnitType as IOrderLineVariantUnitType } from "@ikas/storefront-models";
2
+ import { makeAutoObservable } from "mobx";
3
+
4
+ export class IkasOrderLineVariantUnitType implements IOrderLineVariantUnitType {
5
+ id: string;
6
+ name: string;
7
+
8
+ constructor(data: IOrderLineVariantUnitType) {
9
+ this.id = data.id;
10
+ this.name = data.name;
11
+
12
+ makeAutoObservable(this);
13
+ }
14
+ }
@@ -8,7 +8,7 @@ import { IkasOrderLineItemOption } from "./option";
8
8
  import { IkasBaseModel } from "../../base";
9
9
  import { computed, makeObservable, observable } from "mobx";
10
10
  import { IkasOrderLineItemFunctions } from "@ikas/storefront-model-functions";
11
- import { formatMoney, getCurrencySymbol } from "../../../../utils/currency";
11
+ import { formatCurrency } from "../../../../utils/currency";
12
12
 
13
13
  type IOrderLineItemConstructorParams = {
14
14
  refundQuantity?: number;
@@ -16,9 +16,11 @@ type IOrderLineItemConstructorParams = {
16
16
 
17
17
  export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
18
18
  currencyCode: string | null = null;
19
+ currencySymbol: string | null;
19
20
  discount: IkasOrderLineDiscount | null = null;
20
21
  discountPrice: number | null = null;
21
22
  finalPrice: number | null = null;
23
+ finalUnitPrice: number | null;
22
24
  options: IkasOrderLineItemOption[] | null = null;
23
25
  originalOrderLineItemId: string | null = null;
24
26
  price: number;
@@ -27,6 +29,7 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
27
29
  statusUpdatedAt: number | null = null;
28
30
  stockLocationId: string | null = null;
29
31
  taxValue: number | null = null;
32
+ unitPrice: number | null;
30
33
  variant: IkasOrderLineVariant;
31
34
  orderedAt: number;
32
35
 
@@ -37,17 +40,23 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
37
40
  super(data);
38
41
 
39
42
  this.currencyCode = data.currencyCode || null;
43
+ this.currencySymbol = data.currencySymbol || null;
40
44
  this.discount = data.discount
41
45
  ? new IkasOrderLineDiscount(data.discount)
42
46
  : null;
43
- this.discountPrice = data.discountPrice || null;
44
- this.finalPrice = data.finalPrice || null;
45
- (this.options =
46
- data.options?.map((o) => new IkasOrderLineItemOption(o)) || null),
47
- (this.originalOrderLineItemId = data.originalOrderLineItemId || null);
47
+ this.discountPrice = data.discountPrice ?? null;
48
+ this.finalPrice = data.finalPrice ?? null;
49
+ this.finalUnitPrice = data.finalUnitPrice ?? null;
50
+ this.options =
51
+ data.options?.map((o) => new IkasOrderLineItemOption(o)) || null;
52
+ this.originalOrderLineItemId = data.originalOrderLineItemId || null;
48
53
  this.price = data.price;
49
54
  this.quantity = data.quantity;
50
55
  this.status = data.status;
56
+ this.statusUpdatedAt = data.statusUpdatedAt;
57
+ this.stockLocationId = data.stockLocationId;
58
+ this.taxValue = data.taxValue;
59
+ this.unitPrice = data.unitPrice ?? null;
51
60
  this.variant = new IkasOrderLineVariant(data.variant);
52
61
  this.orderedAt = data.orderedAt;
53
62
 
@@ -55,9 +64,11 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
55
64
 
56
65
  makeObservable(this, {
57
66
  currencyCode: observable,
67
+ currencySymbol: observable,
58
68
  discount: observable,
59
69
  discountPrice: observable,
60
70
  finalPrice: observable,
71
+ finalUnitPrice: observable,
61
72
  options: observable,
62
73
  originalOrderLineItemId: observable,
63
74
  price: observable,
@@ -66,15 +77,19 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
66
77
  statusUpdatedAt: observable,
67
78
  stockLocationId: observable,
68
79
  taxValue: observable,
80
+ unitPrice: observable,
69
81
  variant: observable,
70
82
  orderedAt: observable,
83
+ //@ts-ignore
84
+ _refundQuantity: observable,
71
85
 
72
- currencySymbol: computed,
73
86
  priceWithQuantity: computed,
74
87
  formattedPriceWithQuantity: computed,
75
88
  overridenPriceWithQuantity: computed,
76
89
  formattedOverridenPriceWithQuantity: computed,
77
90
  formattedFinalPrice: computed,
91
+ formattedUnitPrice: computed,
92
+ formattedFinalUnitPrice: computed,
78
93
  formattedDiscountPrice: computed,
79
94
  finalPriceWithQuantity: computed,
80
95
  formattedFinalPriceWithQuantity: computed,
@@ -84,16 +99,16 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
84
99
  });
85
100
  }
86
101
 
87
- get currencySymbol() {
88
- return getCurrencySymbol(this.currencyCode || "");
89
- }
90
-
91
102
  get priceWithQuantity() {
92
103
  return IkasOrderLineItemFunctions.getPriceWithQuantity(this);
93
104
  }
94
105
 
95
106
  get formattedPriceWithQuantity() {
96
- return formatMoney(this.priceWithQuantity, this.currencySymbol);
107
+ return formatCurrency(
108
+ this.priceWithQuantity,
109
+ this.currencyCode || "",
110
+ this.currencySymbol || ""
111
+ );
97
112
  }
98
113
 
99
114
  get overridenPriceWithQuantity() {
@@ -101,18 +116,53 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
101
116
  }
102
117
 
103
118
  get formattedOverridenPriceWithQuantity() {
104
- return formatMoney(
119
+ return formatCurrency(
105
120
  this.overridenPriceWithQuantity || 0,
106
- this.currencySymbol
121
+ this.currencyCode || "",
122
+ this.currencySymbol || ""
107
123
  );
108
124
  }
109
125
 
110
126
  get formattedFinalPrice() {
111
- return formatMoney(this.finalPrice || 0, this.currencySymbol);
127
+ return formatCurrency(
128
+ this.finalPrice || 0,
129
+ this.currencyCode || "",
130
+ this.currencySymbol || ""
131
+ );
132
+ }
133
+
134
+ get formattedUnitPrice() {
135
+ return formatCurrency(
136
+ this.unitPrice || 0,
137
+ this.currencyCode || "",
138
+ this.currencySymbol || ""
139
+ );
140
+ }
141
+
142
+ get formattedFinalUnitPrice() {
143
+ return formatCurrency(
144
+ this.finalUnitPrice || 0,
145
+ this.currencyCode || "",
146
+ this.currencySymbol || ""
147
+ );
148
+ }
149
+
150
+ get unitPriceText() {
151
+ if (this.finalUnitPrice === null) return;
152
+
153
+ return `${formatCurrency(
154
+ this.finalUnitPrice,
155
+ this.currencyCode || "",
156
+ this.currencySymbol || ""
157
+ )} / ${this.variant.baseUnit?.unit?.name || this.variant.baseUnit?.type}`;
112
158
  }
113
159
 
114
160
  get formattedDiscountPrice() {
115
- return formatMoney(this.discountPrice || 0, this.currencySymbol);
161
+ return formatCurrency(
162
+ this.discountPrice || 0,
163
+ this.currencyCode || "",
164
+ this.currencySymbol || ""
165
+ );
116
166
  }
117
167
 
118
168
  get finalPriceWithQuantity() {
@@ -120,7 +170,11 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
120
170
  }
121
171
 
122
172
  get formattedFinalPriceWithQuantity() {
123
- return formatMoney(this.finalPriceWithQuantity || 0, this.currencySymbol);
173
+ return formatCurrency(
174
+ this.finalPriceWithQuantity || 0,
175
+ this.currencyCode || "",
176
+ this.currencySymbol || ""
177
+ );
124
178
  }
125
179
 
126
180
  get tax() {
@@ -128,7 +182,11 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
128
182
  }
129
183
 
130
184
  get formattedTax() {
131
- return formatMoney(this.tax, this.currencySymbol);
185
+ return formatCurrency(
186
+ this.tax,
187
+ this.currencyCode || "",
188
+ this.currencySymbol || ""
189
+ );
132
190
  }
133
191
 
134
192
  get refundQuantity() {
@@ -6,9 +6,12 @@ import { IkasOrderLineVariantBrand } from "./brand";
6
6
  import { IkasOrderLineVariantCategory } from "./category";
7
7
  import { IkasOrderLineVariantPrice } from "./price";
8
8
  import { makeAutoObservable } from "mobx";
9
+ import { IkasOrderLineVariantUnit } from "./unit";
10
+ import { IkasOrderLineBaseUnit } from "../base-unit";
9
11
 
10
12
  export class IkasOrderLineVariant implements IOrderLineVariant {
11
13
  barcodeList: string[] | null = null;
14
+ baseUnit: IkasOrderLineBaseUnit | null;
12
15
  brand: IkasOrderLineVariantBrand | null = null;
13
16
  categories: IkasOrderLineVariantCategory[] | null = null;
14
17
  id: string | null = null;
@@ -21,6 +24,7 @@ export class IkasOrderLineVariant implements IOrderLineVariant {
21
24
  tagIds: string[] | null = null;
22
25
  taxValue: number | null = null;
23
26
  type: number | null = null;
27
+ unit: IkasOrderLineVariantUnit | null;
24
28
  weight: number | null = null;
25
29
  variantValues: IkasOrderLineVariantVariantValue[] | null = null;
26
30
 
@@ -29,6 +33,9 @@ export class IkasOrderLineVariant implements IOrderLineVariant {
29
33
 
30
34
  constructor(data: IOrderLineVariant) {
31
35
  this.barcodeList = data.barcodeList || null;
36
+ this.baseUnit = data.baseUnit
37
+ ? new IkasOrderLineBaseUnit(data.baseUnit)
38
+ : null;
32
39
  this.brand = data.brand ? new IkasOrderLineVariantBrand(data.brand) : null;
33
40
  this.categories =
34
41
  data.categories?.map((c) => new IkasOrderLineVariantCategory(c)) || null;
@@ -43,6 +50,7 @@ export class IkasOrderLineVariant implements IOrderLineVariant {
43
50
  this.tagIds = data.tagIds || null;
44
51
  this.taxValue = data.taxValue || null;
45
52
  this.type = data.type || null;
53
+ this.unit = data.unit ? new IkasOrderLineVariantUnit(data.unit) : null;
46
54
  this.weight = data.weight || null;
47
55
  this.variantValues =
48
56
  data.variantValues?.map(
@@ -7,6 +7,7 @@ export class IkasOrderLineVariantPrice implements IOrderLineVariantPrice {
7
7
  discountPrice: number | null = null;
8
8
  priceListId: string | null = null;
9
9
  sellPrice: number;
10
+ unitPrice: number | null;
10
11
 
11
12
  constructor(data: IOrderLineVariantPrice) {
12
13
  this.buyPrice = data.buyPrice || null;
@@ -14,6 +15,7 @@ export class IkasOrderLineVariantPrice implements IOrderLineVariantPrice {
14
15
  this.discountPrice = data.discountPrice || null;
15
16
  this.priceListId = data.priceListId || null;
16
17
  this.sellPrice = data.sellPrice;
18
+ this.unitPrice = data.unitPrice;
17
19
 
18
20
  makeAutoObservable(this);
19
21
  }
@@ -0,0 +1,17 @@
1
+ import {
2
+ IkasProductUnitType,
3
+ IkasOrderLineVariantUnit as IOrderLineVariantUnit,
4
+ } from "@ikas/storefront-models";
5
+ import { makeAutoObservable } from "mobx";
6
+
7
+ export class IkasOrderLineVariantUnit implements IOrderLineVariantUnit {
8
+ amount: number;
9
+ type: IkasProductUnitType;
10
+
11
+ constructor(data: IOrderLineVariantUnit) {
12
+ this.amount = data.amount;
13
+ this.type = data.type;
14
+
15
+ makeAutoObservable(this);
16
+ }
17
+ }
@@ -16,7 +16,7 @@ export class IkasOrderLineVariantVariantValue
16
16
  this.variantTypeId = data.variantTypeId;
17
17
  this.variantTypeName = data.variantTypeName || null;
18
18
  this.variantValueId = data.variantValueId;
19
- this.variantTypeName = data.variantTypeName || null;
19
+ this.variantValueName = data.variantValueName || null;
20
20
 
21
21
  makeAutoObservable(this);
22
22
  }
@@ -5,7 +5,6 @@ import {
5
5
  IkasOrderTransaction as IOrderTransaction,
6
6
  } from "@ikas/storefront-models";
7
7
  import { makeAutoObservable } from "mobx";
8
- import { getCurrencySymbol } from "../../../../utils/currency";
9
8
  import { IkasTransactionError } from "./error";
10
9
  import { IkasTransactionPaymentMethodDetail } from "./payment-method-detail";
11
10
 
@@ -14,6 +13,7 @@ export class IkasOrderTransaction implements IOrderTransaction {
14
13
  checkoutId: string | null;
15
14
  createdAt: number | null;
16
15
  currencyCode: string | null;
16
+ currencySymbol: string | null;
17
17
  customerId: string | null;
18
18
  error: IkasTransactionError | null;
19
19
  id: string | null;
@@ -33,6 +33,7 @@ export class IkasOrderTransaction implements IOrderTransaction {
33
33
  this.checkoutId = data.checkoutId || null;
34
34
  this.createdAt = data.createdAt || null;
35
35
  this.currencyCode = data.currencyCode || null;
36
+ this.currencySymbol = data.currencySymbol || null;
36
37
  this.customerId = data.customerId || null;
37
38
  this.error = data.error ? new IkasTransactionError(data.error) : null;
38
39
  this.id = data.id;
@@ -49,10 +50,6 @@ export class IkasOrderTransaction implements IOrderTransaction {
49
50
 
50
51
  makeAutoObservable(this);
51
52
  }
52
-
53
- get currencySymbol() {
54
- return getCurrencySymbol(this.currencyCode || "");
55
- }
56
53
  }
57
54
 
58
55
  export { IkasTransactionStatus, IkasTransactionType };
@@ -5,9 +5,11 @@ import {
5
5
  IkasProductAttributeValue as IProductAttributeValue,
6
6
  IkasAttributeTableCellValue as IAttributeTableCellValue,
7
7
  IkasProductAttributeMap as IProductAttributeMap,
8
+ IkasProductAttributeType,
8
9
  } from "@ikas/storefront-models";
9
10
  import { makeAutoObservable } from "mobx";
10
11
  import { IkasProductAttributeValueFunctions } from "@ikas/storefront-model-functions";
12
+ import ProductStore from "../../../../store/product";
11
13
 
12
14
  export class IkasProductAttributeValue implements IProductAttributeValue {
13
15
  imageIds: string[] | null = null;
@@ -40,6 +42,44 @@ export class IkasProductAttributeValue implements IProductAttributeValue {
40
42
  get tableValue() {
41
43
  return IkasProductAttributeValueFunctions.getTableValue(this.value);
42
44
  }
45
+
46
+ get productIds() {
47
+ if (
48
+ this.productAttribute?.type !== IkasProductAttributeType.PRODUCT ||
49
+ !this.value
50
+ ) {
51
+ return [];
52
+ }
53
+
54
+ try {
55
+ return JSON.parse(this.value) as string[];
56
+ } catch (err) {
57
+ console.error(err);
58
+ return [];
59
+ }
60
+ }
61
+
62
+ async getProducts() {
63
+ if (
64
+ this.productAttribute?.type !== IkasProductAttributeType.PRODUCT ||
65
+ !this.value
66
+ ) {
67
+ return [];
68
+ }
69
+
70
+ try {
71
+ const response = await ProductStore.searchProducts({
72
+ input: {
73
+ productIdList: this.productIds,
74
+ },
75
+ });
76
+
77
+ return response.data?.data || [];
78
+ } catch (err) {
79
+ console.error(err);
80
+ return [];
81
+ }
82
+ }
43
83
  }
44
84
 
45
85
  export class IkasAttributeTableCellValue implements IAttributeTableCellValue {
@@ -0,0 +1,32 @@
1
+ import {
2
+ IkasProductUnitType,
3
+ IkasProductBaseUnit as IProductBaseUnit,
4
+ IkasProductUnit as IProductUnit,
5
+ } from "@ikas/storefront-models";
6
+ import { makeAutoObservable } from "mobx";
7
+
8
+ export class IkasProductBaseUnit implements IProductBaseUnit {
9
+ baseAmount: number | null;
10
+ type: IkasProductUnitType;
11
+ unit: IkasProductUnit;
12
+
13
+ constructor(data: IProductBaseUnit) {
14
+ this.baseAmount = data.baseAmount;
15
+ this.type = data.type;
16
+ this.unit = new IkasProductUnit(data.unit);
17
+
18
+ makeAutoObservable(this);
19
+ }
20
+ }
21
+
22
+ export class IkasProductUnit implements IProductUnit {
23
+ id: string;
24
+ name: string;
25
+
26
+ constructor(data: IkasProductUnit) {
27
+ this.id = data.id;
28
+ this.name = data.name;
29
+
30
+ makeAutoObservable(this);
31
+ }
32
+ }