@ikas/storefront 4.0.0-alpha.48 → 4.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -13
- package/src/analytics/analytics.ts +1 -2
- package/src/analytics/googleUniversal.ts +2 -12
- package/src/analytics/head/index.tsx +2 -1
- package/src/analytics/ikas.ts +7 -25
- package/src/components/checkout/components/address-form/index.tsx +1 -1
- package/src/components/checkout/components/address-form/model.ts +0 -1
- package/src/components/checkout/components/button/style.module.scss +2 -2
- package/src/components/checkout/components/cart-summary/cart-item/index.tsx +29 -16
- package/src/components/checkout/components/cart-summary/cart-item/style.module.scss +23 -60
- package/src/components/checkout/components/cart-summary/index.tsx +27 -58
- package/src/components/checkout/components/cart-summary/style.module.scss +3 -48
- package/src/components/checkout/components/customer-addresses/index.tsx +2 -7
- package/src/components/checkout/components/customer-addresses/model.ts +8 -16
- package/src/components/checkout/components/error/index.tsx +1 -1
- package/src/components/checkout/components/error/unknown-error/index.tsx +2 -4
- package/src/components/checkout/components/form-item/index.tsx +11 -9
- package/src/components/checkout/components/master-pass/credit-card-form/index.tsx +0 -2
- package/src/components/checkout/components/offer-product/index.tsx +19 -16
- package/src/components/checkout/components/offer-product/style.module.scss +3 -1
- package/src/components/checkout/components/phone-number-input/get-countries.ts +5 -37
- package/src/components/checkout/components/phone-number-input/index.tsx +10 -15
- package/src/components/checkout/components/phone-number-input/locale/en.ts +257 -0
- package/src/components/checkout/index.tsx +19 -28
- package/src/components/checkout/model.ts +91 -214
- package/src/components/checkout/modelMasterPass.ts +2 -2
- package/src/components/checkout/steps/step-info/index.tsx +3 -9
- package/src/components/checkout/steps/step-payment/billing-address/index.tsx +1 -1
- package/src/components/checkout/steps/step-payment/index.tsx +2 -11
- package/src/components/checkout/steps/step-payment/payment-gateways/index.tsx +3 -12
- package/src/components/checkout/steps/step-payment/payment-gateways/installments/index.tsx +3 -5
- package/src/components/checkout/steps/step-payment/style.module.scss +0 -5
- package/src/components/checkout/steps/step-shipping/index.tsx +4 -9
- package/src/components/checkout/steps/step-success/index.tsx +7 -15
- package/src/components/page/head.tsx +0 -12
- package/src/components/page/index.tsx +9 -10
- package/src/components/page-editor/ThemeComponentEditor.tsx +8 -19
- package/src/components/page-editor/model.ts +107 -44
- package/src/models/data/cart/campaign-offer/index.ts +2 -13
- package/src/models/data/cart/index.ts +1 -1
- package/src/models/data/category/init.ts +33 -0
- package/src/models/data/category/path-item/index.ts +0 -4
- package/src/models/data/checkout/index.ts +4 -36
- package/src/models/data/checkout-settings/price/index.ts +0 -2
- package/src/models/data/country/index.ts +0 -4
- package/src/models/data/index.ts +0 -3
- package/src/models/data/merchant-settings/index.ts +0 -9
- package/src/models/data/order/index.ts +32 -51
- package/src/models/data/order/line-item/index.ts +18 -76
- package/src/models/data/order/line-item/variant/index.ts +0 -8
- package/src/models/data/order/line-item/variant/price/index.ts +0 -2
- package/src/models/data/order/line-item/variant/value/index.ts +1 -1
- package/src/models/data/order/transaction/index.ts +5 -2
- package/src/models/data/product/attribute-value/index.ts +0 -40
- package/src/models/data/product/filter/index.ts +13 -4
- package/src/models/data/product/index.ts +7 -45
- package/src/models/data/product/option-set/index.ts +3 -8
- package/src/models/data/product/option-set/option/index.ts +13 -36
- package/src/models/data/product/variant/index.ts +1 -26
- package/src/models/data/product/variant/price/index.ts +9 -25
- package/src/models/data/product/variant-type/index.ts +0 -2
- package/src/models/data/raffle/index.ts +7 -9
- package/src/models/data/state/index.ts +2 -6
- package/src/models/data/storefront/index.ts +0 -2
- package/src/models/data/storefront/routing/index.tsx +0 -4
- package/src/models/ui/product-list/index.ts +17 -26
- package/src/models/ui/raffle-list/index.ts +1 -1
- package/src/models/ui/validator/form/raffle-form.ts +3 -16
- package/src/models/ui/validator/rules/index.ts +13 -14
- package/src/page-data-init/index.ts +404 -159
- package/src/pages/checkout.tsx +1 -2
- package/src/pages/editor.tsx +2 -5
- package/src/store/base.ts +2 -2
- package/src/store/cart/index.ts +2 -2
- package/src/store/customer/index.ts +17 -7
- package/src/store/index.ts +0 -2
- package/src/store/raffle/index.ts +10 -7
- package/src/utils/constants.ts +1 -1
- package/src/utils/currency.ts +183 -9
- package/src/models/data/country/location-translations/index.ts +0 -15
- package/src/models/data/order/line-item/base-unit/index.ts +0 -22
- package/src/models/data/order/line-item/base-unit/unit-type/index.ts +0 -14
- package/src/models/data/order/line-item/variant/unit/index.ts +0 -17
- package/src/models/data/product/base-unit/index.ts +0 -32
- package/src/models/data/product/variant/unit/index.ts +0 -17
package/src/models/data/index.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IkasMerchantSettingsCurrencyFormat,
|
|
3
3
|
IkasMerchantSettings as IMerchantSettings,
|
|
4
|
-
IkasMerchantAddress,
|
|
5
4
|
} from "@ikas/storefront-models";
|
|
6
5
|
import { makeAutoObservable } from "mobx";
|
|
7
6
|
import { IkasImage } from "../image";
|
|
8
7
|
|
|
9
8
|
export class IkasMerchantSettings implements IMerchantSettings {
|
|
10
9
|
currencyFormats: IkasMerchantSettingsCurrencyFormat[] | null;
|
|
11
|
-
address: IkasMerchantAddress | null;
|
|
12
10
|
logoId: string | null;
|
|
13
11
|
merchantId: string;
|
|
14
12
|
merchantName: string;
|
|
15
|
-
phone: string | null;
|
|
16
13
|
|
|
17
14
|
// Extra
|
|
18
15
|
logo?: IkasImage | null;
|
|
@@ -22,13 +19,7 @@ export class IkasMerchantSettings implements IMerchantSettings {
|
|
|
22
19
|
this.logoId = data.logoId;
|
|
23
20
|
this.merchantId = data.merchantId;
|
|
24
21
|
this.merchantName = data.merchantName;
|
|
25
|
-
this.phone = data.phone || null;
|
|
26
|
-
this.address = data.address || null;
|
|
27
|
-
|
|
28
22
|
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
|
-
}
|
|
32
23
|
|
|
33
24
|
makeAutoObservable(this);
|
|
34
25
|
}
|
|
@@ -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 {
|
|
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:
|
|
62
|
-
super(data
|
|
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.
|
|
98
|
-
|
|
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
|
|
105
|
-
this.totalPrice = data.totalPrice
|
|
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,20 +157,27 @@ 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
|
-
return IkasOrderFunctions.getRefundableItems(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
) as IkasOrderLineItem[];
|
|
166
|
+
return IkasOrderFunctions.getRefundableItems(this, this.refundSettings).map(
|
|
167
|
+
(i) => new IkasOrderLineItem(i)
|
|
168
|
+
);
|
|
173
169
|
}
|
|
174
170
|
|
|
175
171
|
get unfullfilledItems() {
|
|
176
|
-
return IkasOrderFunctions.getUnfullfilledItems(this)
|
|
172
|
+
return IkasOrderFunctions.getUnfullfilledItems(this).map(
|
|
173
|
+
(i) => new IkasOrderLineItem(i)
|
|
174
|
+
);
|
|
177
175
|
}
|
|
178
176
|
|
|
179
177
|
get refundedItems() {
|
|
180
|
-
return IkasOrderFunctions.getRefundedItems(this)
|
|
178
|
+
return IkasOrderFunctions.getRefundedItems(this).map(
|
|
179
|
+
(i) => new IkasOrderLineItem(i)
|
|
180
|
+
);
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
get totalTax() {
|
|
@@ -185,11 +185,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
get formattedTotalTax() {
|
|
188
|
-
return
|
|
189
|
-
this.totalTax,
|
|
190
|
-
this.currencyCode,
|
|
191
|
-
this.currencySymbol || ""
|
|
192
|
-
);
|
|
188
|
+
return formatMoney(this.totalTax, this.currencySymbol);
|
|
193
189
|
}
|
|
194
190
|
|
|
195
191
|
get shippingTotal() {
|
|
@@ -197,27 +193,15 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
197
193
|
}
|
|
198
194
|
|
|
199
195
|
get formattedShippingTotal() {
|
|
200
|
-
return
|
|
201
|
-
this.shippingTotal,
|
|
202
|
-
this.currencyCode,
|
|
203
|
-
this.currencySymbol || ""
|
|
204
|
-
);
|
|
196
|
+
return formatMoney(this.shippingTotal, this.currencySymbol);
|
|
205
197
|
}
|
|
206
198
|
|
|
207
199
|
get formattedTotalFinalPrice() {
|
|
208
|
-
return
|
|
209
|
-
this.totalFinalPrice,
|
|
210
|
-
this.currencyCode,
|
|
211
|
-
this.currencySymbol || ""
|
|
212
|
-
);
|
|
200
|
+
return formatMoney(this.totalFinalPrice, this.currencySymbol);
|
|
213
201
|
}
|
|
214
202
|
|
|
215
203
|
get formattedTotalPrice() {
|
|
216
|
-
return
|
|
217
|
-
this.totalPrice,
|
|
218
|
-
this.currencyCode,
|
|
219
|
-
this.currencySymbol || ""
|
|
220
|
-
);
|
|
204
|
+
return formatMoney(this.totalPrice, this.currencySymbol);
|
|
221
205
|
}
|
|
222
206
|
|
|
223
207
|
get hasCustomer() {
|
|
@@ -237,17 +221,14 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
237
221
|
}
|
|
238
222
|
|
|
239
223
|
get couponAdjustment() {
|
|
240
|
-
|
|
224
|
+
const adjustment = IkasOrderFunctions.getCouponAdjustment(this);
|
|
225
|
+
return adjustment ? new IkasOrderAdjustment(adjustment) : undefined;
|
|
241
226
|
}
|
|
242
227
|
|
|
243
228
|
get nonCouponAdjustments() {
|
|
244
|
-
return IkasOrderFunctions.getNonCouponAdjustments(
|
|
245
|
-
|
|
246
|
-
)
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
get isRefundEnabled() {
|
|
250
|
-
return !this.refundableItems.some((item) => item.refundQuantity === null);
|
|
229
|
+
return IkasOrderFunctions.getNonCouponAdjustments(this)?.map(
|
|
230
|
+
(a) => new IkasOrderAdjustment(a)
|
|
231
|
+
);
|
|
251
232
|
}
|
|
252
233
|
}
|
|
253
234
|
|
|
@@ -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 {
|
|
11
|
+
import { formatMoney, getCurrencySymbol } from "../../../../utils/currency";
|
|
12
12
|
|
|
13
13
|
type IOrderLineItemConstructorParams = {
|
|
14
14
|
refundQuantity?: number;
|
|
@@ -16,11 +16,9 @@ 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;
|
|
23
|
-
finalUnitPrice: number | null;
|
|
24
22
|
options: IkasOrderLineItemOption[] | null = null;
|
|
25
23
|
originalOrderLineItemId: string | null = null;
|
|
26
24
|
price: number;
|
|
@@ -29,7 +27,6 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
29
27
|
statusUpdatedAt: number | null = null;
|
|
30
28
|
stockLocationId: string | null = null;
|
|
31
29
|
taxValue: number | null = null;
|
|
32
|
-
unitPrice: number | null;
|
|
33
30
|
variant: IkasOrderLineVariant;
|
|
34
31
|
orderedAt: number;
|
|
35
32
|
|
|
@@ -40,23 +37,17 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
40
37
|
super(data);
|
|
41
38
|
|
|
42
39
|
this.currencyCode = data.currencyCode || null;
|
|
43
|
-
this.currencySymbol = data.currencySymbol || null;
|
|
44
40
|
this.discount = data.discount
|
|
45
41
|
? new IkasOrderLineDiscount(data.discount)
|
|
46
42
|
: null;
|
|
47
|
-
this.discountPrice = data.discountPrice
|
|
48
|
-
this.finalPrice = data.finalPrice
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.originalOrderLineItemId = data.originalOrderLineItemId || 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);
|
|
53
48
|
this.price = data.price;
|
|
54
49
|
this.quantity = data.quantity;
|
|
55
50
|
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;
|
|
60
51
|
this.variant = new IkasOrderLineVariant(data.variant);
|
|
61
52
|
this.orderedAt = data.orderedAt;
|
|
62
53
|
|
|
@@ -64,11 +55,9 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
64
55
|
|
|
65
56
|
makeObservable(this, {
|
|
66
57
|
currencyCode: observable,
|
|
67
|
-
currencySymbol: observable,
|
|
68
58
|
discount: observable,
|
|
69
59
|
discountPrice: observable,
|
|
70
60
|
finalPrice: observable,
|
|
71
|
-
finalUnitPrice: observable,
|
|
72
61
|
options: observable,
|
|
73
62
|
originalOrderLineItemId: observable,
|
|
74
63
|
price: observable,
|
|
@@ -77,19 +66,15 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
77
66
|
statusUpdatedAt: observable,
|
|
78
67
|
stockLocationId: observable,
|
|
79
68
|
taxValue: observable,
|
|
80
|
-
unitPrice: observable,
|
|
81
69
|
variant: observable,
|
|
82
70
|
orderedAt: observable,
|
|
83
|
-
//@ts-ignore
|
|
84
|
-
_refundQuantity: observable,
|
|
85
71
|
|
|
72
|
+
currencySymbol: computed,
|
|
86
73
|
priceWithQuantity: computed,
|
|
87
74
|
formattedPriceWithQuantity: computed,
|
|
88
75
|
overridenPriceWithQuantity: computed,
|
|
89
76
|
formattedOverridenPriceWithQuantity: computed,
|
|
90
77
|
formattedFinalPrice: computed,
|
|
91
|
-
formattedUnitPrice: computed,
|
|
92
|
-
formattedFinalUnitPrice: computed,
|
|
93
78
|
formattedDiscountPrice: computed,
|
|
94
79
|
finalPriceWithQuantity: computed,
|
|
95
80
|
formattedFinalPriceWithQuantity: computed,
|
|
@@ -99,16 +84,16 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
99
84
|
});
|
|
100
85
|
}
|
|
101
86
|
|
|
87
|
+
get currencySymbol() {
|
|
88
|
+
return getCurrencySymbol(this.currencyCode || "");
|
|
89
|
+
}
|
|
90
|
+
|
|
102
91
|
get priceWithQuantity() {
|
|
103
92
|
return IkasOrderLineItemFunctions.getPriceWithQuantity(this);
|
|
104
93
|
}
|
|
105
94
|
|
|
106
95
|
get formattedPriceWithQuantity() {
|
|
107
|
-
return
|
|
108
|
-
this.priceWithQuantity,
|
|
109
|
-
this.currencyCode || "",
|
|
110
|
-
this.currencySymbol || ""
|
|
111
|
-
);
|
|
96
|
+
return formatMoney(this.priceWithQuantity, this.currencySymbol);
|
|
112
97
|
}
|
|
113
98
|
|
|
114
99
|
get overridenPriceWithQuantity() {
|
|
@@ -116,53 +101,18 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
116
101
|
}
|
|
117
102
|
|
|
118
103
|
get formattedOverridenPriceWithQuantity() {
|
|
119
|
-
return
|
|
104
|
+
return formatMoney(
|
|
120
105
|
this.overridenPriceWithQuantity || 0,
|
|
121
|
-
this.
|
|
122
|
-
this.currencySymbol || ""
|
|
106
|
+
this.currencySymbol
|
|
123
107
|
);
|
|
124
108
|
}
|
|
125
109
|
|
|
126
110
|
get formattedFinalPrice() {
|
|
127
|
-
return
|
|
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}`;
|
|
111
|
+
return formatMoney(this.finalPrice || 0, this.currencySymbol);
|
|
158
112
|
}
|
|
159
113
|
|
|
160
114
|
get formattedDiscountPrice() {
|
|
161
|
-
return
|
|
162
|
-
this.discountPrice || 0,
|
|
163
|
-
this.currencyCode || "",
|
|
164
|
-
this.currencySymbol || ""
|
|
165
|
-
);
|
|
115
|
+
return formatMoney(this.discountPrice || 0, this.currencySymbol);
|
|
166
116
|
}
|
|
167
117
|
|
|
168
118
|
get finalPriceWithQuantity() {
|
|
@@ -170,11 +120,7 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
170
120
|
}
|
|
171
121
|
|
|
172
122
|
get formattedFinalPriceWithQuantity() {
|
|
173
|
-
return
|
|
174
|
-
this.finalPriceWithQuantity || 0,
|
|
175
|
-
this.currencyCode || "",
|
|
176
|
-
this.currencySymbol || ""
|
|
177
|
-
);
|
|
123
|
+
return formatMoney(this.finalPriceWithQuantity || 0, this.currencySymbol);
|
|
178
124
|
}
|
|
179
125
|
|
|
180
126
|
get tax() {
|
|
@@ -182,11 +128,7 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
182
128
|
}
|
|
183
129
|
|
|
184
130
|
get formattedTax() {
|
|
185
|
-
return
|
|
186
|
-
this.tax,
|
|
187
|
-
this.currencyCode || "",
|
|
188
|
-
this.currencySymbol || ""
|
|
189
|
-
);
|
|
131
|
+
return formatMoney(this.tax, this.currencySymbol);
|
|
190
132
|
}
|
|
191
133
|
|
|
192
134
|
get refundQuantity() {
|
|
@@ -6,12 +6,9 @@ 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";
|
|
11
9
|
|
|
12
10
|
export class IkasOrderLineVariant implements IOrderLineVariant {
|
|
13
11
|
barcodeList: string[] | null = null;
|
|
14
|
-
baseUnit: IkasOrderLineBaseUnit | null;
|
|
15
12
|
brand: IkasOrderLineVariantBrand | null = null;
|
|
16
13
|
categories: IkasOrderLineVariantCategory[] | null = null;
|
|
17
14
|
id: string | null = null;
|
|
@@ -24,7 +21,6 @@ export class IkasOrderLineVariant implements IOrderLineVariant {
|
|
|
24
21
|
tagIds: string[] | null = null;
|
|
25
22
|
taxValue: number | null = null;
|
|
26
23
|
type: number | null = null;
|
|
27
|
-
unit: IkasOrderLineVariantUnit | null;
|
|
28
24
|
weight: number | null = null;
|
|
29
25
|
variantValues: IkasOrderLineVariantVariantValue[] | null = null;
|
|
30
26
|
|
|
@@ -33,9 +29,6 @@ export class IkasOrderLineVariant implements IOrderLineVariant {
|
|
|
33
29
|
|
|
34
30
|
constructor(data: IOrderLineVariant) {
|
|
35
31
|
this.barcodeList = data.barcodeList || null;
|
|
36
|
-
this.baseUnit = data.baseUnit
|
|
37
|
-
? new IkasOrderLineBaseUnit(data.baseUnit)
|
|
38
|
-
: null;
|
|
39
32
|
this.brand = data.brand ? new IkasOrderLineVariantBrand(data.brand) : null;
|
|
40
33
|
this.categories =
|
|
41
34
|
data.categories?.map((c) => new IkasOrderLineVariantCategory(c)) || null;
|
|
@@ -50,7 +43,6 @@ export class IkasOrderLineVariant implements IOrderLineVariant {
|
|
|
50
43
|
this.tagIds = data.tagIds || null;
|
|
51
44
|
this.taxValue = data.taxValue || null;
|
|
52
45
|
this.type = data.type || null;
|
|
53
|
-
this.unit = data.unit ? new IkasOrderLineVariantUnit(data.unit) : null;
|
|
54
46
|
this.weight = data.weight || null;
|
|
55
47
|
this.variantValues =
|
|
56
48
|
data.variantValues?.map(
|
|
@@ -7,7 +7,6 @@ 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;
|
|
11
10
|
|
|
12
11
|
constructor(data: IOrderLineVariantPrice) {
|
|
13
12
|
this.buyPrice = data.buyPrice || null;
|
|
@@ -15,7 +14,6 @@ export class IkasOrderLineVariantPrice implements IOrderLineVariantPrice {
|
|
|
15
14
|
this.discountPrice = data.discountPrice || null;
|
|
16
15
|
this.priceListId = data.priceListId || null;
|
|
17
16
|
this.sellPrice = data.sellPrice;
|
|
18
|
-
this.unitPrice = data.unitPrice;
|
|
19
17
|
|
|
20
18
|
makeAutoObservable(this);
|
|
21
19
|
}
|
|
@@ -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.
|
|
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 };
|
|
@@ -5,11 +5,9 @@ import {
|
|
|
5
5
|
IkasProductAttributeValue as IProductAttributeValue,
|
|
6
6
|
IkasAttributeTableCellValue as IAttributeTableCellValue,
|
|
7
7
|
IkasProductAttributeMap as IProductAttributeMap,
|
|
8
|
-
IkasProductAttributeType,
|
|
9
8
|
} from "@ikas/storefront-models";
|
|
10
9
|
import { makeAutoObservable } from "mobx";
|
|
11
10
|
import { IkasProductAttributeValueFunctions } from "@ikas/storefront-model-functions";
|
|
12
|
-
import ProductStore from "../../../../store/product";
|
|
13
11
|
|
|
14
12
|
export class IkasProductAttributeValue implements IProductAttributeValue {
|
|
15
13
|
imageIds: string[] | null = null;
|
|
@@ -42,44 +40,6 @@ export class IkasProductAttributeValue implements IProductAttributeValue {
|
|
|
42
40
|
get tableValue() {
|
|
43
41
|
return IkasProductAttributeValueFunctions.getTableValue(this.value);
|
|
44
42
|
}
|
|
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
|
-
}
|
|
83
43
|
}
|
|
84
44
|
|
|
85
45
|
export class IkasAttributeTableCellValue implements IAttributeTableCellValue {
|
|
@@ -160,7 +160,7 @@ export class IkasApplicableProductFilterValue
|
|
|
160
160
|
resultCount?: number | null;
|
|
161
161
|
|
|
162
162
|
// Extra
|
|
163
|
-
|
|
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.
|
|
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
|
}
|