@tap-payments/auth-jsconnect 2.1.99-test → 2.1.100-test
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/form.d.ts +4 -2
- package/build/constants/app.d.ts +1 -0
- package/build/constants/app.js +18 -1
- package/build/features/app/individual/individualStore.d.ts +9 -2
- package/build/features/app/individual/individualStore.js +141 -66
- package/build/features/featuresScreens.js +5 -0
- package/build/features/individual/screens/IndividualPhoneInfo/MobileNumber.d.ts +12 -0
- package/build/features/individual/screens/IndividualPhoneInfo/MobileNumber.js +143 -0
- package/build/features/individual/screens/IndividualPhoneInfo/PhoneInfo.d.ts +5 -0
- package/build/features/individual/screens/IndividualPhoneInfo/PhoneInfo.js +60 -0
- package/build/features/individual/screens/IndividualPhoneInfo/index.d.ts +3 -0
- package/build/features/individual/screens/IndividualPhoneInfo/index.js +2 -0
- package/build/features/individual/screens/IndividualPhoneInfo/validation.d.ts +8 -0
- package/build/features/individual/screens/IndividualPhoneInfo/validation.js +31 -0
- package/package.json +1 -1
package/build/@types/form.d.ts
CHANGED
|
@@ -77,11 +77,13 @@ export declare type TaxFormValues = {
|
|
|
77
77
|
confirmPolicy: false;
|
|
78
78
|
documentId?: Array<string>;
|
|
79
79
|
};
|
|
80
|
-
export interface
|
|
81
|
-
email: string;
|
|
80
|
+
export interface IndividualMobileFormValues {
|
|
82
81
|
mobile: string | null;
|
|
83
82
|
countryCode: CountryCode;
|
|
84
83
|
}
|
|
84
|
+
export interface IndividualEmailMobileFormValues extends IndividualMobileFormValues {
|
|
85
|
+
email: string;
|
|
86
|
+
}
|
|
85
87
|
export interface IndividualPersonalInfoFormValues extends IndividualEmailMobileFormValues {
|
|
86
88
|
name: string;
|
|
87
89
|
gender: string | null;
|
package/build/constants/app.d.ts
CHANGED
package/build/constants/app.js
CHANGED
|
@@ -241,7 +241,23 @@ export var BUSINESS_SCREENS_NAVIGATION = [
|
|
|
241
241
|
export var INDIVIDUAL_SCREENS_NAVIGATION = [
|
|
242
242
|
{
|
|
243
243
|
name: 'INDIVIDUAL_VERIFY_STEP',
|
|
244
|
-
next: [
|
|
244
|
+
next: [
|
|
245
|
+
'INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP',
|
|
246
|
+
'INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
|
|
247
|
+
'INDIVIDUAL_LIST_STEP',
|
|
248
|
+
'INDIVIDUAL_PHONE_INFO_STEP'
|
|
249
|
+
],
|
|
250
|
+
prev: '',
|
|
251
|
+
order: 1
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: 'INDIVIDUAL_PHONE_INFO_STEP',
|
|
255
|
+
next: [
|
|
256
|
+
'INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP',
|
|
257
|
+
'INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP',
|
|
258
|
+
'INDIVIDUAL_LIST_STEP',
|
|
259
|
+
'INDIVIDUAL_VERIFY_STEP'
|
|
260
|
+
],
|
|
245
261
|
prev: '',
|
|
246
262
|
order: 1
|
|
247
263
|
},
|
|
@@ -626,6 +642,7 @@ export var TAX_STEP_NAMES = {
|
|
|
626
642
|
TAX_SUCCESS: 'tax_completed'
|
|
627
643
|
};
|
|
628
644
|
export var INDIVIDUAl_STEP_NAMES = {
|
|
645
|
+
PHONE_INFO: 'phone_info',
|
|
629
646
|
PHONE_AUTH: 'individual_phone_auth',
|
|
630
647
|
INDIVIDUAl_PERSONAL_INFO: 'individual_personal_info',
|
|
631
648
|
INDIVIDUAl_INFO: 'individual_info',
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { RootState } from '../../../app/store';
|
|
2
|
-
import { CountryCode, FlowsTypes, IndividualExtraFormValues, OTPFormValues, ResponseData, SharedState, ActionState, User, IndividualPersonalInfoFormValues, IndividualEmailMobileFormValues } from '../../../@types';
|
|
2
|
+
import { CountryCode, FlowsTypes, IndividualExtraFormValues, OTPFormValues, ResponseData, SharedState, ActionState, User, IndividualPersonalInfoFormValues, IndividualEmailMobileFormValues, IndividualMobileFormValues } from '../../../@types';
|
|
3
3
|
import { CancelToken } from 'axios';
|
|
4
4
|
interface VerifyLeadTokenProps {
|
|
5
5
|
token: string;
|
|
6
6
|
isInternally?: boolean;
|
|
7
|
+
isUpdatePhoneInfo?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const verifyToken: import("@reduxjs/toolkit").AsyncThunk<{
|
|
9
10
|
data: any;
|
|
10
11
|
boardResponse: {
|
|
11
12
|
brand: any;
|
|
@@ -23,6 +24,7 @@ export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
23
24
|
};
|
|
24
25
|
token: string;
|
|
25
26
|
}, VerifyLeadTokenProps, {}>;
|
|
27
|
+
export declare const verifyLeadToken: import("@reduxjs/toolkit").AsyncThunk<void, VerifyLeadTokenProps, {}>;
|
|
26
28
|
export declare const resendOTP: import("@reduxjs/toolkit").AsyncThunk<{
|
|
27
29
|
data: any;
|
|
28
30
|
}, void, {}>;
|
|
@@ -81,6 +83,10 @@ export declare const verifyLeadOTP: import("@reduxjs/toolkit").AsyncThunk<{
|
|
|
81
83
|
otp: string;
|
|
82
84
|
};
|
|
83
85
|
}, OTPFormValues, {}>;
|
|
86
|
+
export declare const updatePhoneInfo: import("@reduxjs/toolkit").AsyncThunk<{
|
|
87
|
+
data: any;
|
|
88
|
+
formData: IndividualMobileFormValues;
|
|
89
|
+
}, IndividualMobileFormValues, {}>;
|
|
84
90
|
export declare const updateIndividualPersonalInfo: import("@reduxjs/toolkit").AsyncThunk<{
|
|
85
91
|
data: any;
|
|
86
92
|
formData: IndividualPersonalInfoFormValues;
|
|
@@ -107,6 +113,7 @@ declare type VerifyData = {
|
|
|
107
113
|
export interface IndividualData {
|
|
108
114
|
verify: ResponseData & VerifyData;
|
|
109
115
|
otpData: OTPFormValues & ResponseData;
|
|
116
|
+
individualPhoneInfo: IndividualMobileFormValues & ResponseData;
|
|
110
117
|
individualCollectData: IndividualEmailMobileFormValues & ResponseData;
|
|
111
118
|
individualPersonalData: IndividualPersonalInfoFormValues & ResponseData;
|
|
112
119
|
individualData: IndividualExtraFormValues & ResponseData;
|
|
@@ -72,8 +72,8 @@ import { FlowsTypes, IndividualGender, IndividualType, FieldType } from '../../.
|
|
|
72
72
|
import { handleNextScreenStep, handleSetCountryByIso2 } from '../../../app/settings';
|
|
73
73
|
import { defaultCountry, IDENTIFICATION_TYPE, INDIVIDUAl_STEP_NAMES } from '../../../constants';
|
|
74
74
|
import { convertNumbers2English, dateFormat, findCountryByIddPrefix, findCountryByIso2, getEighteenYearsAgo, getUserNameObject, getUserName, sleep, isValidEmail } from '../../../utils';
|
|
75
|
-
export var
|
|
76
|
-
var token = _a.token, isInternally = _a.isInternally;
|
|
75
|
+
export var verifyToken = createAsyncThunk('individual/verifyToken', function (_a, thunkApi) {
|
|
76
|
+
var token = _a.token, isInternally = _a.isInternally, isUpdatePhoneInfo = _a.isUpdatePhoneInfo;
|
|
77
77
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
78
78
|
var payload, settings, data, boardData, individualData, countryCode, boardInfoData, boardInfoStatus, countries, board_id, board_info_id, notification, _b, id, type, payload_1, info, hasIndividualCompleted, birthCountry;
|
|
79
79
|
var _c, _d, _e, _f, _g, _h, _j, _k;
|
|
@@ -98,31 +98,35 @@ export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', funct
|
|
|
98
98
|
countryCode = data === null || data === void 0 ? void 0 : data.country_code;
|
|
99
99
|
thunkApi.dispatch(handleSetCountryByIso2(countryCode));
|
|
100
100
|
}
|
|
101
|
-
if (!(data.step_name
|
|
101
|
+
if (!(data.step_name === INDIVIDUAl_STEP_NAMES.PHONE_INFO)) return [3, 2];
|
|
102
|
+
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_PHONE_INFO_STEP'));
|
|
103
|
+
return [3, 17];
|
|
104
|
+
case 2:
|
|
105
|
+
if (!(data.step_name !== INDIVIDUAl_STEP_NAMES.PHONE_AUTH)) return [3, 16];
|
|
102
106
|
board_id = data === null || data === void 0 ? void 0 : data.id;
|
|
103
107
|
board_info_id = data === null || data === void 0 ? void 0 : data.board_info_id;
|
|
104
|
-
if (!(board_id && board_info_id)) return [3,
|
|
108
|
+
if (!(board_id && board_info_id)) return [3, 5];
|
|
105
109
|
return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
|
|
106
|
-
case
|
|
110
|
+
case 3:
|
|
107
111
|
boardInfoData = _l.sent();
|
|
108
112
|
notification = (boardInfoData || {}).notification;
|
|
109
113
|
_b = (notification === null || notification === void 0 ? void 0 : notification.recipient) || {}, id = _b.id, type = _b.type;
|
|
110
|
-
if (!(id && type)) return [3,
|
|
114
|
+
if (!(id && type)) return [3, 5];
|
|
111
115
|
return [4, thunkApi.dispatch(retrieveIndividualInfo({ id: id, type: type, countryCode: countryCode }))];
|
|
112
|
-
case
|
|
116
|
+
case 4:
|
|
113
117
|
payload_1 = (_l.sent()).payload;
|
|
114
118
|
individualData = payload_1.data || {};
|
|
115
|
-
_l.label =
|
|
116
|
-
case 4:
|
|
117
|
-
if (!board_id) return [3, 7];
|
|
118
|
-
return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
119
|
+
_l.label = 5;
|
|
119
120
|
case 5:
|
|
121
|
+
if (!board_id) return [3, 8];
|
|
122
|
+
return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
123
|
+
case 6:
|
|
120
124
|
boardData = _l.sent();
|
|
121
125
|
return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
|
|
122
|
-
case 6:
|
|
123
|
-
boardInfoStatus = _l.sent();
|
|
124
|
-
_l.label = 7;
|
|
125
126
|
case 7:
|
|
127
|
+
boardInfoStatus = _l.sent();
|
|
128
|
+
_l.label = 8;
|
|
129
|
+
case 8:
|
|
126
130
|
if (!countryCode) {
|
|
127
131
|
countryCode = (_d = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _d === void 0 ? void 0 : _d.country;
|
|
128
132
|
if (countryCode)
|
|
@@ -130,30 +134,36 @@ export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', funct
|
|
|
130
134
|
}
|
|
131
135
|
info = (boardInfoStatus || {}).info;
|
|
132
136
|
hasIndividualCompleted = ((_e = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'individual'; })) === null || _e === void 0 ? void 0 : _e.status) === 'completed';
|
|
133
|
-
if (!hasIndividualCompleted) return [3,
|
|
137
|
+
if (!hasIndividualCompleted) return [3, 9];
|
|
134
138
|
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
135
|
-
return [3,
|
|
136
|
-
case 8:
|
|
137
|
-
if (!(individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized)) return [3, 11];
|
|
138
|
-
if (!((_f = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _f === void 0 ? void 0 : _f.id)) return [3, 10];
|
|
139
|
-
return [4, thunkApi.dispatch(getIndividualList((_g = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _g === void 0 ? void 0 : _g.id))];
|
|
139
|
+
return [3, 15];
|
|
140
140
|
case 9:
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
if (!(individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized)) return [3, 12];
|
|
142
|
+
if (!((_f = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _f === void 0 ? void 0 : _f.id)) return [3, 11];
|
|
143
|
+
return [4, thunkApi.dispatch(getIndividualList((_g = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _g === void 0 ? void 0 : _g.id))];
|
|
143
144
|
case 10:
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
_l.sent();
|
|
146
|
+
_l.label = 11;
|
|
146
147
|
case 11:
|
|
148
|
+
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_LIST_STEP'));
|
|
149
|
+
return [3, 15];
|
|
150
|
+
case 12:
|
|
147
151
|
birthCountry = ((_h = individualData === null || individualData === void 0 ? void 0 : individualData.birth) === null || _h === void 0 ? void 0 : _h.country) || countryCode;
|
|
148
|
-
if (!birthCountry) return [3,
|
|
152
|
+
if (!birthCountry) return [3, 14];
|
|
149
153
|
return [4, thunkApi.dispatch(getCityList(birthCountry))];
|
|
150
|
-
case 12:
|
|
151
|
-
_l.sent();
|
|
152
|
-
_l.label = 13;
|
|
153
154
|
case 13:
|
|
154
|
-
|
|
155
|
+
_l.sent();
|
|
155
156
|
_l.label = 14;
|
|
156
|
-
case 14:
|
|
157
|
+
case 14:
|
|
158
|
+
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP'));
|
|
159
|
+
_l.label = 15;
|
|
160
|
+
case 15: return [3, 17];
|
|
161
|
+
case 16:
|
|
162
|
+
if (isUpdatePhoneInfo) {
|
|
163
|
+
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_VERIFY_STEP'));
|
|
164
|
+
}
|
|
165
|
+
_l.label = 17;
|
|
166
|
+
case 17: return [2, {
|
|
157
167
|
data: data,
|
|
158
168
|
boardResponse: {
|
|
159
169
|
brand: boardData === null || boardData === void 0 ? void 0 : boardData.brand,
|
|
@@ -175,6 +185,19 @@ export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', funct
|
|
|
175
185
|
});
|
|
176
186
|
});
|
|
177
187
|
});
|
|
188
|
+
export var verifyLeadToken = createAsyncThunk('individualVerifyLeadToken', function (_a, thunkApi) {
|
|
189
|
+
var token = _a.token, isInternally = _a.isInternally;
|
|
190
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
191
|
+
return __generator(this, function (_b) {
|
|
192
|
+
switch (_b.label) {
|
|
193
|
+
case 0: return [4, thunkApi.dispatch(verifyToken({ token: token, isInternally: isInternally }))];
|
|
194
|
+
case 1:
|
|
195
|
+
_b.sent();
|
|
196
|
+
return [2];
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
});
|
|
178
201
|
export var resendOTP = createAsyncThunk('resendOTPIndividual', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
179
202
|
var individual, payload, data;
|
|
180
203
|
return __generator(this, function (_a) {
|
|
@@ -404,60 +427,57 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
|
|
|
404
427
|
boardInfoStatus = undefined;
|
|
405
428
|
if ((_e = data.errors) === null || _e === void 0 ? void 0 : _e.length)
|
|
406
429
|
throw new Error(data.errors[0].description);
|
|
407
|
-
if (!board_id) return [3,
|
|
430
|
+
if (!board_id) return [3, 4];
|
|
408
431
|
return [4, API.boardService.retrieveBoardDetails(board_id)];
|
|
409
432
|
case 2:
|
|
410
433
|
boardData = _q.sent();
|
|
411
|
-
|
|
434
|
+
return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
|
|
412
435
|
case 3:
|
|
436
|
+
boardInfoStatus = _q.sent();
|
|
437
|
+
_q.label = 4;
|
|
438
|
+
case 4:
|
|
413
439
|
countryCode = (_f = boardData === null || boardData === void 0 ? void 0 : boardData.entity) === null || _f === void 0 ? void 0 : _f.country;
|
|
414
|
-
if (!(board_id && board_info_id)) return [3,
|
|
440
|
+
if (!(board_id && board_info_id)) return [3, 7];
|
|
415
441
|
return [4, API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id })];
|
|
416
|
-
case
|
|
442
|
+
case 5:
|
|
417
443
|
boardInfoData = _q.sent();
|
|
418
444
|
notification = (boardInfoData || {}).notification;
|
|
419
445
|
_c = (notification === null || notification === void 0 ? void 0 : notification.recipient) || {}, id = _c.id, type = _c.type;
|
|
420
|
-
if (!(id && type)) return [3,
|
|
446
|
+
if (!(id && type)) return [3, 7];
|
|
421
447
|
return [4, thunkApi.dispatch(retrieveIndividualInfo({ id: id, type: type, countryCode: countryCode }))];
|
|
422
|
-
case
|
|
448
|
+
case 6:
|
|
423
449
|
payload_2 = (_q.sent()).payload;
|
|
424
450
|
individualData = payload_2.data || {};
|
|
425
|
-
_q.label =
|
|
426
|
-
case
|
|
451
|
+
_q.label = 7;
|
|
452
|
+
case 7:
|
|
427
453
|
if (countryCode)
|
|
428
454
|
thunkApi.dispatch(handleSetCountryByIso2(countryCode));
|
|
429
|
-
if (!board_id) return [3, 8];
|
|
430
|
-
return [4, API.boardService.retrieveBoardInfoStatus(board_id)];
|
|
431
|
-
case 7:
|
|
432
|
-
boardInfoStatus = _q.sent();
|
|
433
|
-
_q.label = 8;
|
|
434
|
-
case 8:
|
|
435
455
|
info = (boardInfoStatus || {}).info;
|
|
436
456
|
hasIndividualCompleted = ((_g = info === null || info === void 0 ? void 0 : info.find(function (flow) { return flow.name === 'individual'; })) === null || _g === void 0 ? void 0 : _g.status) === 'completed';
|
|
437
|
-
if (!hasIndividualCompleted) return [3,
|
|
457
|
+
if (!hasIndividualCompleted) return [3, 8];
|
|
438
458
|
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_SUCCESS_FOUR_FLOWS_BUTTONS_STEP'));
|
|
439
|
-
return [3,
|
|
440
|
-
case
|
|
441
|
-
if (!(individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized)) return [3,
|
|
442
|
-
if (!((_h = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _h === void 0 ? void 0 : _h.id)) return [3,
|
|
459
|
+
return [3, 14];
|
|
460
|
+
case 8:
|
|
461
|
+
if (!(individualData === null || individualData === void 0 ? void 0 : individualData.is_authorized)) return [3, 11];
|
|
462
|
+
if (!((_h = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _h === void 0 ? void 0 : _h.id)) return [3, 10];
|
|
443
463
|
return [4, thunkApi.dispatch(getIndividualList((_j = boardData === null || boardData === void 0 ? void 0 : boardData.business) === null || _j === void 0 ? void 0 : _j.id))];
|
|
444
|
-
case
|
|
464
|
+
case 9:
|
|
445
465
|
_q.sent();
|
|
446
|
-
_q.label =
|
|
447
|
-
case
|
|
466
|
+
_q.label = 10;
|
|
467
|
+
case 10:
|
|
448
468
|
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_LIST_STEP'));
|
|
449
|
-
return [3,
|
|
450
|
-
case
|
|
469
|
+
return [3, 14];
|
|
470
|
+
case 11:
|
|
451
471
|
birthCountry = ((_k = individualData === null || individualData === void 0 ? void 0 : individualData.birth) === null || _k === void 0 ? void 0 : _k.country) || countryCode;
|
|
452
|
-
if (!birthCountry) return [3,
|
|
472
|
+
if (!birthCountry) return [3, 13];
|
|
453
473
|
return [4, thunkApi.dispatch(getCityList(birthCountry))];
|
|
454
|
-
case
|
|
474
|
+
case 12:
|
|
455
475
|
_q.sent();
|
|
476
|
+
_q.label = 13;
|
|
477
|
+
case 13:
|
|
478
|
+
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP'));
|
|
456
479
|
_q.label = 14;
|
|
457
480
|
case 14:
|
|
458
|
-
thunkApi.dispatch(handleNextScreenStep('INDIVIDUAL_PERSONAL_INDIVIDUAL_INFO_STEP'));
|
|
459
|
-
_q.label = 15;
|
|
460
|
-
case 15:
|
|
461
481
|
(_m = (_l = settings.data.appConfig).onStepCompleted) === null || _m === void 0 ? void 0 : _m.call(_l, settings.data.activeScreen.name, { otp: params.otp });
|
|
462
482
|
return [2, {
|
|
463
483
|
data: data,
|
|
@@ -480,6 +500,36 @@ export var verifyLeadOTP = createAsyncThunk('verifyIndividualLeadOTP', function
|
|
|
480
500
|
}
|
|
481
501
|
});
|
|
482
502
|
}); });
|
|
503
|
+
export var updatePhoneInfo = createAsyncThunk('individual/updatePhoneInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
504
|
+
var individual, _a, token, responseBody, _b, id, type, mobile, countryCode, requestBody, data;
|
|
505
|
+
var _c;
|
|
506
|
+
return __generator(this, function (_d) {
|
|
507
|
+
switch (_d.label) {
|
|
508
|
+
case 0:
|
|
509
|
+
individual = thunkApi.getState().individual;
|
|
510
|
+
_a = individual.data.verify, token = _a.token, responseBody = _a.responseBody;
|
|
511
|
+
_b = (responseBody === null || responseBody === void 0 ? void 0 : responseBody.source) || {}, id = _b.id, type = _b.type;
|
|
512
|
+
mobile = params.mobile, countryCode = params.countryCode;
|
|
513
|
+
requestBody = {
|
|
514
|
+
id: id,
|
|
515
|
+
type: type,
|
|
516
|
+
contact: {
|
|
517
|
+
phone: {
|
|
518
|
+
country_code: (_c = countryCode === null || countryCode === void 0 ? void 0 : countryCode.idd_prefix) === null || _c === void 0 ? void 0 : _c.toString(),
|
|
519
|
+
number: mobile || ''
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
return [4, API.individualService.updateIndividual(requestBody)];
|
|
524
|
+
case 1:
|
|
525
|
+
data = _d.sent();
|
|
526
|
+
return [4, thunkApi.dispatch(verifyToken({ token: token, isUpdatePhoneInfo: true }))];
|
|
527
|
+
case 2:
|
|
528
|
+
_d.sent();
|
|
529
|
+
return [2, { data: data, formData: params }];
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}); });
|
|
483
533
|
export var updateIndividualPersonalInfo = createAsyncThunk('individual/updateIndividualPersonalInfo', function (params, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
484
534
|
var _a, settings, individual, _b, notification, user, entity, _c, id, type, name, email, mobile, countryCode, gender, nid, issuedCountry, expiryDate, dob, placeOfBirthCountry, placeOfBirthCity, nationality, code, data_status, userName, identification_id_type, isNameEditable, isEmailEditable, isMobileNumberEditable, isMobileCountryEditable, isNidEditable, isIssuedCountryEditable, isExpiryEditable, isIdTypeEditable, isNationalityEditable, hasContact, hasPhone, hasIdentification, hasBirth, names, contact, requestBody, data;
|
|
485
535
|
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
@@ -722,6 +772,10 @@ var initialState = {
|
|
|
722
772
|
otpData: {
|
|
723
773
|
otp: ''
|
|
724
774
|
},
|
|
775
|
+
individualPhoneInfo: {
|
|
776
|
+
mobile: '',
|
|
777
|
+
countryCode: defaultCountry
|
|
778
|
+
},
|
|
725
779
|
individualCollectData: {
|
|
726
780
|
email: '',
|
|
727
781
|
mobile: '',
|
|
@@ -780,16 +834,25 @@ export var individualSlice = createSlice({
|
|
|
780
834
|
},
|
|
781
835
|
extraReducers: function (builder) {
|
|
782
836
|
builder
|
|
783
|
-
.addCase(
|
|
837
|
+
.addCase(verifyToken.pending, function (state) {
|
|
784
838
|
state.error = null;
|
|
785
|
-
state.customLoading = true;
|
|
786
839
|
})
|
|
787
|
-
.addCase(
|
|
840
|
+
.addCase(verifyToken.fulfilled, function (state, action) {
|
|
788
841
|
state.error = null;
|
|
789
|
-
state.customLoading = false;
|
|
790
842
|
var _a = action.payload, data = _a.data, token = _a.token, boardResponse = _a.boardResponse;
|
|
791
843
|
state.data.verify.responseBody = __assign(__assign(__assign(__assign({}, data), state.data.verify.responseBody), boardResponse), { board_id: data.id });
|
|
792
844
|
state.data.verify.token = token;
|
|
845
|
+
})
|
|
846
|
+
.addCase(verifyToken.rejected, function (state, action) {
|
|
847
|
+
state.error = action.error.message;
|
|
848
|
+
})
|
|
849
|
+
.addCase(verifyLeadToken.pending, function (state) {
|
|
850
|
+
state.error = null;
|
|
851
|
+
state.customLoading = true;
|
|
852
|
+
})
|
|
853
|
+
.addCase(verifyLeadToken.fulfilled, function (state) {
|
|
854
|
+
state.error = null;
|
|
855
|
+
state.customLoading = false;
|
|
793
856
|
})
|
|
794
857
|
.addCase(verifyLeadToken.rejected, function (state, action) {
|
|
795
858
|
state.error = action.error.message;
|
|
@@ -870,12 +933,10 @@ export var individualSlice = createSlice({
|
|
|
870
933
|
state.error = action.error.message;
|
|
871
934
|
})
|
|
872
935
|
.addCase(retrieveIndividualInfo.pending, function (state) {
|
|
873
|
-
state.loading = true;
|
|
874
936
|
state.error = null;
|
|
875
937
|
})
|
|
876
938
|
.addCase(retrieveIndividualInfo.fulfilled, function (state, action) {
|
|
877
939
|
var _a, _b, _c, _d;
|
|
878
|
-
state.loading = false;
|
|
879
940
|
state.error = null;
|
|
880
941
|
var _e = action.payload, data = _e.data, countries = _e.countries, countryCode = _e.countryCode;
|
|
881
942
|
var user = (state.data.verify.responseBody || {}).user;
|
|
@@ -945,7 +1006,6 @@ export var individualSlice = createSlice({
|
|
|
945
1006
|
state.data.individualData.isInfluencer = is_influencer;
|
|
946
1007
|
})
|
|
947
1008
|
.addCase(retrieveIndividualInfo.rejected, function (state, action) {
|
|
948
|
-
state.loading = false;
|
|
949
1009
|
state.error = action.error.message;
|
|
950
1010
|
})
|
|
951
1011
|
.addCase(getIndividualList.pending, function (state) {
|
|
@@ -1015,6 +1075,21 @@ export var individualSlice = createSlice({
|
|
|
1015
1075
|
.addCase(getCityList.rejected, function (state, action) {
|
|
1016
1076
|
state.cityLoading = false;
|
|
1017
1077
|
state.error = action.error.message;
|
|
1078
|
+
})
|
|
1079
|
+
.addCase(updatePhoneInfo.pending, function (state) {
|
|
1080
|
+
state.loading = true;
|
|
1081
|
+
state.error = null;
|
|
1082
|
+
})
|
|
1083
|
+
.addCase(updatePhoneInfo.fulfilled, function (state, action) {
|
|
1084
|
+
state.loading = false;
|
|
1085
|
+
state.error = null;
|
|
1086
|
+
var _a = action.payload, data = _a.data, formData = _a.formData;
|
|
1087
|
+
state.data.individualPhoneInfo = formData;
|
|
1088
|
+
state.data.individualPhoneInfo.responseBody = data;
|
|
1089
|
+
})
|
|
1090
|
+
.addCase(updatePhoneInfo.rejected, function (state, action) {
|
|
1091
|
+
state.loading = false;
|
|
1092
|
+
state.error = action.error.message;
|
|
1018
1093
|
})
|
|
1019
1094
|
.addCase(updateIndividualPersonalInfo.pending, function (state) {
|
|
1020
1095
|
state.loading = true;
|
|
@@ -38,6 +38,7 @@ import SuccessPasswordPage from './password/screens/Success';
|
|
|
38
38
|
import PasswordSuccessWithFlowPage from './password/screens/SuccessWithFlowButtons';
|
|
39
39
|
import PasswordResetPasswordSuccessPage from './password/screens/ResetPasswordSuccess';
|
|
40
40
|
import IndividualVerifyPage from './individual/screens/Verify';
|
|
41
|
+
import IndividualPhoneInfoPage from './individual/screens/IndividualPhoneInfo';
|
|
41
42
|
import IndividualListPage from './individual/screens/IndividualList';
|
|
42
43
|
import IndividualPersonalInfo from './individual/screens/IndividualPersonalInfo';
|
|
43
44
|
import AdditionalIndividualInfoPage from './individual/screens/AdditionalIndividualInfo';
|
|
@@ -232,6 +233,10 @@ export var individualFeatureScreens = [
|
|
|
232
233
|
name: 'INDIVIDUAL_VERIFY_STEP',
|
|
233
234
|
element: IndividualVerifyPage
|
|
234
235
|
},
|
|
236
|
+
{
|
|
237
|
+
name: 'INDIVIDUAL_PHONE_INFO_STEP',
|
|
238
|
+
element: IndividualPhoneInfoPage
|
|
239
|
+
},
|
|
235
240
|
{
|
|
236
241
|
name: 'INDIVIDUAL_LOADING_DATA_STEP',
|
|
237
242
|
element: IndividualDataLoadingPage
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Theme, SxProps } from '@mui/material/styles';
|
|
3
|
+
import { CountryCode } from '../../../../@types';
|
|
4
|
+
interface MobileNumberProps {
|
|
5
|
+
countries: Array<CountryCode>;
|
|
6
|
+
show: boolean;
|
|
7
|
+
onListOpen?: () => void;
|
|
8
|
+
onListClose?: () => void;
|
|
9
|
+
sx?: SxProps<Theme>;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<MobileNumberProps & React.RefAttributes<unknown>>>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,143 @@
|
|
|
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, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
|
+
import * as React from 'react';
|
|
25
|
+
import { useTranslation } from 'react-i18next';
|
|
26
|
+
import { useController, useFormContext } from 'react-hook-form';
|
|
27
|
+
import Box from '@mui/material/Box';
|
|
28
|
+
import { styled, alpha } from '@mui/material/styles';
|
|
29
|
+
import { removeAllCharsFromNumber } from '../../../../utils';
|
|
30
|
+
import { useLanguage, useAppSelector } from '../../../../hooks';
|
|
31
|
+
import Text from '../../../../components/Text';
|
|
32
|
+
import Collapse from '../../../../components/Collapse';
|
|
33
|
+
import ExpandIcon from '../../../../components/ExpandIcon';
|
|
34
|
+
import SimpleList from '../../../../components/SimpleList';
|
|
35
|
+
import ClearIcon from '../../../shared/ClearIcon';
|
|
36
|
+
import CheckIcon from '../../../shared/CheckIcon';
|
|
37
|
+
import ScreenContainer from '../../../shared/Containers/ScreenContainer';
|
|
38
|
+
import Input from '../../../shared/Input';
|
|
39
|
+
import { individualSelector } from '../../../app/individual/individualStore';
|
|
40
|
+
var LabelContainerStyled = styled(Box)(function (_a) {
|
|
41
|
+
var theme = _a.theme;
|
|
42
|
+
return ({
|
|
43
|
+
display: 'flex',
|
|
44
|
+
justifyContent: 'space-between',
|
|
45
|
+
padding: theme.spacing(0, 2.5, 1.25, 2.5)
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
var CountryItemContainer = styled(Box)(function () { return ({
|
|
49
|
+
display: 'flex'
|
|
50
|
+
}); });
|
|
51
|
+
var CountryCodeText = styled(Text, {
|
|
52
|
+
shouldForwardProp: function (prop) { return prop !== 'isSelected'; }
|
|
53
|
+
})(function (_a) {
|
|
54
|
+
var theme = _a.theme, isSelected = _a.isSelected;
|
|
55
|
+
return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { width: theme.spacing(10), textAlign: 'start', fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight }));
|
|
56
|
+
});
|
|
57
|
+
var CountryNameText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
|
|
58
|
+
var theme = _a.theme, isSelected = _a.isSelected;
|
|
59
|
+
return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25) }));
|
|
60
|
+
});
|
|
61
|
+
var CountryCodeStyled = styled(Text)(function (_a) {
|
|
62
|
+
var theme = _a.theme;
|
|
63
|
+
return (__assign(__assign({ cursor: 'pointer' }, theme.typography.body2), { fontWeight: theme.typography.fontWeightRegular, display: 'flex', alignItems: 'center', minWidth: theme.spacing(8.75) }));
|
|
64
|
+
});
|
|
65
|
+
var InputLabelStyled = styled(Text)(function (_a) {
|
|
66
|
+
var theme = _a.theme;
|
|
67
|
+
return (__assign(__assign({ color: alpha(theme.palette.text.primary, 0.6), fontWeight: theme.typography.fontWeightMedium }, theme.typography.caption), { lineHeight: theme.spacing(2.5) }));
|
|
68
|
+
});
|
|
69
|
+
var ExpandIconStyled = styled(ExpandIcon)(function (_a) {
|
|
70
|
+
var theme = _a.theme;
|
|
71
|
+
return ({
|
|
72
|
+
marginInlineStart: theme.spacing(1)
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
var InputStyled = styled(Input)(function () { return ({
|
|
76
|
+
direction: 'ltr',
|
|
77
|
+
'& .MuiInputBase-input': {
|
|
78
|
+
cursor: 'auto'
|
|
79
|
+
}
|
|
80
|
+
}); });
|
|
81
|
+
var MobileNumber = React.forwardRef(function (_a, ref) {
|
|
82
|
+
var _b, _c, _d;
|
|
83
|
+
var countries = _a.countries, sx = _a.sx, rest = __rest(_a, ["countries", "sx"]);
|
|
84
|
+
var _e = React.useState(countries || []), countriesCode = _e[0], setCountries = _e[1];
|
|
85
|
+
var _f = React.useState(null), anchorEl = _f[0], setAnchorEl = _f[1];
|
|
86
|
+
var t = useTranslation().t;
|
|
87
|
+
var isAr = useLanguage().isAr;
|
|
88
|
+
var _g = useFormContext(), control = _g.control, setValue = _g.setValue;
|
|
89
|
+
var data = useAppSelector(individualSelector).data;
|
|
90
|
+
var phoneControl = useController({ name: 'mobile', control: control });
|
|
91
|
+
var countryCodeControl = useController({ name: 'countryCode', control: control });
|
|
92
|
+
var countryCodeValue = countryCodeControl.field.value;
|
|
93
|
+
var mobileValue = phoneControl.field.value;
|
|
94
|
+
var countryName = (isAr ? (_b = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.name) === null || _b === void 0 ? void 0 : _b.arabic : (_c = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.name) === null || _c === void 0 ? void 0 : _c.english) || '';
|
|
95
|
+
var error = !!mobileValue ? (_d = phoneControl.fieldState.error) === null || _d === void 0 ? void 0 : _d.message : '';
|
|
96
|
+
var isSA = (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.iso2) === 'SA';
|
|
97
|
+
var mobileLen = countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.digits;
|
|
98
|
+
var isStartsWith5 = mobileValue.startsWith('5');
|
|
99
|
+
var requiredLen = isSA && isStartsWith5 ? mobileLen - 1 : mobileLen;
|
|
100
|
+
var verify = data.verify;
|
|
101
|
+
var user = (verify.responseBody || {}).user;
|
|
102
|
+
React.useEffect(function () {
|
|
103
|
+
if (mobileValue)
|
|
104
|
+
setValue('mobile', mobileValue, { shouldValidate: true });
|
|
105
|
+
}, []);
|
|
106
|
+
var onPhoneNumberChange = function (_a) {
|
|
107
|
+
var target = _a.target;
|
|
108
|
+
var value = removeAllCharsFromNumber(target.value);
|
|
109
|
+
phoneControl.field.onChange(value);
|
|
110
|
+
};
|
|
111
|
+
var clearMobileNumber = function () {
|
|
112
|
+
phoneControl.field.onChange('');
|
|
113
|
+
};
|
|
114
|
+
var onCloseCountryList = function () {
|
|
115
|
+
var _a;
|
|
116
|
+
if (anchorEl) {
|
|
117
|
+
setAnchorEl(null);
|
|
118
|
+
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
119
|
+
}
|
|
120
|
+
setCountries(countries);
|
|
121
|
+
};
|
|
122
|
+
var toggleCountryList = function () {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
if (anchorEl) {
|
|
125
|
+
setAnchorEl(null);
|
|
126
|
+
(_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
|
|
127
|
+
setCountries(countries);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
(_b = rest.onListOpen) === null || _b === void 0 ? void 0 : _b.call(rest);
|
|
131
|
+
setAnchorEl(true);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var onSelectItem = function (country) {
|
|
135
|
+
onCloseCountryList();
|
|
136
|
+
setValue('mobile', '');
|
|
137
|
+
countryCodeControl.field.onChange(country);
|
|
138
|
+
};
|
|
139
|
+
return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref, sx: sx }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(InputStyled, { inputProps: { maxLength: requiredLen }, type: 'tel', disabled: !!anchorEl, onClick: onCloseCountryList, 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: '05|5' }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', searchValuePath: ['name.arabic', 'name.english'], list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
|
|
140
|
+
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, {})] }));
|
|
141
|
+
} }) }))] })) })));
|
|
142
|
+
});
|
|
143
|
+
export default React.memo(MobileNumber);
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import { useForm, FormProvider } from 'react-hook-form';
|
|
16
|
+
import { yupResolver } from '@hookform/resolvers/yup';
|
|
17
|
+
import { styled } from '@mui/material/styles';
|
|
18
|
+
import { settingsSelector } from '../../../../app/settings';
|
|
19
|
+
import { useAppDispatch, useSetFromDefaultValues } from '../../../../hooks';
|
|
20
|
+
import { useLanguage, useAppSelector } from '../../../../hooks';
|
|
21
|
+
import Form from '../../../../components/Form';
|
|
22
|
+
import Collapse from '../../../../components/Collapse';
|
|
23
|
+
import { ScreenContainer } from '../../../shared/Containers';
|
|
24
|
+
import { individualSelector, clearError, updatePhoneInfo } from '../../../app/individual/individualStore';
|
|
25
|
+
import Button from '../../../shared/Button';
|
|
26
|
+
import { IndividualPhoneInfoValidationSchema } from './validation';
|
|
27
|
+
import MobileNumber from './MobileNumber';
|
|
28
|
+
var FormStyled = styled(Form)(function () { return ({
|
|
29
|
+
display: 'flex',
|
|
30
|
+
flexDirection: 'column'
|
|
31
|
+
}); });
|
|
32
|
+
var PhoneInfo = function (_a) {
|
|
33
|
+
var dispatch = useAppDispatch();
|
|
34
|
+
var settingsData = useAppSelector(settingsSelector).data;
|
|
35
|
+
var countries = settingsData.countries;
|
|
36
|
+
var _b = useAppSelector(individualSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
37
|
+
var _c = data.individualPhoneInfo, mobile = _c.mobile, countryCode = _c.countryCode;
|
|
38
|
+
var methods = useForm({
|
|
39
|
+
resolver: yupResolver(IndividualPhoneInfoValidationSchema),
|
|
40
|
+
defaultValues: {
|
|
41
|
+
mobile: mobile,
|
|
42
|
+
countryCode: countryCode
|
|
43
|
+
},
|
|
44
|
+
mode: 'onChange'
|
|
45
|
+
});
|
|
46
|
+
useSetFromDefaultValues(methods, data.individualPhoneInfo);
|
|
47
|
+
var t = useTranslation().t;
|
|
48
|
+
var isAr = useLanguage().isAr;
|
|
49
|
+
var _d = React.useState(), listActive = _d[0], setListActive = _d[1];
|
|
50
|
+
var onSubmit = function (formData) {
|
|
51
|
+
dispatch(updatePhoneInfo(formData));
|
|
52
|
+
};
|
|
53
|
+
React.useEffect(function () {
|
|
54
|
+
if (error && methods.formState.isValid)
|
|
55
|
+
dispatch(clearError());
|
|
56
|
+
}, [methods.formState.isValid]);
|
|
57
|
+
var disabled = !methods.formState.isValid || !!error;
|
|
58
|
+
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(MobileNumber, { show: true, sx: { mb: 7.5 }, countries: countries, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(Collapse, __assign({ in: !listActive }, { children: _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') })) }))] })) })) }));
|
|
59
|
+
};
|
|
60
|
+
export default React.memo(PhoneInfo);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
export declare const IndividualPhoneInfoValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
mobile: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
4
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
5
|
+
mobile: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
6
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
|
+
mobile: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
|
|
8
|
+
}>>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as yup from 'yup';
|
|
2
|
+
export var IndividualPhoneInfoValidationSchema = yup.object().shape({
|
|
3
|
+
mobile: yup
|
|
4
|
+
.string()
|
|
5
|
+
.test({
|
|
6
|
+
test: function (value) {
|
|
7
|
+
if (((value === null || value === void 0 ? void 0 : value.length) || 0) > 0) {
|
|
8
|
+
var countryCode = this.parent.countryCode;
|
|
9
|
+
var isSA = countryCode.iso2 === 'SA';
|
|
10
|
+
var digits = countryCode.digits;
|
|
11
|
+
var mobileValue = value || '';
|
|
12
|
+
var valueLen = mobileValue.length;
|
|
13
|
+
var isNumber = mobileValue.match(/^[0-9]/g);
|
|
14
|
+
if (!isNumber)
|
|
15
|
+
return this.createError({ message: 'enter_valid_mobile_number' });
|
|
16
|
+
var isStartWithZero = mobileValue.startsWith('05');
|
|
17
|
+
var isStartWith5 = mobileValue.startsWith('5');
|
|
18
|
+
var isSaudiNumber = isStartWith5 || isStartWithZero;
|
|
19
|
+
if (isSA) {
|
|
20
|
+
if (!isSaudiNumber)
|
|
21
|
+
return this.createError({ message: 'start_with_number' });
|
|
22
|
+
var requiredLen = isStartWith5 ? digits - 1 : digits;
|
|
23
|
+
return valueLen === requiredLen ? true : this.createError({ message: 'enter_valid_mobile_number' });
|
|
24
|
+
}
|
|
25
|
+
return valueLen === digits ? true : this.createError({ message: 'enter_valid_mobile_number' });
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
.required()
|
|
31
|
+
});
|