@tap-payments/auth-jsconnect 2.6.16-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.
@@ -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) && (data === null || data === void 0 ? void 0 : data.phone)) {
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
  }
@@ -1277,6 +1277,10 @@ export var connectSlice = createSlice({
1277
1277
  state.error = null;
1278
1278
  state.loading = false;
1279
1279
  var _a = action.payload, brandList = _a.brandList, entityList = _a.entityList;
1280
+ if (brandList === null || brandList === void 0 ? void 0 : brandList.length)
1281
+ state.data.authenticationData.brandInfo = brandList[0];
1282
+ if (entityList === null || entityList === void 0 ? void 0 : entityList.length)
1283
+ state.data.authenticationData.entityInfo = entityList[0];
1280
1284
  state.data.responseData = __assign(__assign({}, state.data.responseData), { authenticationData: { brandList: brandList, entityList: entityList } });
1281
1285
  })
1282
1286
  .addCase(retrieveAuthenticationListAsync.pending, function (state) {
@@ -1366,6 +1370,9 @@ export var connectSlice = createSlice({
1366
1370
  state.error = null;
1367
1371
  var data = state.data.responseData;
1368
1372
  var merchantList = action.payload;
1373
+ if (merchantList === null || merchantList === void 0 ? void 0 : merchantList.length) {
1374
+ state.data.authenticationData.merchantInfo = merchantList[0];
1375
+ }
1369
1376
  state.data.responseData = __assign(__assign({}, data), { authenticationData: __assign(__assign({}, data === null || data === void 0 ? void 0 : data.authenticationData), { merchantList: merchantList }) });
1370
1377
  })
1371
1378
  .addCase(getMerchantListAsync.rejected, function (state, action) {
@@ -1381,6 +1388,9 @@ export var connectSlice = createSlice({
1381
1388
  state.error = null;
1382
1389
  var data = state.data.responseData;
1383
1390
  var terminalList = action.payload;
1391
+ if (terminalList === null || terminalList === void 0 ? void 0 : terminalList.length) {
1392
+ state.data.authenticationData.terminalInfo = terminalList[0];
1393
+ }
1384
1394
  state.data.responseData = __assign(__assign({}, data), { authenticationData: __assign(__assign({}, data === null || data === void 0 ? void 0 : data.authenticationData), { terminalList: terminalList }) });
1385
1395
  })
1386
1396
  .addCase(getTerminalListAsync.rejected, function (state, action) {
@@ -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
- var _a, _b;
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
- }, [settingLoading]);
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;
@@ -74,6 +74,14 @@ var AuthenticationList = function (_a) {
74
74
  var screen = startWithNID ? (isKW(code) ? 'CONNECT_EXPRESS_CIVIL_ID_STEP' : 'CONNECT_EXPRESS_NID_STEP') : 'CONNECT_EXPRESS_MOBILE_STEP';
75
75
  dispatch(handlePrevScreenStep(screen));
76
76
  };
77
+ React.useEffect(function () {
78
+ if (merchantInfo && !methods.getValues('merchantInfo'))
79
+ methods.setValue('merchantInfo', merchantInfo, { shouldValidate: true });
80
+ }, [merchantInfo]);
81
+ React.useEffect(function () {
82
+ if (terminalInfo && !methods.getValues('terminalInfo'))
83
+ methods.setValue('terminalInfo', terminalInfo, { shouldValidate: true });
84
+ }, [terminalInfo]);
77
85
  React.useEffect(function () {
78
86
  if (error)
79
87
  dispatch(clearError());
@@ -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 = yup.object().shape({
4
- name: yup
5
- .string()
6
- .test({
7
- test: function (value) {
8
- if (((value === null || value === void 0 ? void 0 : value.length) || 0) > 0) {
9
- var name_1 = value || '';
10
- var isMatch = name_1.match(REGEX_FULL_NAME);
11
- return isMatch ? true : this.createError({ message: 'please write your first and last name' });
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 valueLen === digits ? true : this.createError({ message: 'enter_valid_mobile_number' });
14
+ return true;
40
15
  }
41
- return true;
42
- }
43
- })
44
- .optional(),
45
- email: yup.string().email('email_not_valid').optional(),
46
- gender: yup.string().optional(),
47
- nid: yup
48
- .string()
49
- .test({
50
- test: function (value) {
51
- var id = value || '';
52
- if (id.length > 0) {
53
- if (id.length < 10)
54
- return this.createError({ message: 'signup_invalid_national_id' });
55
- var isMatch = id.match(/^(1|2)([0-9]{1,})$/g);
56
- return isMatch ? true : this.createError({ message: 'signup_invalid_national_id_format' });
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
- return true;
59
- }
60
- })
61
- .optional(),
62
- issuedCountry: yup.object().optional(),
63
- expiryDate: yup.string().min(5).optional(),
64
- dob: yup.string().min(5).optional(),
65
- placeOfBirthCountry: yup.object().optional(),
66
- placeOfBirthCity: yup.object().optional(),
67
- nationality: yup.object().optional()
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.6.16-test",
3
+ "version": "2.6.18-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",