@ikas/storefront 4.0.0-alpha.18 → 4.0.0-alpha.2
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 +14 -15
- 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 +0 -8
- package/src/components/checkout/components/address-form/index.tsx +1 -1
- package/src/components/checkout/components/form-item/index.tsx +11 -9
- package/src/components/checkout/model.ts +14 -9
- package/src/components/checkout/modelMasterPass.ts +3 -3
- package/src/components/page/head.tsx +0 -12
- package/src/models/data/merchant-settings/index.ts +0 -6
- package/src/models/data/product/variant-type/index.ts +0 -2
- package/src/models/data/storefront/index.ts +0 -2
- package/src/models/ui/product-list/index.ts +7 -1
- package/src/models/ui/validator/form/raffle-form.ts +3 -16
- package/src/models/ui/validator/rules/index.ts +13 -14
- package/src/store/cart/index.ts +3 -3
- package/src/components/checkout/components/phone-number-input/compare-strings.ts +0 -5
- package/src/components/checkout/components/phone-number-input/get-countries.ts +0 -52
- package/src/components/checkout/components/phone-number-input/index.tsx +0 -125
- package/src/components/checkout/components/phone-number-input/style.module.scss +0 -83
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.2",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "Umut Ozan Yıldırım",
|
|
6
6
|
"license": "ISC",
|
|
@@ -20,22 +20,21 @@
|
|
|
20
20
|
"@stripe/react-stripe-js": "^1.7.2",
|
|
21
21
|
"@stripe/stripe-js": "^1.29.0",
|
|
22
22
|
"query-string": "^6.13.8",
|
|
23
|
-
"react-tooltip": "^4.2.21"
|
|
24
|
-
"libphonenumber-js": "^1.10.6"
|
|
23
|
+
"react-tooltip": "^4.2.21"
|
|
25
24
|
},
|
|
26
25
|
"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.
|
|
26
|
+
"@ikas/storefront-api": "^4.0.0-alpha.2",
|
|
27
|
+
"@ikas/storefront-config": "^4.0.0-alpha.2",
|
|
28
|
+
"@ikas/storefront-model-functions": "^4.0.0-alpha.2",
|
|
29
|
+
"@ikas/storefront-models": "^4.0.0-alpha.2",
|
|
30
|
+
"@ikas/storefront-providers": "^4.0.0-alpha.2",
|
|
32
31
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
33
32
|
"@rollup/plugin-json": "^4.1.0",
|
|
34
33
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
35
34
|
"@types/react-phone-number-input": "^3.0.10",
|
|
36
35
|
"mobx": "^6.1.3",
|
|
37
36
|
"mobx-react-lite": "^3.1.5",
|
|
38
|
-
"next": "
|
|
37
|
+
"next": "canary",
|
|
39
38
|
"prettier": "^2.2.1",
|
|
40
39
|
"react": "17.0.2",
|
|
41
40
|
"react-dom": "17.0.2",
|
|
@@ -52,14 +51,14 @@
|
|
|
52
51
|
"html-react-parser": "^1.4.0"
|
|
53
52
|
},
|
|
54
53
|
"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.
|
|
54
|
+
"@ikas/storefront-api": "^4.0.0-alpha.2",
|
|
55
|
+
"@ikas/storefront-config": "^4.0.0-alpha.2",
|
|
56
|
+
"@ikas/storefront-model-functions": "^4.0.0-alpha.2",
|
|
57
|
+
"@ikas/storefront-models": "^4.0.0-alpha.2",
|
|
58
|
+
"@ikas/storefront-providers": "^4.0.0-alpha.2",
|
|
60
59
|
"mobx": "^6.1.3",
|
|
61
60
|
"mobx-react-lite": "^3.1.5",
|
|
62
|
-
"next": "
|
|
61
|
+
"next": "canary",
|
|
63
62
|
"react": "17.0.2",
|
|
64
63
|
"react-dom": "17.0.2",
|
|
65
64
|
"lodash": "^4.17.20",
|
|
@@ -54,7 +54,6 @@ export class Analytics {
|
|
|
54
54
|
const customerInfo = await Analytics.getCustomerInfo();
|
|
55
55
|
|
|
56
56
|
GoogleTagManager.pageView(url);
|
|
57
|
-
GoogleUniversal.pageView(window.location.pathname);
|
|
58
57
|
IkasAnalytics.pageView(pageType);
|
|
59
58
|
|
|
60
59
|
tryForEach(Analytics.subscribers, (s) => {
|
|
@@ -195,7 +194,7 @@ export class Analytics {
|
|
|
195
194
|
try {
|
|
196
195
|
localStorage.removeItem(LS_BEGIN_CHECKOUT_KEY);
|
|
197
196
|
|
|
198
|
-
FacebookPixel.purchase(checkout,
|
|
197
|
+
FacebookPixel.purchase(checkout, checkout.orderNumber || "");
|
|
199
198
|
GoogleTagManager.purchase(checkout, checkout.orderNumber || "");
|
|
200
199
|
IkasAnalytics.orderSuccess(checkout);
|
|
201
200
|
GoogleAnalytics.purchase(checkout, checkout.orderNumber || "");
|
|
@@ -8,23 +8,12 @@ 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
|
-
|
|
23
11
|
static productView(productDetail: IkasProduct) {
|
|
24
12
|
try {
|
|
25
13
|
if (!isServer && (window as any).ga) {
|
|
26
14
|
(window as any).ga("ec:addProduct", productToGUItem(productDetail));
|
|
27
15
|
(window as any).ga("ec:setAction", "detail");
|
|
16
|
+
(window as any).ga("send", "pageview");
|
|
28
17
|
}
|
|
29
18
|
return;
|
|
30
19
|
} catch (err) {
|
|
@@ -90,6 +79,7 @@ export class GoogleUniversal {
|
|
|
90
79
|
shipping: "" + checkout.shippingTotal,
|
|
91
80
|
coupon: checkout.couponCode,
|
|
92
81
|
});
|
|
82
|
+
(window as any).ga("send", "pageview");
|
|
93
83
|
}
|
|
94
84
|
return;
|
|
95
85
|
} catch (err) {
|
|
@@ -79,7 +79,8 @@ 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')
|
|
82
|
+
ga('require', 'ec');
|
|
83
|
+
ga('send', 'pageview');`,
|
|
83
84
|
}}
|
|
84
85
|
/>
|
|
85
86
|
<script
|
package/src/analytics/ikas.ts
CHANGED
|
@@ -181,10 +181,6 @@ export default class IkasAnalytics {
|
|
|
181
181
|
} else {
|
|
182
182
|
await this.createSessionId();
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
IkasStorefrontConfig.init({
|
|
186
|
-
sessionId: this.sessionId || "",
|
|
187
|
-
});
|
|
188
184
|
} catch (err) {
|
|
189
185
|
console.error(err);
|
|
190
186
|
}
|
|
@@ -200,10 +196,6 @@ export default class IkasAnalytics {
|
|
|
200
196
|
this.visitorId = Date.now() + "";
|
|
201
197
|
localStorage.setItem(this.VISITOR_ID_KEY, this.visitorId);
|
|
202
198
|
}
|
|
203
|
-
|
|
204
|
-
IkasStorefrontConfig.init({
|
|
205
|
-
visitorId: this.visitorId,
|
|
206
|
-
});
|
|
207
199
|
} catch (err) {
|
|
208
200
|
console.error(err);
|
|
209
201
|
}
|
|
@@ -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-level3"
|
|
319
319
|
label={t("checkout-page:city")}
|
|
320
320
|
value={vm.city?.name || ""}
|
|
321
321
|
onChange={vm.onCityInputChange}
|
|
@@ -7,7 +7,6 @@ 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";
|
|
11
10
|
|
|
12
11
|
export const FormItem: React.FC<Props> = observer((props) => {
|
|
13
12
|
const { t } = useTranslation();
|
|
@@ -109,14 +108,17 @@ export const FormItem: React.FC<Props> = observer((props) => {
|
|
|
109
108
|
/>
|
|
110
109
|
)}
|
|
111
110
|
{vm.type === FormItemType.TEL && (
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
<div></div>
|
|
112
|
+
// <PhoneInput
|
|
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
|
+
// international={true}
|
|
120
|
+
// addInternationalOption={false}
|
|
121
|
+
// />
|
|
120
122
|
)}
|
|
121
123
|
{vm.type === FormItemType.TEXT_AREA && <TextArea vm={vm} />}
|
|
122
124
|
{vm.type === FormItemType.SELECT && (
|
|
@@ -32,6 +32,7 @@ import CreditCardData from "./components/credit-card-form/model";
|
|
|
32
32
|
import { IkasCheckoutSettings } from "../../models/data/checkout-settings";
|
|
33
33
|
import { TFunction } from "../../utils/i18n";
|
|
34
34
|
import CustomerStoreAPI from "../../store/customer/api";
|
|
35
|
+
import MerchantStore from "../../store/merchant";
|
|
35
36
|
import CheckoutStore from "../../store/checkout";
|
|
36
37
|
import CartStoreAPI from "../../store/cart/api";
|
|
37
38
|
import { IkasCheckoutCustomizationProps } from ".";
|
|
@@ -44,7 +45,7 @@ import {
|
|
|
44
45
|
RetrieveInstallmentInfoResponse,
|
|
45
46
|
TransactionResponse,
|
|
46
47
|
UpdateCartCampaignOfferInput,
|
|
47
|
-
} from "@ikas/storefront-api";
|
|
48
|
+
} from "@ikas/storefront-api/build/__api/types";
|
|
48
49
|
import { IkasBaseStore } from "../../store";
|
|
49
50
|
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
50
51
|
import { Analytics } from "../../analytics";
|
|
@@ -53,6 +54,11 @@ import {
|
|
|
53
54
|
RetrieveInstallmentInfoQueryParams,
|
|
54
55
|
SaveCartInput,
|
|
55
56
|
} from "@ikas/storefront-api";
|
|
57
|
+
import { OrderAddressCountryInputData } from "@ikas/storefront-api/build/__api/models/OrderAddressCountryInput";
|
|
58
|
+
import { OrderAddressCityInputData } from "@ikas/storefront-api/build/__api/models/OrderAddressCityInput";
|
|
59
|
+
import { OrderAddressStateInputData } from "@ikas/storefront-api/build/__api/models/OrderAddressStateInput";
|
|
60
|
+
import { OrderAddressDistrictInputData } from "@ikas/storefront-api/build/__api/models/OrderAddressDistrictInput";
|
|
61
|
+
import { CampaignOfferTargetPageTypeEnum } from "@ikas/storefront-api/build/__api/types";
|
|
56
62
|
|
|
57
63
|
const NUMBER_ONLY_REGEX = /^\d+$/;
|
|
58
64
|
const MAX_CARD_NUMBER_LENGTH = 16;
|
|
@@ -440,10 +446,7 @@ export default class CheckoutViewModel {
|
|
|
440
446
|
input = await this.inStockDeliveryInputData(input);
|
|
441
447
|
}
|
|
442
448
|
|
|
443
|
-
if (
|
|
444
|
-
this.step === CheckoutStep.INFO ||
|
|
445
|
-
this.step === CheckoutStep.SHIPPING
|
|
446
|
-
) {
|
|
449
|
+
if (this.step === CheckoutStep.INFO) {
|
|
447
450
|
input.billingAddress = null;
|
|
448
451
|
}
|
|
449
452
|
|
|
@@ -479,11 +482,13 @@ export default class CheckoutViewModel {
|
|
|
479
482
|
inStoreLocation.address
|
|
480
483
|
) {
|
|
481
484
|
inputData.shippingAddress.country = inStoreLocation.address
|
|
482
|
-
.country as
|
|
483
|
-
inputData.shippingAddress.city = inStoreLocation.address
|
|
484
|
-
|
|
485
|
+
.country as OrderAddressCountryInputData;
|
|
486
|
+
inputData.shippingAddress.city = inStoreLocation.address
|
|
487
|
+
.city as OrderAddressCityInputData;
|
|
488
|
+
inputData.shippingAddress.state = inStoreLocation.address
|
|
489
|
+
.state as OrderAddressStateInputData;
|
|
485
490
|
inputData.shippingAddress.district = inStoreLocation.address
|
|
486
|
-
.district as
|
|
491
|
+
.district as OrderAddressDistrictInputData;
|
|
487
492
|
inputData.shippingAddress.postalCode = inStoreLocation.address.postalCode;
|
|
488
493
|
inputData.shippingAddress.addressLine1 =
|
|
489
494
|
inStoreLocation.address.address || "";
|
|
@@ -5,8 +5,8 @@ import { SuccessModalType } from "./components/master-pass/modal-success";
|
|
|
5
5
|
import { useTranslation } from "../../utils/i18n";
|
|
6
6
|
import { IkasBaseStore } from "../../store";
|
|
7
7
|
import { IkasCheckout, IkasPaymentGateway } from "../../models";
|
|
8
|
-
import { MasterPassOperationTypeEnum } from "@ikas/storefront-api";
|
|
9
|
-
import {
|
|
8
|
+
import { MasterPassOperationTypeEnum } from "@ikas/storefront-api/build/__api/types";
|
|
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,
|
|
@@ -251,18 +251,6 @@ 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
|
-
},
|
|
266
254
|
};
|
|
267
255
|
}
|
|
268
256
|
|
|
@@ -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,9 +19,6 @@ 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
23
|
|
|
30
24
|
makeAutoObservable(this);
|
|
@@ -3,12 +3,10 @@ import { IkasProductVariantType as IProductVariantType } from "@ikas/storefront-
|
|
|
3
3
|
import { makeAutoObservable } from "mobx";
|
|
4
4
|
|
|
5
5
|
export class IkasProductVariantType implements IProductVariantType {
|
|
6
|
-
order: number;
|
|
7
6
|
variantType: IkasVariantType;
|
|
8
7
|
variantValueIds: string[];
|
|
9
8
|
|
|
10
9
|
constructor(data: Partial<IkasProductVariantType>) {
|
|
11
|
-
this.order = data.order || 0;
|
|
12
10
|
this.variantType = data.variantType
|
|
13
11
|
? new IkasVariantType(data.variantType)
|
|
14
12
|
: new IkasVariantType();
|
|
@@ -20,7 +20,6 @@ export class IkasStorefront implements IStorefront {
|
|
|
20
20
|
analytics4Id: string | null;
|
|
21
21
|
universalAnalyticsId: string | null;
|
|
22
22
|
tiktokPixelId: string | null;
|
|
23
|
-
token: string | null;
|
|
24
23
|
|
|
25
24
|
localizations: IkasStorefrontLocalization[];
|
|
26
25
|
routings: IkasStorefrontRouting[];
|
|
@@ -41,7 +40,6 @@ export class IkasStorefront implements IStorefront {
|
|
|
41
40
|
this.analytics4Id = data.analytics4Id || null;
|
|
42
41
|
this.universalAnalyticsId = data.universalAnalyticsId || null;
|
|
43
42
|
this.tiktokPixelId = data.tiktokPixelId || null;
|
|
44
|
-
this.token = data.token || null;
|
|
45
43
|
|
|
46
44
|
// Sub Models
|
|
47
45
|
this.localizations = data.localizations
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
SearchInputOrderByInput,
|
|
26
26
|
SortByDirectionEnum,
|
|
27
27
|
SortByTypeEnum,
|
|
28
|
-
} from "@ikas/storefront-api";
|
|
28
|
+
} from "@ikas/storefront-api/build/__api/types";
|
|
29
29
|
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
30
30
|
import { IkasBaseStore } from "../../..";
|
|
31
31
|
import { Analytics } from "../../../analytics";
|
|
@@ -221,6 +221,12 @@ 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
|
+
}
|
|
224
230
|
|
|
225
231
|
this.filters?.forEach((f) => {
|
|
226
232
|
if (f.keyList.length) queryParams[f.key] = f.keyList;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { saveRaffleParticipant } from "@ikas/storefront-api";
|
|
2
2
|
import { action, computed, makeObservable, observable } from "mobx";
|
|
3
|
-
import { GraphQLError } from "graphql";
|
|
4
3
|
|
|
5
4
|
import { Validator } from "..";
|
|
6
5
|
import { IkasBaseStore } from "../../../../store";
|
|
@@ -238,11 +237,7 @@ export class RaffleForm {
|
|
|
238
237
|
}
|
|
239
238
|
|
|
240
239
|
async submit() {
|
|
241
|
-
const response:
|
|
242
|
-
isFormError: boolean;
|
|
243
|
-
isSuccess: boolean;
|
|
244
|
-
errors?: readonly GraphQLError[];
|
|
245
|
-
} = { isFormError: false, isSuccess: false };
|
|
240
|
+
const response = { isFormError: false, isSuccess: false };
|
|
246
241
|
const hasFormError = await this.validateAll();
|
|
247
242
|
if (hasFormError) {
|
|
248
243
|
response.isFormError = true;
|
|
@@ -251,7 +246,7 @@ export class RaffleForm {
|
|
|
251
246
|
|
|
252
247
|
try {
|
|
253
248
|
const selectedVariant = this.raffle.products[0].selectedVariant;
|
|
254
|
-
const
|
|
249
|
+
const isRaffleFormSuccess = await saveRaffleParticipant({
|
|
255
250
|
input: {
|
|
256
251
|
appliedProduct: {
|
|
257
252
|
productId: selectedVariant.productId,
|
|
@@ -269,20 +264,12 @@ export class RaffleForm {
|
|
|
269
264
|
},
|
|
270
265
|
});
|
|
271
266
|
|
|
272
|
-
if (
|
|
273
|
-
response.errors = saveRaffleParticipantResponse.graphQLErrors;
|
|
274
|
-
response.isSuccess = false;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
if (saveRaffleParticipantResponse.data) {
|
|
267
|
+
if (isRaffleFormSuccess) {
|
|
278
268
|
response.isSuccess = true;
|
|
279
269
|
}
|
|
280
270
|
|
|
281
271
|
return response;
|
|
282
272
|
} catch (error) {
|
|
283
|
-
if (error) {
|
|
284
|
-
response.errors = error;
|
|
285
|
-
}
|
|
286
273
|
return response;
|
|
287
274
|
}
|
|
288
275
|
}
|
|
@@ -183,16 +183,6 @@ export class EmailRule<T> extends ValidationRule<T> {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
/**
|
|
187
|
-
* 1) start with plus(+) or digit
|
|
188
|
-
* 2) any digit or one char white space
|
|
189
|
-
* 3) end with digit
|
|
190
|
-
*
|
|
191
|
-
* For example:
|
|
192
|
-
* ✅ Valid +90535 555 5555
|
|
193
|
-
* ✅ valid 905355555555
|
|
194
|
-
* 🚫 Unvalid +90535 5 55 5555
|
|
195
|
-
*/
|
|
196
186
|
export class PhoneRule<T> extends ValidationRule<T> {
|
|
197
187
|
get errorMessage() {
|
|
198
188
|
if (!this.message) return "";
|
|
@@ -203,8 +193,10 @@ export class PhoneRule<T> extends ValidationRule<T> {
|
|
|
203
193
|
async run(): Promise<boolean> {
|
|
204
194
|
if (!this.value) return true;
|
|
205
195
|
|
|
206
|
-
const result = this.value.match(
|
|
207
|
-
return
|
|
196
|
+
const result = this.value.match(/\d/g);
|
|
197
|
+
return (
|
|
198
|
+
(!!result && result.length <= 11) || !!/^\+(\d{12})$/gm.test(this.value)
|
|
199
|
+
);
|
|
208
200
|
}
|
|
209
201
|
}
|
|
210
202
|
|
|
@@ -254,8 +246,15 @@ export class IdentityNumberRule<T> extends ValidationRule<T> {
|
|
|
254
246
|
TCSum = 0;
|
|
255
247
|
|
|
256
248
|
const incorrect = [
|
|
257
|
-
11111111110,
|
|
258
|
-
|
|
249
|
+
11111111110,
|
|
250
|
+
22222222220,
|
|
251
|
+
33333333330,
|
|
252
|
+
44444444440,
|
|
253
|
+
55555555550,
|
|
254
|
+
66666666660,
|
|
255
|
+
7777777770,
|
|
256
|
+
88888888880,
|
|
257
|
+
99999999990,
|
|
259
258
|
];
|
|
260
259
|
|
|
261
260
|
if (tcknString.length !== 11) return false;
|
package/src/store/cart/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "../../models/data";
|
|
11
11
|
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
12
12
|
import { Analytics } from "../../analytics";
|
|
13
|
-
import { CartLineOptionInput } from "@ikas/storefront-api";
|
|
13
|
+
import { CartLineOptionInput } from "@ikas/storefront-api/build/__api/types";
|
|
14
14
|
|
|
15
15
|
export const CART_LS_KEY = "cartId";
|
|
16
16
|
|
|
@@ -100,7 +100,7 @@ export class IkasCartStore {
|
|
|
100
100
|
|
|
101
101
|
product.productOptionSet?.initOptionValues();
|
|
102
102
|
|
|
103
|
-
return
|
|
103
|
+
return true;
|
|
104
104
|
} catch (err) {
|
|
105
105
|
console.log(err);
|
|
106
106
|
return false;
|
|
@@ -145,7 +145,7 @@ export class IkasCartStore {
|
|
|
145
145
|
Analytics.addToCart(item, quantity - oldQuantity, eventId, this.cart);
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
return
|
|
148
|
+
return true;
|
|
149
149
|
} catch (err) {
|
|
150
150
|
console.log(err);
|
|
151
151
|
return false;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
2
|
-
import { CountryCode, getCountries as categories } from "libphonenumber-js";
|
|
3
|
-
import compareStrings from "./compare-strings";
|
|
4
|
-
|
|
5
|
-
export type CountryType = {
|
|
6
|
-
value: CountryCode;
|
|
7
|
-
label: string | undefined;
|
|
8
|
-
};
|
|
9
|
-
|
|
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
|
-
|
|
44
|
-
return categories()
|
|
45
|
-
.map((country) => ({
|
|
46
|
-
value: country,
|
|
47
|
-
label: lang[country],
|
|
48
|
-
}))
|
|
49
|
-
.sort((a, b) => compareStrings(a.label, b.label));
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default getCountries;
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { observer } from "mobx-react-lite";
|
|
3
|
-
import parsePhoneNumber, {
|
|
4
|
-
CountryCode,
|
|
5
|
-
formatIncompletePhoneNumber,
|
|
6
|
-
getCountryCallingCode,
|
|
7
|
-
parseIncompletePhoneNumber,
|
|
8
|
-
} from "libphonenumber-js";
|
|
9
|
-
import getCountries, { CountryType } from "./get-countries";
|
|
10
|
-
|
|
11
|
-
import styles from "./style.module.scss";
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
defaultCountry?: string | null;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
placeholder: string | undefined;
|
|
17
|
-
value: string;
|
|
18
|
-
onChange: (value: string) => void;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const DEFAULT_COUNTRY = "TR";
|
|
22
|
-
|
|
23
|
-
export const PhoneNumberInput: React.FC<Props> = observer(
|
|
24
|
-
({ defaultCountry, disabled = false, placeholder, value, onChange }) => {
|
|
25
|
-
const [countries, setCountries] = React.useState<CountryType[]>([]);
|
|
26
|
-
const [activeCountry, setActiveCountry] = React.useState(
|
|
27
|
-
(defaultCountry as CountryCode) || DEFAULT_COUNTRY
|
|
28
|
-
);
|
|
29
|
-
const [formatedValue, setFormatedValue] = React.useState("");
|
|
30
|
-
|
|
31
|
-
React.useEffect(() => {
|
|
32
|
-
fetchCountries();
|
|
33
|
-
|
|
34
|
-
let countryCode = activeCountry;
|
|
35
|
-
|
|
36
|
-
if (value) {
|
|
37
|
-
const parsedPhoneNumber = parsePhoneNumber(value);
|
|
38
|
-
|
|
39
|
-
if (parsedPhoneNumber && parsedPhoneNumber.country) {
|
|
40
|
-
countryCode = parsedPhoneNumber.country;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
setFormatedValue(formatIncompletePhoneNumber(value, countryCode));
|
|
44
|
-
} else {
|
|
45
|
-
setDefaultValue(countryCode);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
setActiveCountry(countryCode);
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
const fetchCountries = async () => {
|
|
52
|
-
const categories = await getCountries();
|
|
53
|
-
setCountries(categories);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const onValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
57
|
-
const phoneNumber = formatPhoneNumber(event.target.value);
|
|
58
|
-
setFormatedValue(phoneNumber);
|
|
59
|
-
onChange(
|
|
60
|
-
!phoneNumber
|
|
61
|
-
? event.target.value
|
|
62
|
-
: parseIncompletePhoneNumber(phoneNumber)
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const onCountryChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
|
|
67
|
-
if (event.target.value) {
|
|
68
|
-
const country = event.target.value as CountryCode;
|
|
69
|
-
|
|
70
|
-
setActiveCountry(country);
|
|
71
|
-
setDefaultValue(country);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const setDefaultValue = (countyCode: CountryCode) => {
|
|
76
|
-
const countryCallingCode = getCountryCallingCode(countyCode);
|
|
77
|
-
|
|
78
|
-
setFormatedValue(`+${countryCallingCode}`);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const formatPhoneNumber = (phoneNumber: string) => {
|
|
82
|
-
return formatIncompletePhoneNumber(phoneNumber, activeCountry);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const getImageSrc = () => {
|
|
86
|
-
return `https://cdn.myikas.com/sf/assets/flags/3x2/${activeCountry}.svg`;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<React.Fragment>
|
|
91
|
-
<div className={styles.SelectFlag}>
|
|
92
|
-
<div className={styles.FlagContainer}>
|
|
93
|
-
<div className={styles.Flag}>
|
|
94
|
-
<img
|
|
95
|
-
className={styles.FlagImage}
|
|
96
|
-
alt={activeCountry}
|
|
97
|
-
src={getImageSrc()}
|
|
98
|
-
></img>
|
|
99
|
-
<div className={styles.Arrow}></div>
|
|
100
|
-
</div>
|
|
101
|
-
<select
|
|
102
|
-
className={styles.Select}
|
|
103
|
-
value={activeCountry}
|
|
104
|
-
onChange={onCountryChange}
|
|
105
|
-
disabled={disabled}
|
|
106
|
-
>
|
|
107
|
-
{countries.map((country) => (
|
|
108
|
-
<option key={country.value} value={country.value}>
|
|
109
|
-
{country.label}
|
|
110
|
-
</option>
|
|
111
|
-
))}
|
|
112
|
-
</select>
|
|
113
|
-
</div>
|
|
114
|
-
</div>
|
|
115
|
-
<input
|
|
116
|
-
className={styles.Input}
|
|
117
|
-
value={formatedValue}
|
|
118
|
-
onChange={onValueChange}
|
|
119
|
-
placeholder={placeholder}
|
|
120
|
-
disabled={disabled}
|
|
121
|
-
></input>
|
|
122
|
-
</React.Fragment>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
);
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
.SelectFlag {
|
|
2
|
-
position: absolute;
|
|
3
|
-
top: 26px;
|
|
4
|
-
left: 16px;
|
|
5
|
-
|
|
6
|
-
.FlagContainer {
|
|
7
|
-
position: relative;
|
|
8
|
-
width: 35px;
|
|
9
|
-
height: 24px;
|
|
10
|
-
|
|
11
|
-
flex: 0 0 35px;
|
|
12
|
-
|
|
13
|
-
.Select {
|
|
14
|
-
position: absolute;
|
|
15
|
-
top: 0;
|
|
16
|
-
left: 0;
|
|
17
|
-
z-index: 1;
|
|
18
|
-
padding: 0;
|
|
19
|
-
opacity: 0;
|
|
20
|
-
border: 0;
|
|
21
|
-
width: 100%;
|
|
22
|
-
height: 100%;
|
|
23
|
-
cursor: pointer;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.Flag {
|
|
28
|
-
position: relative;
|
|
29
|
-
width: 35px;
|
|
30
|
-
height: 24px;
|
|
31
|
-
|
|
32
|
-
display: flex;
|
|
33
|
-
align-items: center;
|
|
34
|
-
|
|
35
|
-
&Image {
|
|
36
|
-
width: 24px;
|
|
37
|
-
flex: 0 0 24px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.Arrow {
|
|
41
|
-
display: block;
|
|
42
|
-
content: "";
|
|
43
|
-
width: 0.3em;
|
|
44
|
-
height: 0.3em;
|
|
45
|
-
margin-left: 0.35em;
|
|
46
|
-
margin-top: -0.2em;
|
|
47
|
-
border-style: solid;
|
|
48
|
-
border-color: inherit;
|
|
49
|
-
border-top-width: 0;
|
|
50
|
-
border-bottom-width: 1px;
|
|
51
|
-
border-left-width: 0;
|
|
52
|
-
border-right-width: 1px;
|
|
53
|
-
transform: rotate(45deg);
|
|
54
|
-
opacity: 0.45;
|
|
55
|
-
|
|
56
|
-
flex: 0 0 0.3em;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.Input {
|
|
62
|
-
padding-left: 64px !important;
|
|
63
|
-
|
|
64
|
-
&:disabled {
|
|
65
|
-
color: #8A8B94 !important;
|
|
66
|
-
background-color: #F7F7F9 !important;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
&::placeholder {
|
|
70
|
-
color: #8A8B94 !important;
|
|
71
|
-
font-size: 14px !important;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// &:disabled {
|
|
75
|
-
// color: $buttonDisabledTextColor !important;
|
|
76
|
-
// background-color: $buttonDisabledBgColor !important;
|
|
77
|
-
// }
|
|
78
|
-
|
|
79
|
-
// &::placeholder {
|
|
80
|
-
// color: $secondaryTextColor !important;
|
|
81
|
-
// font-size: 14px !important;
|
|
82
|
-
// }
|
|
83
|
-
}
|