@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
@@ -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 { formatCurrency } from "../../../utils/currency";
23
+ import { formatMoney, getCurrencySymbol } from "../../../utils/currency";
24
24
 
25
25
  type IOrderConstructorData = {
26
26
  refundSettings?: IkasOrderRefundSettings | null;
@@ -31,7 +31,6 @@ 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;
35
34
  customer: IkasOrderCustomer | null = null;
36
35
  customerId: string | null = null;
37
36
  giftPackageLines: IkasOrderGiftPackageLine[] | null = null;
@@ -58,16 +57,15 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
58
57
  // Extra
59
58
  refundSettings?: IkasOrderRefundSettings | null;
60
59
 
61
- constructor(data: Partial<IOrderConstructorData>) {
62
- super(data as any);
60
+ constructor(data: IOrderConstructorData) {
61
+ super(data);
63
62
 
64
63
  this.billingAddress = data.billingAddress
65
64
  ? new IkasOrderAddress(data.billingAddress)
66
65
  : null;
67
66
  this.cancelReason = data.cancelReason || null;
68
67
  this.cancelledAt = data.cancelledAt || null;
69
- this.currencyCode = data.currencyCode || "";
70
- this.currencySymbol = data.currencySymbol || null;
68
+ this.currencyCode = data.currencyCode;
71
69
  this.customer = data.customer ? new IkasOrderCustomer(data.customer) : null;
72
70
  this.customerId = data.customerId || null;
73
71
  this.giftPackageLines =
@@ -80,9 +78,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
80
78
  this.orderAdjustments =
81
79
  data.orderAdjustments?.map((oa) => new IkasOrderAdjustment(oa)) || null;
82
80
  this.orderLineItems =
83
- data.orderLineItems
84
- ?.map((oli) => new IkasOrderLineItem(oli))
85
- .filter((i) => !i.deleted) || [];
81
+ data.orderLineItems.map((oli) => new IkasOrderLineItem(oli)) || null;
86
82
  this.orderNumber = data.orderNumber || null;
87
83
  this.orderPackageStatus = data.orderPackageStatus || null;
88
84
  this.orderPackages =
@@ -94,15 +90,12 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
94
90
  this.shippingAddress = data.shippingAddress
95
91
  ? new IkasOrderAddress(data.shippingAddress)
96
92
  : null;
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;
93
+ this.shippingMethod = data.shippingMethod;
94
+ this.status = data.status;
102
95
  this.taxLines =
103
96
  data.taxLines?.map((tl) => new IkasOrderTaxLine(tl)) || null;
104
- this.totalFinalPrice = data.totalFinalPrice ?? 0;
105
- this.totalPrice = data.totalPrice ?? 0;
97
+ this.totalFinalPrice = data.totalFinalPrice;
98
+ this.totalPrice = data.totalPrice;
106
99
 
107
100
  this.refundSettings = data.refundSettings;
108
101
 
@@ -111,7 +104,6 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
111
104
  cancelReason: observable,
112
105
  cancelledAt: observable,
113
106
  currencyCode: observable,
114
- currencySymbol: observable,
115
107
  customer: observable,
116
108
  customerId: observable,
117
109
  giftPackageLines: observable,
@@ -138,6 +130,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
138
130
 
139
131
  items: computed,
140
132
  itemCount: computed,
133
+ currencySymbol: computed,
141
134
  refundableItems: computed,
142
135
  unfullfilledItems: computed,
143
136
  refundedItems: computed,
@@ -164,6 +157,10 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
164
157
  return this.items?.length || 0;
165
158
  }
166
159
 
160
+ get currencySymbol() {
161
+ return getCurrencySymbol(this.currencyCode);
162
+ }
163
+
167
164
  get refundableItems() {
168
165
  if (!this.refundSettings) return [];
169
166
  return IkasOrderFunctions.getRefundableItems(this, this.refundSettings).map(
@@ -188,11 +185,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
188
185
  }
189
186
 
190
187
  get formattedTotalTax() {
191
- return formatCurrency(
192
- this.totalTax,
193
- this.currencyCode,
194
- this.currencySymbol || ""
195
- );
188
+ return formatMoney(this.totalTax, this.currencySymbol);
196
189
  }
197
190
 
198
191
  get shippingTotal() {
@@ -200,27 +193,15 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
200
193
  }
201
194
 
202
195
  get formattedShippingTotal() {
203
- return formatCurrency(
204
- this.shippingTotal,
205
- this.currencyCode,
206
- this.currencySymbol || ""
207
- );
196
+ return formatMoney(this.shippingTotal, this.currencySymbol);
208
197
  }
209
198
 
210
199
  get formattedTotalFinalPrice() {
211
- return formatCurrency(
212
- this.totalFinalPrice,
213
- this.currencyCode,
214
- this.currencySymbol || ""
215
- );
200
+ return formatMoney(this.totalFinalPrice, this.currencySymbol);
216
201
  }
217
202
 
218
203
  get formattedTotalPrice() {
219
- return formatCurrency(
220
- this.totalPrice,
221
- this.currencyCode,
222
- this.currencySymbol || ""
223
- );
204
+ return formatMoney(this.totalPrice, this.currencySymbol);
224
205
  }
225
206
 
226
207
  get hasCustomer() {
@@ -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 { formatCurrency } from "../../../../utils/currency";
11
+ import { formatMoney, getCurrencySymbol } from "../../../../utils/currency";
12
12
 
13
13
  type IOrderLineItemConstructorParams = {
14
14
  refundQuantity?: number;
@@ -16,7 +16,6 @@ type IOrderLineItemConstructorParams = {
16
16
 
17
17
  export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
18
18
  currencyCode: string | null = null;
19
- currencySymbol: string | null;
20
19
  discount: IkasOrderLineDiscount | null = null;
21
20
  discountPrice: number | null = null;
22
21
  finalPrice: number | null = null;
@@ -38,7 +37,6 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
38
37
  super(data);
39
38
 
40
39
  this.currencyCode = data.currencyCode || null;
41
- this.currencySymbol = data.currencySymbol || null;
42
40
  this.discount = data.discount
43
41
  ? new IkasOrderLineDiscount(data.discount)
44
42
  : null;
@@ -57,7 +55,6 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
57
55
 
58
56
  makeObservable(this, {
59
57
  currencyCode: observable,
60
- currencySymbol: observable,
61
58
  discount: observable,
62
59
  discountPrice: observable,
63
60
  finalPrice: observable,
@@ -71,9 +68,8 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
71
68
  taxValue: observable,
72
69
  variant: observable,
73
70
  orderedAt: observable,
74
- //@ts-ignore
75
- _refundQuantity: observable,
76
71
 
72
+ currencySymbol: computed,
77
73
  priceWithQuantity: computed,
78
74
  formattedPriceWithQuantity: computed,
79
75
  overridenPriceWithQuantity: computed,
@@ -88,16 +84,16 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
88
84
  });
89
85
  }
90
86
 
87
+ get currencySymbol() {
88
+ return getCurrencySymbol(this.currencyCode || "");
89
+ }
90
+
91
91
  get priceWithQuantity() {
92
92
  return IkasOrderLineItemFunctions.getPriceWithQuantity(this);
93
93
  }
94
94
 
95
95
  get formattedPriceWithQuantity() {
96
- return formatCurrency(
97
- this.priceWithQuantity,
98
- this.currencyCode || "",
99
- this.currencySymbol || ""
100
- );
96
+ return formatMoney(this.priceWithQuantity, this.currencySymbol);
101
97
  }
102
98
 
103
99
  get overridenPriceWithQuantity() {
@@ -105,27 +101,18 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
105
101
  }
106
102
 
107
103
  get formattedOverridenPriceWithQuantity() {
108
- return formatCurrency(
104
+ return formatMoney(
109
105
  this.overridenPriceWithQuantity || 0,
110
- this.currencyCode || "",
111
- this.currencySymbol || ""
106
+ this.currencySymbol
112
107
  );
113
108
  }
114
109
 
115
110
  get formattedFinalPrice() {
116
- return formatCurrency(
117
- this.finalPrice || 0,
118
- this.currencyCode || "",
119
- this.currencySymbol || ""
120
- );
111
+ return formatMoney(this.finalPrice || 0, this.currencySymbol);
121
112
  }
122
113
 
123
114
  get formattedDiscountPrice() {
124
- return formatCurrency(
125
- this.discountPrice || 0,
126
- this.currencyCode || "",
127
- this.currencySymbol || ""
128
- );
115
+ return formatMoney(this.discountPrice || 0, this.currencySymbol);
129
116
  }
130
117
 
131
118
  get finalPriceWithQuantity() {
@@ -133,11 +120,7 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
133
120
  }
134
121
 
135
122
  get formattedFinalPriceWithQuantity() {
136
- return formatCurrency(
137
- this.finalPriceWithQuantity || 0,
138
- this.currencyCode || "",
139
- this.currencySymbol || ""
140
- );
123
+ return formatMoney(this.finalPriceWithQuantity || 0, this.currencySymbol);
141
124
  }
142
125
 
143
126
  get tax() {
@@ -145,11 +128,7 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
145
128
  }
146
129
 
147
130
  get formattedTax() {
148
- return formatCurrency(
149
- this.tax,
150
- this.currencyCode || "",
151
- this.currencySymbol || ""
152
- );
131
+ return formatMoney(this.tax, this.currencySymbol);
153
132
  }
154
133
 
155
134
  get refundQuantity() {
@@ -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.variantValueName = data.variantValueName || null;
19
+ this.variantTypeName = data.variantTypeName || null;
20
20
 
21
21
  makeAutoObservable(this);
22
22
  }
@@ -5,6 +5,7 @@ import {
5
5
  IkasOrderTransaction as IOrderTransaction,
6
6
  } from "@ikas/storefront-models";
7
7
  import { makeAutoObservable } from "mobx";
8
+ import { getCurrencySymbol } from "../../../../utils/currency";
8
9
  import { IkasTransactionError } from "./error";
9
10
  import { IkasTransactionPaymentMethodDetail } from "./payment-method-detail";
10
11
 
@@ -13,7 +14,6 @@ export class IkasOrderTransaction implements IOrderTransaction {
13
14
  checkoutId: string | null;
14
15
  createdAt: number | null;
15
16
  currencyCode: string | null;
16
- currencySymbol: string | null;
17
17
  customerId: string | null;
18
18
  error: IkasTransactionError | null;
19
19
  id: string | null;
@@ -33,7 +33,6 @@ 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;
37
36
  this.customerId = data.customerId || null;
38
37
  this.error = data.error ? new IkasTransactionError(data.error) : null;
39
38
  this.id = data.id;
@@ -50,6 +49,10 @@ export class IkasOrderTransaction implements IOrderTransaction {
50
49
 
51
50
  makeAutoObservable(this);
52
51
  }
52
+
53
+ get currencySymbol() {
54
+ return getCurrencySymbol(this.currencyCode || "");
55
+ }
53
56
  }
54
57
 
55
58
  export { IkasTransactionStatus, IkasTransactionType };
@@ -160,7 +160,7 @@ export class IkasApplicableProductFilterValue
160
160
  resultCount?: number | null;
161
161
 
162
162
  // Extra
163
- isSelected: boolean;
163
+ private _isSelected: boolean;
164
164
 
165
165
  constructor(data: IApplicableProductFilterValue) {
166
166
  this.id = data.id || "";
@@ -174,7 +174,7 @@ export class IkasApplicableProductFilterValue
174
174
  isVideo: false,
175
175
  });
176
176
 
177
- this.isSelected = data.isSelected || false;
177
+ this._isSelected = data.isSelected || false;
178
178
  this.resultCount =
179
179
  data.resultCount !== undefined && data.resultCount !== null
180
180
  ? data.resultCount
@@ -182,6 +182,17 @@ export class IkasApplicableProductFilterValue
182
182
 
183
183
  makeAutoObservable(this);
184
184
  }
185
+
186
+ get isSelected() {
187
+ return this._isSelected;
188
+ }
189
+
190
+ toJSON() {
191
+ return {
192
+ ...this,
193
+ isSelected: this._isSelected,
194
+ };
195
+ }
185
196
  }
186
197
 
187
198
  export class IkasProductFilterValue implements IProductFilterValue {
@@ -205,14 +216,12 @@ export class IkasProductFilterSettings implements IProductFilterSettings {
205
216
  showCollapsedOnDesktop: boolean;
206
217
  showCollapsedOnMobile: boolean;
207
218
  sortType: IkasProductFilterSortType;
208
- customSortedValues: string[] | null;
209
219
 
210
220
  constructor(data: Partial<IkasProductFilterSettings>) {
211
221
  this.useAndFilter = data.useAndFilter || false;
212
222
  this.showCollapsedOnDesktop = data.showCollapsedOnDesktop || false;
213
223
  this.showCollapsedOnMobile = data.showCollapsedOnMobile || false;
214
224
  this.sortType = data.sortType || IkasProductFilterSortType.ALPHABETICAL_ASC;
215
- this.customSortedValues = data.customSortedValues || null;
216
225
 
217
226
  makeAutoObservable(this);
218
227
  }
@@ -23,8 +23,6 @@ import { IkasStorefrontConfig } from "@ikas/storefront-config";
23
23
  import { Analytics } from "../../../analytics";
24
24
  import { IkasVariantType } from "../variant-type";
25
25
  import { IkasBaseStore } from "../../../store/base";
26
- import { IkasProductAttributeMap } from "./attribute-value";
27
- import _groupBy from "lodash/groupBy";
28
26
 
29
27
  export class IkasProduct implements IProduct {
30
28
  id: string;
@@ -163,24 +161,6 @@ export class IkasProduct implements IProduct {
163
161
  );
164
162
  }
165
163
 
166
- get groupedAttributeValues(): IkasProductAttributeMap[] {
167
- const groupedValues = _groupBy(this.attributes, "productAttributeId");
168
-
169
- return (this.attributes
170
- ?.map((attribute) => {
171
- const attributeId = attribute.productAttributeId;
172
- if (!attributeId) return;
173
-
174
- const values = groupedValues[attributeId];
175
- if (values?.length && values[0].productAttribute)
176
- return {
177
- attribute: values[0].productAttribute,
178
- values: values,
179
- };
180
- })
181
- .filter((v) => !!v) || []) as IkasProductAttributeMap[];
182
- }
183
-
184
164
  selectVariantValue(variantValue: IkasVariantValue) {
185
165
  const metaData = this.metaData;
186
166
  const selectedVariantValues = this.selectedVariantValues.map((vv) => {
@@ -13,7 +13,7 @@ import { makeAutoObservable } from "mobx";
13
13
  import { IkasImage } from "../../../image";
14
14
  import _sortBy from "lodash/sortBy";
15
15
  import { IkasProductOptionFunctions } from "@ikas/storefront-model-functions";
16
- import { getProductOptionFileUrl, uploadFile } from "@ikas/storefront-api";
16
+ import { uploadProductOptionFile } from "@ikas/storefront-api";
17
17
 
18
18
  export class IkasProductOptionOtherPrice implements IProductOptionOtherPrice {
19
19
  currencyCode: string;
@@ -202,30 +202,11 @@ export class IkasProductOption implements IProductOption {
202
202
  )
203
203
  return [];
204
204
 
205
- let tempUploadFiles = (
206
- await Promise.all(
207
- files.map((file) =>
208
- getProductOptionFileUrl(
209
- {
210
- fileName: file.name,
211
- productOptionSetId: this.productOptionSetId,
212
- productOptionId: this.id,
213
- },
214
- file
215
- )
216
- )
217
- )
218
- ).filter((file) => file.data);
219
-
220
- const uploadedFiles: string[] = [];
221
- for (const file of tempUploadFiles) {
222
- const isSuccess = await uploadFile(file.data!, file.data!.file);
223
- if (isSuccess) {
224
- uploadedFiles.push(file.data!.optionUrl);
225
- }
226
- }
227
-
228
- return uploadedFiles;
205
+ let fileIds = await Promise.all(
206
+ files.map((file) => uploadProductOptionFile(file, this))
207
+ );
208
+ fileIds = fileIds.filter((id) => id !== null);
209
+ return fileIds;
229
210
  };
230
211
 
231
212
  get hasValidValues() {
@@ -1,9 +1,6 @@
1
1
  import { IkasProductPrice } from "./price";
2
2
  import { IkasVariantValue } from "../../variant-type/variant-value";
3
- import {
4
- IkasProductAttributeMap,
5
- IkasProductAttributeValue,
6
- } from "../attribute-value";
3
+ import { IkasProductAttributeValue } from "../attribute-value";
7
4
  import { IkasProductCampaign } from "../campaign";
8
5
  import { IkasProductImage } from "../image";
9
6
  import { IkasProductVariant as IProductVariant } from "@ikas/storefront-models";
@@ -14,7 +11,6 @@ import {
14
11
  listProductBackInStockRemind,
15
12
  saveProductBackInStockRemind,
16
13
  } from "@ikas/storefront-api";
17
- import _groupBy from "lodash/groupBy";
18
14
 
19
15
  export class IkasProductVariant implements IProductVariant {
20
16
  id: string;
@@ -77,24 +73,6 @@ export class IkasProductVariant implements IProductVariant {
77
73
  return this._backInStockReminderSaved;
78
74
  }
79
75
 
80
- get groupedAttributeValues(): IkasProductAttributeMap[] {
81
- const groupedValues = _groupBy(this.attributes, "productAttributeId");
82
-
83
- return (this.attributes
84
- ?.map((attribute) => {
85
- const attributeId = attribute.productAttributeId;
86
- if (!attributeId) return;
87
-
88
- const values = groupedValues[attributeId];
89
- if (values?.length && values[0].productAttribute)
90
- return {
91
- attribute: values[0].productAttribute,
92
- values: values,
93
- };
94
- })
95
- .filter((v) => !!v) || []) as IkasProductAttributeMap[];
96
- }
97
-
98
76
  async saveBackInStockReminder(email: string) {
99
77
  const listResponse = await listProductBackInStockRemind({
100
78
  email: { eq: email },
@@ -1,12 +1,11 @@
1
1
  import { IkasProductPriceFunctions } from "@ikas/storefront-model-functions";
2
2
  import { IkasProductPrice as IProductPrice } from "@ikas/storefront-models";
3
3
  import { makeAutoObservable } from "mobx";
4
- import { formatCurrency } from "../../../../../utils/currency";
4
+ import { getCurrencySymbol, formatMoney } from "../../../../../utils/currency";
5
5
 
6
6
  export class IkasProductPrice implements IProductPrice {
7
7
  buyPrice: number | null = null;
8
8
  currency: string | null = null;
9
- currencySymbol: string | null = null;
10
9
  discountPrice: number | null = null;
11
10
  priceListId: string | null = null;
12
11
  sellPrice: number;
@@ -14,7 +13,6 @@ export class IkasProductPrice implements IProductPrice {
14
13
  constructor(data?: IProductPrice) {
15
14
  this.buyPrice = data?.buyPrice ?? null;
16
15
  this.currency = data?.currency ?? null;
17
- this.currencySymbol = data?.currencySymbol ?? "";
18
16
  this.discountPrice = data?.discountPrice ?? null;
19
17
  this.priceListId = data?.priceListId ?? null;
20
18
  this.sellPrice = data?.sellPrice ?? 0;
@@ -22,40 +20,28 @@ export class IkasProductPrice implements IProductPrice {
22
20
  makeAutoObservable(this);
23
21
  }
24
22
 
23
+ get currencySymbol() {
24
+ return getCurrencySymbol(this.currency || "");
25
+ }
26
+
25
27
  get finalPrice() {
26
28
  return IkasProductPriceFunctions.getFinalPrice(this);
27
29
  }
28
30
 
29
31
  get formattedFinalPrice() {
30
- return formatCurrency(
31
- this.finalPrice,
32
- this.currency || "",
33
- this.currencySymbol || ""
34
- );
32
+ return formatMoney(this.finalPrice, this.currencySymbol);
35
33
  }
36
34
 
37
35
  get formattedBuyPrice() {
38
- return formatCurrency(
39
- this.buyPrice || 0,
40
- this.currency || "",
41
- this.currencySymbol || ""
42
- );
36
+ return formatMoney(this.buyPrice || 0, this.currencySymbol);
43
37
  }
44
38
 
45
39
  get formattedDiscountPrice() {
46
- return formatCurrency(
47
- this.discountPrice || 0,
48
- this.currency || "",
49
- this.currencySymbol || ""
50
- );
40
+ return formatMoney(this.discountPrice || 0, this.currencySymbol);
51
41
  }
52
42
 
53
43
  get formattedSellPrice() {
54
- return formatCurrency(
55
- this.sellPrice || 0,
56
- this.currency || "",
57
- this.currencySymbol || ""
58
- );
44
+ return formatMoney(this.sellPrice || 0, this.currencySymbol);
59
45
  }
60
46
 
61
47
  get hasDiscount() {
@@ -3,12 +3,10 @@ import { IkasProductVariantType as IProductVariantType } from "@ikas/storefront-
3
3
  import { makeAutoObservable } from "mobx";
4
4
 
5
5
  export class IkasProductVariantType implements IProductVariantType {
6
- order: number;
7
6
  variantType: IkasVariantType;
8
7
  variantValueIds: string[];
9
8
 
10
9
  constructor(data: Partial<IkasProductVariantType>) {
11
- this.order = data.order || 0;
12
10
  this.variantType = data.variantType
13
11
  ? new IkasVariantType(data.variantType)
14
12
  : new IkasVariantType();
@@ -8,7 +8,6 @@ import {
8
8
  IkasRaffleAppliedProduct as IRaffleAppliedProduct,
9
9
  IkasRaffleVerificationType,
10
10
  IkasRaffleMetadataTargetType,
11
- IkasRaffleParticipantStatus,
12
11
  } from "@ikas/storefront-models";
13
12
  import { IkasRaffleFunctions } from "@ikas/storefront-model-functions";
14
13
 
@@ -34,12 +33,13 @@ export class IkasRaffle implements IRaffle {
34
33
  dateRange: IkasRaffleDateRangeField | null;
35
34
  metadata: IkasRaffleMetaData | null;
36
35
  name: string;
36
+ participantCount?: number | null;
37
37
  requiredCustomerAccount: boolean;
38
38
  status: boolean;
39
39
  variants: IkasRaffleAppliedProduct[] | null;
40
- verificationType: IkasRaffleVerificationType;
41
-
42
40
  products: IkasProduct[];
41
+ verificationType: IkasRaffleVerificationType;
42
+ isCustomerWinner: boolean | null;
43
43
 
44
44
  constructor(data: Partial<IkasRaffle> = {}) {
45
45
  this.id = data.id || Date.now() + "";
@@ -47,10 +47,12 @@ export class IkasRaffle implements IRaffle {
47
47
  this.updatedAt = data.updatedAt || Date.now();
48
48
  this.deleted = data.deleted || null;
49
49
  this.name = data.name || "";
50
+ this.participantCount = data.participantCount || 0;
50
51
  this.requiredCustomerAccount = data.requiredCustomerAccount || false;
51
52
  this.status = data.status || false;
52
53
  this.verificationType =
53
54
  data.verificationType || IkasRaffleVerificationType.EMAIL;
55
+ this.isCustomerWinner = data.isCustomerWinner || null;
54
56
 
55
57
  this.dateRange = data.dateRange
56
58
  ? new IkasRaffleDateRangeField(data.dateRange)
@@ -111,10 +113,8 @@ export class IkasRaffleParticipant implements IRaffleParticipant {
111
113
  email: string;
112
114
  applicationDate: number;
113
115
  phone: string | null = null;
114
- isDeliveredCargo: boolean | null;
116
+ isWinner: boolean | null = null;
115
117
 
116
- raffle: IkasRaffle;
117
- status: IkasRaffleParticipantStatus | null;
118
118
  extraData: Record<string, any> | null = null;
119
119
  appliedProduct: IkasRaffleAppliedProduct;
120
120
 
@@ -131,10 +131,8 @@ export class IkasRaffleParticipant implements IRaffleParticipant {
131
131
  this.email = data.email || "";
132
132
  this.applicationDate = data.applicationDate || 0;
133
133
  this.phone = data.phone || null;
134
- this.isDeliveredCargo = data.isDeliveredCargo || false;
134
+ this.isWinner = data.isWinner || null;
135
135
 
136
- this.raffle = new IkasRaffle(data.raffle);
137
- this.status = data.status || null;
138
136
  this.extraData = data.extraData || {};
139
137
  this.appliedProduct = new IkasRaffleAppliedProduct(
140
138
  data.appliedProduct || {}
@@ -1,6 +1,6 @@
1
1
  import { IkasBaseModel } from "../base";
2
2
  import { IkasState as IState } from "@ikas/storefront-models";
3
- import { makeObservable, observable } from "mobx";
3
+ import { makeAutoObservable } from "mobx";
4
4
 
5
5
  export class IkasState extends IkasBaseModel implements IState {
6
6
  countryId: string;
@@ -13,10 +13,6 @@ export class IkasState extends IkasBaseModel implements IState {
13
13
  this.name = data.name;
14
14
  this.stateCode = data.stateCode;
15
15
 
16
- makeObservable(this, {
17
- countryId: observable,
18
- name: observable,
19
- stateCode: observable,
20
- });
16
+ makeAutoObservable(this);
21
17
  }
22
18
  }
@@ -20,7 +20,6 @@ export class IkasStorefront implements IStorefront {
20
20
  analytics4Id: string | null;
21
21
  universalAnalyticsId: string | null;
22
22
  tiktokPixelId: string | null;
23
- token: string | null;
24
23
 
25
24
  localizations: IkasStorefrontLocalization[];
26
25
  routings: IkasStorefrontRouting[];
@@ -41,7 +40,6 @@ export class IkasStorefront implements IStorefront {
41
40
  this.analytics4Id = data.analytics4Id || null;
42
41
  this.universalAnalyticsId = data.universalAnalyticsId || null;
43
42
  this.tiktokPixelId = data.tiktokPixelId || null;
44
- this.token = data.token || null;
45
43
 
46
44
  // Sub Models
47
45
  this.localizations = data.localizations