@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.31",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "Umut Ozan Yıldırım",
|
|
6
6
|
"license": "ISC",
|
|
@@ -24,18 +24,18 @@
|
|
|
24
24
|
"libphonenumber-js": "^1.10.6"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@ikas/storefront-api": "^4.0.0-alpha.
|
|
28
|
-
"@ikas/storefront-config": "^4.0.0-alpha.
|
|
29
|
-
"@ikas/storefront-model-functions": "^4.0.0-alpha.
|
|
30
|
-
"@ikas/storefront-models": "^4.0.0-alpha.
|
|
31
|
-
"@ikas/storefront-providers": "^4.0.0-alpha.
|
|
27
|
+
"@ikas/storefront-api": "^4.0.0-alpha.31",
|
|
28
|
+
"@ikas/storefront-config": "^4.0.0-alpha.31",
|
|
29
|
+
"@ikas/storefront-model-functions": "^4.0.0-alpha.31",
|
|
30
|
+
"@ikas/storefront-models": "^4.0.0-alpha.31",
|
|
31
|
+
"@ikas/storefront-providers": "^4.0.0-alpha.31",
|
|
32
32
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
33
33
|
"@rollup/plugin-json": "^4.1.0",
|
|
34
34
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
35
35
|
"@types/react-phone-number-input": "^3.0.10",
|
|
36
36
|
"mobx": "^6.1.3",
|
|
37
37
|
"mobx-react-lite": "^3.1.5",
|
|
38
|
-
"next": "
|
|
38
|
+
"next": "12.2.0",
|
|
39
39
|
"prettier": "^2.2.1",
|
|
40
40
|
"react": "17.0.2",
|
|
41
41
|
"react-dom": "17.0.2",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"html-react-parser": "^1.4.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@ikas/storefront-api": "^4.0.0-alpha.
|
|
56
|
-
"@ikas/storefront-config": "^4.0.0-alpha.
|
|
57
|
-
"@ikas/storefront-model-functions": "^4.0.0-alpha.
|
|
58
|
-
"@ikas/storefront-models": "^4.0.0-alpha.
|
|
59
|
-
"@ikas/storefront-providers": "^4.0.0-alpha.
|
|
55
|
+
"@ikas/storefront-api": "^4.0.0-alpha.31",
|
|
56
|
+
"@ikas/storefront-config": "^4.0.0-alpha.31",
|
|
57
|
+
"@ikas/storefront-model-functions": "^4.0.0-alpha.31",
|
|
58
|
+
"@ikas/storefront-models": "^4.0.0-alpha.31",
|
|
59
|
+
"@ikas/storefront-providers": "^4.0.0-alpha.31",
|
|
60
60
|
"mobx": "^6.1.3",
|
|
61
61
|
"mobx-react-lite": "^3.1.5",
|
|
62
|
-
"next": "
|
|
62
|
+
"next": "12.2.0",
|
|
63
63
|
"react": "17.0.2",
|
|
64
64
|
"react-dom": "17.0.2",
|
|
65
65
|
"lodash": "^4.17.20",
|
|
@@ -54,6 +54,7 @@ export class Analytics {
|
|
|
54
54
|
const customerInfo = await Analytics.getCustomerInfo();
|
|
55
55
|
|
|
56
56
|
GoogleTagManager.pageView(url);
|
|
57
|
+
GoogleUniversal.pageView(window.location.pathname);
|
|
57
58
|
IkasAnalytics.pageView(pageType);
|
|
58
59
|
|
|
59
60
|
tryForEach(Analytics.subscribers, (s) => {
|
|
@@ -194,7 +195,7 @@ export class Analytics {
|
|
|
194
195
|
try {
|
|
195
196
|
localStorage.removeItem(LS_BEGIN_CHECKOUT_KEY);
|
|
196
197
|
|
|
197
|
-
FacebookPixel.purchase(checkout,
|
|
198
|
+
FacebookPixel.purchase(checkout, transaction.id || "");
|
|
198
199
|
GoogleTagManager.purchase(checkout, checkout.orderNumber || "");
|
|
199
200
|
IkasAnalytics.orderSuccess(checkout);
|
|
200
201
|
GoogleAnalytics.purchase(checkout, checkout.orderNumber || "");
|
|
@@ -8,12 +8,23 @@ export class GoogleUniversal {
|
|
|
8
8
|
makeAutoObservable(this);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
static pageView(url: string) {
|
|
12
|
+
try {
|
|
13
|
+
if (!isServer && (window as any).ga) {
|
|
14
|
+
(window as any).ga("set", "page", url);
|
|
15
|
+
(window as any).ga("send", "pageview");
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
} catch (err) {
|
|
19
|
+
console.error(err);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
11
23
|
static productView(productDetail: IkasProduct) {
|
|
12
24
|
try {
|
|
13
25
|
if (!isServer && (window as any).ga) {
|
|
14
26
|
(window as any).ga("ec:addProduct", productToGUItem(productDetail));
|
|
15
27
|
(window as any).ga("ec:setAction", "detail");
|
|
16
|
-
(window as any).ga("send", "pageview");
|
|
17
28
|
}
|
|
18
29
|
return;
|
|
19
30
|
} catch (err) {
|
|
@@ -79,7 +90,6 @@ export class GoogleUniversal {
|
|
|
79
90
|
shipping: "" + checkout.shippingTotal,
|
|
80
91
|
coupon: checkout.couponCode,
|
|
81
92
|
});
|
|
82
|
-
(window as any).ga("send", "pageview");
|
|
83
93
|
}
|
|
84
94
|
return;
|
|
85
95
|
} catch (err) {
|
|
@@ -79,8 +79,7 @@ export const AnalyticsHead: React.FC<HeadProps> = observer(({ blockHTML }) => {
|
|
|
79
79
|
dangerouslySetInnerHTML={{
|
|
80
80
|
__html: `window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
|
|
81
81
|
ga('create', '${universalAnalyticsId}', 'auto');
|
|
82
|
-
ga('require', 'ec')
|
|
83
|
-
ga('send', 'pageview');`,
|
|
82
|
+
ga('require', 'ec');`,
|
|
84
83
|
}}
|
|
85
84
|
/>
|
|
86
85
|
<script
|
package/src/analytics/ikas.ts
CHANGED
|
@@ -181,6 +181,10 @@ export default class IkasAnalytics {
|
|
|
181
181
|
} else {
|
|
182
182
|
await this.createSessionId();
|
|
183
183
|
}
|
|
184
|
+
|
|
185
|
+
IkasStorefrontConfig.init({
|
|
186
|
+
sessionId: this.sessionId || "",
|
|
187
|
+
});
|
|
184
188
|
} catch (err) {
|
|
185
189
|
console.error(err);
|
|
186
190
|
}
|
|
@@ -196,6 +200,10 @@ export default class IkasAnalytics {
|
|
|
196
200
|
this.visitorId = Date.now() + "";
|
|
197
201
|
localStorage.setItem(this.VISITOR_ID_KEY, this.visitorId);
|
|
198
202
|
}
|
|
203
|
+
|
|
204
|
+
IkasStorefrontConfig.init({
|
|
205
|
+
visitorId: this.visitorId,
|
|
206
|
+
});
|
|
199
207
|
} catch (err) {
|
|
200
208
|
console.error(err);
|
|
201
209
|
}
|
|
@@ -315,7 +315,7 @@ const CityInput: React.FC<FormItemProps> = observer(({ vm }) => {
|
|
|
315
315
|
return (
|
|
316
316
|
<FormItem
|
|
317
317
|
type={FormItemType.TEXT}
|
|
318
|
-
autocomplete="address-
|
|
318
|
+
autocomplete="address-level2"
|
|
319
319
|
label={t("checkout-page:city")}
|
|
320
320
|
value={vm.city?.name || ""}
|
|
321
321
|
onChange={vm.onCityInputChange}
|
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
IkasOrderLineItem,
|
|
5
5
|
IkasProductOptionType,
|
|
6
6
|
} from "../../../../../models";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
formatDate,
|
|
9
|
+
formatCurrency,
|
|
10
|
+
useTranslation,
|
|
11
|
+
} from "../../../../../utils";
|
|
8
12
|
import CheckoutViewModel from "../../../../../components/checkout/model";
|
|
9
13
|
import { Modal } from "../../modal";
|
|
10
14
|
|
|
@@ -159,19 +163,17 @@ export const CartItem: React.FC<Props> = observer(
|
|
|
159
163
|
{!!cartItem.overridenPriceWithQuantity && (
|
|
160
164
|
<span className={styles.GrayPrice}>
|
|
161
165
|
{!!adjustmentTotal
|
|
162
|
-
?
|
|
163
|
-
:
|
|
164
|
-
cartItem.overridenPriceWithQuantity,
|
|
165
|
-
currencyCode
|
|
166
|
-
)}
|
|
166
|
+
? cartItem.formattedFinalPriceWithQuantity
|
|
167
|
+
: cartItem.formattedOverridenPriceWithQuantity}
|
|
167
168
|
</span>
|
|
168
169
|
)}
|
|
169
170
|
{!!adjustmentTotal
|
|
170
|
-
?
|
|
171
|
+
? formatCurrency(
|
|
171
172
|
cartItem.finalPriceWithQuantity - adjustmentTotal,
|
|
172
|
-
currencyCode
|
|
173
|
+
currencyCode,
|
|
174
|
+
cartItem.currencySymbol
|
|
173
175
|
)
|
|
174
|
-
:
|
|
176
|
+
: cartItem.formattedFinalPriceWithQuantity}
|
|
175
177
|
</div>
|
|
176
178
|
</div>
|
|
177
179
|
</div>
|
|
@@ -5,7 +5,7 @@ import _sortBy from "lodash/sortBy";
|
|
|
5
5
|
import InputWithButton from "../input-with-button";
|
|
6
6
|
import NotificationBox from "../notification-box";
|
|
7
7
|
import CheckoutViewModel, { CheckoutStep } from "../../model";
|
|
8
|
-
import {
|
|
8
|
+
import { formatCurrency, useTranslation } from "../../../../utils";
|
|
9
9
|
import { CartItem } from "./cart-item";
|
|
10
10
|
import { FormItem } from "../form-item";
|
|
11
11
|
import { FormItemType } from "../form-item/model";
|
|
@@ -95,9 +95,13 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
|
|
|
95
95
|
<div className={styles.Left}>{t("checkout-page:summary")}</div>
|
|
96
96
|
<div className={styles.Price}>
|
|
97
97
|
<span className={styles.PriceText}>
|
|
98
|
-
{`${
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
{`${formatCurrency(
|
|
99
|
+
vm.finalPrice || 0,
|
|
100
|
+
checkout.currencyCode,
|
|
101
|
+
checkout.currencySymbol
|
|
102
|
+
)} (${checkout.items.length} ${t(
|
|
103
|
+
"checkout-page:cartItemProduct"
|
|
104
|
+
)})`}
|
|
101
105
|
</span>
|
|
102
106
|
<span className={arrowDownClasses}>
|
|
103
107
|
<SVGArrowDown />
|
|
@@ -132,7 +136,7 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
|
|
|
132
136
|
)}
|
|
133
137
|
<InfoRow
|
|
134
138
|
label={t("checkout-page:subtotal")}
|
|
135
|
-
value={
|
|
139
|
+
value={checkout.formattedTotalPrice}
|
|
136
140
|
tooltipText={t("checkout-page:subtotalTooltip")}
|
|
137
141
|
/>
|
|
138
142
|
{!!checkout.shippingLines?.length && (
|
|
@@ -140,10 +144,7 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
|
|
|
140
144
|
label={t("checkout-page:cartShippingTitle")}
|
|
141
145
|
value={
|
|
142
146
|
checkout.shippingTotal
|
|
143
|
-
?
|
|
144
|
-
checkout.shippingTotal,
|
|
145
|
-
checkout.currencyCode
|
|
146
|
-
)
|
|
147
|
+
? checkout.formattedShippingTotal
|
|
147
148
|
: t("checkout-page:free")
|
|
148
149
|
}
|
|
149
150
|
/>
|
|
@@ -151,15 +152,16 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
|
|
|
151
152
|
{!!checkout.totalTax && !!vm.customizationProps?.showTax && (
|
|
152
153
|
<InfoRow
|
|
153
154
|
label={t("checkout-page:cartTaxTitle")}
|
|
154
|
-
value={
|
|
155
|
+
value={checkout.formattedTotalTax}
|
|
155
156
|
/>
|
|
156
157
|
)}
|
|
157
158
|
{!!vm.installmentExtraPrice && (
|
|
158
159
|
<InfoRow
|
|
159
160
|
label={t("checkout-page:cartInterest")}
|
|
160
|
-
value={
|
|
161
|
+
value={formatCurrency(
|
|
161
162
|
vm.installmentExtraPrice,
|
|
162
|
-
checkout.currencyCode
|
|
163
|
+
checkout.currencyCode,
|
|
164
|
+
checkout.currencySymbol
|
|
163
165
|
)}
|
|
164
166
|
/>
|
|
165
167
|
)}
|
|
@@ -193,7 +195,11 @@ export const CartSummary: React.FC<Props> = observer(({ vm, allowExpand }) => {
|
|
|
193
195
|
<div className={styles.Title}>{t("checkout-page:total")}</div>
|
|
194
196
|
</div>
|
|
195
197
|
<div className={styles.TotalPrice}>
|
|
196
|
-
{
|
|
198
|
+
{formatCurrency(
|
|
199
|
+
vm.finalPrice || 0,
|
|
200
|
+
checkout.currencyCode,
|
|
201
|
+
checkout.currencySymbol
|
|
202
|
+
)}
|
|
197
203
|
</div>
|
|
198
204
|
</div>
|
|
199
205
|
|
|
@@ -273,7 +279,11 @@ const Adjustments: React.FC<CommonProps> = observer(({ vm }) => {
|
|
|
273
279
|
<div className={styles.Value}>
|
|
274
280
|
<span>{adjustment.type === "DECREMENT" ? "- " : ""}</span>{" "}
|
|
275
281
|
<span>
|
|
276
|
-
{
|
|
282
|
+
{formatCurrency(
|
|
283
|
+
adjustment.amount,
|
|
284
|
+
vm.checkout.currencyCode,
|
|
285
|
+
vm.checkout.currencySymbol
|
|
286
|
+
)}
|
|
277
287
|
</span>
|
|
278
288
|
</div>
|
|
279
289
|
</div>
|
|
@@ -304,7 +314,11 @@ const CalculatedAdditionalPrices: React.FC<CommonProps> = observer(({ vm }) => {
|
|
|
304
314
|
<div className={styles.Value}>
|
|
305
315
|
<span>{adjustment.type === "DECREMENT" ? "- " : ""}</span>{" "}
|
|
306
316
|
<span>
|
|
307
|
-
{
|
|
317
|
+
{formatCurrency(
|
|
318
|
+
adjustment.amount,
|
|
319
|
+
vm.checkout!.currencyCode,
|
|
320
|
+
vm.checkout!.currencySymbol
|
|
321
|
+
)}
|
|
308
322
|
</span>
|
|
309
323
|
</div>
|
|
310
324
|
</div>
|
|
@@ -318,7 +332,13 @@ const CalculatedAdditionalPrices: React.FC<CommonProps> = observer(({ vm }) => {
|
|
|
318
332
|
</div>
|
|
319
333
|
</div>
|
|
320
334
|
<div className={styles.Value}>
|
|
321
|
-
<span>
|
|
335
|
+
<span>
|
|
336
|
+
{formatCurrency(
|
|
337
|
+
gpl.price,
|
|
338
|
+
vm.checkout.currencyCode,
|
|
339
|
+
vm.checkout!.currencySymbol
|
|
340
|
+
)}
|
|
341
|
+
</span>
|
|
322
342
|
</div>
|
|
323
343
|
</div>
|
|
324
344
|
))}
|
|
@@ -410,7 +430,11 @@ const Coupon: React.FC<CouponProps> = observer(
|
|
|
410
430
|
<div className={styles.Value}>
|
|
411
431
|
<span>{adjustment?.type === "DECREMENT" ? "- " : ""}</span>{" "}
|
|
412
432
|
<span>
|
|
413
|
-
{
|
|
433
|
+
{formatCurrency(
|
|
434
|
+
adjustment?.amount || 0,
|
|
435
|
+
vm.checkout.currencyCode,
|
|
436
|
+
vm.checkout.currencySymbol
|
|
437
|
+
)}
|
|
414
438
|
</span>
|
|
415
439
|
</div>
|
|
416
440
|
)}
|
|
@@ -7,6 +7,7 @@ import styles from "./style.module.scss";
|
|
|
7
7
|
|
|
8
8
|
import { useTranslation } from "../../../../utils";
|
|
9
9
|
import ReactTooltip from "react-tooltip";
|
|
10
|
+
import { PhoneNumberInput } from "../phone-number-input";
|
|
10
11
|
|
|
11
12
|
export const FormItem: React.FC<Props> = observer((props) => {
|
|
12
13
|
const { t } = useTranslation();
|
|
@@ -108,17 +109,14 @@ export const FormItem: React.FC<Props> = observer((props) => {
|
|
|
108
109
|
/>
|
|
109
110
|
)}
|
|
110
111
|
{vm.type === FormItemType.TEL && (
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
// international={true}
|
|
120
|
-
// addInternationalOption={false}
|
|
121
|
-
// />
|
|
112
|
+
<PhoneNumberInput
|
|
113
|
+
key={props.currentCountryCode || "1"}
|
|
114
|
+
disabled={vm.disabled}
|
|
115
|
+
defaultCountry={props.currentCountryCode}
|
|
116
|
+
placeholder={t("checkout-page:enterPhoneNumber")}
|
|
117
|
+
value={vm.value ? vm.value : ""}
|
|
118
|
+
onChange={vm.onPhoneChange}
|
|
119
|
+
/>
|
|
122
120
|
)}
|
|
123
121
|
{vm.type === FormItemType.TEXT_AREA && <TextArea vm={vm} />}
|
|
124
122
|
{vm.type === FormItemType.SELECT && (
|
|
@@ -8,7 +8,7 @@ import SVGCross from "../svg/cross";
|
|
|
8
8
|
import styles from "./style.module.scss";
|
|
9
9
|
import { useTranslation } from "../../../../utils/i18n";
|
|
10
10
|
import { IkasProductVariant } from "../../../../models";
|
|
11
|
-
import {
|
|
11
|
+
import { formatCurrency } from "../../../../utils/currency";
|
|
12
12
|
|
|
13
13
|
type Props = {
|
|
14
14
|
vm: CheckoutViewModel;
|
|
@@ -95,12 +95,13 @@ const OfferProduct: React.FC<Props> = ({ vm, campaignOffer }) => {
|
|
|
95
95
|
<span className={styles.Discount}>
|
|
96
96
|
{selectedVariant.price.formattedFinalPrice}
|
|
97
97
|
</span>{" "}
|
|
98
|
-
{
|
|
98
|
+
{formatCurrency(
|
|
99
99
|
selectedVariant.price.finalPrice -
|
|
100
100
|
(selectedVariant.price.finalPrice *
|
|
101
101
|
(campaignOffer.offer.discountAmount || 100)) /
|
|
102
102
|
100,
|
|
103
|
-
vm.checkout!.currencyCode
|
|
103
|
+
vm.checkout!.currencyCode,
|
|
104
|
+
vm.checkout!.currencySymbol
|
|
104
105
|
)}
|
|
105
106
|
</div>
|
|
106
107
|
<div className={styles.Actions}>
|
|
@@ -1,18 +1,50 @@
|
|
|
1
|
+
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
1
2
|
import { CountryCode, getCountries as categories } from "libphonenumber-js";
|
|
2
3
|
import compareStrings from "./compare-strings";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type CountryType = {
|
|
5
|
+
export type CountryType = {
|
|
7
6
|
value: CountryCode;
|
|
8
7
|
label: string | undefined;
|
|
9
8
|
};
|
|
10
9
|
|
|
11
|
-
const
|
|
10
|
+
const getUrl = () => {
|
|
11
|
+
const languages = [
|
|
12
|
+
"de",
|
|
13
|
+
"el",
|
|
14
|
+
"en",
|
|
15
|
+
"es",
|
|
16
|
+
"fi",
|
|
17
|
+
"fr",
|
|
18
|
+
"it",
|
|
19
|
+
"nb",
|
|
20
|
+
"pl",
|
|
21
|
+
"pt-BR",
|
|
22
|
+
"pt",
|
|
23
|
+
"ru",
|
|
24
|
+
"sv",
|
|
25
|
+
"tr",
|
|
26
|
+
"ua",
|
|
27
|
+
"vi",
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
let locale = IkasStorefrontConfig.getCurrentLocale();
|
|
31
|
+
|
|
32
|
+
if (!languages.some((language) => language === locale)) {
|
|
33
|
+
locale = "en";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return `https://cdn.myikas.com/sf/static/locale/country/${locale}.json`;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const getCountries = async (): Promise<CountryType[]> => {
|
|
40
|
+
const url = getUrl();
|
|
41
|
+
const response = await fetch(url);
|
|
42
|
+
const lang = await response.json();
|
|
43
|
+
|
|
12
44
|
return categories()
|
|
13
45
|
.map((country) => ({
|
|
14
46
|
value: country,
|
|
15
|
-
label:
|
|
47
|
+
label: lang[country],
|
|
16
48
|
}))
|
|
17
49
|
.sort((a, b) => compareStrings(a.label, b.label));
|
|
18
50
|
};
|
|
@@ -6,8 +6,7 @@ import parsePhoneNumber, {
|
|
|
6
6
|
getCountryCallingCode,
|
|
7
7
|
parseIncompletePhoneNumber,
|
|
8
8
|
} from "libphonenumber-js";
|
|
9
|
-
|
|
10
|
-
import getCountries from "./get-countries";
|
|
9
|
+
import getCountries, { CountryType } from "./get-countries";
|
|
11
10
|
|
|
12
11
|
import styles from "./style.module.scss";
|
|
13
12
|
|
|
@@ -19,17 +18,20 @@ type Props = {
|
|
|
19
18
|
onChange: (value: string) => void;
|
|
20
19
|
};
|
|
21
20
|
|
|
22
|
-
const
|
|
21
|
+
const DEFAULT_COUNTRY = "TR";
|
|
23
22
|
|
|
24
23
|
export const PhoneNumberInput: React.FC<Props> = observer(
|
|
25
24
|
({ defaultCountry, disabled = false, placeholder, value, onChange }) => {
|
|
25
|
+
const [countries, setCountries] = React.useState<CountryType[]>([]);
|
|
26
26
|
const [activeCountry, setActiveCountry] = React.useState(
|
|
27
|
-
defaultCountry as CountryCode
|
|
27
|
+
(defaultCountry as CountryCode) || DEFAULT_COUNTRY
|
|
28
28
|
);
|
|
29
29
|
const [formatedValue, setFormatedValue] = React.useState("");
|
|
30
30
|
|
|
31
31
|
React.useEffect(() => {
|
|
32
|
-
|
|
32
|
+
fetchCountries();
|
|
33
|
+
|
|
34
|
+
let countryCode = activeCountry;
|
|
33
35
|
|
|
34
36
|
if (value) {
|
|
35
37
|
const parsedPhoneNumber = parsePhoneNumber(value);
|
|
@@ -46,6 +48,11 @@ export const PhoneNumberInput: React.FC<Props> = observer(
|
|
|
46
48
|
setActiveCountry(countryCode);
|
|
47
49
|
}, []);
|
|
48
50
|
|
|
51
|
+
const fetchCountries = async () => {
|
|
52
|
+
const categories = await getCountries();
|
|
53
|
+
setCountries(categories);
|
|
54
|
+
};
|
|
55
|
+
|
|
49
56
|
const onValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
50
57
|
const phoneNumber = formatPhoneNumber(event.target.value);
|
|
51
58
|
setFormatedValue(phoneNumber);
|
|
@@ -76,9 +83,7 @@ export const PhoneNumberInput: React.FC<Props> = observer(
|
|
|
76
83
|
};
|
|
77
84
|
|
|
78
85
|
const getImageSrc = () => {
|
|
79
|
-
return `https://cdn.myikas.com/sf/assets/flags/3x2/${
|
|
80
|
-
activeCountry || "TR"
|
|
81
|
-
}.svg`;
|
|
86
|
+
return `https://cdn.myikas.com/sf/assets/flags/3x2/${activeCountry}.svg`;
|
|
82
87
|
};
|
|
83
88
|
|
|
84
89
|
return (
|
|
@@ -88,14 +93,14 @@ export const PhoneNumberInput: React.FC<Props> = observer(
|
|
|
88
93
|
<div className={styles.Flag}>
|
|
89
94
|
<img
|
|
90
95
|
className={styles.FlagImage}
|
|
91
|
-
alt={activeCountry
|
|
96
|
+
alt={activeCountry}
|
|
92
97
|
src={getImageSrc()}
|
|
93
98
|
></img>
|
|
94
99
|
<div className={styles.Arrow}></div>
|
|
95
100
|
</div>
|
|
96
101
|
<select
|
|
97
102
|
className={styles.Select}
|
|
98
|
-
value={activeCountry
|
|
103
|
+
value={activeCountry}
|
|
99
104
|
onChange={onCountryChange}
|
|
100
105
|
disabled={disabled}
|
|
101
106
|
>
|
|
@@ -7,7 +7,7 @@ import ReactTooltip from "react-tooltip";
|
|
|
7
7
|
import CheckoutViewModel, { CheckoutStep } from "./model";
|
|
8
8
|
import { IkasCheckoutSettings } from "../../models/data/checkout-settings";
|
|
9
9
|
import { IkasCheckout } from "../../models/data/checkout";
|
|
10
|
-
import {
|
|
10
|
+
import { formatCurrency, useTranslation } from "../../utils";
|
|
11
11
|
|
|
12
12
|
import CheckoutStepInfo from "./steps/step-info";
|
|
13
13
|
import { CheckoutStepShipping } from "./steps/step-shipping";
|
|
@@ -443,9 +443,10 @@ const StepSummaryShipping: React.FC<CommonProps> = observer(({ vm }) => {
|
|
|
443
443
|
{" / " +
|
|
444
444
|
(vm.checkout.shippingLines[0].price === 0
|
|
445
445
|
? t("checkout-page:free")
|
|
446
|
-
:
|
|
446
|
+
: formatCurrency(
|
|
447
447
|
vm.checkout.shippingLines[0].price,
|
|
448
|
-
vm.checkout!.currencyCode
|
|
448
|
+
vm.checkout!.currencyCode,
|
|
449
|
+
vm.checkout.currencySymbol
|
|
449
450
|
))}
|
|
450
451
|
</span>
|
|
451
452
|
</React.Fragment>
|
|
@@ -53,10 +53,6 @@ import {
|
|
|
53
53
|
RetrieveInstallmentInfoQueryParams,
|
|
54
54
|
SaveCartInput,
|
|
55
55
|
} from "@ikas/storefront-api";
|
|
56
|
-
import { OrderAddressCountryInputData } from "@ikas/storefront-api/build/__api/models/OrderAddressCountryInput";
|
|
57
|
-
import { OrderAddressCityInputData } from "@ikas/storefront-api/build/__api/models/OrderAddressCityInput";
|
|
58
|
-
import { OrderAddressStateInputData } from "@ikas/storefront-api/build/__api/models/OrderAddressStateInput";
|
|
59
|
-
import { OrderAddressDistrictInputData } from "@ikas/storefront-api/build/__api/models/OrderAddressDistrictInput";
|
|
60
56
|
|
|
61
57
|
const NUMBER_ONLY_REGEX = /^\d+$/;
|
|
62
58
|
const MAX_CARD_NUMBER_LENGTH = 16;
|
|
@@ -444,7 +440,10 @@ export default class CheckoutViewModel {
|
|
|
444
440
|
input = await this.inStockDeliveryInputData(input);
|
|
445
441
|
}
|
|
446
442
|
|
|
447
|
-
if (
|
|
443
|
+
if (
|
|
444
|
+
this.step === CheckoutStep.INFO ||
|
|
445
|
+
this.step === CheckoutStep.SHIPPING
|
|
446
|
+
) {
|
|
448
447
|
input.billingAddress = null;
|
|
449
448
|
}
|
|
450
449
|
|
|
@@ -480,13 +479,11 @@ export default class CheckoutViewModel {
|
|
|
480
479
|
inStoreLocation.address
|
|
481
480
|
) {
|
|
482
481
|
inputData.shippingAddress.country = inStoreLocation.address
|
|
483
|
-
.country as
|
|
484
|
-
inputData.shippingAddress.city = inStoreLocation.address
|
|
485
|
-
|
|
486
|
-
inputData.shippingAddress.state = inStoreLocation.address
|
|
487
|
-
.state as OrderAddressStateInputData;
|
|
482
|
+
.country as any;
|
|
483
|
+
inputData.shippingAddress.city = inStoreLocation.address.city as any;
|
|
484
|
+
inputData.shippingAddress.state = inStoreLocation.address.state as any;
|
|
488
485
|
inputData.shippingAddress.district = inStoreLocation.address
|
|
489
|
-
.district as
|
|
486
|
+
.district as any;
|
|
490
487
|
inputData.shippingAddress.postalCode = inStoreLocation.address.postalCode;
|
|
491
488
|
inputData.shippingAddress.addressLine1 =
|
|
492
489
|
inStoreLocation.address.address || "";
|
|
@@ -6,7 +6,7 @@ import { useTranslation } from "../../utils/i18n";
|
|
|
6
6
|
import { IkasBaseStore } from "../../store";
|
|
7
7
|
import { IkasCheckout, IkasPaymentGateway } from "../../models";
|
|
8
8
|
import { MasterPassOperationTypeEnum } from "@ikas/storefront-api";
|
|
9
|
-
import {
|
|
9
|
+
import { getMasterPassRequestToken } from "@ikas/storefront-api";
|
|
10
10
|
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
11
11
|
|
|
12
12
|
const isServer = typeof localStorage === "undefined";
|
|
@@ -437,7 +437,7 @@ export default class MasterPassModel {
|
|
|
437
437
|
operationType: MasterPassOperationTypeEnum;
|
|
438
438
|
phoneNumber: string;
|
|
439
439
|
}) => {
|
|
440
|
-
const response = await
|
|
440
|
+
const response = await getMasterPassRequestToken({
|
|
441
441
|
cartId,
|
|
442
442
|
paymentGatewayId,
|
|
443
443
|
operationType,
|
|
@@ -12,7 +12,7 @@ import { CreditCardForm } from "../../../components/credit-card-form";
|
|
|
12
12
|
import { Installments } from "./installments";
|
|
13
13
|
import SelectBox from "../../../components/select-box";
|
|
14
14
|
import styles from "./style.module.scss";
|
|
15
|
-
import {
|
|
15
|
+
import { formatCurrency, useTranslation } from "../../../../../utils";
|
|
16
16
|
import SVGExternal from "../../../components/svg/external";
|
|
17
17
|
import SVGMasterCard from "../../../components/master-pass/payment-gateway/svg/master-card";
|
|
18
18
|
import { IkasPaymentGatewayAdditionalPrice } from "../../../../../models/data/payment-gateway/additional-price";
|
|
@@ -50,7 +50,11 @@ export const PaymentGateways: React.FC<Props> = observer(({ vm }) => {
|
|
|
50
50
|
|
|
51
51
|
return `${
|
|
52
52
|
ap.amountType === IkasPaymentGatewayTransactionFeeType.AMOUNT
|
|
53
|
-
?
|
|
53
|
+
? formatCurrency(
|
|
54
|
+
ap.amount,
|
|
55
|
+
vm.checkout.currencyCode,
|
|
56
|
+
vm.checkout.currencySymbol
|
|
57
|
+
)
|
|
54
58
|
: " %" + ap.amount
|
|
55
59
|
}${
|
|
56
60
|
ap.type === IkasPaymentGatewayAdditionalPriceType.DECREMENT
|
|
@@ -2,7 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
3
|
import CheckoutViewModel from "../../../../model";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { formatCurrency, useTranslation } from "../../../../../../utils";
|
|
6
6
|
import styles from "./style.module.scss";
|
|
7
7
|
import { Toggle } from "../../../../../../components/checkout/components/toggle";
|
|
8
8
|
|
|
@@ -33,17 +33,19 @@ export const Installments: React.FC<Props> = observer(({ vm }) => {
|
|
|
33
33
|
</div>
|
|
34
34
|
{ip.installmentCount !== 1 && (
|
|
35
35
|
<div className={styles.InstallmentPrice}>
|
|
36
|
-
{
|
|
36
|
+
{formatCurrency(
|
|
37
37
|
ip.installmentPrice!,
|
|
38
38
|
vm.checkout!.currencyCode,
|
|
39
|
+
vm.checkout!.currencySymbol
|
|
39
40
|
)}
|
|
40
41
|
</div>
|
|
41
42
|
)}
|
|
42
43
|
</div>
|
|
43
44
|
<div className={styles.Price}>
|
|
44
|
-
{
|
|
45
|
+
{formatCurrency(
|
|
45
46
|
ip.totalPrice!,
|
|
46
47
|
vm.checkout!.currencyCode,
|
|
48
|
+
vm.checkout!.currencySymbol
|
|
47
49
|
)}
|
|
48
50
|
</div>
|
|
49
51
|
</div>
|