@ikas/storefront 4.0.0-alpha.11 → 4.0.0-alpha.12
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 +11 -11
- package/src/analytics/analytics.ts +2 -1
- package/src/analytics/googleUniversal.ts +12 -2
- package/src/analytics/head/index.tsx +1 -2
- package/src/components/checkout/components/address-form/index.tsx +1 -1
- package/src/components/checkout/model.ts +4 -1
- package/src/components/page/head.tsx +12 -0
- package/src/models/data/merchant-settings/index.ts +6 -0
- package/src/models/data/product/variant-type/index.ts +2 -0
- package/src/models/data/storefront/index.ts +2 -0
- package/src/models/ui/product-list/index.ts +0 -6
- package/src/models/ui/validator/form/raffle-form.ts +16 -3
- package/src/models/ui/validator/rules/index.ts +14 -13
- package/src/store/cart/index.ts +2 -2
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.12",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "Umut Ozan Yıldırım",
|
|
6
6
|
"license": "ISC",
|
|
@@ -24,11 +24,11 @@
|
|
|
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.12",
|
|
28
|
+
"@ikas/storefront-config": "^4.0.0-alpha.12",
|
|
29
|
+
"@ikas/storefront-model-functions": "^4.0.0-alpha.12",
|
|
30
|
+
"@ikas/storefront-models": "^4.0.0-alpha.12",
|
|
31
|
+
"@ikas/storefront-providers": "^4.0.0-alpha.12",
|
|
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",
|
|
@@ -52,11 +52,11 @@
|
|
|
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.12",
|
|
56
|
+
"@ikas/storefront-config": "^4.0.0-alpha.12",
|
|
57
|
+
"@ikas/storefront-model-functions": "^4.0.0-alpha.12",
|
|
58
|
+
"@ikas/storefront-models": "^4.0.0-alpha.12",
|
|
59
|
+
"@ikas/storefront-providers": "^4.0.0-alpha.12",
|
|
60
60
|
"mobx": "^6.1.3",
|
|
61
61
|
"mobx-react-lite": "^3.1.5",
|
|
62
62
|
"next": "canary",
|
|
@@ -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
|
|
@@ -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}
|
|
@@ -440,7 +440,10 @@ export default class CheckoutViewModel {
|
|
|
440
440
|
input = await this.inStockDeliveryInputData(input);
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
if (
|
|
443
|
+
if (
|
|
444
|
+
this.step === CheckoutStep.INFO ||
|
|
445
|
+
this.step === CheckoutStep.SHIPPING
|
|
446
|
+
) {
|
|
444
447
|
input.billingAddress = null;
|
|
445
448
|
}
|
|
446
449
|
|
|
@@ -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
|
|
|
@@ -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);
|
|
@@ -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();
|
|
@@ -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;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { saveRaffleParticipant } from "@ikas/storefront-api";
|
|
2
2
|
import { action, computed, makeObservable, observable } from "mobx";
|
|
3
|
+
import { GraphQLError } from "graphql";
|
|
3
4
|
|
|
4
5
|
import { Validator } from "..";
|
|
5
6
|
import { IkasBaseStore } from "../../../../store";
|
|
@@ -237,7 +238,11 @@ export class RaffleForm {
|
|
|
237
238
|
}
|
|
238
239
|
|
|
239
240
|
async submit() {
|
|
240
|
-
const response
|
|
241
|
+
const response: {
|
|
242
|
+
isFormError: boolean;
|
|
243
|
+
isSuccess: boolean;
|
|
244
|
+
errors?: readonly GraphQLError[];
|
|
245
|
+
} = { isFormError: false, isSuccess: false };
|
|
241
246
|
const hasFormError = await this.validateAll();
|
|
242
247
|
if (hasFormError) {
|
|
243
248
|
response.isFormError = true;
|
|
@@ -246,7 +251,7 @@ export class RaffleForm {
|
|
|
246
251
|
|
|
247
252
|
try {
|
|
248
253
|
const selectedVariant = this.raffle.products[0].selectedVariant;
|
|
249
|
-
const
|
|
254
|
+
const saveRaffleParticipantResponse = await saveRaffleParticipant({
|
|
250
255
|
input: {
|
|
251
256
|
appliedProduct: {
|
|
252
257
|
productId: selectedVariant.productId,
|
|
@@ -264,12 +269,20 @@ export class RaffleForm {
|
|
|
264
269
|
},
|
|
265
270
|
});
|
|
266
271
|
|
|
267
|
-
if (
|
|
272
|
+
if (saveRaffleParticipantResponse?.graphQLErrors) {
|
|
273
|
+
response.errors = saveRaffleParticipantResponse.graphQLErrors;
|
|
274
|
+
response.isSuccess = false;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (saveRaffleParticipantResponse.data) {
|
|
268
278
|
response.isSuccess = true;
|
|
269
279
|
}
|
|
270
280
|
|
|
271
281
|
return response;
|
|
272
282
|
} catch (error) {
|
|
283
|
+
if (error) {
|
|
284
|
+
response.errors = error;
|
|
285
|
+
}
|
|
273
286
|
return response;
|
|
274
287
|
}
|
|
275
288
|
}
|
|
@@ -183,6 +183,16 @@ 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
|
+
*/
|
|
186
196
|
export class PhoneRule<T> extends ValidationRule<T> {
|
|
187
197
|
get errorMessage() {
|
|
188
198
|
if (!this.message) return "";
|
|
@@ -193,10 +203,8 @@ export class PhoneRule<T> extends ValidationRule<T> {
|
|
|
193
203
|
async run(): Promise<boolean> {
|
|
194
204
|
if (!this.value) return true;
|
|
195
205
|
|
|
196
|
-
const result = this.value.match(
|
|
197
|
-
return
|
|
198
|
-
(!!result && result.length <= 11) || !!/^\+(\d{12})$/gm.test(this.value)
|
|
199
|
-
);
|
|
206
|
+
const result = this.value.match(/^[\+\d](\d+\s)*\d+$/g);
|
|
207
|
+
return !!result;
|
|
200
208
|
}
|
|
201
209
|
}
|
|
202
210
|
|
|
@@ -246,15 +254,8 @@ export class IdentityNumberRule<T> extends ValidationRule<T> {
|
|
|
246
254
|
TCSum = 0;
|
|
247
255
|
|
|
248
256
|
const incorrect = [
|
|
249
|
-
11111111110,
|
|
250
|
-
|
|
251
|
-
33333333330,
|
|
252
|
-
44444444440,
|
|
253
|
-
55555555550,
|
|
254
|
-
66666666660,
|
|
255
|
-
7777777770,
|
|
256
|
-
88888888880,
|
|
257
|
-
99999999990,
|
|
257
|
+
11111111110, 22222222220, 33333333330, 44444444440, 55555555550,
|
|
258
|
+
66666666660, 7777777770, 88888888880, 99999999990,
|
|
258
259
|
];
|
|
259
260
|
|
|
260
261
|
if (tcknString.length !== 11) return false;
|
package/src/store/cart/index.ts
CHANGED
|
@@ -100,7 +100,7 @@ export class IkasCartStore {
|
|
|
100
100
|
|
|
101
101
|
product.productOptionSet?.initOptionValues();
|
|
102
102
|
|
|
103
|
-
return
|
|
103
|
+
return response;
|
|
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 response;
|
|
149
149
|
} catch (err) {
|
|
150
150
|
console.log(err);
|
|
151
151
|
return false;
|