@tap-payments/auth-jsconnect 2.12.8 → 2.12.9

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.
@@ -17,7 +17,7 @@ import Collapse from '@mui/material/Collapse';
17
17
  import { yupResolver } from '@hookform/resolvers/yup';
18
18
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
19
19
  import { handlePrevScreenStep, settingsSelector } from '../../../../app/settings';
20
- import { deepCopy, isKW, isSA, sendCustomEventToGTM } from '../../../../utils';
20
+ import { deepCopy, isKW, isSA, isQA, 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, _d;
40
40
  var settingsData = useAppSelector(settingsSelector).data;
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];
41
+ var _e = useAppSelector(connectExpressSelector), data = _e.data, loading = _e.loading, error = _e.error;
42
+ var _f = data.authenticationData, brandInfo = _f.brandInfo, entityInfo = _f.entityInfo;
43
+ var _g = React.useState(), listActive = _g[0], setListActive = _g[1];
44
44
  var brandList = (((_b = data.responseData) === null || _b === void 0 ? void 0 : _b.authenticationData) || {}).brandList;
45
- var _g = React.useState(false), isAddEntity = _g[0], setIsAddEntity = _g[1];
45
+ var _h = React.useState(false), isAddEntity = _h[0], setIsAddEntity = _h[1];
46
46
  var otpData = data.otpData;
47
47
  var startWithNID = otpData.authFor === AuthForType.NATIONAL_ID;
48
- var startWithEmail = otpData.authFor === AuthForType.EMAIL;
48
+ var startWithEmail = isQA((_c = settingsData.businessCountry) === null || _c === void 0 ? void 0 : _c.iso2);
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 = (_c = settingsData.businessCountry) === null || _c === void 0 ? void 0 : _c.iso2;
67
+ var code = (_d = settingsData.businessCountry) === null || _d === void 0 ? void 0 : _d.iso2;
68
68
  var isSACountry = React.useMemo(function () { return isSA(code); }, [code]);
69
69
  var onSubmit = function (formData) {
70
70
  if (isAddEntity) {
@@ -18,7 +18,7 @@ import { styled } from '@mui/material/styles';
18
18
  import { useAppDispatch, useAppSelector, useExcludeReadOnlyFelids, useFormErrorAndUpdateReadOnly, useFormReadOnly, useSetFromDefaultValues } from '../../../../hooks';
19
19
  import { AuthForType } from '../../../../@types';
20
20
  import { useLanguage } from '../../../../hooks';
21
- import { deepCopy, isKW, sendCustomEventToGTM } from '../../../../utils';
21
+ import { deepCopy, isKW, isQA, 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 _c = React.useState(false), listActive = _c[0], setListActive = _c[1];
41
- var _d = React.useState(false), emailChecking = _d[0], setEmailChecking = _d[1];
39
+ var _b, _c;
40
+ var _d = React.useState(false), listActive = _d[0], setListActive = _d[1];
41
+ var _e = React.useState(false), emailChecking = _e[0], setEmailChecking = _e[1];
42
42
  var settingsData = useAppSelector(settingsSelector).data;
43
- var _e = useAppSelector(connectExpressSelector), data = _e.data, loading = _e.loading, error = _e.error;
43
+ var _f = useAppSelector(connectExpressSelector), data = _f.data, loading = _f.loading, error = _f.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 = otpData.authFor === AuthForType.EMAIL;
48
+ var startWithEmail = isQA((_b = settingsData.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2);
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'] && !((_b = methods.getFieldState('email').error) === null || _b === void 0 ? void 0 : _b.message) && !methods.getFieldState('email').isDirty;
122
+ var emailReadOnly = readOnly['email'] && !((_c = methods.getFieldState('email').error) === null || _c === void 0 ? void 0 : _c.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);
@@ -22,24 +22,24 @@ import { clearError, connectExpressSelector, createNIDNafathAuthIdentityAsync }
22
22
  import Form from '../../../../components/Form';
23
23
  import Button from '../../../shared/Button';
24
24
  import { ScreenContainer } from '../../../shared/Containers';
25
- import { AuthForType } from '../../../../@types';
26
25
  import Collapse from '../../../../components/Collapse';
27
26
  import IDNumber from './IDNumber';
28
27
  import DOB from './DOB';
29
- import { deepCopy, isOtherThanKWOrSA } from '../../../../utils';
28
+ import { deepCopy, isOtherThanKWOrSA, isQA } from '../../../../utils';
30
29
  var FormStyled = styled(Form)(function () { return ({
31
30
  display: 'flex',
32
31
  flexDirection: 'column'
33
32
  }); });
34
33
  var NID = function (_a) {
35
- var _b = React.useState(false), collapse = _b[0], setCollapse = _b[1];
34
+ var _b;
35
+ var _c = React.useState(false), collapse = _c[0], setCollapse = _c[1];
36
36
  var isAr = useLanguage().isAr;
37
37
  var dispatch = useAppDispatch();
38
38
  var t = useTranslation().t;
39
39
  var settingsData = useAppSelector(settingsSelector).data;
40
- var _c = useAppSelector(connectExpressSelector), data = _c.data, loading = _c.loading, error = _c.error;
40
+ var _d = useAppSelector(connectExpressSelector), data = _d.data, loading = _d.loading, error = _d.error;
41
41
  var isOtherCountry = React.useMemo(function () { return isOtherThanKWOrSA(settingsData.businessCountry.iso2); }, [settingsData.businessCountry.iso2]);
42
- var startWithEmail = data.otpData.authFor === AuthForType.EMAIL;
42
+ var startWithEmail = isQA((_b = settingsData.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2);
43
43
  var methods = useForm({
44
44
  resolver: yupResolver(isOtherCountry ? NIDOtherCountryValidationSchema : NIDValidationSchema),
45
45
  defaultValues: data.nidData,
@@ -18,13 +18,12 @@ import { clearError, connectExpressSelector, verifyMobileOtpAsync, verifyEmailOt
18
18
  import Button from '../../../shared/Button';
19
19
  import { ScreenContainer } from '../../../shared/Containers';
20
20
  import { useAppDispatch, useAppSelector, useSanitizedTranslation } from '../../../../hooks';
21
- import { handlePrevScreenStep } from '../../../../app/settings';
21
+ import { handlePrevScreenStep, settingsSelector } 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 } from '../../../../utils';
27
- import { AuthForType } from '../../../../@types';
26
+ import { maskPhone, deepCopy, sendCustomEventToGTM, maskEmail, isQA } from '../../../../utils';
28
27
  import { OTPValidation } from './validation';
29
28
  import OTPInput from './OTPInput';
30
29
  var OTPTitleContainerStyled = styled(Box)(function (_a) {
@@ -47,11 +46,13 @@ var FormStyled = styled(Form)(function () { return ({
47
46
  flexDirection: 'column'
48
47
  }); });
49
48
  var OTP = function () {
50
- var _a;
49
+ var _a, _b;
51
50
  var dispatch = useAppDispatch();
52
- var _b = useAppSelector(connectExpressSelector), data = _b.data, loading = _b.loading, error = _b.error;
51
+ var _c = useAppSelector(connectExpressSelector), data = _c.data, loading = _c.loading, error = _c.error;
52
+ var settingsData = useAppSelector(settingsSelector).data;
53
53
  var st = useSanitizedTranslation();
54
54
  var isAr = useLanguage().isAr;
55
+ var isEmailFlow = isQA((_a = settingsData.businessCountry) === null || _a === void 0 ? void 0 : _a.iso2);
55
56
  var methods = useForm({
56
57
  resolver: yupResolver(OTPValidation),
57
58
  defaultValues: data.otpData,
@@ -72,7 +73,7 @@ var OTP = function () {
72
73
  };
73
74
  }, []);
74
75
  var onSubmit = function (formData) {
75
- if (data.otpData.authFor === AuthForType.EMAIL) {
76
+ if (isEmailFlow) {
76
77
  dispatch(verifyEmailOtpAsync(deepCopy(formData)));
77
78
  }
78
79
  else {
@@ -80,11 +81,11 @@ var OTP = function () {
80
81
  }
81
82
  };
82
83
  var onBack = function () {
83
- dispatch(handlePrevScreenStep());
84
+ var screen = isEmailFlow ? 'CONNECT_EXPRESS_EMAIL_STEP' : 'CONNECT_EXPRESS_MOBILE_STEP';
85
+ dispatch(handlePrevScreenStep(screen));
84
86
  };
85
87
  var disabled = !methods.formState.isValid;
86
- var isEmailFlow = data.otpData.authFor === AuthForType.EMAIL;
87
- var phone = data.mobileData.mobile ? ((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix) + data.mobileData.mobile : '';
88
+ var phone = data.mobileData.mobile ? ((_b = data.mobileData.countryCode) === null || _b === void 0 ? void 0 : _b.idd_prefix) + data.mobileData.mobile : '';
88
89
  var contactInfo = isEmailFlow ? maskEmail(data.emailData.email) : maskPhone(phone);
89
90
  var title = isEmailFlow ? st('otp_email_sent_title') : st('ide_opt_sent_title');
90
91
  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') }))] })) })) }));
@@ -19,8 +19,8 @@ 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
21
  import { useAppDispatch, useAppSelector } from '../../../../hooks';
22
- import { sendCustomEventToGTM } from '../../../../utils';
23
- import { AuthForType } from '../../../../@types';
22
+ import { sendCustomEventToGTM, isQA } from '../../../../utils';
23
+ import { settingsSelector } from '../../../../app/settings';
24
24
  var BoxStyled = styled(Box)(function (_a) {
25
25
  var theme = _a.theme;
26
26
  return ({
@@ -30,13 +30,15 @@ var BoxStyled = styled(Box)(function (_a) {
30
30
  });
31
31
  });
32
32
  var OTPInput = function (_a) {
33
- var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
33
+ var _b;
34
+ var _c = useFormContext(), control = _c.control, setValue = _c.setValue;
34
35
  var t = useTranslation().t;
35
36
  var dispatch = useAppDispatch();
36
37
  var otpControl = useController({ name: 'otp', control: control });
37
- var _c = useAppSelector(connectExpressSelector), data = _c.data, error = _c.error;
38
- var mobileData = data.mobileData, emailData = data.emailData, otpData = data.otpData;
39
- var isEmailFlow = otpData.authFor === AuthForType.EMAIL;
38
+ var _d = useAppSelector(connectExpressSelector), data = _d.data, error = _d.error;
39
+ var settingsData = useAppSelector(settingsSelector).data;
40
+ var mobileData = data.mobileData, emailData = data.emailData;
41
+ var isEmailFlow = isQA((_b = settingsData.businessCountry) === null || _b === void 0 ? void 0 : _b.iso2);
40
42
  var sendEventAskAnotherOTP = function () {
41
43
  sendCustomEventToGTM({
42
44
  event: 'Send Event',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.12.8",
3
+ "version": "2.12.9",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",