@tap-payments/auth-jsconnect 2.12.13-development → 2.12.14-development
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 -0
- package/build/features/app/connectExpress/connectExpressStore.js +19 -16
- package/build/features/connectExpress/ConnectExpress.js +4 -4
- package/build/features/connectExpress/screens/AuthenticationList/AuthenticationList.js +9 -9
- package/build/features/connectExpress/screens/BusinessCountry/BusinessCountry.js +7 -6
- package/build/features/connectExpress/screens/CollectIndividualInfo/CollectIndividualInfo.js +8 -8
- package/build/features/connectExpress/screens/NIDMissed/NID.js +5 -6
- package/build/features/connectExpress/screens/OTP/OTP.js +7 -8
- package/build/features/connectExpress/screens/OTP/OTPInput.js +5 -8
- package/build/hooks/index.d.ts +1 -0
- package/build/hooks/index.js +1 -0
- package/build/hooks/useAppConfig.js +1 -1
- package/build/hooks/useIsEmailAuth.d.ts +1 -0
- package/build/hooks/useIsEmailAuth.js +11 -0
- package/build/utils/string.d.ts +1 -0
- package/build/utils/string.js +3 -0
- package/package.json +1 -1
package/build/@types/app.d.ts
CHANGED
|
@@ -236,6 +236,7 @@ export interface LibConfig extends LibCallbacks {
|
|
|
236
236
|
closeButton?: boolean;
|
|
237
237
|
disableNafath?: boolean;
|
|
238
238
|
disablePaci?: boolean;
|
|
239
|
+
emailAuth?: boolean;
|
|
239
240
|
dialogStartTransition?: 'left' | 'right' | 'up' | 'down';
|
|
240
241
|
dialogEndTransition?: 'left' | 'right' | 'up' | 'down';
|
|
241
242
|
};
|
|
@@ -61,7 +61,7 @@ import { FlowsTypes, AuthForType, BusinessType, LicenseType, AuthForScreen } fro
|
|
|
61
61
|
import API, { setAuthSessionToGlobalHeaders } from '../../../api';
|
|
62
62
|
import { ADD_NEW_ENTITY, COLLECT_DOB_INFO_NAFATH, CONNECT_EXPRESS_STEP_NAMES, IDENTIFICATION_TYPE, NAFATH_PACI_TIMEOUT_DURATION, NAFATH_VERIFICATION_FAILED, OTHER_CR_LICENSE, OTHER_FL_LICENSE, SCOPE_AUTH, SCOPE_MERCHANT } from '../../../constants';
|
|
63
63
|
import { defaultCountry } from '../../../constants';
|
|
64
|
-
import { getIndividualName, capitalizeTheFirstLetterOfEachWord, sleep, findCountryByIddPrefix, concatenateObjectValues, isSA, isKW,
|
|
64
|
+
import { getIndividualName, capitalizeTheFirstLetterOfEachWord, sleep, findCountryByIddPrefix, concatenateObjectValues, isSA, isKW, isEmailAuthEnabled, isOtherThanKWOrSA, sendCustomEventToGTM, sendCustomDimension, getMetaData, isNetworkError, isTimeoutError, isInternalServerError, isAuthenticationVerificationFailed } from '../../../utils';
|
|
65
65
|
export var updateBusinessCountryAsync = createAsyncThunk('connectExpress/updateBusinessCountryAsync', function (countryCode, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
66
|
var connectExpress, payload, data;
|
|
67
67
|
return __generator(this, function (_a) {
|
|
@@ -81,17 +81,17 @@ export var updateBusinessCountryAsync = createAsyncThunk('connectExpress/updateB
|
|
|
81
81
|
});
|
|
82
82
|
}); });
|
|
83
83
|
export var retrieveLeadIdentityByIdAsync = createAsyncThunk('expressConnect/retrieveLeadIdentityByIdAsync', function (leadId, thunkApi) { return __awaiter(void 0, void 0, void 0, function () {
|
|
84
|
-
var settings, countryCode, showBoard, data, _a, country_code, contact, phone, status, board_id, board_info_id, isRegistered, screen_1, screen_2, _b, boardInfo, boardData, error_1;
|
|
85
|
-
var _c, _d, _e, _f, _g, _h;
|
|
86
|
-
return __generator(this, function (
|
|
87
|
-
switch (
|
|
84
|
+
var settings, countryCode, showBoard, data, _a, country_code, contact, phone, status, board_id, board_info_id, emailAuth, isRegistered, screen_1, screen_2, _b, boardInfo, boardData, error_1;
|
|
85
|
+
var _c, _d, _e, _f, _g, _h, _j;
|
|
86
|
+
return __generator(this, function (_k) {
|
|
87
|
+
switch (_k.label) {
|
|
88
88
|
case 0:
|
|
89
89
|
settings = thunkApi.getState().settings;
|
|
90
90
|
countryCode = settings.data.businessCountry;
|
|
91
91
|
showBoard = settings.data.appConfig.showBoard;
|
|
92
92
|
return [4, API.leadService.retrieveLeadIdentity(leadId)];
|
|
93
93
|
case 1:
|
|
94
|
-
data =
|
|
94
|
+
data = _k.sent();
|
|
95
95
|
_a = data || {}, country_code = _a.country_code, contact = _a.contact;
|
|
96
96
|
if (country_code)
|
|
97
97
|
thunkApi.dispatch(handleSetCountryByIso2(country_code));
|
|
@@ -103,20 +103,23 @@ export var retrieveLeadIdentityByIdAsync = createAsyncThunk('expressConnect/retr
|
|
|
103
103
|
thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_BUSINESS_COUNTRY_STEP'));
|
|
104
104
|
return [2, { data: data, countryCode: countryCode }];
|
|
105
105
|
}
|
|
106
|
+
emailAuth = (_d = settings.data.appConfig.features) === null || _d === void 0 ? void 0 : _d.emailAuth;
|
|
106
107
|
isRegistered = (status === null || status === void 0 ? void 0 : status.toLowerCase()) === 'registered';
|
|
107
108
|
if (!isRegistered && !(data === null || data === void 0 ? void 0 : data.identification) && phone) {
|
|
108
|
-
screen_1 =
|
|
109
|
+
screen_1 = isEmailAuthEnabled(emailAuth, country_code || ((_e = settings.data.businessCountry) === null || _e === void 0 ? void 0 : _e.iso2))
|
|
110
|
+
? 'CONNECT_EXPRESS_EMAIL_STEP'
|
|
111
|
+
: 'CONNECT_EXPRESS_MOBILE_STEP';
|
|
109
112
|
thunkApi.dispatch(handleCurrentActiveScreen(screen_1));
|
|
110
113
|
return [2, { data: data, countryCode: countryCode }];
|
|
111
114
|
}
|
|
112
115
|
if (!isRegistered && country_code) {
|
|
113
116
|
screen_2 = 'CONNECT_EXPRESS_NID_STEP';
|
|
114
117
|
if (!isSA(data.country_code))
|
|
115
|
-
screen_2 =
|
|
118
|
+
screen_2 = isEmailAuthEnabled(emailAuth, data.country_code) ? 'CONNECT_EXPRESS_EMAIL_STEP' : 'CONNECT_EXPRESS_MOBILE_STEP';
|
|
116
119
|
thunkApi.dispatch(handleCurrentActiveScreen(screen_2));
|
|
117
120
|
return [2, { data: data, countryCode: countryCode }];
|
|
118
121
|
}
|
|
119
|
-
if (!isRegistered &&
|
|
122
|
+
if (!isRegistered && isEmailAuthEnabled(emailAuth, settings.data.businessCountry.iso2)) {
|
|
120
123
|
thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_EMAIL_STEP'));
|
|
121
124
|
return [2, { data: data, countryCode: countryCode }];
|
|
122
125
|
}
|
|
@@ -128,11 +131,11 @@ export var retrieveLeadIdentityByIdAsync = createAsyncThunk('expressConnect/retr
|
|
|
128
131
|
thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_NID_STEP'));
|
|
129
132
|
return [2, { data: data, countryCode: countryCode }];
|
|
130
133
|
}
|
|
131
|
-
if ((
|
|
132
|
-
thunkApi.dispatch(storeAuthId((
|
|
134
|
+
if ((_f = data === null || data === void 0 ? void 0 : data.identification) === null || _f === void 0 ? void 0 : _f.authentication_id) {
|
|
135
|
+
thunkApi.dispatch(storeAuthId((_g = data === null || data === void 0 ? void 0 : data.identification) === null || _g === void 0 ? void 0 : _g.authentication_id));
|
|
133
136
|
}
|
|
134
137
|
if (isRegistered && !showBoard) {
|
|
135
|
-
(
|
|
138
|
+
(_j = (_h = settings.data.appConfig).onFlowCompleted) === null || _j === void 0 ? void 0 : _j.call(_h, data);
|
|
136
139
|
thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_ACCOUNT_ALREADY_CREATED_STEP'));
|
|
137
140
|
return [2, { data: data, countryCode: countryCode }];
|
|
138
141
|
}
|
|
@@ -141,19 +144,19 @@ export var retrieveLeadIdentityByIdAsync = createAsyncThunk('expressConnect/retr
|
|
|
141
144
|
return [2, { data: data, countryCode: countryCode }];
|
|
142
145
|
}
|
|
143
146
|
if (!(isRegistered && board_id && board_info_id)) return [3, 5];
|
|
144
|
-
|
|
147
|
+
_k.label = 2;
|
|
145
148
|
case 2:
|
|
146
|
-
|
|
149
|
+
_k.trys.push([2, 4, , 5]);
|
|
147
150
|
return [4, Promise.all([
|
|
148
151
|
API.boardService.retrieveBoardInfo({ id: board_id, infoId: board_info_id }),
|
|
149
152
|
API.boardService.retrieveBoardDetails(board_id)
|
|
150
153
|
])];
|
|
151
154
|
case 3:
|
|
152
|
-
_b =
|
|
155
|
+
_b = _k.sent(), boardInfo = _b[0], boardData = _b[1];
|
|
153
156
|
thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_SUCCESS_WITH_FLOW_BUTTONS_STEP'));
|
|
154
157
|
return [2, { data: data, countryCode: countryCode, boardInfo: boardInfo, boardData: boardData }];
|
|
155
158
|
case 4:
|
|
156
|
-
error_1 =
|
|
159
|
+
error_1 = _k.sent();
|
|
157
160
|
thunkApi.dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_ACCOUNT_ALREADY_CREATED_STEP'));
|
|
158
161
|
return [2, { data: data, countryCode: countryCode }];
|
|
159
162
|
case 5: return [2, { data: data, countryCode: countryCode }];
|
|
@@ -67,7 +67,7 @@ import { store } from '../../app/store';
|
|
|
67
67
|
import { connectExpressSelector, setIsLeadIdPassed, setLeadId, retrieveLeadIdentityByIdAsync, setDefaultCountryCode, clearError, createAuthSessionExpiredAsync } from '../app/connectExpress/connectExpressStore';
|
|
68
68
|
import { ReduxProvider, ThemeProvider } from '../../components/Providers';
|
|
69
69
|
import Collapse from '../../components/Collapse';
|
|
70
|
-
import { isKW,
|
|
70
|
+
import { isKW, isEmailAuthEnabled, findOrCreateElementAndInject, sendPageView, isOtherThanKWOrSA, initializeGTM, sendCustomEventToGTM, sendCustomDimension } from '../../utils';
|
|
71
71
|
import { CONNECT_EXPRESS_SCREENS_NAVIGATION } from '../../constants';
|
|
72
72
|
import { connectExpressFeatureScreens } from '../featuresScreens';
|
|
73
73
|
import Background from '../shared/Background';
|
|
@@ -123,7 +123,7 @@ var ConnectExpress = memo(function (_a) {
|
|
|
123
123
|
}
|
|
124
124
|
}, [data.businessCountry]);
|
|
125
125
|
React.useEffect(function () {
|
|
126
|
-
var _a, _b, _c;
|
|
126
|
+
var _a, _b, _c, _d;
|
|
127
127
|
if (settingLoading || !props.open)
|
|
128
128
|
return;
|
|
129
129
|
if (!data.isValidOperator) {
|
|
@@ -146,10 +146,10 @@ var ConnectExpress = memo(function (_a) {
|
|
|
146
146
|
dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_BUSINESS_COUNTRY_STEP'));
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
if (((_b = data.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2) &&
|
|
149
|
+
if (((_b = data.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2) && isEmailAuthEnabled((_c = appConfig.features) === null || _c === void 0 ? void 0 : _c.emailAuth, data.businessCountry.iso2)) {
|
|
150
150
|
dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_EMAIL_STEP'));
|
|
151
151
|
}
|
|
152
|
-
else if (((
|
|
152
|
+
else if (((_d = data.businessCountry) === null || _d === void 0 ? void 0 : _d.iso2) && (isKW(data.businessCountry.iso2) || isOtherThanKWOrSA(data.businessCountry.iso2))) {
|
|
153
153
|
dispatch(handleCurrentActiveScreen('CONNECT_EXPRESS_MOBILE_STEP'));
|
|
154
154
|
}
|
|
155
155
|
}, [data.isValidOperator, settingLoading]);
|
|
@@ -15,9 +15,9 @@ import { useForm, FormProvider } from 'react-hook-form';
|
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
16
|
import Collapse from '@mui/material/Collapse';
|
|
17
17
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
18
|
-
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
18
|
+
import { useAppDispatch, useAppSelector, useIsEmailAuth } from '../../../../hooks';
|
|
19
19
|
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
20
|
-
import { deepCopy, isKW, isSA,
|
|
20
|
+
import { deepCopy, isKW, isSA, sendCustomEventToGTM } from '../../../../utils';
|
|
21
21
|
import { AuthForType } from '../../../../@types';
|
|
22
22
|
import Form from '../../../../components/Form';
|
|
23
23
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
@@ -36,16 +36,16 @@ var ListType;
|
|
|
36
36
|
ListType["EntityList"] = "EntityList";
|
|
37
37
|
})(ListType || (ListType = {}));
|
|
38
38
|
var AuthenticationList = function (_a) {
|
|
39
|
-
var _b, _c
|
|
39
|
+
var _b, _c;
|
|
40
40
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
41
|
+
var _d = useAppSelector(connectExpressSelector), data = _d.data, loading = _d.loading, error = _d.error;
|
|
42
|
+
var _e = data.authenticationData, brandInfo = _e.brandInfo, entityInfo = _e.entityInfo;
|
|
43
|
+
var _f = React.useState(), listActive = _f[0], setListActive = _f[1];
|
|
44
44
|
var brandList = (((_b = data.responseData) === null || _b === void 0 ? void 0 : _b.authenticationData) || {}).brandList;
|
|
45
|
-
var
|
|
45
|
+
var _g = React.useState(false), isAddEntity = _g[0], setIsAddEntity = _g[1];
|
|
46
46
|
var otpData = data.otpData;
|
|
47
47
|
var startWithNID = otpData.authFor === AuthForType.NATIONAL_ID;
|
|
48
|
-
var startWithEmail =
|
|
48
|
+
var startWithEmail = useIsEmailAuth();
|
|
49
49
|
React.useEffect(function () {
|
|
50
50
|
sendCustomEventToGTM({
|
|
51
51
|
event: 'Send Event',
|
|
@@ -64,7 +64,7 @@ var AuthenticationList = function (_a) {
|
|
|
64
64
|
var t = useTranslation().t;
|
|
65
65
|
var isAr = useLanguage().isAr;
|
|
66
66
|
var dispatch = useAppDispatch();
|
|
67
|
-
var code = (
|
|
67
|
+
var code = (_c = settingsData.businessCountry) === null || _c === void 0 ? void 0 : _c.iso2;
|
|
68
68
|
var isSACountry = React.useMemo(function () { return isSA(code); }, [code]);
|
|
69
69
|
var onSubmit = function (formData) {
|
|
70
70
|
if (isAddEntity) {
|
|
@@ -53,7 +53,7 @@ import { ScreenContainer } from '../../../shared/Containers';
|
|
|
53
53
|
import BusinessCountry from '../../../shared/BusinessCountry';
|
|
54
54
|
import Button from '../../../shared/Button';
|
|
55
55
|
import Collapse from '../../../../components/Collapse';
|
|
56
|
-
import { findCountryByIso2, isKW,
|
|
56
|
+
import { findCountryByIso2, isKW, isEmailAuthEnabled, isOtherThanKWOrSA, sendCustomEventToGTM } from '../../../../utils';
|
|
57
57
|
import { handleNextScreenStep, handleSetCountryByIso2, settingsSelector } from '../../../../app/settings';
|
|
58
58
|
import { clearError, connectExpressSelector, setDefaultCountryCode, storeIsStartFromBusinessCountry, updateBusinessCountryAsync } from '../../../app/connectExpress/connectExpressStore';
|
|
59
59
|
var BusinessCountryScreen = function (_a) {
|
|
@@ -74,8 +74,9 @@ var BusinessCountryScreen = function (_a) {
|
|
|
74
74
|
}, [settingsData.businessCountry, settingsData.ipCountry]);
|
|
75
75
|
var onSelectCountry = function (iso2) { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
76
|
var countryCode;
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
var _a;
|
|
78
|
+
return __generator(this, function (_b) {
|
|
79
|
+
switch (_b.label) {
|
|
79
80
|
case 0:
|
|
80
81
|
if (!iso2)
|
|
81
82
|
return [2];
|
|
@@ -90,12 +91,12 @@ var BusinessCountryScreen = function (_a) {
|
|
|
90
91
|
if (!data.leadId) return [3, 2];
|
|
91
92
|
return [4, dispatch(updateBusinessCountryAsync(iso2))];
|
|
92
93
|
case 1:
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
_b.sent();
|
|
95
|
+
_b.label = 2;
|
|
95
96
|
case 2:
|
|
96
97
|
if (countryCode)
|
|
97
98
|
dispatch(setDefaultCountryCode(countryCode));
|
|
98
|
-
if (
|
|
99
|
+
if (isEmailAuthEnabled((_a = settingsData.appConfig.features) === null || _a === void 0 ? void 0 : _a.emailAuth, iso2)) {
|
|
99
100
|
dispatch(handleNextScreenStep('CONNECT_EXPRESS_EMAIL_STEP'));
|
|
100
101
|
return [2];
|
|
101
102
|
}
|
package/build/features/connectExpress/screens/CollectIndividualInfo/CollectIndividualInfo.js
CHANGED
|
@@ -17,8 +17,8 @@ import { yupResolver } from '@hookform/resolvers/yup';
|
|
|
17
17
|
import { styled } from '@mui/material/styles';
|
|
18
18
|
import { useAppDispatch, useAppSelector, useExcludeReadOnlyFelids, useFormErrorAndUpdateReadOnly, useFormReadOnly, useSetFromDefaultValues } from '../../../../hooks';
|
|
19
19
|
import { AuthForType } from '../../../../@types';
|
|
20
|
-
import { useLanguage } from '../../../../hooks';
|
|
21
|
-
import { deepCopy, isKW,
|
|
20
|
+
import { useLanguage, useIsEmailAuth } from '../../../../hooks';
|
|
21
|
+
import { deepCopy, isKW, sendCustomEventToGTM } from '../../../../utils';
|
|
22
22
|
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
23
23
|
import Form from '../../../../components/Form';
|
|
24
24
|
import Collapse from '../../../../components/Collapse';
|
|
@@ -36,16 +36,16 @@ var FormStyled = styled(Form)(function () { return ({
|
|
|
36
36
|
justifyContent: 'space-between'
|
|
37
37
|
}); });
|
|
38
38
|
var CollectIndividualInfo = function (_a) {
|
|
39
|
-
var _b
|
|
40
|
-
var
|
|
41
|
-
var
|
|
39
|
+
var _b;
|
|
40
|
+
var _c = React.useState(false), listActive = _c[0], setListActive = _c[1];
|
|
41
|
+
var _d = React.useState(false), emailChecking = _d[0], setEmailChecking = _d[1];
|
|
42
42
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
43
|
-
var
|
|
43
|
+
var _e = useAppSelector(connectExpressSelector), data = _e.data, loading = _e.loading, error = _e.error;
|
|
44
44
|
var dispatch = useAppDispatch();
|
|
45
45
|
var t = useTranslation().t;
|
|
46
46
|
var isAr = useLanguage().isAr;
|
|
47
47
|
var individualData = data.individualData, otpData = data.otpData, responseData = data.responseData;
|
|
48
|
-
var startWithEmail =
|
|
48
|
+
var startWithEmail = useIsEmailAuth();
|
|
49
49
|
var startWithNID = otpData.authFor === AuthForType.NATIONAL_ID;
|
|
50
50
|
var startWithNIDMissed = otpData.authFor === AuthForType.NATIONAL_ID_MISSED;
|
|
51
51
|
var contact = ((responseData === null || responseData === void 0 ? void 0 : responseData.leadData) || {}).contact;
|
|
@@ -119,7 +119,7 @@ var CollectIndividualInfo = function (_a) {
|
|
|
119
119
|
var isEmailValid = typeof isEmailAvailable === 'undefined' ? isLeadEmailAvailable : isEmailAvailable;
|
|
120
120
|
var emailErrChecks = !methods.formState.isValid || !!methods.formState.errors.email;
|
|
121
121
|
var disabled = emailErrChecks || emailChecking || !isEmailValid;
|
|
122
|
-
var emailReadOnly = readOnly['email'] && !((
|
|
122
|
+
var emailReadOnly = readOnly['email'] && !((_b = methods.getFieldState('email').error) === null || _b === void 0 ? void 0 : _b.message) && !methods.getFieldState('email').isDirty;
|
|
123
123
|
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(Name, { readOnly: readOnly['name'], show: !listActive }), _jsx(MobileNumber, { readOnly: readOnly['mobile'], show: true, onListOpen: function () { return handleMenuListClick(); }, onListClose: function () { return handleMenuListClick(); }, countries: settingsData.countries }), _jsx(Email, { readOnly: emailReadOnly, 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') })) }))] })) })) }));
|
|
124
124
|
};
|
|
125
125
|
export default React.memo(CollectIndividualInfo);
|
|
@@ -16,7 +16,7 @@ import { styled } from '@mui/material/styles';
|
|
|
16
16
|
import { useForm, FormProvider } from 'react-hook-form';
|
|
17
17
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
18
18
|
import { NIDOtherCountryValidationSchema, NIDValidationSchema } from './validation';
|
|
19
|
-
import { useAppDispatch, useLanguage, useAppSelector } from '../../../../hooks';
|
|
19
|
+
import { useAppDispatch, useLanguage, useAppSelector, useIsEmailAuth } from '../../../../hooks';
|
|
20
20
|
import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
|
|
21
21
|
import { clearError, connectExpressSelector, createNIDNafathAuthIdentityAsync } from '../../../app/connectExpress/connectExpressStore';
|
|
22
22
|
import Form from '../../../../components/Form';
|
|
@@ -25,21 +25,20 @@ import { ScreenContainer } from '../../../shared/Containers';
|
|
|
25
25
|
import Collapse from '../../../../components/Collapse';
|
|
26
26
|
import IDNumber from './IDNumber';
|
|
27
27
|
import DOB from './DOB';
|
|
28
|
-
import { deepCopy, isOtherThanKWOrSA
|
|
28
|
+
import { deepCopy, isOtherThanKWOrSA } from '../../../../utils';
|
|
29
29
|
var FormStyled = styled(Form)(function () { return ({
|
|
30
30
|
display: 'flex',
|
|
31
31
|
flexDirection: 'column'
|
|
32
32
|
}); });
|
|
33
33
|
var NID = function (_a) {
|
|
34
|
-
var _b;
|
|
35
|
-
var _c = React.useState(false), collapse = _c[0], setCollapse = _c[1];
|
|
34
|
+
var _b = React.useState(false), collapse = _b[0], setCollapse = _b[1];
|
|
36
35
|
var isAr = useLanguage().isAr;
|
|
37
36
|
var dispatch = useAppDispatch();
|
|
38
37
|
var t = useTranslation().t;
|
|
39
38
|
var settingsData = useAppSelector(settingsSelector).data;
|
|
40
|
-
var
|
|
39
|
+
var _c = useAppSelector(connectExpressSelector), data = _c.data, loading = _c.loading, error = _c.error;
|
|
41
40
|
var isOtherCountry = React.useMemo(function () { return isOtherThanKWOrSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
|
|
42
|
-
var startWithEmail =
|
|
41
|
+
var startWithEmail = useIsEmailAuth();
|
|
43
42
|
var methods = useForm({
|
|
44
43
|
resolver: yupResolver(isOtherCountry ? NIDOtherCountryValidationSchema : NIDValidationSchema),
|
|
45
44
|
defaultValues: data.nidData,
|
|
@@ -17,13 +17,13 @@ import Text from '../../../../components/Text';
|
|
|
17
17
|
import { clearError, connectExpressSelector, verifyMobileOtpAsync, verifyEmailOtpAsync, resetOTPValue } from '../../../app/connectExpress/connectExpressStore';
|
|
18
18
|
import Button from '../../../shared/Button';
|
|
19
19
|
import { ScreenContainer } from '../../../shared/Containers';
|
|
20
|
-
import { useAppDispatch, useAppSelector, useSanitizedTranslation } from '../../../../hooks';
|
|
21
|
-
import { handlePrevScreenStep
|
|
20
|
+
import { useAppDispatch, useAppSelector, useSanitizedTranslation, useIsEmailAuth } from '../../../../hooks';
|
|
21
|
+
import { handlePrevScreenStep } from '../../../../app/settings';
|
|
22
22
|
import { useLanguage } from '../../../../hooks';
|
|
23
23
|
import { useForm, FormProvider } from 'react-hook-form';
|
|
24
24
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
25
25
|
import Form from '../../../../components/Form';
|
|
26
|
-
import { maskPhone, deepCopy, sendCustomEventToGTM, maskEmail
|
|
26
|
+
import { maskPhone, deepCopy, sendCustomEventToGTM, maskEmail } from '../../../../utils';
|
|
27
27
|
import { OTPValidation } from './validation';
|
|
28
28
|
import OTPInput from './OTPInput';
|
|
29
29
|
var OTPTitleContainerStyled = styled(Box)(function (_a) {
|
|
@@ -46,13 +46,12 @@ var FormStyled = styled(Form)(function () { return ({
|
|
|
46
46
|
flexDirection: 'column'
|
|
47
47
|
}); });
|
|
48
48
|
var OTP = function () {
|
|
49
|
-
var _a
|
|
49
|
+
var _a;
|
|
50
50
|
var dispatch = useAppDispatch();
|
|
51
|
-
var
|
|
52
|
-
var settingsData = useAppSelector(settingsSelector).data;
|
|
51
|
+
var _b = useAppSelector(connectExpressSelector), data = _b.data, loading = _b.loading, error = _b.error;
|
|
53
52
|
var st = useSanitizedTranslation();
|
|
54
53
|
var isAr = useLanguage().isAr;
|
|
55
|
-
var isEmailFlow =
|
|
54
|
+
var isEmailFlow = useIsEmailAuth();
|
|
56
55
|
var methods = useForm({
|
|
57
56
|
resolver: yupResolver(OTPValidation),
|
|
58
57
|
defaultValues: data.otpData,
|
|
@@ -85,7 +84,7 @@ var OTP = function () {
|
|
|
85
84
|
dispatch(handlePrevScreenStep(screen));
|
|
86
85
|
};
|
|
87
86
|
var disabled = !methods.formState.isValid;
|
|
88
|
-
var phone = data.mobileData.mobile ? ((
|
|
87
|
+
var phone = data.mobileData.mobile ? ((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix) + data.mobileData.mobile : '';
|
|
89
88
|
var contactInfo = isEmailFlow ? maskEmail(data.emailData.email) : maskPhone(phone);
|
|
90
89
|
var title = isEmailFlow ? st('otp_email_sent_title') : st('ide_opt_sent_title');
|
|
91
90
|
return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? st('ide_otp_waiting_title') : title, !loading && _jsx("span", __assign({ dir: 'ltr' }, { children: contactInfo }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, loading: loading, error: st(error || '') }, { children: st('next') }))] })) })) }));
|
|
@@ -18,9 +18,8 @@ import { styled } from '@mui/material/styles';
|
|
|
18
18
|
import OTPField from '../../../shared/OTP';
|
|
19
19
|
import { DEFAULT_TIMER_VALUE } from '../../../../constants';
|
|
20
20
|
import { resendMobileAuthOTP, resendEmailAuthOTP, connectExpressSelector, clearError } from '../../../app/connectExpress/connectExpressStore';
|
|
21
|
-
import { useAppDispatch, useAppSelector } from '../../../../hooks';
|
|
22
|
-
import { sendCustomEventToGTM
|
|
23
|
-
import { settingsSelector } from '../../../../app/settings';
|
|
21
|
+
import { useAppDispatch, useAppSelector, useIsEmailAuth } from '../../../../hooks';
|
|
22
|
+
import { sendCustomEventToGTM } from '../../../../utils';
|
|
24
23
|
var BoxStyled = styled(Box)(function (_a) {
|
|
25
24
|
var theme = _a.theme;
|
|
26
25
|
return ({
|
|
@@ -30,15 +29,13 @@ var BoxStyled = styled(Box)(function (_a) {
|
|
|
30
29
|
});
|
|
31
30
|
});
|
|
32
31
|
var OTPInput = function (_a) {
|
|
33
|
-
var _b;
|
|
34
|
-
var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
|
|
32
|
+
var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
|
|
35
33
|
var t = useTranslation().t;
|
|
36
34
|
var dispatch = useAppDispatch();
|
|
37
35
|
var otpControl = useController({ name: 'otp', control: control });
|
|
38
|
-
var
|
|
39
|
-
var settingsData = useAppSelector(settingsSelector).data;
|
|
36
|
+
var _c = useAppSelector(connectExpressSelector), data = _c.data, error = _c.error;
|
|
40
37
|
var mobileData = data.mobileData, emailData = data.emailData;
|
|
41
|
-
var isEmailFlow =
|
|
38
|
+
var isEmailFlow = useIsEmailAuth();
|
|
42
39
|
var sendEventAskAnotherOTP = function () {
|
|
43
40
|
sendCustomEventToGTM({
|
|
44
41
|
event: 'Send Event',
|
package/build/hooks/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './useSetFromDefaultValues';
|
|
|
15
15
|
export * from './useCountUp';
|
|
16
16
|
export * from './useCountDown';
|
|
17
17
|
export * from './useCountry';
|
|
18
|
+
export * from './useIsEmailAuth';
|
|
18
19
|
export * from './useVerifyToken';
|
|
19
20
|
export * from './useFormReadOnly';
|
|
20
21
|
export * from './useDataNoneEditable';
|
package/build/hooks/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from './useSetFromDefaultValues';
|
|
|
15
15
|
export * from './useCountUp';
|
|
16
16
|
export * from './useCountDown';
|
|
17
17
|
export * from './useCountry';
|
|
18
|
+
export * from './useIsEmailAuth';
|
|
18
19
|
export * from './useVerifyToken';
|
|
19
20
|
export * from './useFormReadOnly';
|
|
20
21
|
export * from './useDataNoneEditable';
|
|
@@ -31,7 +31,7 @@ export var useAppConfig = function (_a) {
|
|
|
31
31
|
var data = useAppSelector(settingsSelector).data;
|
|
32
32
|
var setAppConfig = function () {
|
|
33
33
|
if (!disableSettingFetching) {
|
|
34
|
-
dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey, scope: scope === null || scope === void 0 ? void 0 : scope.toLowerCase(), mode: mode !== null && mode !== void 0 ? mode : 'page', showBoard: showBoard !== null && showBoard !== void 0 ? showBoard : true, features: __assign({ merchantLogo: true, switchLanguage: true, overlay: true, loaderOverlay: true }, features) }, rest)));
|
|
34
|
+
dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey, scope: scope === null || scope === void 0 ? void 0 : scope.toLowerCase(), mode: mode !== null && mode !== void 0 ? mode : 'page', showBoard: showBoard !== null && showBoard !== void 0 ? showBoard : true, features: __assign({ merchantLogo: true, switchLanguage: true, overlay: true, loaderOverlay: true, emailAuth: true }, features) }, rest)));
|
|
35
35
|
}
|
|
36
36
|
dispatch(handleActiveFlowScreens(navigation));
|
|
37
37
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsEmailAuth: () => boolean | undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useAppSelector } from './useAppSelector';
|
|
3
|
+
import { settingsSelector } from '../app/settings';
|
|
4
|
+
import { isEmailAuthEnabled } from '../utils';
|
|
5
|
+
export var useIsEmailAuth = function () {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
var settingsData = useAppSelector(settingsSelector).data;
|
|
8
|
+
var emailAuth = (_a = settingsData.appConfig.features) === null || _a === void 0 ? void 0 : _a.emailAuth;
|
|
9
|
+
var countryIso2 = (_b = settingsData.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2;
|
|
10
|
+
return useMemo(function () { return isEmailAuthEnabled(emailAuth, countryIso2); }, [emailAuth, countryIso2]);
|
|
11
|
+
};
|
package/build/utils/string.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export declare const isKW: (flag: string) => boolean;
|
|
|
49
49
|
export declare const isSA: (flag: string | undefined) => boolean;
|
|
50
50
|
export declare const isOtherThanKWOrSA: (flag: string) => boolean;
|
|
51
51
|
export declare const isQA: (flag: string | undefined) => boolean;
|
|
52
|
+
export declare const isEmailAuthEnabled: (emailAuth: boolean | undefined, countryIso2: string | undefined) => boolean | undefined;
|
|
52
53
|
export declare const isKWOrSA: (flag: string) => boolean;
|
|
53
54
|
export declare const isLinkedIn: (flag: string) => boolean;
|
|
54
55
|
export declare const isTwitter: (flag: string) => boolean;
|
package/build/utils/string.js
CHANGED
|
@@ -229,6 +229,9 @@ export var isQA = function (flag) {
|
|
|
229
229
|
return false;
|
|
230
230
|
return ['qa', 'qat'].includes(flag.toLowerCase());
|
|
231
231
|
};
|
|
232
|
+
export var isEmailAuthEnabled = function (emailAuth, countryIso2) {
|
|
233
|
+
return emailAuth && isQA(countryIso2);
|
|
234
|
+
};
|
|
232
235
|
export var isKWOrSA = function (flag) {
|
|
233
236
|
return isKW(flag) || isSA(flag);
|
|
234
237
|
};
|