@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.
- 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 +25 -7
- package/src/components/checkout/components/address-form/index.tsx +1 -1
- package/src/components/checkout/components/address-form/model.ts +1 -0
- package/src/components/checkout/components/button/style.module.scss +2 -2
- package/src/components/checkout/components/cart-summary/cart-item/index.tsx +16 -29
- package/src/components/checkout/components/cart-summary/cart-item/style.module.scss +60 -23
- package/src/components/checkout/components/cart-summary/index.tsx +58 -27
- package/src/components/checkout/components/cart-summary/style.module.scss +48 -3
- package/src/components/checkout/components/customer-addresses/index.tsx +7 -2
- package/src/components/checkout/components/customer-addresses/model.ts +16 -8
- package/src/components/checkout/components/error/index.tsx +1 -1
- package/src/components/checkout/components/error/unknown-error/index.tsx +4 -2
- package/src/components/checkout/components/form-item/index.tsx +9 -11
- package/src/components/checkout/components/master-pass/credit-card-form/index.tsx +2 -0
- package/src/components/checkout/components/offer-product/index.tsx +16 -19
- package/src/components/checkout/components/offer-product/style.module.scss +1 -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 +28 -19
- package/src/components/checkout/model.ts +214 -91
- package/src/components/checkout/modelMasterPass.ts +2 -2
- package/src/components/checkout/steps/step-info/index.tsx +9 -3
- package/src/components/checkout/steps/step-payment/billing-address/index.tsx +1 -1
- package/src/components/checkout/steps/step-payment/index.tsx +11 -2
- package/src/components/checkout/steps/step-payment/payment-gateways/index.tsx +12 -3
- package/src/components/checkout/steps/step-payment/payment-gateways/installments/index.tsx +5 -3
- package/src/components/checkout/steps/step-payment/style.module.scss +5 -0
- package/src/components/checkout/steps/step-shipping/index.tsx +9 -4
- package/src/components/checkout/steps/step-success/index.tsx +15 -7
- package/src/components/page/head.tsx +12 -0
- package/src/components/page/index.tsx +10 -9
- package/src/components/page-editor/ThemeComponentEditor.tsx +19 -8
- package/src/components/page-editor/model.ts +44 -107
- package/src/models/data/cart/campaign-offer/index.ts +13 -2
- package/src/models/data/cart/index.ts +1 -1
- package/src/models/data/category/path-item/index.ts +4 -0
- package/src/models/data/checkout/index.ts +36 -4
- package/src/models/data/checkout-settings/price/index.ts +2 -0
- package/src/models/data/country/index.ts +4 -0
- package/src/models/data/country/location-translations/index.ts +15 -0
- package/src/models/data/index.ts +3 -0
- package/src/models/data/merchant-settings/index.ts +9 -0
- package/src/models/data/order/index.ts +51 -32
- package/src/models/data/order/line-item/base-unit/index.ts +22 -0
- package/src/models/data/order/line-item/base-unit/unit-type/index.ts +14 -0
- package/src/models/data/order/line-item/index.ts +76 -18
- package/src/models/data/order/line-item/variant/index.ts +8 -0
- package/src/models/data/order/line-item/variant/price/index.ts +2 -0
- package/src/models/data/order/line-item/variant/unit/index.ts +17 -0
- package/src/models/data/order/line-item/variant/value/index.ts +1 -1
- package/src/models/data/order/transaction/index.ts +2 -5
- package/src/models/data/product/attribute-value/index.ts +40 -0
- package/src/models/data/product/base-unit/index.ts +32 -0
- package/src/models/data/product/filter/index.ts +4 -13
- package/src/models/data/product/index.ts +45 -7
- package/src/models/data/product/option-set/index.ts +8 -3
- package/src/models/data/product/option-set/option/index.ts +36 -13
- package/src/models/data/product/variant/index.ts +26 -1
- package/src/models/data/product/variant/price/index.ts +25 -9
- package/src/models/data/product/variant/unit/index.ts +17 -0
- package/src/models/data/product/variant-type/index.ts +2 -0
- package/src/models/data/raffle/index.ts +9 -7
- package/src/models/data/state/index.ts +6 -2
- package/src/models/data/storefront/index.ts +2 -0
- package/src/models/data/storefront/routing/index.tsx +4 -0
- package/src/models/ui/product-list/index.ts +26 -17
- 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/page-data-init/index.ts +159 -404
- package/src/pages/checkout.tsx +2 -1
- package/src/pages/editor.tsx +5 -2
- package/src/store/base.ts +2 -2
- package/src/store/cart/index.ts +2 -2
- package/src/store/customer/index.ts +7 -17
- package/src/store/index.ts +2 -0
- package/src/store/raffle/index.ts +7 -10
- package/src/utils/constants.ts +1 -1
- package/src/utils/currency.ts +9 -183
- package/src/components/checkout/components/phone-number-input/locale/en.ts +0 -257
- package/src/models/data/category/init.ts +0 -33
|
@@ -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,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
} from "../../../../models/data/payment-gateway";
|
|
20
20
|
import OfferProduct from "../../components/offer-product";
|
|
21
21
|
import { IkasTransactionCardAssociation } from "@ikas/storefront-models";
|
|
22
|
+
import { Analytics } from "../../../../analytics";
|
|
22
23
|
|
|
23
24
|
type Props = {
|
|
24
25
|
vm: CheckoutViewModel;
|
|
@@ -31,8 +32,12 @@ export const StepSuccess: React.FC<Props> = observer(({ vm }) => {
|
|
|
31
32
|
if (typeof localStorage !== "undefined") {
|
|
32
33
|
const lsCartId = localStorage.getItem(CART_LS_KEY);
|
|
33
34
|
|
|
34
|
-
if (lsCartId && lsCartId === vm.checkout.id)
|
|
35
|
+
if (lsCartId && lsCartId === vm.checkout.id) {
|
|
36
|
+
if (vm.successTransaction)
|
|
37
|
+
Analytics.purchase(vm.checkout, vm.successTransaction);
|
|
38
|
+
|
|
35
39
|
localStorage.removeItem(CART_LS_KEY);
|
|
40
|
+
}
|
|
36
41
|
}
|
|
37
42
|
}, []);
|
|
38
43
|
|
|
@@ -125,9 +130,10 @@ export const StepSuccess: React.FC<Props> = observer(({ vm }) => {
|
|
|
125
130
|
null && (
|
|
126
131
|
<div className={styles.InfoText}>{`${
|
|
127
132
|
paymentMethodDetail.installment.installmentCount
|
|
128
|
-
} x ${
|
|
133
|
+
} x ${formatCurrency(
|
|
129
134
|
paymentMethodDetail.installment.installmentPrice,
|
|
130
|
-
vm.checkout.currencyCode
|
|
135
|
+
vm.checkout.currencyCode,
|
|
136
|
+
vm.checkout.currencySymbol
|
|
131
137
|
)}`}</div>
|
|
132
138
|
)}
|
|
133
139
|
</React.Fragment>
|
|
@@ -245,9 +251,11 @@ export const StepSuccess: React.FC<Props> = observer(({ vm }) => {
|
|
|
245
251
|
<ExpandableSection title={t("checkout-page:paymentSummary")}>
|
|
246
252
|
{paymentInfoGrid}
|
|
247
253
|
</ExpandableSection>
|
|
248
|
-
|
|
249
|
-
{
|
|
250
|
-
|
|
254
|
+
{!vm.isDigitalOnly && (
|
|
255
|
+
<ExpandableSection title={t("checkout-page:shippingSummary")}>
|
|
256
|
+
{contactInfoGrid}
|
|
257
|
+
</ExpandableSection>
|
|
258
|
+
)}
|
|
251
259
|
|
|
252
260
|
<div className={styles.Actions}>
|
|
253
261
|
<div className={styles.HelpText}>
|
|
@@ -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);
|
|
@@ -73,7 +75,11 @@ export const IkasPage: React.FC<IkasPageProps> = observer(
|
|
|
73
75
|
pageType,
|
|
74
76
|
isBrowser
|
|
75
77
|
);
|
|
76
|
-
return IkasPageDataInit.
|
|
78
|
+
return IkasPageDataInit.initPagePropValues(
|
|
79
|
+
propValues,
|
|
80
|
+
settings,
|
|
81
|
+
isBrowser
|
|
82
|
+
);
|
|
77
83
|
}, [isBrowser, propValues, pageType, settings, pageSpecificData]);
|
|
78
84
|
|
|
79
85
|
React.useEffect(() => {
|
|
@@ -99,7 +105,7 @@ export const IkasPage: React.FC<IkasPageProps> = observer(
|
|
|
99
105
|
|
|
100
106
|
React.useEffect(() => {
|
|
101
107
|
handleAnalytics(pageType, IkasPageDataInit.pageSpecificData);
|
|
102
|
-
}, [pageType,
|
|
108
|
+
}, [pageType, pageSpecificData]); // Not IkasPageDataInit.pageSpecificData on purpose
|
|
103
109
|
|
|
104
110
|
const renderedComponents = React.useMemo(() => {
|
|
105
111
|
const headerComponentPropValue = _propValues.find(
|
|
@@ -181,11 +187,6 @@ async function handleAnalytics(
|
|
|
181
187
|
if (pageType === IkasThemeJsonPageType.PRODUCT) {
|
|
182
188
|
const product = pageSpecificData as IkasProduct;
|
|
183
189
|
|
|
184
|
-
const isBrowser = typeof window !== "undefined";
|
|
185
|
-
// if (isBrowser) {
|
|
186
|
-
// IkasPageDataInit._initProductOnBrowser(product);
|
|
187
|
-
// }
|
|
188
|
-
|
|
189
190
|
Analytics.productView(product);
|
|
190
191
|
|
|
191
192
|
//@ts-ignore
|
|
@@ -15,6 +15,11 @@ import {
|
|
|
15
15
|
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
16
16
|
import { IkasPageDataInit } from "../../page-data-init";
|
|
17
17
|
import { IkasBaseStore } from "../../store";
|
|
18
|
+
import {
|
|
19
|
+
IkasCheckout,
|
|
20
|
+
IkasOrderLineItem,
|
|
21
|
+
IkasCheckoutSettings,
|
|
22
|
+
} from "../../models/data";
|
|
18
23
|
|
|
19
24
|
type Props = {
|
|
20
25
|
vm: IkasPageEditorViewModel;
|
|
@@ -59,7 +64,7 @@ export class ThemeEditorComponent extends React.Component<Props> {
|
|
|
59
64
|
get pageComponentPropValue() {
|
|
60
65
|
const { vm, pageComponent } = this.props;
|
|
61
66
|
|
|
62
|
-
return vm.
|
|
67
|
+
return vm.initializedPropValues.find(
|
|
63
68
|
(pc) => pc.pageComponent.id === pageComponent.id
|
|
64
69
|
);
|
|
65
70
|
}
|
|
@@ -70,13 +75,16 @@ export class ThemeEditorComponent extends React.Component<Props> {
|
|
|
70
75
|
|
|
71
76
|
if (vm.page?.type === IkasThemeJsonPageType.CHECKOUT) {
|
|
72
77
|
const checkoutProps: IkasCheckoutPageProps = {
|
|
73
|
-
checkout: {
|
|
78
|
+
checkout: new IkasCheckout({
|
|
79
|
+
currencyCode: "TRY",
|
|
80
|
+
currencySymbol: "₺",
|
|
74
81
|
orderLineItems: [
|
|
75
|
-
{
|
|
82
|
+
new IkasOrderLineItem({
|
|
76
83
|
id: "",
|
|
77
84
|
createdAt: 0,
|
|
78
85
|
updatedAt: 0,
|
|
79
86
|
currencyCode: "TRY",
|
|
87
|
+
currencySymbol: "₺",
|
|
80
88
|
discount: null,
|
|
81
89
|
discountPrice: null,
|
|
82
90
|
finalPrice: 100,
|
|
@@ -88,6 +96,8 @@ export class ThemeEditorComponent extends React.Component<Props> {
|
|
|
88
96
|
statusUpdatedAt: null,
|
|
89
97
|
stockLocationId: null,
|
|
90
98
|
taxValue: null,
|
|
99
|
+
unitPrice: null,
|
|
100
|
+
finalUnitPrice: null,
|
|
91
101
|
variant: {
|
|
92
102
|
barcodeList: null,
|
|
93
103
|
brand: null,
|
|
@@ -104,13 +114,14 @@ export class ThemeEditorComponent extends React.Component<Props> {
|
|
|
104
114
|
type: null,
|
|
105
115
|
weight: null,
|
|
106
116
|
variantValues: [],
|
|
117
|
+
baseUnit: null,
|
|
118
|
+
unit: null,
|
|
107
119
|
},
|
|
108
120
|
orderedAt: 0,
|
|
109
|
-
|
|
110
|
-
},
|
|
121
|
+
}),
|
|
111
122
|
],
|
|
112
|
-
}
|
|
113
|
-
checkoutSettings: {
|
|
123
|
+
}),
|
|
124
|
+
checkoutSettings: new IkasCheckoutSettings({
|
|
114
125
|
createdAt: 0,
|
|
115
126
|
updatedAt: 0,
|
|
116
127
|
id: "",
|
|
@@ -126,7 +137,7 @@ export class ThemeEditorComponent extends React.Component<Props> {
|
|
|
126
137
|
showCheckoutNote: true,
|
|
127
138
|
showTermsAndConditionsCheckbox: true,
|
|
128
139
|
storefrontId: "",
|
|
129
|
-
},
|
|
140
|
+
}),
|
|
130
141
|
customizationProps: {
|
|
131
142
|
...propValues,
|
|
132
143
|
},
|
|
@@ -14,7 +14,10 @@ import {
|
|
|
14
14
|
IkasThemeJsonSettings,
|
|
15
15
|
IkasVariantValue,
|
|
16
16
|
} from "../../models";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
IkasPageComponentPropValue,
|
|
19
|
+
IkasPageDataProvider,
|
|
20
|
+
} from "@ikas/storefront-providers";
|
|
18
21
|
import { makeAutoObservable, reaction } from "mobx";
|
|
19
22
|
import { NextRouter } from "next/router.js";
|
|
20
23
|
import { IkasPageDataInit } from "../../page-data-init";
|
|
@@ -23,6 +26,8 @@ import HtmlMetaDataStore from "../../store/html-meta-data";
|
|
|
23
26
|
import BlogStore from "../../store/blog";
|
|
24
27
|
import RaffleStore from "../../store/raffle";
|
|
25
28
|
import ProductStore from "../../store/product";
|
|
29
|
+
import { setAPIClientConfig } from "@ikas/storefront-api";
|
|
30
|
+
import { runInAction } from "mobx";
|
|
26
31
|
|
|
27
32
|
const PACKAGE_VERSION = "2.0.20";
|
|
28
33
|
// import { version as PACKAGE_VERSION } from "../../../package.json";
|
|
@@ -43,6 +48,7 @@ export default class IkasPageEditorViewModel {
|
|
|
43
48
|
pageParams: Record<string, any> = {};
|
|
44
49
|
apiKey?: string | null = null;
|
|
45
50
|
pageDataProvider?: IkasPageDataProvider | null = null;
|
|
51
|
+
initializedPropValues: IkasPageComponentPropValue[] = [];
|
|
46
52
|
|
|
47
53
|
router: NextRouter;
|
|
48
54
|
|
|
@@ -366,18 +372,20 @@ export default class IkasPageEditorViewModel {
|
|
|
366
372
|
this.pageParams
|
|
367
373
|
);
|
|
368
374
|
|
|
369
|
-
|
|
370
|
-
|
|
375
|
+
runInAction(() => {
|
|
376
|
+
IkasBaseStore.getInstance().currentPageType = pageType;
|
|
377
|
+
this.pageDataProvider = pageDataProvider;
|
|
371
378
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
379
|
+
if (pageType === IkasThemeJsonPageType.CUSTOM)
|
|
380
|
+
this.page = this.theme?.pages.find(
|
|
381
|
+
(p) => p.type === pageType && p.slug === this.pageParams.slug
|
|
382
|
+
);
|
|
383
|
+
else this.page = this.theme?.pages.find((p) => p.type === pageType);
|
|
377
384
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
385
|
+
requestAnimationFrame(() => {
|
|
386
|
+
document.body.scrollTop = 0;
|
|
387
|
+
if (document.scrollingElement) document.scrollingElement.scrollTop = 0;
|
|
388
|
+
});
|
|
381
389
|
});
|
|
382
390
|
|
|
383
391
|
this.sendMessage(BridgeMessageType.EDITOR_PAGE_CHANGE, {
|
|
@@ -504,8 +512,8 @@ export default class IkasPageEditorViewModel {
|
|
|
504
512
|
IkasPageDataInit.pageSpecificData = undefined;
|
|
505
513
|
}
|
|
506
514
|
|
|
507
|
-
|
|
508
|
-
pageDataProvider
|
|
515
|
+
this.initializedPropValues = IkasPageDataInit.initPagePropValues(
|
|
516
|
+
pageDataProvider.$pageComponentPropValues,
|
|
509
517
|
theme!.settings,
|
|
510
518
|
false
|
|
511
519
|
);
|
|
@@ -565,7 +573,13 @@ export default class IkasPageEditorViewModel {
|
|
|
565
573
|
translations: this.translations || {},
|
|
566
574
|
isEditor: true,
|
|
567
575
|
apiKey: data.apiKey,
|
|
576
|
+
apiUrl: data.apiUrl,
|
|
577
|
+
adminApiUrl: data.adminApiUrl,
|
|
578
|
+
cdnUrl: data.cdnUrl,
|
|
579
|
+
merchantSettings: data.merchantSettings,
|
|
568
580
|
});
|
|
581
|
+
|
|
582
|
+
setAPIClientConfig();
|
|
569
583
|
}
|
|
570
584
|
|
|
571
585
|
// (window as any).editorApiKey = data.apiKey;
|
|
@@ -601,96 +615,28 @@ export default class IkasPageEditorViewModel {
|
|
|
601
615
|
|
|
602
616
|
if (!prop || !this.selectedPageComponent) return;
|
|
603
617
|
|
|
604
|
-
const pageComponentPropValues =
|
|
605
|
-
this.
|
|
606
|
-
|
|
607
|
-
|
|
618
|
+
const pageComponentPropValues = this.initializedPropValues.find(
|
|
619
|
+
(pv) => pv.pageComponent.id === this.selectedPageComponentId
|
|
620
|
+
);
|
|
621
|
+
if (!this.pageDataProvider || !pageComponentPropValues) return;
|
|
608
622
|
|
|
609
623
|
this.selectedPageComponent.propValues[propName] = value;
|
|
610
624
|
|
|
611
|
-
if (!this.pageDataProvider) return;
|
|
612
|
-
|
|
613
625
|
const propValue = await this.pageDataProvider.getPageComponentPropValue(
|
|
614
626
|
this.selectedPageComponent,
|
|
615
627
|
prop
|
|
616
628
|
);
|
|
617
629
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
if (pageComponentPropValues) {
|
|
621
|
-
pageComponentPropValues.propValues[propName] = propValue;
|
|
630
|
+
if (propValue && JSON.stringify(propValue).includes("href"))
|
|
631
|
+
await this.pageDataProvider.setLinkSlugs();
|
|
622
632
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
);
|
|
631
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.COMPONENT) {
|
|
632
|
-
IkasPageDataInit.initComponentPropValue(
|
|
633
|
-
prop,
|
|
634
|
-
propValue,
|
|
635
|
-
pageComponentPropValues,
|
|
636
|
-
this.theme!.settings,
|
|
637
|
-
true
|
|
638
|
-
);
|
|
639
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.COMPONENT_LIST) {
|
|
640
|
-
IkasPageDataInit.initComponentListPropValue(
|
|
641
|
-
prop,
|
|
642
|
-
propValue,
|
|
643
|
-
pageComponentPropValues,
|
|
644
|
-
this.theme!.settings,
|
|
645
|
-
true
|
|
646
|
-
);
|
|
647
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.PRODUCT_DETAIL) {
|
|
648
|
-
IkasPageDataInit.initProductPropValue(
|
|
649
|
-
prop,
|
|
650
|
-
propValue,
|
|
651
|
-
pageComponentPropValues
|
|
652
|
-
);
|
|
653
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.CATEGORY) {
|
|
654
|
-
IkasPageDataInit.initCategoryPropValue(
|
|
655
|
-
prop,
|
|
656
|
-
propValue,
|
|
657
|
-
pageComponentPropValues
|
|
658
|
-
);
|
|
659
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.BRAND) {
|
|
660
|
-
IkasPageDataInit.initBrandPropValue(
|
|
661
|
-
prop,
|
|
662
|
-
propValue,
|
|
663
|
-
pageComponentPropValues
|
|
664
|
-
);
|
|
665
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.BLOG) {
|
|
666
|
-
IkasPageDataInit.initBlogPropValue(
|
|
667
|
-
prop,
|
|
668
|
-
propValue,
|
|
669
|
-
pageComponentPropValues
|
|
670
|
-
);
|
|
671
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.BLOG_CATEGORY) {
|
|
672
|
-
IkasPageDataInit.initBlogCategoryPropValue(
|
|
673
|
-
prop,
|
|
674
|
-
propValue,
|
|
675
|
-
pageComponentPropValues
|
|
676
|
-
);
|
|
677
|
-
} else if (prop.type === IkasThemeJsonComponentPropType.RAFFLE) {
|
|
678
|
-
IkasPageDataInit.initRafflePropValue(
|
|
679
|
-
prop,
|
|
680
|
-
propValue,
|
|
681
|
-
pageComponentPropValues
|
|
682
|
-
);
|
|
683
|
-
} else if (
|
|
684
|
-
prop.type === IkasThemeJsonComponentPropType.LINK ||
|
|
685
|
-
prop.type === IkasThemeJsonComponentPropType.LIST_OF_LINK
|
|
686
|
-
) {
|
|
687
|
-
IkasPageDataInit.initLinkPropValue(
|
|
688
|
-
prop,
|
|
689
|
-
propValue,
|
|
690
|
-
pageComponentPropValues
|
|
691
|
-
);
|
|
692
|
-
}
|
|
693
|
-
}
|
|
633
|
+
pageComponentPropValues.propValues[propName] =
|
|
634
|
+
IkasPageDataInit.initPropValue(
|
|
635
|
+
prop,
|
|
636
|
+
propValue,
|
|
637
|
+
this.theme!.settings,
|
|
638
|
+
true
|
|
639
|
+
);
|
|
694
640
|
};
|
|
695
641
|
|
|
696
642
|
handleUpdatePageParams = async (data: any) => {
|
|
@@ -758,24 +704,15 @@ export default class IkasPageEditorViewModel {
|
|
|
758
704
|
const pageComponentPropValues =
|
|
759
705
|
await this.pageDataProvider!.getPageComponentPropValues(pageComponent);
|
|
760
706
|
|
|
761
|
-
const
|
|
762
|
-
(
|
|
763
|
-
);
|
|
764
|
-
|
|
765
|
-
customDataProps.forEach((customDataProp) => {
|
|
766
|
-
IkasPageDataInit.initCustomDataPropValue(
|
|
767
|
-
customDataProp,
|
|
768
|
-
pageComponentPropValues.propValues[customDataProp.name],
|
|
707
|
+
const initializedPageComponentPropValues =
|
|
708
|
+
IkasPageDataInit.initPageComponentPropValue(
|
|
769
709
|
pageComponentPropValues,
|
|
770
710
|
this.theme!.settings,
|
|
771
711
|
true
|
|
772
712
|
);
|
|
773
713
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
);
|
|
777
|
-
this.pageComponents.push(pageComponent);
|
|
778
|
-
});
|
|
714
|
+
this.initializedPropValues.push(initializedPageComponentPropValues);
|
|
715
|
+
this.pageComponents.push(pageComponent);
|
|
779
716
|
};
|
|
780
717
|
|
|
781
718
|
handleDeletePageComponent = (data: any) => {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
IkasCartCampaignOfferStatus,
|
|
4
4
|
IkasCartCampaignOffer as ICartCampaignOffer,
|
|
5
5
|
} from "@ikas/storefront-models";
|
|
6
|
-
import { makeAutoObservable } from "mobx";
|
|
6
|
+
import { makeAutoObservable, makeObservable, observable } from "mobx";
|
|
7
7
|
import { IkasBaseModel } from "../../base";
|
|
8
8
|
import { IkasCampaignOffer } from "../../campaign-offer";
|
|
9
9
|
|
|
@@ -36,7 +36,18 @@ export class IkasCartCampaignOffer
|
|
|
36
36
|
this.targetPageTypes = data.targetPageTypes;
|
|
37
37
|
this.triggerSourceOrderLineId = data.triggerSourceOrderLineId;
|
|
38
38
|
|
|
39
|
-
makeAutoObservable(this);
|
|
39
|
+
// makeAutoObservable(this);
|
|
40
|
+
makeObservable(this, {
|
|
41
|
+
appliedOrderLineId: observable,
|
|
42
|
+
campaignOfferId: observable,
|
|
43
|
+
campaignOffer: observable,
|
|
44
|
+
campaignOfferProductId: observable,
|
|
45
|
+
offerEndDate: observable,
|
|
46
|
+
offerStartDate: observable,
|
|
47
|
+
status: observable,
|
|
48
|
+
targetPageTypes: observable,
|
|
49
|
+
triggerSourceOrderLineId: observable,
|
|
50
|
+
});
|
|
40
51
|
}
|
|
41
52
|
}
|
|
42
53
|
|
|
@@ -12,7 +12,7 @@ export class IkasCart extends IkasOrder implements ICart {
|
|
|
12
12
|
shippingZoneRateId: string | null = null;
|
|
13
13
|
stockLocationId: string | null = null;
|
|
14
14
|
|
|
15
|
-
constructor(data: ICart) {
|
|
15
|
+
constructor(data: Partial<ICart>) {
|
|
16
16
|
super(data);
|
|
17
17
|
|
|
18
18
|
this.availableShippingMethods =
|
|
@@ -3,6 +3,8 @@ import { IkasBaseModel } from "../../base";
|
|
|
3
3
|
import { IkasCategoryPathItem as ICategoryPathItem } from "@ikas/storefront-models";
|
|
4
4
|
import { computed, makeObservable, observable } from "mobx";
|
|
5
5
|
import { IkasCategoryPathItemFunctions } from "@ikas/storefront-model-functions";
|
|
6
|
+
import { IkasCategoryTranslation } from "../translations";
|
|
7
|
+
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
6
8
|
|
|
7
9
|
export class IkasCategoryPathItem
|
|
8
10
|
extends IkasBaseModel
|
|
@@ -12,6 +14,7 @@ export class IkasCategoryPathItem
|
|
|
12
14
|
description: string | null;
|
|
13
15
|
imageId: string | null;
|
|
14
16
|
name: string;
|
|
17
|
+
translations?: IkasCategoryTranslation[] | null = null;
|
|
15
18
|
|
|
16
19
|
constructor(data: ICategoryPathItem) {
|
|
17
20
|
super(data);
|
|
@@ -20,6 +23,7 @@ export class IkasCategoryPathItem
|
|
|
20
23
|
this.description = data.description || null;
|
|
21
24
|
this.imageId = data.imageId || null;
|
|
22
25
|
this.name = data.name;
|
|
26
|
+
this.translations = data.translations || null;
|
|
23
27
|
|
|
24
28
|
makeObservable(this, {
|
|
25
29
|
metaData: observable,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { IkasCart } from "../cart";
|
|
2
2
|
import { IkasCheckout as ICheckout } from "@ikas/storefront-models";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IkasCheckoutFunctions,
|
|
5
|
+
IkasOrderFunctions,
|
|
6
|
+
} from "@ikas/storefront-model-functions";
|
|
4
7
|
import { IkasPaymentGateway } from "../payment-gateway";
|
|
5
|
-
import {
|
|
8
|
+
import { formatCurrency } from "../../../utils/currency";
|
|
6
9
|
import { computed, makeObservable, observable } from "mobx";
|
|
7
10
|
import { formatDate } from "../../../utils/helper";
|
|
8
11
|
|
|
@@ -17,9 +20,13 @@ export class IkasCheckout extends IkasCart implements ICheckout {
|
|
|
17
20
|
selectedPaymentGateway?: IkasPaymentGateway | null = null;
|
|
18
21
|
masterPassPaymentGateway?: IkasPaymentGateway | null = null;
|
|
19
22
|
|
|
20
|
-
constructor(data: IkasCheckoutConstructorData) {
|
|
23
|
+
constructor(data: Partial<IkasCheckoutConstructorData>) {
|
|
21
24
|
super(data);
|
|
22
25
|
|
|
26
|
+
this.appliedCouponCode = data.couponCode;
|
|
27
|
+
this.selectedPaymentGateway = data.selectedPaymentGateway;
|
|
28
|
+
this.masterPassPaymentGateway = data.masterPassPaymentGateway;
|
|
29
|
+
|
|
23
30
|
makeObservable(this, {
|
|
24
31
|
appliedCouponCode: observable,
|
|
25
32
|
selectedPaymentGateway: observable,
|
|
@@ -27,6 +34,9 @@ export class IkasCheckout extends IkasCart implements ICheckout {
|
|
|
27
34
|
|
|
28
35
|
isComplete: computed,
|
|
29
36
|
$totalFinalPrice: computed,
|
|
37
|
+
$totalFinalPriceTaxModifier: computed,
|
|
38
|
+
$totalTax: computed,
|
|
39
|
+
$formattedTotalTax: computed,
|
|
30
40
|
$formattedTotalFinalPrice: computed,
|
|
31
41
|
});
|
|
32
42
|
}
|
|
@@ -43,8 +53,30 @@ export class IkasCheckout extends IkasCart implements ICheckout {
|
|
|
43
53
|
);
|
|
44
54
|
}
|
|
45
55
|
|
|
56
|
+
get $totalFinalPriceTaxModifier() {
|
|
57
|
+
return this.$totalFinalPrice / this.totalFinalPrice;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get $totalTax() {
|
|
61
|
+
return (
|
|
62
|
+
IkasOrderFunctions.getTotalTax(this) * this.$totalFinalPriceTaxModifier
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get $formattedTotalTax() {
|
|
67
|
+
return formatCurrency(
|
|
68
|
+
this.totalTax,
|
|
69
|
+
this.currencyCode,
|
|
70
|
+
this.currencySymbol || ""
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
46
74
|
get $formattedTotalFinalPrice() {
|
|
47
|
-
return
|
|
75
|
+
return formatCurrency(
|
|
76
|
+
this.$totalFinalPrice,
|
|
77
|
+
this.currencyCode,
|
|
78
|
+
this.currencySymbol
|
|
79
|
+
);
|
|
48
80
|
}
|
|
49
81
|
|
|
50
82
|
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,4 +1,5 @@
|
|
|
1
1
|
import { IkasBaseModel } from "../base";
|
|
2
|
+
import { IkasLocationTranslations } from "./location-translations";
|
|
2
3
|
import { IkasCountry as ICountry } from "@ikas/storefront-models";
|
|
3
4
|
import { makeObservable, observable } from "mobx";
|
|
4
5
|
|
|
@@ -9,6 +10,7 @@ export class IkasCountry extends IkasBaseModel implements ICountry {
|
|
|
9
10
|
emojiString: string | null = null;
|
|
10
11
|
iso2: string | null = null;
|
|
11
12
|
iso3: string | null = null;
|
|
13
|
+
locationTranslations?: IkasLocationTranslations | null = null;
|
|
12
14
|
name: string;
|
|
13
15
|
native: string | null = null;
|
|
14
16
|
phoneCode: string | null = null;
|
|
@@ -23,6 +25,7 @@ export class IkasCountry extends IkasBaseModel implements ICountry {
|
|
|
23
25
|
this.emojiString = data.emojiString || null;
|
|
24
26
|
this.iso2 = data.iso2 || null;
|
|
25
27
|
this.iso3 = data.iso3 || null;
|
|
28
|
+
this.locationTranslations = data.locationTranslations || null;
|
|
26
29
|
this.name = data.name || "";
|
|
27
30
|
this.native = data.native || null;
|
|
28
31
|
this.phoneCode = data.phoneCode || null;
|
|
@@ -36,6 +39,7 @@ export class IkasCountry extends IkasBaseModel implements ICountry {
|
|
|
36
39
|
emojiString: observable,
|
|
37
40
|
iso2: observable,
|
|
38
41
|
iso3: observable,
|
|
42
|
+
locationTranslations: observable,
|
|
39
43
|
name: observable,
|
|
40
44
|
native: observable,
|
|
41
45
|
phoneCode: observable,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IkasLocationTranslations as ILocationTranslations } from "@ikas/storefront-models";
|
|
2
|
+
import { makeAutoObservable } from "mobx";
|
|
3
|
+
|
|
4
|
+
export class IkasLocationTranslations implements ILocationTranslations {
|
|
5
|
+
de: string | null;
|
|
6
|
+
en: string;
|
|
7
|
+
tr: string;
|
|
8
|
+
|
|
9
|
+
constructor(data: ILocationTranslations) {
|
|
10
|
+
this.de = data.de || null;
|
|
11
|
+
this.en = data.en || "";
|
|
12
|
+
this.tr = data.tr || "";
|
|
13
|
+
makeAutoObservable(this);
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/models/data/index.ts
CHANGED