@ikas/storefront 4.0.0-alpha.3 → 4.0.0-alpha.31
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 +2 -1
- package/src/analytics/googleUniversal.ts +12 -2
- package/src/analytics/head/index.tsx +1 -2
- package/src/analytics/ikas.ts +8 -0
- package/src/components/checkout/components/address-form/index.tsx +1 -1
- package/src/components/checkout/components/cart-summary/cart-item/index.tsx +11 -9
- package/src/components/checkout/components/cart-summary/index.tsx +41 -17
- package/src/components/checkout/components/form-item/index.tsx +9 -11
- package/src/components/checkout/components/offer-product/index.tsx +4 -3
- package/src/components/checkout/components/phone-number-input/get-countries.ts +37 -5
- package/src/components/checkout/components/phone-number-input/index.tsx +15 -10
- package/src/components/checkout/index.tsx +4 -3
- package/src/components/checkout/model.ts +8 -11
- package/src/components/checkout/modelMasterPass.ts +2 -2
- package/src/components/checkout/steps/step-payment/payment-gateways/index.tsx +6 -2
- package/src/components/checkout/steps/step-payment/payment-gateways/installments/index.tsx +5 -3
- package/src/components/checkout/steps/step-shipping/index.tsx +9 -4
- package/src/components/checkout/steps/step-success/index.tsx +4 -3
- package/src/components/page/head.tsx +12 -0
- package/src/components/page/index.tsx +4 -2
- package/src/components/page-editor/model.ts +15 -2
- package/src/models/data/checkout/index.ts +6 -2
- package/src/models/data/checkout-settings/price/index.ts +2 -0
- package/src/models/data/merchant-settings/index.ts +6 -0
- package/src/models/data/order/index.ts +24 -10
- package/src/models/data/order/line-item/index.ts +32 -13
- package/src/models/data/order/transaction/index.ts +2 -5
- package/src/models/data/product/variant/price/index.ts +23 -9
- package/src/models/data/product/variant-type/index.ts +2 -0
- package/src/models/data/raffle/index.ts +9 -7
- package/src/models/data/storefront/index.ts +2 -0
- package/src/models/ui/product-list/index.ts +0 -6
- package/src/models/ui/raffle-list/index.ts +1 -1
- package/src/models/ui/validator/form/raffle-form.ts +16 -3
- package/src/models/ui/validator/rules/index.ts +14 -13
- package/src/pages/checkout.tsx +2 -1
- package/src/pages/editor.tsx +5 -2
- package/src/store/cart/index.ts +2 -2
- package/src/store/customer/index.ts +6 -16
- package/src/store/raffle/index.ts +7 -10
- package/src/utils/currency.ts +9 -183
- package/src/components/checkout/components/phone-number-input/locale/en.ts +0 -257
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
3
|
import CheckoutViewModel from "../../model";
|
|
4
|
-
import {
|
|
4
|
+
import { formatCurrency, useTranslation } from "../../../../utils";
|
|
5
5
|
|
|
6
6
|
import styles from "./style.module.scss";
|
|
7
7
|
import { Button } from "../../components/button";
|
|
@@ -59,7 +59,11 @@ const ShippingMethods: React.FC<CommonProps> = observer(({ vm }) => {
|
|
|
59
59
|
<div className={styles.ShippingPrice}>
|
|
60
60
|
{asm.price === 0
|
|
61
61
|
? t("checkout-page:free")
|
|
62
|
-
:
|
|
62
|
+
: formatCurrency(
|
|
63
|
+
asm.price,
|
|
64
|
+
vm.checkout.currencyCode,
|
|
65
|
+
vm.checkout.currencySymbol
|
|
66
|
+
)}
|
|
63
67
|
</div>
|
|
64
68
|
}
|
|
65
69
|
onClick={() => vm.onShippingMethodChange(asm)}
|
|
@@ -95,9 +99,10 @@ const GiftPackage: React.FC<CommonProps> = observer(({ vm }) => {
|
|
|
95
99
|
const checkboxLabel =
|
|
96
100
|
t("checkout-page:giftPackageCta") +
|
|
97
101
|
(giftPackagePrice && giftPackagePrice.price
|
|
98
|
-
? ` (+ ${
|
|
102
|
+
? ` (+ ${formatCurrency(
|
|
99
103
|
giftPackagePrice!.price,
|
|
100
|
-
giftPackagePrice!.currencyCode
|
|
104
|
+
giftPackagePrice!.currencyCode,
|
|
105
|
+
giftPackagePrice!.currencySymbol
|
|
101
106
|
)})`
|
|
102
107
|
: "");
|
|
103
108
|
|
|
@@ -11,7 +11,7 @@ import SVGAmex from "../../components/credit-card-form/svg/amex";
|
|
|
11
11
|
import SVGMasterCard from "../../components/credit-card-form/svg/master-card";
|
|
12
12
|
import SVGTroy from "../../components/credit-card-form/svg/troy";
|
|
13
13
|
import SVGVisa from "../../components/credit-card-form/svg/visa";
|
|
14
|
-
import {
|
|
14
|
+
import { formatCurrency, useTranslation } from "../../../../utils";
|
|
15
15
|
import { IkasOrderPackageStatus } from "../../../../models";
|
|
16
16
|
import {
|
|
17
17
|
IkasPaymentGatewayType,
|
|
@@ -125,9 +125,10 @@ export const StepSuccess: React.FC<Props> = observer(({ vm }) => {
|
|
|
125
125
|
null && (
|
|
126
126
|
<div className={styles.InfoText}>{`${
|
|
127
127
|
paymentMethodDetail.installment.installmentCount
|
|
128
|
-
} x ${
|
|
128
|
+
} x ${formatCurrency(
|
|
129
129
|
paymentMethodDetail.installment.installmentPrice,
|
|
130
|
-
vm.checkout.currencyCode
|
|
130
|
+
vm.checkout.currencyCode,
|
|
131
|
+
vm.checkout.currencySymbol
|
|
131
132
|
)}`}</div>
|
|
132
133
|
)}
|
|
133
134
|
</React.Fragment>
|
|
@@ -251,6 +251,18 @@ function createStoreSchema(merchantSettings: IkasMerchantSettings) {
|
|
|
251
251
|
logo: logo,
|
|
252
252
|
image: logo,
|
|
253
253
|
url: "https://" + IkasStorefrontConfig.getDomain(),
|
|
254
|
+
telephone: merchantSettings?.phone,
|
|
255
|
+
address: {
|
|
256
|
+
"@type": "PostalAddress",
|
|
257
|
+
streetAddress: merchantSettings.address?.addressLine1,
|
|
258
|
+
addressLocality: merchantSettings.address?.city?.name,
|
|
259
|
+
...(merchantSettings.address &&
|
|
260
|
+
merchantSettings.address.state && {
|
|
261
|
+
addressRegion: merchantSettings.address.state.code,
|
|
262
|
+
}),
|
|
263
|
+
postalCode: merchantSettings.address?.postalCode,
|
|
264
|
+
addressCountry: merchantSettings.address?.country?.code,
|
|
265
|
+
},
|
|
254
266
|
};
|
|
255
267
|
}
|
|
256
268
|
|
|
@@ -19,6 +19,7 @@ import { ThemeComponent } from "./ThemeComponent";
|
|
|
19
19
|
import { IkasBaseStore } from "../../store";
|
|
20
20
|
import { initIkasEvents } from "../../analytics/events";
|
|
21
21
|
import { IkasPageDataInit } from "../../page-data-init";
|
|
22
|
+
import { setAPIClientConfig } from "@ikas/storefront-api";
|
|
22
23
|
|
|
23
24
|
export type IkasPageProps = {
|
|
24
25
|
propValues: IkasPageComponentPropValue[];
|
|
@@ -55,15 +56,16 @@ export const IkasPage: React.FC<IkasPageProps> = observer(
|
|
|
55
56
|
productReviewSummary,
|
|
56
57
|
}) => {
|
|
57
58
|
const router = useRouter();
|
|
58
|
-
const store = IkasBaseStore.getInstance();
|
|
59
|
-
store.router = router;
|
|
60
59
|
|
|
61
60
|
IkasStorefrontConfig.init({
|
|
62
61
|
...configJson,
|
|
63
62
|
currentPageComponents: components,
|
|
64
63
|
});
|
|
65
64
|
IkasBaseStore.getInstance().router = router;
|
|
65
|
+
setAPIClientConfig();
|
|
66
66
|
|
|
67
|
+
const store = IkasBaseStore.getInstance();
|
|
68
|
+
store.router = router;
|
|
67
69
|
store.currentPageType = pageType;
|
|
68
70
|
|
|
69
71
|
const [isBrowser, setIsBrowser] = React.useState(false);
|
|
@@ -23,6 +23,7 @@ import HtmlMetaDataStore from "../../store/html-meta-data";
|
|
|
23
23
|
import BlogStore from "../../store/blog";
|
|
24
24
|
import RaffleStore from "../../store/raffle";
|
|
25
25
|
import ProductStore from "../../store/product";
|
|
26
|
+
import { setAPIClientConfig } from "@ikas/storefront-api";
|
|
26
27
|
|
|
27
28
|
const PACKAGE_VERSION = "2.0.20";
|
|
28
29
|
// import { version as PACKAGE_VERSION } from "../../../package.json";
|
|
@@ -565,7 +566,13 @@ export default class IkasPageEditorViewModel {
|
|
|
565
566
|
translations: this.translations || {},
|
|
566
567
|
isEditor: true,
|
|
567
568
|
apiKey: data.apiKey,
|
|
569
|
+
apiUrl: data.apiUrl,
|
|
570
|
+
adminApiUrl: data.adminApiUrl,
|
|
571
|
+
cdnUrl: data.cdnUrl,
|
|
572
|
+
merchantSettings: data.merchantSettings,
|
|
568
573
|
});
|
|
574
|
+
|
|
575
|
+
setAPIClientConfig();
|
|
569
576
|
}
|
|
570
577
|
|
|
571
578
|
// (window as any).editorApiKey = data.apiKey;
|
|
@@ -618,8 +625,6 @@ export default class IkasPageEditorViewModel {
|
|
|
618
625
|
await this.pageDataProvider.setLinkSlugs();
|
|
619
626
|
|
|
620
627
|
if (pageComponentPropValues) {
|
|
621
|
-
pageComponentPropValues.propValues[propName] = propValue;
|
|
622
|
-
|
|
623
628
|
if (prop.type === IkasThemeJsonComponentPropType.CUSTOM) {
|
|
624
629
|
IkasPageDataInit.initCustomDataPropValue(
|
|
625
630
|
prop,
|
|
@@ -650,6 +655,12 @@ export default class IkasPageEditorViewModel {
|
|
|
650
655
|
propValue,
|
|
651
656
|
pageComponentPropValues
|
|
652
657
|
);
|
|
658
|
+
} else if (prop.type === IkasThemeJsonComponentPropType.PRODUCT_LIST) {
|
|
659
|
+
IkasPageDataInit.initProductListPropValue(
|
|
660
|
+
prop,
|
|
661
|
+
propValue,
|
|
662
|
+
pageComponentPropValues
|
|
663
|
+
);
|
|
653
664
|
} else if (prop.type === IkasThemeJsonComponentPropType.CATEGORY) {
|
|
654
665
|
IkasPageDataInit.initCategoryPropValue(
|
|
655
666
|
prop,
|
|
@@ -689,6 +700,8 @@ export default class IkasPageEditorViewModel {
|
|
|
689
700
|
propValue,
|
|
690
701
|
pageComponentPropValues
|
|
691
702
|
);
|
|
703
|
+
} else {
|
|
704
|
+
pageComponentPropValues.propValues[propName] = propValue;
|
|
692
705
|
}
|
|
693
706
|
}
|
|
694
707
|
};
|
|
@@ -2,7 +2,7 @@ import { IkasCart } from "../cart";
|
|
|
2
2
|
import { IkasCheckout as ICheckout } from "@ikas/storefront-models";
|
|
3
3
|
import { IkasCheckoutFunctions } from "@ikas/storefront-model-functions";
|
|
4
4
|
import { IkasPaymentGateway } from "../payment-gateway";
|
|
5
|
-
import {
|
|
5
|
+
import { formatCurrency } from "../../../utils/currency";
|
|
6
6
|
import { computed, makeObservable, observable } from "mobx";
|
|
7
7
|
import { formatDate } from "../../../utils/helper";
|
|
8
8
|
|
|
@@ -44,7 +44,11 @@ export class IkasCheckout extends IkasCart implements ICheckout {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
get $formattedTotalFinalPrice() {
|
|
47
|
-
return
|
|
47
|
+
return formatCurrency(
|
|
48
|
+
this.$totalFinalPrice,
|
|
49
|
+
this.currencyCode,
|
|
50
|
+
this.currencySymbol
|
|
51
|
+
);
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
get dateStr() {
|
|
@@ -3,10 +3,12 @@ import { makeAutoObservable } from "mobx";
|
|
|
3
3
|
|
|
4
4
|
export class IkasCheckoutSettingsPrice implements ICheckoutSettingsPrice {
|
|
5
5
|
currencyCode: string;
|
|
6
|
+
currencySymbol: string | null;
|
|
6
7
|
price: number;
|
|
7
8
|
|
|
8
9
|
constructor(data: ICheckoutSettingsPrice) {
|
|
9
10
|
this.currencyCode = data.currencyCode;
|
|
11
|
+
this.currencySymbol = data.currencySymbol || null;
|
|
10
12
|
this.price = data.price;
|
|
11
13
|
|
|
12
14
|
makeAutoObservable(this);
|
|
@@ -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,6 +22,9 @@ 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;
|
|
23
29
|
|
|
24
30
|
makeAutoObservable(this);
|
|
@@ -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 { 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;
|
|
@@ -66,6 +67,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
66
67
|
this.cancelReason = data.cancelReason || null;
|
|
67
68
|
this.cancelledAt = data.cancelledAt || null;
|
|
68
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 =
|
|
@@ -104,6 +106,7 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
104
106
|
cancelReason: observable,
|
|
105
107
|
cancelledAt: observable,
|
|
106
108
|
currencyCode: observable,
|
|
109
|
+
currencySymbol: observable,
|
|
107
110
|
customer: observable,
|
|
108
111
|
customerId: observable,
|
|
109
112
|
giftPackageLines: observable,
|
|
@@ -130,7 +133,6 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
130
133
|
|
|
131
134
|
items: computed,
|
|
132
135
|
itemCount: computed,
|
|
133
|
-
currencySymbol: computed,
|
|
134
136
|
refundableItems: computed,
|
|
135
137
|
unfullfilledItems: computed,
|
|
136
138
|
refundedItems: computed,
|
|
@@ -157,10 +159,6 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
157
159
|
return this.items?.length || 0;
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
get currencySymbol() {
|
|
161
|
-
return getCurrencySymbol(this.currencyCode);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
162
|
get refundableItems() {
|
|
165
163
|
if (!this.refundSettings) return [];
|
|
166
164
|
return IkasOrderFunctions.getRefundableItems(this, this.refundSettings).map(
|
|
@@ -185,7 +183,11 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
185
183
|
}
|
|
186
184
|
|
|
187
185
|
get formattedTotalTax() {
|
|
188
|
-
return
|
|
186
|
+
return formatCurrency(
|
|
187
|
+
this.totalTax,
|
|
188
|
+
this.currencyCode,
|
|
189
|
+
this.currencySymbol || ""
|
|
190
|
+
);
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
get shippingTotal() {
|
|
@@ -193,15 +195,27 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
|
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
get formattedShippingTotal() {
|
|
196
|
-
return
|
|
198
|
+
return formatCurrency(
|
|
199
|
+
this.shippingTotal,
|
|
200
|
+
this.currencyCode,
|
|
201
|
+
this.currencySymbol || ""
|
|
202
|
+
);
|
|
197
203
|
}
|
|
198
204
|
|
|
199
205
|
get formattedTotalFinalPrice() {
|
|
200
|
-
return
|
|
206
|
+
return formatCurrency(
|
|
207
|
+
this.totalFinalPrice,
|
|
208
|
+
this.currencyCode,
|
|
209
|
+
this.currencySymbol || ""
|
|
210
|
+
);
|
|
201
211
|
}
|
|
202
212
|
|
|
203
213
|
get formattedTotalPrice() {
|
|
204
|
-
return
|
|
214
|
+
return formatCurrency(
|
|
215
|
+
this.totalPrice,
|
|
216
|
+
this.currencyCode,
|
|
217
|
+
this.currencySymbol || ""
|
|
218
|
+
);
|
|
205
219
|
}
|
|
206
220
|
|
|
207
221
|
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 {
|
|
11
|
+
import { formatCurrency } from "../../../../utils/currency";
|
|
12
12
|
|
|
13
13
|
type IOrderLineItemConstructorParams = {
|
|
14
14
|
refundQuantity?: number;
|
|
@@ -16,6 +16,7 @@ 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;
|
|
@@ -37,6 +38,7 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
37
38
|
super(data);
|
|
38
39
|
|
|
39
40
|
this.currencyCode = data.currencyCode || null;
|
|
41
|
+
this.currencySymbol = data.currencySymbol || null;
|
|
40
42
|
this.discount = data.discount
|
|
41
43
|
? new IkasOrderLineDiscount(data.discount)
|
|
42
44
|
: null;
|
|
@@ -55,6 +57,7 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
55
57
|
|
|
56
58
|
makeObservable(this, {
|
|
57
59
|
currencyCode: observable,
|
|
60
|
+
currencySymbol: observable,
|
|
58
61
|
discount: observable,
|
|
59
62
|
discountPrice: observable,
|
|
60
63
|
finalPrice: observable,
|
|
@@ -69,7 +72,6 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
69
72
|
variant: observable,
|
|
70
73
|
orderedAt: observable,
|
|
71
74
|
|
|
72
|
-
currencySymbol: computed,
|
|
73
75
|
priceWithQuantity: computed,
|
|
74
76
|
formattedPriceWithQuantity: computed,
|
|
75
77
|
overridenPriceWithQuantity: computed,
|
|
@@ -84,16 +86,16 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
84
86
|
});
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
get currencySymbol() {
|
|
88
|
-
return getCurrencySymbol(this.currencyCode || "");
|
|
89
|
-
}
|
|
90
|
-
|
|
91
89
|
get priceWithQuantity() {
|
|
92
90
|
return IkasOrderLineItemFunctions.getPriceWithQuantity(this);
|
|
93
91
|
}
|
|
94
92
|
|
|
95
93
|
get formattedPriceWithQuantity() {
|
|
96
|
-
return
|
|
94
|
+
return formatCurrency(
|
|
95
|
+
this.priceWithQuantity,
|
|
96
|
+
this.currencyCode || "",
|
|
97
|
+
this.currencySymbol || ""
|
|
98
|
+
);
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
get overridenPriceWithQuantity() {
|
|
@@ -101,18 +103,27 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
get formattedOverridenPriceWithQuantity() {
|
|
104
|
-
return
|
|
106
|
+
return formatCurrency(
|
|
105
107
|
this.overridenPriceWithQuantity || 0,
|
|
106
|
-
this.
|
|
108
|
+
this.currencyCode || "",
|
|
109
|
+
this.currencySymbol || ""
|
|
107
110
|
);
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
get formattedFinalPrice() {
|
|
111
|
-
return
|
|
114
|
+
return formatCurrency(
|
|
115
|
+
this.finalPrice || 0,
|
|
116
|
+
this.currencyCode || "",
|
|
117
|
+
this.currencySymbol || ""
|
|
118
|
+
);
|
|
112
119
|
}
|
|
113
120
|
|
|
114
121
|
get formattedDiscountPrice() {
|
|
115
|
-
return
|
|
122
|
+
return formatCurrency(
|
|
123
|
+
this.discountPrice || 0,
|
|
124
|
+
this.currencyCode || "",
|
|
125
|
+
this.currencySymbol || ""
|
|
126
|
+
);
|
|
116
127
|
}
|
|
117
128
|
|
|
118
129
|
get finalPriceWithQuantity() {
|
|
@@ -120,7 +131,11 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
120
131
|
}
|
|
121
132
|
|
|
122
133
|
get formattedFinalPriceWithQuantity() {
|
|
123
|
-
return
|
|
134
|
+
return formatCurrency(
|
|
135
|
+
this.finalPriceWithQuantity || 0,
|
|
136
|
+
this.currencyCode || "",
|
|
137
|
+
this.currencySymbol || ""
|
|
138
|
+
);
|
|
124
139
|
}
|
|
125
140
|
|
|
126
141
|
get tax() {
|
|
@@ -128,7 +143,11 @@ export class IkasOrderLineItem extends IkasBaseModel implements IOrderLineItem {
|
|
|
128
143
|
}
|
|
129
144
|
|
|
130
145
|
get formattedTax() {
|
|
131
|
-
return
|
|
146
|
+
return formatCurrency(
|
|
147
|
+
this.tax,
|
|
148
|
+
this.currencyCode || "",
|
|
149
|
+
this.currencySymbol || ""
|
|
150
|
+
);
|
|
132
151
|
}
|
|
133
152
|
|
|
134
153
|
get refundQuantity() {
|
|
@@ -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 };
|
|
@@ -1,11 +1,12 @@
|
|
|
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 {
|
|
4
|
+
import { formatCurrency } 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;
|
|
9
10
|
discountPrice: number | null = null;
|
|
10
11
|
priceListId: string | null = null;
|
|
11
12
|
sellPrice: number;
|
|
@@ -13,6 +14,7 @@ export class IkasProductPrice implements IProductPrice {
|
|
|
13
14
|
constructor(data?: IProductPrice) {
|
|
14
15
|
this.buyPrice = data?.buyPrice ?? null;
|
|
15
16
|
this.currency = data?.currency ?? null;
|
|
17
|
+
this.currencySymbol = data?.currencySymbol ?? "";
|
|
16
18
|
this.discountPrice = data?.discountPrice ?? null;
|
|
17
19
|
this.priceListId = data?.priceListId ?? null;
|
|
18
20
|
this.sellPrice = data?.sellPrice ?? 0;
|
|
@@ -20,28 +22,40 @@ export class IkasProductPrice implements IProductPrice {
|
|
|
20
22
|
makeAutoObservable(this);
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
get currencySymbol() {
|
|
24
|
-
return getCurrencySymbol(this.currency || "");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
25
|
get finalPrice() {
|
|
28
26
|
return IkasProductPriceFunctions.getFinalPrice(this);
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
get formattedFinalPrice() {
|
|
32
|
-
return
|
|
30
|
+
return formatCurrency(
|
|
31
|
+
this.finalPrice,
|
|
32
|
+
this.currency || "",
|
|
33
|
+
this.currencySymbol || ""
|
|
34
|
+
);
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
get formattedBuyPrice() {
|
|
36
|
-
return
|
|
38
|
+
return formatCurrency(
|
|
39
|
+
this.buyPrice || 0,
|
|
40
|
+
this.currency || "",
|
|
41
|
+
this.currencySymbol || ""
|
|
42
|
+
);
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
get formattedDiscountPrice() {
|
|
40
|
-
return
|
|
46
|
+
return formatCurrency(
|
|
47
|
+
this.discountPrice || 0,
|
|
48
|
+
this.currency || "",
|
|
49
|
+
this.currencySymbol || ""
|
|
50
|
+
);
|
|
41
51
|
}
|
|
42
52
|
|
|
43
53
|
get formattedSellPrice() {
|
|
44
|
-
return
|
|
54
|
+
return formatCurrency(
|
|
55
|
+
this.sellPrice || 0,
|
|
56
|
+
this.currency || "",
|
|
57
|
+
this.currencySymbol || ""
|
|
58
|
+
);
|
|
45
59
|
}
|
|
46
60
|
|
|
47
61
|
get hasDiscount() {
|
|
@@ -3,10 +3,12 @@ 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;
|
|
6
7
|
variantType: IkasVariantType;
|
|
7
8
|
variantValueIds: string[];
|
|
8
9
|
|
|
9
10
|
constructor(data: Partial<IkasProductVariantType>) {
|
|
11
|
+
this.order = data.order || 0;
|
|
10
12
|
this.variantType = data.variantType
|
|
11
13
|
? new IkasVariantType(data.variantType)
|
|
12
14
|
: new IkasVariantType();
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
IkasRaffleAppliedProduct as IRaffleAppliedProduct,
|
|
9
9
|
IkasRaffleVerificationType,
|
|
10
10
|
IkasRaffleMetadataTargetType,
|
|
11
|
+
IkasRaffleParticipantStatus,
|
|
11
12
|
} from "@ikas/storefront-models";
|
|
12
13
|
import { IkasRaffleFunctions } from "@ikas/storefront-model-functions";
|
|
13
14
|
|
|
@@ -33,13 +34,12 @@ export class IkasRaffle implements IRaffle {
|
|
|
33
34
|
dateRange: IkasRaffleDateRangeField | null;
|
|
34
35
|
metadata: IkasRaffleMetaData | null;
|
|
35
36
|
name: string;
|
|
36
|
-
participantCount?: number | null;
|
|
37
37
|
requiredCustomerAccount: boolean;
|
|
38
38
|
status: boolean;
|
|
39
39
|
variants: IkasRaffleAppliedProduct[] | null;
|
|
40
|
-
products: IkasProduct[];
|
|
41
40
|
verificationType: IkasRaffleVerificationType;
|
|
42
|
-
|
|
41
|
+
|
|
42
|
+
products: IkasProduct[];
|
|
43
43
|
|
|
44
44
|
constructor(data: Partial<IkasRaffle> = {}) {
|
|
45
45
|
this.id = data.id || Date.now() + "";
|
|
@@ -47,12 +47,10 @@ 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;
|
|
51
50
|
this.requiredCustomerAccount = data.requiredCustomerAccount || false;
|
|
52
51
|
this.status = data.status || false;
|
|
53
52
|
this.verificationType =
|
|
54
53
|
data.verificationType || IkasRaffleVerificationType.EMAIL;
|
|
55
|
-
this.isCustomerWinner = data.isCustomerWinner || null;
|
|
56
54
|
|
|
57
55
|
this.dateRange = data.dateRange
|
|
58
56
|
? new IkasRaffleDateRangeField(data.dateRange)
|
|
@@ -113,8 +111,10 @@ export class IkasRaffleParticipant implements IRaffleParticipant {
|
|
|
113
111
|
email: string;
|
|
114
112
|
applicationDate: number;
|
|
115
113
|
phone: string | null = null;
|
|
116
|
-
|
|
114
|
+
isDeliveredCargo: boolean | null;
|
|
117
115
|
|
|
116
|
+
raffle: IkasRaffle;
|
|
117
|
+
status: IkasRaffleParticipantStatus | null;
|
|
118
118
|
extraData: Record<string, any> | null = null;
|
|
119
119
|
appliedProduct: IkasRaffleAppliedProduct;
|
|
120
120
|
|
|
@@ -131,8 +131,10 @@ 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.
|
|
134
|
+
this.isDeliveredCargo = data.isDeliveredCargo || false;
|
|
135
135
|
|
|
136
|
+
this.raffle = new IkasRaffle(data.raffle);
|
|
137
|
+
this.status = data.status || null;
|
|
136
138
|
this.extraData = data.extraData || {};
|
|
137
139
|
this.appliedProduct = new IkasRaffleAppliedProduct(
|
|
138
140
|
data.appliedProduct || {}
|
|
@@ -20,6 +20,7 @@ export class IkasStorefront implements IStorefront {
|
|
|
20
20
|
analytics4Id: string | null;
|
|
21
21
|
universalAnalyticsId: string | null;
|
|
22
22
|
tiktokPixelId: string | null;
|
|
23
|
+
token: string | null;
|
|
23
24
|
|
|
24
25
|
localizations: IkasStorefrontLocalization[];
|
|
25
26
|
routings: IkasStorefrontRouting[];
|
|
@@ -40,6 +41,7 @@ export class IkasStorefront implements IStorefront {
|
|
|
40
41
|
this.analytics4Id = data.analytics4Id || null;
|
|
41
42
|
this.universalAnalyticsId = data.universalAnalyticsId || null;
|
|
42
43
|
this.tiktokPixelId = data.tiktokPixelId || null;
|
|
44
|
+
this.token = data.token || null;
|
|
43
45
|
|
|
44
46
|
// Sub Models
|
|
45
47
|
this.localizations = data.localizations
|
|
@@ -221,12 +221,6 @@ export class IkasProductList {
|
|
|
221
221
|
|
|
222
222
|
get filterQueryParams() {
|
|
223
223
|
const queryParams: Record<string, any> = {};
|
|
224
|
-
const _getQueryParams = this.getQueryParams();
|
|
225
|
-
if (_getQueryParams) {
|
|
226
|
-
_getQueryParams.forEach((value, key) => {
|
|
227
|
-
queryParams[key] = value;
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
224
|
|
|
231
225
|
this.filters?.forEach((f) => {
|
|
232
226
|
if (f.keyList.length) queryParams[f.key] = f.keyList;
|
|
@@ -75,7 +75,7 @@ export class IkasRaffleList {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
private async getRaffleList(page: number, limit: number) {
|
|
78
|
-
const response = await RaffleStore.
|
|
78
|
+
const response = await RaffleStore.listStorefrontRaffle({
|
|
79
79
|
start: this._start ? { eq: this._start } : undefined,
|
|
80
80
|
end: this._end ? { eq: this._end } : undefined,
|
|
81
81
|
includeDeleted: this._includeDeleted || false,
|