@tap-payments/auth-jsconnect 1.0.47 → 1.0.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/build/@types/app.d.ts +1 -1
- package/build/api/entity.d.ts +2 -1
- package/build/api/entity.js +5 -1
- package/build/api/index.d.ts +1 -0
- package/build/constants/app.d.ts +2 -0
- package/build/constants/app.js +2 -0
- package/build/constants/assets.d.ts +1 -0
- package/build/constants/assets.js +2 -1
- package/build/constants/validation.d.ts +0 -1
- package/build/constants/validation.js +0 -1
- package/build/features/app/business/businessStore.d.ts +1 -1
- package/build/features/app/business/businessStore.js +14 -23
- package/build/features/app/connect/connectStore.d.ts +1 -1
- package/build/features/app/connect/connectStore.js +17 -22
- package/build/features/business/screens/Customers/CustomerLocations.js +1 -1
- package/build/features/business/screens/Customers/ExpectedCustomers.js +2 -2
- package/build/features/business/screens/Customers/ExpectedSalesRange.js +1 -1
- package/build/features/connect/screens/Individual/Email.js +2 -1
- package/build/features/connect/screens/Individual/Individual.js +5 -11
- package/build/features/connect/screens/Individual/MobileNumber.d.ts +0 -1
- package/build/features/connect/screens/Individual/MobileNumber.js +3 -3
- package/build/features/connect/screens/Individual/validation.d.ts +2 -2
- package/build/features/connect/screens/Individual/validation.js +40 -24
- package/build/features/connect/screens/Merchant/BrandList.js +0 -5
- package/build/features/connect/screens/Merchant/BrandName.js +2 -1
- package/build/features/connect/screens/Merchant/Merchant.js +11 -3
- package/build/features/connect/screens/Merchant/SocialMedia.js +1 -1
- package/build/features/connect/screens/Merchant/validation.d.ts +4 -4
- package/build/features/connect/screens/Merchant/validation.js +9 -9
- package/build/features/connect/screens/Mobile/Mobile.js +3 -9
- package/build/features/connect/screens/Mobile/MobileNumber.js +3 -3
- package/build/features/connect/screens/Mobile/validation.d.ts +1 -1
- package/build/features/connect/screens/Mobile/validation.js +27 -10
- package/build/features/connect/screens/NID/NID.js +2 -2
- package/build/features/shared/Button/MobileButton.d.ts +9 -0
- package/build/features/shared/Button/MobileButton.js +67 -0
- package/build/features/shared/Button/index.d.ts +2 -1
- package/build/features/shared/Button/index.js +2 -1
- package/package.json +1 -1
package/build/@types/app.d.ts
CHANGED
package/build/api/entity.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare type EntityInfoUpdateBody = {
|
|
|
5
5
|
channel_services?: Array<string>;
|
|
6
6
|
physical_store_available?: boolean;
|
|
7
7
|
yearly_sales_range?: string;
|
|
8
|
-
customers_served_monthly?:
|
|
8
|
+
customers_served_monthly?: number;
|
|
9
9
|
customers_base?: Array<string>;
|
|
10
10
|
vat_id?: string;
|
|
11
11
|
agree_chargeback?: boolean;
|
|
@@ -14,6 +14,7 @@ export declare type EntityInfoUpdateBody = {
|
|
|
14
14
|
encryption_contract?: Array<string>;
|
|
15
15
|
};
|
|
16
16
|
declare const entityService: {
|
|
17
|
+
createEntityInfo: (data: EntityInfoUpdateBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
17
18
|
updateEntityInfo: (data: EntityInfoUpdateBody, config?: AxiosRequestConfig) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
18
19
|
};
|
|
19
20
|
export { entityService };
|
package/build/api/entity.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { ENDPOINT_PATHS } from '../constants';
|
|
2
2
|
import instance from './axios';
|
|
3
|
-
var
|
|
3
|
+
var createEntityInfo = function (data, config) {
|
|
4
4
|
return instance.post("".concat(ENDPOINT_PATHS.ENTITY), data, config);
|
|
5
5
|
};
|
|
6
|
+
var updateEntityInfo = function (data, config) {
|
|
7
|
+
return instance.put("".concat(ENDPOINT_PATHS.ENTITY), data, config);
|
|
8
|
+
};
|
|
6
9
|
var entityService = {
|
|
10
|
+
createEntityInfo: createEntityInfo,
|
|
7
11
|
updateEntityInfo: updateEntityInfo
|
|
8
12
|
};
|
|
9
13
|
export { entityService };
|
package/build/api/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare const API: {
|
|
|
30
30
|
retrieveEntityList: (leadId: string) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
31
31
|
};
|
|
32
32
|
entityService: {
|
|
33
|
+
createEntityInfo: (data: EntityInfoUpdateBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
33
34
|
updateEntityInfo: (data: EntityInfoUpdateBody, config?: import("axios").AxiosRequestConfig<any> | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
34
35
|
};
|
|
35
36
|
availabilityServices: {
|
package/build/constants/app.d.ts
CHANGED
|
@@ -92,3 +92,5 @@ export declare const BUSINESS_STEP_NAMES: {
|
|
|
92
92
|
export declare const RSA_FRONTEND_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCgC9kH1SQvjbXAUXd0PbrDUG8P\nLhRig9pJNBmdQBZjihuaxfkzYu6ToMbIMAfmYgVgQw338/y7aQ8X3m03CXNIlkxo\nOwxKCA8ymKsZQptXJn9IxlPO7yjoFgTFBrpmTgvcC4XO1uoUYTAPq3szK8kj4zgT\nucWG1hSKsOdRU7sl/wIDAQAB\n-----END PUBLIC KEY-----";
|
|
93
93
|
export declare const ENCRYPTION_FLAG = "encryption_contract";
|
|
94
94
|
export declare const BACKEND_ENCRYPTION_FLAG = "backend_encryption_contract";
|
|
95
|
+
export declare const INSTAGRAM_URL = "https://www.instagram.com";
|
|
96
|
+
export declare const TWITTER_URL = "https://twitter.com";
|
package/build/constants/app.js
CHANGED
|
@@ -241,3 +241,5 @@ export var BUSINESS_STEP_NAMES = {
|
|
|
241
241
|
export var RSA_FRONTEND_MW_PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCgC9kH1SQvjbXAUXd0PbrDUG8P\nLhRig9pJNBmdQBZjihuaxfkzYu6ToMbIMAfmYgVgQw338/y7aQ8X3m03CXNIlkxo\nOwxKCA8ymKsZQptXJn9IxlPO7yjoFgTFBrpmTgvcC4XO1uoUYTAPq3szK8kj4zgT\nucWG1hSKsOdRU7sl/wIDAQAB\n-----END PUBLIC KEY-----";
|
|
242
242
|
export var ENCRYPTION_FLAG = 'encryption_contract';
|
|
243
243
|
export var BACKEND_ENCRYPTION_FLAG = 'backend_encryption_contract';
|
|
244
|
+
export var INSTAGRAM_URL = 'https://www.instagram.com';
|
|
245
|
+
export var TWITTER_URL = 'https://twitter.com';
|
|
@@ -32,5 +32,6 @@ export var ICONS_NAMES = {
|
|
|
32
32
|
WHITE_ARROW: 'https://tap-connecet.b-cdn.net/imgs/whiteArrow.svg',
|
|
33
33
|
SUCCESS: 'https://tap-connecet.b-cdn.net/imgs/success.svg',
|
|
34
34
|
ABSHER_LOGO: 'https://dash.b-cdn.net/icons/menu/Absher.svg',
|
|
35
|
-
EMAIL_ICON: 'https://dash.b-cdn.net/icons/menu/email.png'
|
|
35
|
+
EMAIL_ICON: 'https://dash.b-cdn.net/icons/menu/email.png',
|
|
36
|
+
MOBILE_ICON: 'https://dash.b-cdn.net/icons/menu/mobile.svg'
|
|
36
37
|
};
|
|
@@ -7,4 +7,3 @@ export var CR_NUMBER_LENGTH = 10;
|
|
|
7
7
|
export var SAUDI_NUMBER_LENGTH = 9;
|
|
8
8
|
export var REGEX_FULL_NAME = /^([a-zA-Z]{2,}\s{1}[a-zA-Z]{1,}|[a-zA-Z]+\s{1}[a-zA-Z.-]{1,}\s{1}[a-zA-Z.-]{1,}\s{1}[a-zA-Z]{1,}|[a-zA-Z]+\s{1}[a-zA-Z.-]{1,}\s{1}[a-zA-Z]{1,})$/g;
|
|
9
9
|
export var REGEX_WEBSITE = /^[a-zA-Z0-9]+([\-\.]{1}[a-zA-Z0-9]+)*\.[a-zA-Z]{2,63}(:[0-9]{1,5})?(\/.*)?$/;
|
|
10
|
-
export var REGEX_SAUDI_NUMBER = /^(05|5)([0-9]{1,})$/g;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RootState } from '../../../app/store';
|
|
2
2
|
import { ActivitiesFormValues, BusinessInfoFormValues, CustomersFormValues, BusinessTypeFormValues, CountryCode, License, NIDFormValues, OTPFormValues, ResponseData, SharedState } from '../../../@types';
|
|
3
3
|
export declare const getCountries: import("@reduxjs/toolkit").AsyncThunk<{
|
|
4
|
-
businessCountry:
|
|
4
|
+
businessCountry: any;
|
|
5
5
|
countries: any;
|
|
6
6
|
}, void, {}>;
|
|
7
7
|
export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
|
|
@@ -55,7 +55,7 @@ import i18n from '../../../i18n';
|
|
|
55
55
|
import { convertNumbers2English, removeRequestHeaders } from '../../../utils';
|
|
56
56
|
import { handleCurrentActiveScreen, handleNextScreenStep } from '../../../app/settings';
|
|
57
57
|
export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
58
|
-
var settings, countriesBody, businessCountry
|
|
58
|
+
var settings, countriesBody, businessCountry;
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
|
61
61
|
case 0:
|
|
@@ -63,17 +63,10 @@ export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi
|
|
|
63
63
|
return [4, API.countryService.getAllCountries()];
|
|
64
64
|
case 1:
|
|
65
65
|
countriesBody = (_a.sent()).data;
|
|
66
|
-
businessCountry =
|
|
67
|
-
|
|
68
|
-
if ([country.iso2, country.iso3].includes(settings.data.appConfig.businessCountryCode.toUpperCase())) {
|
|
69
|
-
businessCountry = country;
|
|
70
|
-
}
|
|
71
|
-
if (country.iso2 === 'SA') {
|
|
72
|
-
country.digits = 9;
|
|
73
|
-
}
|
|
74
|
-
return country;
|
|
66
|
+
businessCountry = (countriesBody.list || []).find(function (country) {
|
|
67
|
+
return [country.iso2, country.iso3].includes(settings.data.appConfig.businessCountryCode.toUpperCase());
|
|
75
68
|
});
|
|
76
|
-
return [2, { businessCountry: businessCountry, countries: list }];
|
|
69
|
+
return [2, { businessCountry: businessCountry, countries: (countriesBody === null || countriesBody === void 0 ? void 0 : countriesBody.list) || [] }];
|
|
77
70
|
}
|
|
78
71
|
});
|
|
79
72
|
}); });
|
|
@@ -268,7 +261,7 @@ export var updateActivitiesInfo = createAsyncThunk('updateActivitiesInfo', funct
|
|
|
268
261
|
step_name: BUSINESS_STEP_NAMES.BUSINESS_CR_ACTIVITIES
|
|
269
262
|
};
|
|
270
263
|
headers = { entity_id: (_c = business.data.businessInfo.responseBody) === null || _c === void 0 ? void 0 : _c.entity_id };
|
|
271
|
-
return [4, API.entityService.
|
|
264
|
+
return [4, API.entityService.createEntityInfo(requestBody, { headers: headers })];
|
|
272
265
|
case 1:
|
|
273
266
|
data = (_f.sent()).data;
|
|
274
267
|
if (!data.errors) {
|
|
@@ -309,18 +302,18 @@ export var updateCustomersInfo = createAsyncThunk('updateCustomersInfo', functio
|
|
|
309
302
|
case 0:
|
|
310
303
|
_a = thunkApi.getState(), settings = _a.settings, business = _a.business;
|
|
311
304
|
customerBase = params.customerLocations.map(function (_a) {
|
|
312
|
-
var
|
|
313
|
-
return
|
|
305
|
+
var title = _a.title;
|
|
306
|
+
return title;
|
|
314
307
|
});
|
|
315
308
|
requestBody = {
|
|
316
309
|
customers_base: customerBase,
|
|
317
|
-
customers_served_monthly: ((_b = params.expectedCustomers) === null || _b === void 0 ? void 0 : _b.
|
|
318
|
-
yearly_sales_range: ((_c = params.
|
|
310
|
+
customers_served_monthly: parseInt(((_b = params.expectedCustomers) === null || _b === void 0 ? void 0 : _b.id) || '0'),
|
|
311
|
+
yearly_sales_range: ((_c = params.expectedSalesRange) === null || _c === void 0 ? void 0 : _c.title) || '',
|
|
319
312
|
agree_refund: params.refundPolicy,
|
|
320
313
|
agree_chargeback: params.transactionPolicy,
|
|
321
314
|
step_name: BUSINESS_STEP_NAMES.BUSINESS_CUSTOMERS
|
|
322
315
|
};
|
|
323
|
-
headers = { entity_id: (_d = business.data.
|
|
316
|
+
headers = { entity_id: (_d = business.data.activitiesData.responseBody) === null || _d === void 0 ? void 0 : _d.entity_id };
|
|
324
317
|
return [4, API.entityService.updateEntityInfo(requestBody, { headers: headers })];
|
|
325
318
|
case 1:
|
|
326
319
|
data = (_g.sent()).data;
|
|
@@ -490,12 +483,10 @@ export var businessSlice = createSlice({
|
|
|
490
483
|
state.error = action.error.message;
|
|
491
484
|
})
|
|
492
485
|
.addCase(retrieveEntityList.pending, function (state) {
|
|
493
|
-
state.loading = true;
|
|
494
486
|
state.error = null;
|
|
495
487
|
})
|
|
496
488
|
.addCase(retrieveEntityList.fulfilled, function (state, action) {
|
|
497
489
|
var _a;
|
|
498
|
-
state.loading = false;
|
|
499
490
|
state.error = null;
|
|
500
491
|
var data = action.payload.data;
|
|
501
492
|
var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
|
|
@@ -513,7 +504,6 @@ export var businessSlice = createSlice({
|
|
|
513
504
|
}
|
|
514
505
|
})
|
|
515
506
|
.addCase(retrieveEntityList.rejected, function (state, action) {
|
|
516
|
-
state.loading = false;
|
|
517
507
|
state.error = action.error.message;
|
|
518
508
|
})
|
|
519
509
|
.addCase(updateLeadBusinessType.pending, function (state) {
|
|
@@ -533,10 +523,11 @@ export var businessSlice = createSlice({
|
|
|
533
523
|
state.data.businessTypeData = formData;
|
|
534
524
|
var isAr = i18n.dir() === 'rtl';
|
|
535
525
|
state.data.businessInfo.brandName = isAr ? (_c = (_b = data === null || data === void 0 ? void 0 : data.brand) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.ar : (_e = (_d = data === null || data === void 0 ? void 0 : data.brand) === null || _d === void 0 ? void 0 : _d.name) === null || _e === void 0 ? void 0 : _e.en;
|
|
536
|
-
state.data.businessInfo.licenseNumber = data === null || data === void 0 ? void 0 : data.license_number;
|
|
526
|
+
state.data.businessInfo.licenseNumber = (data === null || data === void 0 ? void 0 : data.license_number) || '';
|
|
537
527
|
state.data.businessInfo.legalName = isAr ? (_g = (_f = data === null || data === void 0 ? void 0 : data.entity) === null || _f === void 0 ? void 0 : _f.legal_name) === null || _g === void 0 ? void 0 : _g.ar : (_j = (_h = data === null || data === void 0 ? void 0 : data.entity) === null || _h === void 0 ? void 0 : _h.legal_name) === null || _j === void 0 ? void 0 : _j.en;
|
|
538
|
-
if (!!((_l = (_k = data === null || data === void 0 ? void 0 : data.entity) === null || _k === void 0 ? void 0 : _k.license) === null || _l === void 0 ? void 0 : _l.
|
|
539
|
-
state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_o = (_m = data === null || data === void 0 ? void 0 : data.entity) === null || _m === void 0 ? void 0 : _m.license) === null || _o === void 0 ? void 0 : _o.
|
|
528
|
+
if (!!((_l = (_k = data === null || data === void 0 ? void 0 : data.entity) === null || _k === void 0 ? void 0 : _k.license) === null || _l === void 0 ? void 0 : _l.issuing_date)) {
|
|
529
|
+
state.data.activitiesData.operationStartDate = convertNumbers2English(moment((_o = (_m = data === null || data === void 0 ? void 0 : data.entity) === null || _m === void 0 ? void 0 : _m.license) === null || _o === void 0 ? void 0 : _o.issuing_date).format('YYYY-MM-DD'));
|
|
530
|
+
}
|
|
540
531
|
if (formData.businessType === BusinessType.CR) {
|
|
541
532
|
var activities = ((_q = (_p = data === null || data === void 0 ? void 0 : data.license) === null || _p === void 0 ? void 0 : _p.activities) === null || _q === void 0 ? void 0 : _q.isic) || [];
|
|
542
533
|
var selectedActivity = activities === null || activities === void 0 ? void 0 : activities[0];
|
|
@@ -2,7 +2,7 @@ import { RootState } from '../../../app/store';
|
|
|
2
2
|
import { ResponseData, CountryCode, MobileFormValues, NIDFormValues, OTPFormValues, IndividualFormValues, SharedState, BrandFormValues } from '../../../@types';
|
|
3
3
|
import { CancelToken } from 'axios';
|
|
4
4
|
export declare const getCountries: import("@reduxjs/toolkit").AsyncThunk<{
|
|
5
|
-
businessCountry:
|
|
5
|
+
businessCountry: any;
|
|
6
6
|
countries: any;
|
|
7
7
|
}, void, {}>;
|
|
8
8
|
export declare const createMobileAuth: import("@reduxjs/toolkit").AsyncThunk<{
|
|
@@ -49,11 +49,11 @@ var _a;
|
|
|
49
49
|
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
50
50
|
import { handleNextScreenStep } from '../../../app/settings';
|
|
51
51
|
import API from '../../../api';
|
|
52
|
-
import { BRAND_LIST, CONNECT_STEP_NAMES, IDENTIFICATION_TYPE } from '../../../constants';
|
|
52
|
+
import { BRAND_LIST, CONNECT_STEP_NAMES, IDENTIFICATION_TYPE, INSTAGRAM_URL, TWITTER_URL } from '../../../constants';
|
|
53
53
|
import { defaultCountry } from '../../../constants';
|
|
54
54
|
import { getIndividualName, getClientEmailUrl, capitalizeTheFirstLetterOfEachWord, removeRequestHeaders } from '../../../utils';
|
|
55
55
|
export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
-
var settings, countriesBody, businessCountry
|
|
56
|
+
var settings, countriesBody, businessCountry;
|
|
57
57
|
return __generator(this, function (_a) {
|
|
58
58
|
switch (_a.label) {
|
|
59
59
|
case 0:
|
|
@@ -61,17 +61,10 @@ export var getCountries = createAsyncThunk('getCountries', function (_, thunkApi
|
|
|
61
61
|
return [4, API.countryService.getAllCountries()];
|
|
62
62
|
case 1:
|
|
63
63
|
countriesBody = (_a.sent()).data;
|
|
64
|
-
businessCountry =
|
|
65
|
-
|
|
66
|
-
if ([country.iso2, country.iso3].includes(settings.data.appConfig.businessCountryCode.toUpperCase())) {
|
|
67
|
-
businessCountry = country;
|
|
68
|
-
}
|
|
69
|
-
if (country.iso2 === 'SA') {
|
|
70
|
-
country.digits = 9;
|
|
71
|
-
}
|
|
72
|
-
return country;
|
|
64
|
+
businessCountry = (countriesBody.list || []).find(function (country) {
|
|
65
|
+
return [country.iso2, country.iso3].includes(settings.data.appConfig.businessCountryCode.toUpperCase());
|
|
73
66
|
});
|
|
74
|
-
return [2, { businessCountry: businessCountry, countries: list }];
|
|
67
|
+
return [2, { businessCountry: businessCountry, countries: countriesBody.list }];
|
|
75
68
|
}
|
|
76
69
|
});
|
|
77
70
|
}); });
|
|
@@ -257,12 +250,14 @@ export var updateLeadIndividual = createAsyncThunk('updateLeadIndividual', funct
|
|
|
257
250
|
});
|
|
258
251
|
}); });
|
|
259
252
|
export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
260
|
-
var _a, settings, connect, payload, data;
|
|
261
|
-
var _b, _c, _d, _e, _f, _g;
|
|
262
|
-
return __generator(this, function (
|
|
263
|
-
switch (
|
|
253
|
+
var _a, settings, connect, instagram, twitter, payload, data;
|
|
254
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
255
|
+
return __generator(this, function (_k) {
|
|
256
|
+
switch (_k.label) {
|
|
264
257
|
case 0:
|
|
265
258
|
_a = thunkApi.getState(), settings = _a.settings, connect = _a.connect;
|
|
259
|
+
instagram = !!((_b = params.links) === null || _b === void 0 ? void 0 : _b.instagram) ? "".concat(INSTAGRAM_URL, "/").concat((_c = params.links) === null || _c === void 0 ? void 0 : _c.twitter) : '';
|
|
260
|
+
twitter = !!((_d = params.links) === null || _d === void 0 ? void 0 : _d.twitter) ? "".concat(TWITTER_URL, "/").concat((_e = params.links) === null || _e === void 0 ? void 0 : _e.twitter) : '';
|
|
266
261
|
payload = {
|
|
267
262
|
brand: {
|
|
268
263
|
name: {
|
|
@@ -270,20 +265,20 @@ export var updateLeadBrand = createAsyncThunk('updateLeadBrand', function (param
|
|
|
270
265
|
ar: params.brandName,
|
|
271
266
|
zh: params.brandName
|
|
272
267
|
},
|
|
273
|
-
website: (
|
|
274
|
-
social: [
|
|
268
|
+
website: (_f = params.links) === null || _f === void 0 ? void 0 : _f.website,
|
|
269
|
+
social: [twitter, instagram]
|
|
275
270
|
},
|
|
276
|
-
lead_id: ((
|
|
271
|
+
lead_id: ((_g = connect.data.otpData.responseBody) === null || _g === void 0 ? void 0 : _g.lead_id) || '',
|
|
277
272
|
terms_conditions_accepted: params.termAndConditionChecked,
|
|
278
273
|
step_name: CONNECT_STEP_NAMES.UPDATE_LEAD_MERCHANT,
|
|
279
|
-
encryption_contract: ['brand.name.en', 'brand.name.ar', 'brand.name.zh']
|
|
274
|
+
encryption_contract: ['brand.name.en', 'brand.name.ar', 'brand.name.zh', 'social[0]', 'social[1]']
|
|
280
275
|
};
|
|
281
276
|
return [4, API.leadService.updateLead(payload)];
|
|
282
277
|
case 1:
|
|
283
|
-
data = (
|
|
278
|
+
data = (_k.sent()).data;
|
|
284
279
|
if (!data.errors) {
|
|
285
280
|
thunkApi.dispatch(handleNextScreenStep());
|
|
286
|
-
(
|
|
281
|
+
(_j = (_h = settings.data.appConfig).onStepCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, settings.data.activeScreen.name, params);
|
|
287
282
|
}
|
|
288
283
|
return [2, { response: data, formData: params }];
|
|
289
284
|
}
|
|
@@ -111,7 +111,7 @@ var customerLocations = function (_a) {
|
|
|
111
111
|
};
|
|
112
112
|
var customerLocationsValue = customerLocationsControl.field.value;
|
|
113
113
|
var customerLocationSelected = customerLocationsValue[customerLocationsValue.length - 1];
|
|
114
|
-
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('select_customer_base') }), _jsx(InputStyled, { readOnly: true, value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.
|
|
114
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('select_customer_base') }), _jsx(InputStyled, { readOnly: true, value: isAr ? customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.titleAr : customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.title, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: customerLocationsList, placeholder: 'choose_customer_base', onSelectItem: onSelectItem, renderItem: function (item) {
|
|
115
115
|
return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (customerLocationsValue === null || customerLocationsValue === void 0 ? void 0 : customerLocationsValue.id) }, { children: isAr ? item.titleAr : item.title })) })), item.id === (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(CheckIconStyled, {}), checkRemainingCondition(item) && item.id != (customerLocationSelected === null || customerLocationSelected === void 0 ? void 0 : customerLocationSelected.id) && _jsx(RemainingCheck, {})] }));
|
|
116
116
|
} }) }))] }) })));
|
|
117
117
|
};
|
|
@@ -72,12 +72,12 @@ var ExpectedCustomers = function (_a) {
|
|
|
72
72
|
}
|
|
73
73
|
}, [response === null || response === void 0 ? void 0 : response.expectedCustomerSales]);
|
|
74
74
|
var onSelectItem = function (expectedCustomers) {
|
|
75
|
-
onCloseList();
|
|
76
75
|
expectedCustomersControl.field.onChange(expectedCustomers);
|
|
76
|
+
onCloseList();
|
|
77
77
|
};
|
|
78
78
|
var expectedCustomersValue = expectedCustomersControl.field.value;
|
|
79
79
|
var expectedCustomersSelected = expectedCustomersValue;
|
|
80
|
-
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_customers_to_serve') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.
|
|
80
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_customers_to_serve') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.titleAr : expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.title, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: expectedCustomersList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
81
81
|
return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedCustomersValue === null || expectedCustomersValue === void 0 ? void 0 : expectedCustomersValue.id) }, { children: isAr ? item.titleAr : item.title })) }), item.id === (expectedCustomersSelected === null || expectedCustomersSelected === void 0 ? void 0 : expectedCustomersSelected.id) && _jsx(CheckIconStyled, {})] }));
|
|
82
82
|
} }) }))] }) })));
|
|
83
83
|
};
|
|
@@ -78,7 +78,7 @@ var ExpectedSalesRange = function (_a) {
|
|
|
78
78
|
};
|
|
79
79
|
var expectedSalesRangeValue = expectedSalesRangeControl.field.value || expectedSalesRangeList;
|
|
80
80
|
var expectedSalesRangeSelected = expectedSalesRangeValue;
|
|
81
|
-
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_sales_yearly') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.
|
|
81
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_sales_yearly') }), _jsx(InputStyled, { readOnly: true, value: isAr ? expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.titleAr : expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.title, onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, placeholder: t('choose_expected_sales'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name', list: expectedSalesRangeList, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
82
82
|
return (_jsxs(_Fragment, { children: [_jsx(ListItemContainer, { children: _jsx(NameContainer, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.id) === (expectedSalesRangeValue === null || expectedSalesRangeValue === void 0 ? void 0 : expectedSalesRangeValue.id) }, { children: isAr ? item.titleAr : item.title })) }), item.id === (expectedSalesRangeSelected === null || expectedSalesRangeSelected === void 0 ? void 0 : expectedSalesRangeSelected.id) && _jsx(CheckIconStyled, {})] }));
|
|
83
83
|
} }) }))] }) })));
|
|
84
84
|
};
|
|
@@ -59,6 +59,7 @@ import { useAppDispatch } from '../../../../hooks';
|
|
|
59
59
|
import { debounce } from 'lodash-es';
|
|
60
60
|
import Collapse from '../../../../components/Collapse';
|
|
61
61
|
import { styled } from '@mui/material/styles';
|
|
62
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
62
63
|
var InputStyled = styled(Input)(function (_a) {
|
|
63
64
|
var theme = _a.theme;
|
|
64
65
|
return ({
|
|
@@ -102,6 +103,6 @@ var Email = function (_a) {
|
|
|
102
103
|
var clearNumber = function () {
|
|
103
104
|
emailControl.field.onChange('');
|
|
104
105
|
};
|
|
105
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('signup_email_lable'), value: emailValue, onEnterPressed: function (e) { return e.preventDefault(); }, onChange: handleEmailChange, type: 'email', placeholder: t('signup_email_placeholder'), warningType: 'alert', warningMessage:
|
|
106
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(InputStyled, { label: t('signup_email_lable'), value: emailValue, onEnterPressed: function (e) { return e.preventDefault(); }, onChange: handleEmailChange, type: 'email', placeholder: t('signup_email_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: emailChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && emailValue ? (_jsx(CheckIcon, {})) : (emailValue && _jsx(ClearIcon, { onClick: clearNumber })) }) }) })));
|
|
106
107
|
};
|
|
107
108
|
export default React.memo(Email);
|
|
@@ -35,22 +35,19 @@ var FormStyled = styled(Form)(function () { return ({
|
|
|
35
35
|
}); });
|
|
36
36
|
var Individual = function (_a) {
|
|
37
37
|
var _b, _c, _d;
|
|
38
|
-
var _e = React.useState(false),
|
|
39
|
-
var _f = React.useState(false),
|
|
40
|
-
var _g =
|
|
41
|
-
var _h = useSelector(connectSelector), data = _h.data, loading = _h.loading, error = _h.error;
|
|
42
|
-
var _j = React.useState(data.individualData.countryCode.digits), mobileLength = _j[0], setMobileLength = _j[1];
|
|
38
|
+
var _e = React.useState(false), listActive = _e[0], setListActive = _e[1];
|
|
39
|
+
var _f = React.useState(false), emailChecking = _f[0], setEmailChecking = _f[1];
|
|
40
|
+
var _g = useSelector(connectSelector), data = _g.data, loading = _g.loading, error = _g.error;
|
|
43
41
|
var dispatch = useAppDispatch();
|
|
44
42
|
var t = useTranslation().t;
|
|
45
43
|
var isAr = useLanguage().isAr;
|
|
46
44
|
var isAbsher = (_b = data.otpData) === null || _b === void 0 ? void 0 : _b.isAbsher;
|
|
47
45
|
var individualData = data.individualData;
|
|
48
46
|
var methods = useForm({
|
|
49
|
-
resolver: yupResolver(isAbsher ? IndividualMobileValidation
|
|
47
|
+
resolver: yupResolver(isAbsher ? IndividualMobileValidation : IndividualValidation),
|
|
50
48
|
defaultValues: data.individualData,
|
|
51
49
|
mode: 'onChange'
|
|
52
50
|
});
|
|
53
|
-
var countryCodeSA = methods.getValues('countryCode').iso2 === 'SA';
|
|
54
51
|
var onSubmit = function (formData) {
|
|
55
52
|
dispatch(updateLeadIndividual(formData));
|
|
56
53
|
};
|
|
@@ -81,11 +78,8 @@ var Individual = function (_a) {
|
|
|
81
78
|
if (((_b = (_a = data.individualData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.is_available) === false)
|
|
82
79
|
methods.setError('email', { message: 'tap_js_email_already_exist' });
|
|
83
80
|
}, [(_c = data.individualData) === null || _c === void 0 ? void 0 : _c.responseBody]);
|
|
84
|
-
React.useEffect(function () {
|
|
85
|
-
setIsSA(countryCodeSA);
|
|
86
|
-
}, [countryCodeSA]);
|
|
87
81
|
var emailErrChecks = !methods.formState.isValid || !!methods.formState.errors.email || !!error;
|
|
88
82
|
var disabled = emailErrChecks || emailChecking || !((_d = data.individualData.responseBody) === null || _d === void 0 ? void 0 : _d.is_available);
|
|
89
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, { show: !listActive }), _jsx(MobileNumber, {
|
|
83
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, { show: !listActive }), _jsx(MobileNumber, { show: isAbsher, onListOpen: function () { return handleMenuListClick(); }, onListClose: function () { return handleMenuListClick(); }, countries: countriesCode }), _jsx(Email, { show: !listActive, fetchingEmail: function (v) { return setEmailChecking(v); }, emailChecking: emailChecking }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
|
|
90
84
|
};
|
|
91
85
|
export default React.memo(Individual);
|
|
@@ -87,6 +87,8 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
87
87
|
var error = (_d = phoneControl.fieldState.error) === null || _d === void 0 ? void 0 : _d.message;
|
|
88
88
|
var isSA = countryCodeValue.iso2 === 'SA';
|
|
89
89
|
var mobileLen = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits;
|
|
90
|
+
var isStartsWith5 = mobileValue.startsWith('5');
|
|
91
|
+
var requiredLen = isSA && isStartsWith5 ? mobileLen - 1 : mobileLen;
|
|
90
92
|
React.useEffect(function () {
|
|
91
93
|
if (mobileValue)
|
|
92
94
|
setValue('mobile', mobileValue, { shouldValidate: true });
|
|
@@ -110,13 +112,11 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
110
112
|
anchorEl ? (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest) : (_b = rest.onListOpen) === null || _b === void 0 ? void 0 : _b.call(rest);
|
|
111
113
|
};
|
|
112
114
|
var onSelectItem = function (country) {
|
|
113
|
-
var _a;
|
|
114
115
|
onCloseCountryList();
|
|
115
116
|
setValue('mobile', '');
|
|
116
117
|
countryCodeControl.field.onChange(country);
|
|
117
|
-
(_a = rest.setMobileLength) === null || _a === void 0 ? void 0 : _a.call(rest, country.digits);
|
|
118
118
|
};
|
|
119
|
-
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mb: 3 }
|
|
119
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: { mb: 3 } }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(Input, { sx: { direction: 'ltr' }, inputProps: { maxLength: requiredLen }, type: 'tel', onChange: onPhoneNumberChange, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () { return toggleCountryList(); } }, { children: ["+".concat(countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix), !anchorEl && _jsx(ExpandIconStyled, { anchorEl: !!anchorEl })] })), endAdornment: !!anchorEl ? (_jsx(ExpandIconStyled, { onClick: function () { return toggleCountryList(); }, anchorEl: !!anchorEl })) : !error && mobileValue ? (_jsx(CheckIcon, {})) : (mobileValue && _jsx(ClearIcon, { onClick: clearMobileNumber })), placeholder: "".concat(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: error && t(error, { length: requiredLen, number: '0|5' }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
120
120
|
return (_jsxs(_Fragment, { children: [_jsxs(CountryItemContainer, { children: [_jsxs(CountryCodeText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: ["+", item.idd_prefix] })), _jsx(CountryNameText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: isAr ? item.name.arabic : item.name.english }))] }), item.idd_prefix === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) && _jsx(CheckIcon, {})] }));
|
|
121
121
|
} }) }))] })) })));
|
|
122
122
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
export declare const IndividualValidation:
|
|
2
|
+
export declare const IndividualValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
3
|
name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
4
|
email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
5
5
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
@@ -9,7 +9,7 @@ export declare const IndividualValidation: () => yup.ObjectSchema<import("yup/li
|
|
|
9
9
|
name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
10
10
|
email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
11
11
|
}>>>;
|
|
12
|
-
export declare const IndividualMobileValidation:
|
|
12
|
+
export declare const IndividualMobileValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
13
13
|
name: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
14
14
|
email: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
15
15
|
mobile: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
@@ -1,25 +1,41 @@
|
|
|
1
|
-
import { REGEX_FULL_NAME
|
|
1
|
+
import { REGEX_FULL_NAME } from '../../../../constants';
|
|
2
2
|
import * as yup from 'yup';
|
|
3
|
-
export var IndividualValidation =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
name
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.
|
|
21
|
-
.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
3
|
+
export var IndividualValidation = yup.object().shape({
|
|
4
|
+
name: yup
|
|
5
|
+
.string()
|
|
6
|
+
.matches(REGEX_FULL_NAME, 'please write your first and last name')
|
|
7
|
+
.required('please write your first and last name'),
|
|
8
|
+
email: yup.string().email('email_not_valid').required('email_not_valid')
|
|
9
|
+
});
|
|
10
|
+
export var IndividualMobileValidation = yup.object().shape({
|
|
11
|
+
name: yup
|
|
12
|
+
.string()
|
|
13
|
+
.matches(REGEX_FULL_NAME, 'please write your first and last name')
|
|
14
|
+
.required('please write your first and last name'),
|
|
15
|
+
email: yup.string().email('email_not_valid').required('email_not_valid'),
|
|
16
|
+
mobile: yup
|
|
17
|
+
.string()
|
|
18
|
+
.test({
|
|
19
|
+
test: function (value) {
|
|
20
|
+
var countryCode = this.parent.countryCode;
|
|
21
|
+
var isSA = countryCode.iso2 === 'SA';
|
|
22
|
+
var digits = countryCode.digits;
|
|
23
|
+
var mobileValue = value || '';
|
|
24
|
+
var valueLen = mobileValue.length;
|
|
25
|
+
var isNumber = mobileValue.match(/^[0-9]/g);
|
|
26
|
+
if (!isNumber)
|
|
27
|
+
return this.createError({ message: 'enter_valid_mobile_number' });
|
|
28
|
+
var isStartWithZero = mobileValue.startsWith('0');
|
|
29
|
+
var isStartWith5 = mobileValue.startsWith('5');
|
|
30
|
+
var isSaudiNumber = isStartWith5 || isStartWithZero;
|
|
31
|
+
if (isSA) {
|
|
32
|
+
if (!isSaudiNumber)
|
|
33
|
+
return this.createError({ message: 'start_with_number' });
|
|
34
|
+
var requiredLen = isStartWith5 ? digits - 1 : digits;
|
|
35
|
+
return valueLen === requiredLen ? true : this.createError({ message: 'enter_valid_mobile_number' });
|
|
36
|
+
}
|
|
37
|
+
return valueLen === digits ? true : this.createError({ message: 'enter_valid_mobile_number' });
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
.required('mobile_number_error')
|
|
41
|
+
});
|
|
@@ -32,7 +32,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
32
32
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
33
33
|
import * as React from 'react';
|
|
34
34
|
import { useTranslation } from 'react-i18next';
|
|
35
|
-
import { useFormContext } from 'react-hook-form';
|
|
36
35
|
import Box from '@mui/material/Box';
|
|
37
36
|
import { styled } from '@mui/material/styles';
|
|
38
37
|
import { useLanguage } from '../../../../hooks';
|
|
@@ -63,7 +62,6 @@ var BrandList = function (_a) {
|
|
|
63
62
|
var _d = React.useState(null), anchorEl = _d[0], setAnchorEl = _d[1];
|
|
64
63
|
var t = useTranslation().t;
|
|
65
64
|
var isAr = useLanguage().isAr;
|
|
66
|
-
var setValue = useFormContext().setValue;
|
|
67
65
|
var onOpenBrandList = function (event) {
|
|
68
66
|
var _a;
|
|
69
67
|
setAnchorEl(event.currentTarget);
|
|
@@ -81,7 +79,6 @@ var BrandList = function (_a) {
|
|
|
81
79
|
var first = array[0];
|
|
82
80
|
if (first) {
|
|
83
81
|
setSelectedBrand(first);
|
|
84
|
-
setValue('brandName', getBrandName(first), { shouldValidate: true });
|
|
85
82
|
if (!hasOther)
|
|
86
83
|
array = __spreadArray(__spreadArray([], array, true), [OTHER_BRAND], false);
|
|
87
84
|
setBrandList(array);
|
|
@@ -103,11 +100,9 @@ var BrandList = function (_a) {
|
|
|
103
100
|
setSelectedBrand(brand);
|
|
104
101
|
onCloseBrandList();
|
|
105
102
|
if (isOtherLicense(brand)) {
|
|
106
|
-
setValue('brandName', '', { shouldValidate: true });
|
|
107
103
|
(_a = rest.showTerms) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
108
104
|
return;
|
|
109
105
|
}
|
|
110
|
-
setValue('brandName', getBrandName(brand), { shouldValidate: true });
|
|
111
106
|
(_b = rest.hideTerms) === null || _b === void 0 ? void 0 : _b.call(rest);
|
|
112
107
|
};
|
|
113
108
|
var hasList = (brandList === null || brandList === void 0 ? void 0 : brandList.length) > 0;
|
|
@@ -56,6 +56,7 @@ import { styled, alpha } from '@mui/material/styles';
|
|
|
56
56
|
import InfoIcon from '@mui/icons-material/Info';
|
|
57
57
|
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
|
|
58
58
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
59
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
59
60
|
import Text from '../../../../components/Text';
|
|
60
61
|
import Input from '../../../shared/Input';
|
|
61
62
|
import ClearIcon from '../../../shared/ClearIcon';
|
|
@@ -137,6 +138,6 @@ var BrandName = function (_a) {
|
|
|
137
138
|
var clearBrandName = function () {
|
|
138
139
|
brandControl.field.onChange('');
|
|
139
140
|
};
|
|
140
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb:
|
|
141
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t('signup_brand_name_label') }), _jsx(Tooltip, __assign({ title: t('brand_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsx(Input, { onChange: handleBrandNameChange, value: brandNameValue, placeholder: t('signup_brand_name_placeholder'), warningType: 'alert', warningMessage: error && t(error), endAdornment: brandNameChecking ? (_jsx(CircularProgress, { size: 25, thickness: 5, sx: { height: 'auto !important' } })) : !error && brandNameValue ? (_jsx(CheckIcon, {})) : (brandNameValue && _jsx(ClearIcon, { onClick: clearBrandName })) })] })) })));
|
|
141
142
|
};
|
|
142
143
|
export default React.memo(BrandName);
|
|
@@ -33,9 +33,9 @@ var Merchant = function (_a) {
|
|
|
33
33
|
var _j = React.useState(false), brandNameChecking = _j[0], setBrandNameChecking = _j[1];
|
|
34
34
|
var _k = useSelector(connectSelector), data = _k.data, loading = _k.loading, error = _k.error;
|
|
35
35
|
var isNewUser = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.new_user;
|
|
36
|
-
var _l = React.useState(isNewUser),
|
|
36
|
+
var _l = React.useState(isNewUser), isOther = _l[0], setIsOther = _l[1];
|
|
37
37
|
var methods = useForm({
|
|
38
|
-
resolver: yupResolver(MerchantValidationSchema(
|
|
38
|
+
resolver: yupResolver(MerchantValidationSchema(isOther)),
|
|
39
39
|
defaultValues: data.brandData,
|
|
40
40
|
mode: 'onChange'
|
|
41
41
|
});
|
|
@@ -54,6 +54,14 @@ var Merchant = function (_a) {
|
|
|
54
54
|
}
|
|
55
55
|
dispatch(handlePrevScreenStep(isAbsher ? 'CONNECT_NID_STEP' : 'CONNECT_MOBILE_STEP'));
|
|
56
56
|
};
|
|
57
|
+
React.useEffect(function () {
|
|
58
|
+
if (!isNewUser) {
|
|
59
|
+
methods.setValue('brandName', '', { shouldValidate: true });
|
|
60
|
+
methods.setValue('termAndConditionChecked', false, {
|
|
61
|
+
shouldValidate: true
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, [isOther]);
|
|
57
65
|
React.useEffect(function () {
|
|
58
66
|
if (error)
|
|
59
67
|
dispatch(clearError());
|
|
@@ -66,6 +74,6 @@ var Merchant = function (_a) {
|
|
|
66
74
|
var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
|
|
67
75
|
var disabled = brandErrChecks || brandNameChecking || ((_e = (_d = data.brandData) === null || _d === void 0 ? void 0 : _d.responseBody) === null || _e === void 0 ? void 0 : _e.response_code) === '5';
|
|
68
76
|
var showBrandList = ((_g = (((_f = data.brandData) === null || _f === void 0 ? void 0 : _f.brandList) || [])) === null || _g === void 0 ? void 0 : _g.length) > 0 && !isNewUser;
|
|
69
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: showBrandList, list: ((_h = data.brandData) === null || _h === void 0 ? void 0 : _h.brandList) || [], onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); }, showTerms: function () { return
|
|
77
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: showBrandList, list: ((_h = data.brandData) === null || _h === void 0 ? void 0 : _h.brandList) || [], onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); }, showTerms: function () { return setIsOther(true); }, hideTerms: function () { return setIsOther(false); } }), _jsx(BrandName, { show: !listActive && isOther, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(SocialMedia, { show: !listActive, sx: !isOther ? { mb: 0 } : {} }), _jsx(TAC, { show: !listActive && isOther }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
|
|
70
78
|
};
|
|
71
79
|
export default React.memo(Merchant);
|
|
@@ -79,7 +79,7 @@ var SocialMedia = function (_a) {
|
|
|
79
79
|
var websiteError = (_b = errors === null || errors === void 0 ? void 0 : errors.website) === null || _b === void 0 ? void 0 : _b.message;
|
|
80
80
|
var twitterError = (_c = errors === null || errors === void 0 ? void 0 : errors.twitter) === null || _c === void 0 ? void 0 : _c.message;
|
|
81
81
|
var instagramError = (_d = errors === null || errors === void 0 ? void 0 : errors.instagram) === null || _d === void 0 ? void 0 : _d.message;
|
|
82
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: __assign({ mb: 3, direction: 'ltr' }, sx) }, { children: [_jsx(SocialMediaGroupStyled, { defaultValue: socialMediaType, exclusive: true, onChange: function (e, value) {
|
|
82
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: __assign({ mt: 3, mb: 3, direction: 'ltr' }, sx) }, { children: [_jsx(SocialMediaGroupStyled, { defaultValue: socialMediaType, exclusive: true, onChange: function (e, value) {
|
|
83
83
|
setSocialMediaType(value);
|
|
84
84
|
} }), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.WEB, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: websiteValue, startAdornment: _jsx(TextStyled, { children: "https://" }), placeholder: t('signup_website_placeholder'), warningType: 'alert', warningMessage: websiteError && t(websiteError), endAdornment: !websiteError && websiteValue ? _jsx(CheckIcon, {}) : websiteValue && _jsx(ClearIconStyled, { onClick: handleClear }) }) })), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.TWITTER, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: twitterValue, startAdornment: _jsx(TextStyled, { children: "@" }), placeholder: t('signup_twitter_placeholder'), warningType: 'alert', warningMessage: twitterError && t(twitterError), endAdornment: !twitterError && twitterValue ? _jsx(CheckIcon, {}) : twitterValue && _jsx(ClearIconStyled, { onClick: handleClear }) }) })), _jsx(Collapse, __assign({ in: socialMediaType === SocialMediaTypes.INSTAGRAM, timeout: 300 }, { children: _jsx(InputStyled, { onChange: handleChange, value: instagramValue, startAdornment: _jsx(TextStyled, { children: "@" }), placeholder: t('signup_instagram_placeholder'), warningType: 'alert', warningMessage: instagramError && t(instagramError), endAdornment: !instagramError && instagramValue ? (_jsx(CheckIcon, {})) : (instagramValue && _jsx(ClearIconStyled, { onClick: handleClear })) }) }))] })) })));
|
|
85
85
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
export declare const MerchantValidationSchema: (
|
|
3
|
-
brandName:
|
|
2
|
+
export declare const MerchantValidationSchema: (isOther: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
4
4
|
termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, boolean | undefined>;
|
|
5
5
|
links: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
6
6
|
website: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
@@ -16,7 +16,7 @@ export declare const MerchantValidationSchema: (termsIsRequired: boolean) => yup
|
|
|
16
16
|
twitter: yup.StringSchema<string | null | undefined, import("yup/lib/types").AnyObject, string | null | undefined>;
|
|
17
17
|
}>>>;
|
|
18
18
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
19
|
-
brandName:
|
|
19
|
+
brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
20
20
|
termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, boolean | undefined>;
|
|
21
21
|
links: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
22
22
|
website: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
@@ -32,7 +32,7 @@ export declare const MerchantValidationSchema: (termsIsRequired: boolean) => yup
|
|
|
32
32
|
twitter: yup.StringSchema<string | null | undefined, import("yup/lib/types").AnyObject, string | null | undefined>;
|
|
33
33
|
}>>>;
|
|
34
34
|
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
35
|
-
brandName:
|
|
35
|
+
brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
36
36
|
termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, boolean | undefined>;
|
|
37
37
|
links: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
38
38
|
website: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { REGEX_WEBSITE } from '../../../../constants';
|
|
2
2
|
import * as yup from 'yup';
|
|
3
|
-
export var MerchantValidationSchema = function (
|
|
3
|
+
export var MerchantValidationSchema = function (isOther) {
|
|
4
4
|
return yup.object().shape({
|
|
5
|
-
brandName:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
brandName: isOther
|
|
6
|
+
? yup
|
|
7
|
+
.string()
|
|
8
|
+
.min(3, 'enter_brand_name_english_chars_numbers_space')
|
|
9
|
+
.max(250, 'enter_brand_name_english_chars_numbers_space')
|
|
10
|
+
.required('enter_valid_brand_name')
|
|
11
|
+
: yup.string().optional(),
|
|
12
|
+
termAndConditionChecked: isOther ? yup.boolean().required().isTrue('check_terms_cond') : yup.boolean().optional(),
|
|
13
13
|
links: yup.object().shape({
|
|
14
14
|
website: yup.string().when(['instagram', 'twitter'], function (instagram, twitter) {
|
|
15
15
|
if (!instagram && !twitter) {
|
|
@@ -75,18 +75,15 @@ var ListType;
|
|
|
75
75
|
var Mobile = function (_a) {
|
|
76
76
|
var settingsStore = useSelector(settingsSelector);
|
|
77
77
|
var _b = useSelector(connectSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
78
|
-
var _c = React.useState(
|
|
79
|
-
var _d = React.useState(), listType = _d[0], setListType = _d[1];
|
|
80
|
-
var _e = React.useState(false), isSA = _e[0], setIsSA = _e[1];
|
|
78
|
+
var _c = React.useState(), listType = _c[0], setListType = _c[1];
|
|
81
79
|
var dispatch = useAppDispatch();
|
|
82
80
|
var methods = useForm({
|
|
83
|
-
resolver: yupResolver(PhoneValidationSchema
|
|
81
|
+
resolver: yupResolver(PhoneValidationSchema),
|
|
84
82
|
defaultValues: data.mobileData,
|
|
85
83
|
mode: 'onChange'
|
|
86
84
|
});
|
|
87
85
|
var t = useTranslation().t;
|
|
88
86
|
var isAr = useLanguage().isAr;
|
|
89
|
-
var countryCodeSA = methods.getValues('countryCode').iso2 === 'SA';
|
|
90
87
|
var handleMenuListClick = function (flag) {
|
|
91
88
|
setListType(flag);
|
|
92
89
|
};
|
|
@@ -95,9 +92,6 @@ var Mobile = function (_a) {
|
|
|
95
92
|
methods.setValue('countryCode', data.mobileData.countryCode);
|
|
96
93
|
}
|
|
97
94
|
}, [data.mobileData]);
|
|
98
|
-
React.useEffect(function () {
|
|
99
|
-
setIsSA(countryCodeSA);
|
|
100
|
-
}, [countryCodeSA]);
|
|
101
95
|
React.useEffect(function () {
|
|
102
96
|
if (error)
|
|
103
97
|
dispatch(clearError());
|
|
@@ -112,6 +106,6 @@ var Mobile = function (_a) {
|
|
|
112
106
|
var isCountryListActive = listType === ListType.CountryCodeList;
|
|
113
107
|
var listActive = isBusinessListActive || isCountryListActive;
|
|
114
108
|
var disabled = !methods.formState.isValid || !!error;
|
|
115
|
-
return (_jsxs(ScreenContainer, { children: [_jsx(MIDTitle, { show: !listActive, title: t('join_our_community'), description: t('ide_terms_and_conditions_description') }), _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputsContainerStyled, { children: _jsx(MobileNumber, { show: !isBusinessListActive,
|
|
109
|
+
return (_jsxs(ScreenContainer, { children: [_jsx(MIDTitle, { show: !listActive, title: t('join_our_community'), description: t('ide_terms_and_conditions_description') }), _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(InputsContainerStyled, { children: _jsx(MobileNumber, { show: !isBusinessListActive, countries: data.countries, onListOpen: function () { return handleMenuListClick(ListType.CountryCodeList); }, onListClose: function () { return handleMenuListClick(); } }) }), _jsxs(Collapse, __assign({ in: !listActive }, { children: [_jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, loading: loading, error: t(error || '') }, { children: t('next') })), _jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(AbsherButton, __assign({ disabled: settingsStore.loading || loading, onClick: function () { return onBack(); }, isAr: isAr }, { children: t('absher_button_label') }))] }))] })) }))] }));
|
|
116
110
|
};
|
|
117
111
|
export default React.memo(Mobile);
|
|
@@ -87,6 +87,8 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
87
87
|
var error = (_d = phoneControl.fieldState.error) === null || _d === void 0 ? void 0 : _d.message;
|
|
88
88
|
var isSA = countryCodeValue.iso2 === 'SA';
|
|
89
89
|
var mobileLen = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits;
|
|
90
|
+
var isStartsWith5 = mobileValue.startsWith('5');
|
|
91
|
+
var requiredLen = isSA && isStartsWith5 ? mobileLen - 1 : mobileLen;
|
|
90
92
|
React.useEffect(function () {
|
|
91
93
|
if (mobileValue)
|
|
92
94
|
setValue('mobile', mobileValue, { shouldValidate: true });
|
|
@@ -110,13 +112,11 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
|
110
112
|
anchorEl ? (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest) : (_b = rest.onListOpen) === null || _b === void 0 ? void 0 : _b.call(rest);
|
|
111
113
|
};
|
|
112
114
|
var onSelectItem = function (country) {
|
|
113
|
-
var _a;
|
|
114
115
|
onCloseCountryList();
|
|
115
116
|
setValue('mobile', '');
|
|
116
117
|
countryCodeControl.field.onChange(country);
|
|
117
|
-
(_a = rest.setMobileLength) === null || _a === void 0 ? void 0 : _a.call(rest, country.digits);
|
|
118
118
|
};
|
|
119
|
-
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(Input, { sx: { direction: 'ltr' }, inputProps: { maxLength:
|
|
119
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(Input, { sx: { direction: 'ltr' }, inputProps: { maxLength: requiredLen }, type: 'tel', onChange: onPhoneNumberChange, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () { return toggleCountryList(); } }, { children: ["+".concat(countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix), !anchorEl && _jsx(ExpandIconStyled, { anchorEl: !!anchorEl })] })), endAdornment: !!anchorEl ? (_jsx(ExpandIconStyled, { onClick: function () { return toggleCountryList(); }, anchorEl: !!anchorEl })) : !error && mobileValue ? (_jsx(CheckIcon, {})) : (mobileValue && _jsx(ClearIcon, { onClick: clearMobileNumber })), placeholder: "".concat(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: error && t(error, { length: requiredLen, number: '0|5' }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
120
120
|
return (_jsxs(_Fragment, { children: [_jsxs(CountryItemContainer, { children: [_jsxs(CountryCodeText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: ["+", item.idd_prefix] })), _jsx(CountryNameText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: isAr ? item.name.arabic : item.name.english }))] }), item.idd_prefix === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) && _jsx(CheckIcon, {})] }));
|
|
121
121
|
} }) }))] })) })));
|
|
122
122
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
export declare const PhoneValidationSchema:
|
|
2
|
+
export declare const PhoneValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
3
|
mobile: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
4
|
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
5
5
|
mobile: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
import { REGEX_SAUDI_NUMBER } from '../../../../constants';
|
|
2
1
|
import * as yup from 'yup';
|
|
3
|
-
export var PhoneValidationSchema =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
export var PhoneValidationSchema = yup.object().shape({
|
|
3
|
+
mobile: yup
|
|
4
|
+
.string()
|
|
5
|
+
.test({
|
|
6
|
+
test: function (value) {
|
|
7
|
+
var countryCode = this.parent.countryCode;
|
|
8
|
+
var isSA = countryCode.iso2 === 'SA';
|
|
9
|
+
var digits = countryCode.digits;
|
|
10
|
+
var mobileValue = value || '';
|
|
11
|
+
var valueLen = mobileValue.length;
|
|
12
|
+
var isNumber = mobileValue.match(/^[0-9]/g);
|
|
13
|
+
if (!isNumber)
|
|
14
|
+
return this.createError({ message: 'enter_valid_mobile_number' });
|
|
15
|
+
var isStartWithZero = mobileValue.startsWith('0');
|
|
16
|
+
var isStartWith5 = mobileValue.startsWith('5');
|
|
17
|
+
var isSaudiNumber = isStartWith5 || isStartWithZero;
|
|
18
|
+
if (isSA) {
|
|
19
|
+
if (!isSaudiNumber)
|
|
20
|
+
return this.createError({ message: 'start_with_number' });
|
|
21
|
+
var requiredLen = isStartWith5 ? digits - 1 : digits;
|
|
22
|
+
return valueLen === requiredLen ? true : this.createError({ message: 'enter_valid_mobile_number' });
|
|
23
|
+
}
|
|
24
|
+
return valueLen === digits ? true : this.createError({ message: 'enter_valid_mobile_number' });
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
.required('mobile_number_error')
|
|
28
|
+
});
|
|
@@ -21,7 +21,7 @@ import { useAppDispatch, useLanguage } from '../../../../hooks';
|
|
|
21
21
|
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
22
22
|
import { clearError, connectSelector, createNIDAuth } from '../../../app/connect/connectStore';
|
|
23
23
|
import Form from '../../../../components/Form';
|
|
24
|
-
import Button, {
|
|
24
|
+
import Button, { MobileButton } from '../../../shared/Button';
|
|
25
25
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
26
26
|
import Collapse from '../../../../components/Collapse';
|
|
27
27
|
import Box from '@mui/material/Box';
|
|
@@ -86,6 +86,6 @@ var NID = function (_a) {
|
|
|
86
86
|
dispatch(handlePrevScreenStep('CONNECT_MOBILE_STEP'));
|
|
87
87
|
};
|
|
88
88
|
var disabled = !methods.formState.isValid || !!error;
|
|
89
|
-
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(IDNumber, { show: !collapse }) })), _jsx(DOB, { onDateClicked: handleCollapseOpenClose }), _jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') })), _jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(
|
|
89
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Collapse, __assign({ in: !collapse }, { children: _jsx(IDNumber, { show: !collapse }) })), _jsx(DOB, { onDateClicked: handleCollapseOpenClose }), _jsxs(Collapse, __assign({ in: !collapse }, { children: [_jsx(Button, __assign({ loading: loading, isAr: isAr, disableBack: true, disabled: disabled || settingsStore.loading, error: t(error || '') }, { children: t('next') })), _jsxs(OrBoxStyled, { children: [_jsx(DividerStyled, {}), _jsx(TextStyled, { children: t('or') }), _jsx(DividerStyled, {})] }), _jsx(MobileButton, __assign({ onClick: function () { return onBack(); }, disabled: loading || settingsStore.loading, isAr: isAr }, { children: t('mobile_button_label') }))] }))] })) })) }));
|
|
90
90
|
};
|
|
91
91
|
export default React.memo(NID);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonProps } from '../../../components/Button';
|
|
3
|
+
interface MobileButtonProps extends ButtonProps {
|
|
4
|
+
isAr: boolean;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
hideIcon?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export default function MobileButton({ children, isAr, hideIcon, disabled, ...props }: MobileButtonProps): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import Button from '../../../components/Button';
|
|
25
|
+
import Icon from '../../../components/Icon';
|
|
26
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
27
|
+
import Box from '@mui/material/Box';
|
|
28
|
+
import { ICONS_NAMES } from '../../../constants';
|
|
29
|
+
var IconStyled = styled(Icon, { shouldForwardProp: function (prop) { return prop !== 'disabled'; } })(function (_a) {
|
|
30
|
+
var theme = _a.theme, disabled = _a.disabled;
|
|
31
|
+
return (__assign({ width: theme.spacing(3), height: theme.spacing(3), marginInlineStart: theme.spacing(0.75) }, (disabled && {
|
|
32
|
+
opacity: 0.3
|
|
33
|
+
})));
|
|
34
|
+
});
|
|
35
|
+
var ButtonBoxStyled = styled(Box)(function (_a) {
|
|
36
|
+
var theme = _a.theme;
|
|
37
|
+
return ({
|
|
38
|
+
margin: theme.spacing(0, 2.5, 2.5, 2.5)
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
var ButtonStyled = styled(Button)(function (_a) {
|
|
42
|
+
var theme = _a.theme;
|
|
43
|
+
return ({
|
|
44
|
+
paddingInlineStart: theme.spacing(0.75),
|
|
45
|
+
backgroundColor: theme.palette.common.white,
|
|
46
|
+
border: "1px solid ".concat(theme.palette.primary.main),
|
|
47
|
+
color: theme.palette.primary.main,
|
|
48
|
+
'&:hover': {
|
|
49
|
+
backgroundColor: theme.palette.primary.main,
|
|
50
|
+
color: theme.palette.common.white,
|
|
51
|
+
img: {
|
|
52
|
+
filter: 'brightness(0) invert(1)'
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
'&:active': {
|
|
56
|
+
backgroundColor: theme.palette.common.white
|
|
57
|
+
},
|
|
58
|
+
'&:disabled': {
|
|
59
|
+
backgroundColor: theme.palette.common.white,
|
|
60
|
+
color: alpha(theme.palette.primary.main, 0.3)
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
export default function MobileButton(_a) {
|
|
65
|
+
var children = _a.children, isAr = _a.isAr, hideIcon = _a.hideIcon, disabled = _a.disabled, props = __rest(_a, ["children", "isAr", "hideIcon", "disabled"]);
|
|
66
|
+
return (_jsx(ButtonBoxStyled, { children: _jsx(ButtonStyled, __assign({ disabled: disabled, type: 'button', startIcon: !hideIcon && _jsx(IconStyled, { disabled: disabled, src: ICONS_NAMES.MOBILE_ICON }) }, props, { children: children })) }));
|
|
67
|
+
}
|