@tap-payments/auth-jsconnect 2.6.17-test → 2.6.18-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/features/app/connectExpress/connectExpressStore.js +1 -1
- package/build/features/app/individual/individualStore.js +4 -1
- package/build/features/connectExpress/ConnectExpress.js +2 -3
- package/build/features/individual/screens/IndividualPersonalInfo/ID.js +6 -2
- package/build/features/individual/screens/IndividualPersonalInfo/IndividualPersonalInfo.js +3 -2
- package/build/features/individual/screens/IndividualPersonalInfo/validation.d.ts +1 -1
- package/build/features/individual/screens/IndividualPersonalInfo/validation.js +67 -63
- package/package.json +1 -1
|
@@ -82,7 +82,7 @@ export var retrieveLeadIdentityByIdAsync = createAsyncThunk('expressConnect/retr
|
|
|
82
82
|
countryCode = findCountryByIddPrefix(settings.data.countries, phone.country_code);
|
|
83
83
|
status = data.status, board_id = data.board_id, board_info_id = data.board_info_id;
|
|
84
84
|
isRegistered = (status === null || status === void 0 ? void 0 : status.toLowerCase()) === 'registered';
|
|
85
|
-
if (!isRegistered && !(data === null || data === void 0 ? void 0 : data.identification) &&
|
|
85
|
+
if (!isRegistered && !(data === null || data === void 0 ? void 0 : data.identification) && phone) {
|
|
86
86
|
thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_MOBILE_STEP'));
|
|
87
87
|
return [2, { data: data, countryCode: countryCode }];
|
|
88
88
|
}
|
|
@@ -71,7 +71,7 @@ import API from '../../../api';
|
|
|
71
71
|
import { FlowsTypes, IndividualGender, DocumentPurpose } from '../../../@types';
|
|
72
72
|
import { handleNextScreenStep, handlePrevScreenStep, handlePublicKey, handleSetCountryByIso2, onCloseComplete } from '../../../app/settings';
|
|
73
73
|
import { defaultCountry, IDENTIFICATION_TYPE, INDIVIDUAl_STEP_NAMES, MONTHLY_INCOME_LIST } from '../../../constants';
|
|
74
|
-
import { convertNumbers2English, dateFormat, findCountryByIddPrefix, findCountryByIso2, hasNoneEditableValue, getUserNameObject, getUserName, sleep, isValidEmail, getRecentDocumentBasedOnPurpose, formatNumberAsCurrency, removeAllCharsFromNumber, mapUserList, sortUserList, getIndividualType } from '../../../utils';
|
|
74
|
+
import { convertNumbers2English, dateFormat, findCountryByIddPrefix, findCountryByIso2, hasNoneEditableValue, getUserNameObject, getUserName, sleep, isValidEmail, getRecentDocumentBasedOnPurpose, formatNumberAsCurrency, removeAllCharsFromNumber, mapUserList, sortUserList, getIndividualType, isOtherThanKWOrSA } from '../../../utils';
|
|
75
75
|
export var verifyToken = createAsyncThunk('individual/verifyToken', function (_a, thunkApi) {
|
|
76
76
|
var token = _a.token, isInternally = _a.isInternally, isUpdatePhoneInfo = _a.isUpdatePhoneInfo;
|
|
77
77
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -568,6 +568,9 @@ export var updateIndividualPersonalInfo = createAsyncThunk('individual/updateInd
|
|
|
568
568
|
data_status = (user || {}).data_status;
|
|
569
569
|
userName = getUserNameObject(name);
|
|
570
570
|
identification_id_type = nid ? (nid.startsWith('1') ? IDENTIFICATION_TYPE.NID : IDENTIFICATION_TYPE.IQAMA) : undefined;
|
|
571
|
+
if (isOtherThanKWOrSA(settings.data.businessCountry.iso2)) {
|
|
572
|
+
identification_id_type = IDENTIFICATION_TYPE.NID;
|
|
573
|
+
}
|
|
571
574
|
isGenderNonEditable = hasNoneEditableValue(data_status, 'gender');
|
|
572
575
|
isNameENNonEditable = hasNoneEditableValue(data_status, 'name.en');
|
|
573
576
|
isNameARNonEditable = hasNoneEditableValue(data_status, 'name.ar');
|
|
@@ -124,11 +124,10 @@ var ConnectExpress = memo(function (_a) {
|
|
|
124
124
|
}
|
|
125
125
|
}, [data.isValidOperator, settingLoading]);
|
|
126
126
|
React.useEffect(function () {
|
|
127
|
-
|
|
128
|
-
if (!settingLoading && (isKW((_a = data.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2) || isOtherThanKWOrSA((_b = data.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2))) {
|
|
127
|
+
if (data.businessCountry.iso2 && (isKW(data.businessCountry.iso2) || isOtherThanKWOrSA(data.businessCountry.iso2))) {
|
|
129
128
|
dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_MOBILE_STEP'));
|
|
130
129
|
}
|
|
131
|
-
}, [
|
|
130
|
+
}, [data.businessCountry]);
|
|
132
131
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ open: open, isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ pointerEvents: loading ? 'none' : 'auto', isTapOrigin: isTapOrigin, loading: settingLoading || customLoading, error: error, open: open, screenId: activeScreen.name, merchantInfo: merchant, isMaturityExpress: true }, { children: _jsx(FeatureContainer, __assign({ isMaturityExpress: true }, { children: connectExpressFeatureScreens.map(function (_a, index) {
|
|
133
132
|
var Element = _a.element, name = _a.name;
|
|
134
133
|
var isActive = activeScreen.name === name;
|
|
@@ -13,8 +13,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
13
13
|
import * as React from 'react';
|
|
14
14
|
import { useTranslation } from 'react-i18next';
|
|
15
15
|
import { useController, useFormContext } from 'react-hook-form';
|
|
16
|
-
import { removeAllCharsFromNumber } from '../../../../utils';
|
|
16
|
+
import { isOtherThanKWOrSA, removeAllCharsFromNumber } from '../../../../utils';
|
|
17
17
|
import { ID_NUMBER_LENGTH } from '../../../../constants';
|
|
18
|
+
import { useAppSelector } from '../../../../hooks';
|
|
19
|
+
import { settingsSelector } from '../../../../app/settings';
|
|
18
20
|
import Collapse from '../../../../components/Collapse';
|
|
19
21
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
20
22
|
import Input from '../../../shared/Input';
|
|
@@ -24,7 +26,9 @@ var IDNumber = function (_a) {
|
|
|
24
26
|
var show = _a.show, readOnly = _a.readOnly, isVerified = _a.isVerified;
|
|
25
27
|
var t = useTranslation().t;
|
|
26
28
|
var control = useFormContext().control;
|
|
29
|
+
var settingsData = useAppSelector(settingsSelector).data;
|
|
27
30
|
var nidControl = useController({ control: control, name: 'nid' });
|
|
31
|
+
var isOtherCountry = React.useMemo(function () { return isOtherThanKWOrSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
28
32
|
var handleIdChange = function (_a) {
|
|
29
33
|
var target = _a.target;
|
|
30
34
|
var value = removeAllCharsFromNumber(target.value);
|
|
@@ -35,6 +39,6 @@ var IDNumber = function (_a) {
|
|
|
35
39
|
};
|
|
36
40
|
var nidValue = nidControl.field.value;
|
|
37
41
|
var error = (_b = nidControl.fieldState.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
38
|
-
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t('enter_national_id'), inputProps: { maxLength: ID_NUMBER_LENGTH }, onChange: handleIdChange, value: nidValue, endAdornment: _jsx(EndAdornment, { value: nidValue, isVerified: isVerified, onClear: clearIdNumber, error: error }), placeholder: '0000000000', warningType: 'alert', warningMessage: error && t(error, { number: '1' }) }) }) })));
|
|
42
|
+
return (_jsx(Collapse, __assign({ in: show }, { children: _jsx(ScreenContainer, { children: _jsx(Input, { readOnly: readOnly, label: t('enter_national_id'), inputProps: isOtherCountry ? {} : { maxLength: ID_NUMBER_LENGTH }, onChange: handleIdChange, value: nidValue, endAdornment: _jsx(EndAdornment, { value: nidValue, isVerified: isVerified, onClear: clearIdNumber, error: error }), placeholder: '0000000000', warningType: 'alert', warningMessage: error && t(error, { number: '1' }) }) }) })));
|
|
39
43
|
};
|
|
40
44
|
export default React.memo(IDNumber);
|
|
@@ -18,7 +18,7 @@ import { handleCurrentActiveScreen, handlePrevScreenStep, settingsSelector } fro
|
|
|
18
18
|
import Box from '@mui/material/Box';
|
|
19
19
|
import { alpha, styled } from '@mui/material/styles';
|
|
20
20
|
import { useAppDispatch, useAppSelector, useSetFromDefaultValues, useLanguage, useFormReadOnly, useDataNoneEditable, useFormErrorAndUpdateReadOnly, useExcludeReadOnlyFelids, useDataVerified } from '../../../../hooks';
|
|
21
|
-
import { convertToEnglishDateFormat, deepCopy, getUserName } from '../../../../utils';
|
|
21
|
+
import { convertToEnglishDateFormat, deepCopy, getUserName, isOtherThanKWOrSA } from '../../../../utils';
|
|
22
22
|
import Form from '../../../../components/Form';
|
|
23
23
|
import Collapse from '../../../../components/Collapse';
|
|
24
24
|
import Text from '../../../../components/Text';
|
|
@@ -61,8 +61,9 @@ var IndividualPersonalInfo = function (_a) {
|
|
|
61
61
|
var _m = verify.responseBody || {}, user = _m.user, flows = _m.flows;
|
|
62
62
|
var name = individualPersonalData.name, email = individualPersonalData.email, mobile = individualPersonalData.mobile, countryCode = individualPersonalData.countryCode, gender = individualPersonalData.gender, nid = individualPersonalData.nid, issuedCountry = individualPersonalData.issuedCountry, expiryDate = individualPersonalData.expiryDate, dob = individualPersonalData.dob, placeOfBirthCountry = individualPersonalData.placeOfBirthCountry, placeOfBirthCity = individualPersonalData.placeOfBirthCity, nationality = individualPersonalData.nationality;
|
|
63
63
|
var _o = user || {}, data_status = _o.data_status, is_authorized = _o.is_authorized, data_verification = _o.data_verification, contact = _o.contact, genderRes = _o.gender, identification = _o.identification, birth = _o.birth, nationalityRes = _o.nationality;
|
|
64
|
+
var isOtherCountry = React.useMemo(function () { return isOtherThanKWOrSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
64
65
|
var methods = useForm({
|
|
65
|
-
resolver: yupResolver(IndividualInfoValidationSchema),
|
|
66
|
+
resolver: yupResolver(IndividualInfoValidationSchema(isOtherCountry)),
|
|
66
67
|
defaultValues: {
|
|
67
68
|
name: name,
|
|
68
69
|
email: email,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
|
-
export declare const IndividualInfoValidationSchema: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
2
|
+
export declare const IndividualInfoValidationSchema: (isOtherCountry: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
3
|
name: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
4
4
|
mobile: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
5
5
|
email: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
|
|
@@ -1,68 +1,72 @@
|
|
|
1
1
|
import * as yup from 'yup';
|
|
2
2
|
import { REGEX_FULL_NAME } from '../../../../constants';
|
|
3
|
-
export var IndividualInfoValidationSchema =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
})
|
|
16
|
-
.optional(),
|
|
17
|
-
mobile: yup
|
|
18
|
-
.string()
|
|
19
|
-
.test({
|
|
20
|
-
test: function (value) {
|
|
21
|
-
if (((value === null || value === void 0 ? void 0 : value.length) || 0) > 0) {
|
|
22
|
-
var countryCode = this.parent.countryCode;
|
|
23
|
-
var isSA = countryCode.iso2 === 'SA';
|
|
24
|
-
var digits = countryCode.digits;
|
|
25
|
-
var mobileValue = value || '';
|
|
26
|
-
var valueLen = mobileValue.length;
|
|
27
|
-
var isNumber = mobileValue.match(/^[0-9]/g);
|
|
28
|
-
if (!isNumber)
|
|
29
|
-
return this.createError({ message: 'enter_valid_mobile_number' });
|
|
30
|
-
var isStartWithZero = mobileValue.startsWith('05');
|
|
31
|
-
var isStartWith5 = mobileValue.startsWith('5');
|
|
32
|
-
var isSaudiNumber = isStartWith5 || isStartWithZero;
|
|
33
|
-
if (isSA) {
|
|
34
|
-
if (!isSaudiNumber)
|
|
35
|
-
return this.createError({ message: 'start_with_number' });
|
|
36
|
-
var requiredLen = isStartWith5 ? digits - 1 : digits;
|
|
37
|
-
return valueLen === requiredLen ? true : this.createError({ message: 'enter_valid_mobile_number' });
|
|
3
|
+
export var IndividualInfoValidationSchema = function (isOtherCountry) {
|
|
4
|
+
return yup.object().shape({
|
|
5
|
+
name: yup
|
|
6
|
+
.string()
|
|
7
|
+
.test({
|
|
8
|
+
test: function (value) {
|
|
9
|
+
if (((value === null || value === void 0 ? void 0 : value.length) || 0) > 0) {
|
|
10
|
+
var name_1 = value || '';
|
|
11
|
+
var isMatch = name_1.match(REGEX_FULL_NAME);
|
|
12
|
+
return isMatch ? true : this.createError({ message: 'please write your first and last name' });
|
|
38
13
|
}
|
|
39
|
-
return
|
|
14
|
+
return true;
|
|
40
15
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
16
|
+
})
|
|
17
|
+
.optional(),
|
|
18
|
+
mobile: yup
|
|
19
|
+
.string()
|
|
20
|
+
.test({
|
|
21
|
+
test: function (value) {
|
|
22
|
+
if (((value === null || value === void 0 ? void 0 : value.length) || 0) > 0) {
|
|
23
|
+
var countryCode = this.parent.countryCode;
|
|
24
|
+
var isSA = countryCode.iso2 === 'SA';
|
|
25
|
+
var digits = countryCode.digits;
|
|
26
|
+
var mobileValue = value || '';
|
|
27
|
+
var valueLen = mobileValue.length;
|
|
28
|
+
var isNumber = mobileValue.match(/^[0-9]/g);
|
|
29
|
+
if (!isNumber)
|
|
30
|
+
return this.createError({ message: 'enter_valid_mobile_number' });
|
|
31
|
+
var isStartWithZero = mobileValue.startsWith('05');
|
|
32
|
+
var isStartWith5 = mobileValue.startsWith('5');
|
|
33
|
+
var isSaudiNumber = isStartWith5 || isStartWithZero;
|
|
34
|
+
if (isSA) {
|
|
35
|
+
if (!isSaudiNumber)
|
|
36
|
+
return this.createError({ message: 'start_with_number' });
|
|
37
|
+
var requiredLen = isStartWith5 ? digits - 1 : digits;
|
|
38
|
+
return valueLen === requiredLen ? true : this.createError({ message: 'enter_valid_mobile_number' });
|
|
39
|
+
}
|
|
40
|
+
return valueLen === digits ? true : this.createError({ message: 'enter_valid_mobile_number' });
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
57
43
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.optional(),
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
44
|
+
})
|
|
45
|
+
.optional(),
|
|
46
|
+
email: yup.string().email('email_not_valid').optional(),
|
|
47
|
+
gender: yup.string().optional(),
|
|
48
|
+
nid: isOtherCountry
|
|
49
|
+
? yup.string().min(3, 'signup_invalid_national_id').required('signup_invalid_national_id')
|
|
50
|
+
: yup
|
|
51
|
+
.string()
|
|
52
|
+
.test({
|
|
53
|
+
test: function (value) {
|
|
54
|
+
var id = value || '';
|
|
55
|
+
if (id.length > 0) {
|
|
56
|
+
if (id.length < 10)
|
|
57
|
+
return this.createError({ message: 'signup_invalid_national_id' });
|
|
58
|
+
var isMatch = id.match(/^(1|2)([0-9]{1,})$/g);
|
|
59
|
+
return isMatch ? true : this.createError({ message: 'signup_invalid_national_id_format' });
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
.optional(),
|
|
65
|
+
issuedCountry: yup.object().optional(),
|
|
66
|
+
expiryDate: yup.string().min(5).optional(),
|
|
67
|
+
dob: yup.string().min(5).optional(),
|
|
68
|
+
placeOfBirthCountry: yup.object().optional(),
|
|
69
|
+
placeOfBirthCity: yup.object().optional(),
|
|
70
|
+
nationality: yup.object().optional()
|
|
71
|
+
});
|
|
72
|
+
};
|