@tap-payments/auth-jsconnect 2.11.31-development → 2.12.0-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.
Files changed (109) hide show
  1. package/build/api/lead.d.ts +2 -2
  2. package/build/assets/locales/ar.json +3 -3
  3. package/build/constants/app.js +60 -3
  4. package/build/constants/flows.d.ts +1 -0
  5. package/build/constants/flows.js +2 -1
  6. package/build/features/app/bank/bankStore.d.ts +7 -0
  7. package/build/features/app/bank/bankStore.js +84 -0
  8. package/build/features/app/board/boardStore.d.ts +5 -0
  9. package/build/features/app/board/boardStore.js +81 -0
  10. package/build/features/app/brand/brandStore.d.ts +7 -0
  11. package/build/features/app/brand/brandStore.js +83 -1
  12. package/build/features/app/business/businessStore.d.ts +10 -0
  13. package/build/features/app/business/businessStore.js +83 -1
  14. package/build/features/app/entity/entityStore.d.ts +7 -0
  15. package/build/features/app/entity/entityStore.js +85 -1
  16. package/build/features/app/individual/individualStore.d.ts +9 -0
  17. package/build/features/app/individual/individualStore.js +85 -1
  18. package/build/features/app/password/passwordStore.d.ts +9 -0
  19. package/build/features/app/password/passwordStore.js +82 -0
  20. package/build/features/app/tax/taxStore.d.ts +7 -0
  21. package/build/features/app/tax/taxStore.js +81 -0
  22. package/build/features/app/terminal/terminalStore.d.ts +9 -0
  23. package/build/features/app/terminal/terminalStore.js +76 -0
  24. package/build/features/auth/screens/OTPSessionExpired/OTPSessionExpired.js +2 -2
  25. package/build/features/bank/Bank.js +3 -2
  26. package/build/features/bank/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  27. package/build/features/bank/screens/OTPSessionExpired/OTPInput.js +51 -0
  28. package/build/features/bank/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  29. package/build/features/bank/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  30. package/build/features/bank/screens/OTPSessionExpired/index.d.ts +2 -0
  31. package/build/features/bank/screens/OTPSessionExpired/index.js +2 -0
  32. package/build/features/bank/screens/OTPSessionExpired/validation.d.ts +8 -0
  33. package/build/features/bank/screens/OTPSessionExpired/validation.js +4 -0
  34. package/build/features/board/Board.js +5 -4
  35. package/build/features/board/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  36. package/build/features/board/screens/OTPSessionExpired/OTPInput.js +51 -0
  37. package/build/features/board/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  38. package/build/features/board/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  39. package/build/features/board/screens/OTPSessionExpired/index.d.ts +2 -0
  40. package/build/features/board/screens/OTPSessionExpired/index.js +2 -0
  41. package/build/features/board/screens/OTPSessionExpired/validation.d.ts +8 -0
  42. package/build/features/board/screens/OTPSessionExpired/validation.js +4 -0
  43. package/build/features/brand/Brand.js +3 -2
  44. package/build/features/brand/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  45. package/build/features/brand/screens/OTPSessionExpired/OTPInput.js +51 -0
  46. package/build/features/brand/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  47. package/build/features/brand/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  48. package/build/features/brand/screens/OTPSessionExpired/index.d.ts +2 -0
  49. package/build/features/brand/screens/OTPSessionExpired/index.js +2 -0
  50. package/build/features/brand/screens/OTPSessionExpired/validation.d.ts +8 -0
  51. package/build/features/brand/screens/OTPSessionExpired/validation.js +4 -0
  52. package/build/features/business/Business.js +3 -2
  53. package/build/features/business/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  54. package/build/features/business/screens/OTPSessionExpired/OTPInput.js +51 -0
  55. package/build/features/business/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  56. package/build/features/business/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  57. package/build/features/business/screens/OTPSessionExpired/index.d.ts +2 -0
  58. package/build/features/business/screens/OTPSessionExpired/index.js +2 -0
  59. package/build/features/business/screens/OTPSessionExpired/validation.d.ts +8 -0
  60. package/build/features/business/screens/OTPSessionExpired/validation.js +4 -0
  61. package/build/features/connect/screens/OTPSessionExpired/OTPSessionExpired.js +2 -2
  62. package/build/features/connectExpress/screens/OTPSessionExpired/OTPSessionExpired.js +2 -2
  63. package/build/features/entity/Entity.js +3 -2
  64. package/build/features/entity/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  65. package/build/features/entity/screens/OTPSessionExpired/OTPInput.js +51 -0
  66. package/build/features/entity/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  67. package/build/features/entity/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  68. package/build/features/entity/screens/OTPSessionExpired/index.d.ts +2 -0
  69. package/build/features/entity/screens/OTPSessionExpired/index.js +2 -0
  70. package/build/features/entity/screens/OTPSessionExpired/validation.d.ts +8 -0
  71. package/build/features/entity/screens/OTPSessionExpired/validation.js +4 -0
  72. package/build/features/featuresScreens.js +45 -0
  73. package/build/features/individual/Individual.js +3 -2
  74. package/build/features/individual/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  75. package/build/features/individual/screens/OTPSessionExpired/OTPInput.js +51 -0
  76. package/build/features/individual/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  77. package/build/features/individual/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  78. package/build/features/individual/screens/OTPSessionExpired/index.d.ts +2 -0
  79. package/build/features/individual/screens/OTPSessionExpired/index.js +2 -0
  80. package/build/features/individual/screens/OTPSessionExpired/validation.d.ts +8 -0
  81. package/build/features/individual/screens/OTPSessionExpired/validation.js +4 -0
  82. package/build/features/password/Password.js +3 -2
  83. package/build/features/password/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  84. package/build/features/password/screens/OTPSessionExpired/OTPInput.js +51 -0
  85. package/build/features/password/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  86. package/build/features/password/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  87. package/build/features/password/screens/OTPSessionExpired/index.d.ts +2 -0
  88. package/build/features/password/screens/OTPSessionExpired/index.js +2 -0
  89. package/build/features/password/screens/OTPSessionExpired/validation.d.ts +8 -0
  90. package/build/features/password/screens/OTPSessionExpired/validation.js +4 -0
  91. package/build/features/tax/Tax.js +3 -2
  92. package/build/features/tax/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  93. package/build/features/tax/screens/OTPSessionExpired/OTPInput.js +51 -0
  94. package/build/features/tax/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  95. package/build/features/tax/screens/OTPSessionExpired/OTPSessionExpired.js +75 -0
  96. package/build/features/tax/screens/OTPSessionExpired/index.d.ts +2 -0
  97. package/build/features/tax/screens/OTPSessionExpired/index.js +2 -0
  98. package/build/features/tax/screens/OTPSessionExpired/validation.d.ts +8 -0
  99. package/build/features/tax/screens/OTPSessionExpired/validation.js +4 -0
  100. package/build/features/terminal/Terminal.js +3 -2
  101. package/build/features/terminal/screens/OTPSessionExpired/OTPInput.d.ts +7 -0
  102. package/build/features/terminal/screens/OTPSessionExpired/OTPInput.js +51 -0
  103. package/build/features/terminal/screens/OTPSessionExpired/OTPSessionExpired.d.ts +5 -0
  104. package/build/features/terminal/screens/OTPSessionExpired/OTPSessionExpired.js +89 -0
  105. package/build/features/terminal/screens/OTPSessionExpired/index.d.ts +2 -0
  106. package/build/features/terminal/screens/OTPSessionExpired/index.js +2 -0
  107. package/build/features/terminal/screens/OTPSessionExpired/validation.d.ts +8 -0
  108. package/build/features/terminal/screens/OTPSessionExpired/validation.js +4 -0
  109. package/package.json +1 -1
@@ -0,0 +1,51 @@
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 } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import Box from '@mui/material/Box/Box';
15
+ import { styled } from '@mui/material/styles';
16
+ import OTPField from '../../../shared/OTP';
17
+ import { useController, useFormContext } from 'react-hook-form';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { DEFAULT_TIMER_VALUE } from '../../../../constants';
20
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
21
+ import { isTokenExpired } from '../../../../utils';
22
+ import { businessSelector, clearError, verifyLeadTokenSessionExpired } from '../../../app/business/businessStore';
23
+ var BoxStyled = styled(Box)(function (_a) {
24
+ var theme = _a.theme;
25
+ return ({
26
+ display: 'flex',
27
+ flexDirection: 'column',
28
+ fontFamily: theme.typography.fontFamily
29
+ });
30
+ });
31
+ var OTPInput = function (_a) {
32
+ var loading = _a.loading;
33
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
34
+ var t = useTranslation().t;
35
+ var otpControl = useController({ name: 'otp', control: control });
36
+ var dispatch = useAppDispatch();
37
+ var error = useAppSelector(businessSelector).error;
38
+ var handleOnOTPChange = function (otp) {
39
+ if (error)
40
+ dispatch(clearError());
41
+ otpControl.field.onChange(otp);
42
+ };
43
+ var handleOnResendOTP = function () {
44
+ if (otpControl.field.value)
45
+ setValue('otp', '', { shouldValidate: true });
46
+ dispatch(verifyLeadTokenSessionExpired(false));
47
+ };
48
+ var otpValue = otpControl.field.value;
49
+ return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { loading: loading, timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, hasError: isTokenExpired(error), onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
50
+ };
51
+ export default React.memo(OTPInput);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,75 @@
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 { useAppDispatch } from '../../../../hooks';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useForm, FormProvider } from 'react-hook-form';
17
+ import { yupResolver } from '@hookform/resolvers/yup';
18
+ import Box from '@mui/material/Box/Box';
19
+ import { styled } from '@mui/material/styles';
20
+ import { useLanguage, useAppSelector, useSanitizedTranslation } from '../../../../hooks';
21
+ import { deepCopy, maskPhone } from '../../../../utils';
22
+ import Form from '../../../../components/Form';
23
+ import Text from '../../../../components/Text';
24
+ import { ScreenContainer } from '../../../shared/Containers';
25
+ import { businessSelector, clearError, resetOTPScreen, verifyLeadOTPSessionExpired } from '../../../app/business/businessStore';
26
+ import Button from '../../../shared/Button';
27
+ import { OTPValidation } from './validation';
28
+ import OTPInput from './OTPInput';
29
+ var OTPTitleContainerStyled = styled(Box)(function (_a) {
30
+ var theme = _a.theme;
31
+ return ({
32
+ background: theme.palette.common.white,
33
+ border: '1px solid',
34
+ borderColor: theme.palette.divider,
35
+ direction: theme.direction,
36
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25),
37
+ marginBottom: theme.spacing(5.75)
38
+ });
39
+ });
40
+ var OTPTitleStyled = styled(Text)(function (_a) {
41
+ var theme = _a.theme;
42
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInlineStart: theme.spacing(2.5), lineHeight: 1.5, display: 'flex', flexDirection: 'column' }));
43
+ });
44
+ var FormStyled = styled(Form)(function () { return ({
45
+ display: 'flex',
46
+ flexDirection: 'column'
47
+ }); });
48
+ var OTPSessionExpired = function (_a) {
49
+ var _b, _c;
50
+ var dispatch = useAppDispatch();
51
+ var _d = useAppSelector(businessSelector), data = _d.data, loading = _d.loading, error = _d.error;
52
+ var methods = useForm({
53
+ resolver: yupResolver(OTPValidation),
54
+ defaultValues: data.otpData,
55
+ mode: 'onChange'
56
+ });
57
+ var t = useTranslation().t;
58
+ var st = useSanitizedTranslation();
59
+ var isAr = useLanguage().isAr;
60
+ var _e = React.useState(false), resendLoading = _e[0], setResendLoading = _e[1];
61
+ var phone = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.verification_by) === null || _c === void 0 ? void 0 : _c.sent_to;
62
+ React.useEffect(function () {
63
+ if (error && methods.formState.isValid && phone)
64
+ dispatch(clearError());
65
+ return function () {
66
+ dispatch(resetOTPScreen());
67
+ };
68
+ }, [methods.formState.isValid]);
69
+ var onSubmit = function (formData) {
70
+ dispatch(verifyLeadOTPSessionExpired(deepCopy(formData)));
71
+ };
72
+ var disabled = !methods.formState.isValid || !!error || !phone || resendLoading;
73
+ 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') : st('session_expired_otp'), !loading && phone && (_jsxs("span", { children: [st('code_sent_to'), " ", _jsx("span", __assign({ dir: 'ltr' }, { children: maskPhone(phone) }))] }))] }) }), _jsx(OTPInput, { loading: resendLoading, setLoading: setResendLoading }), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: st(error || '') }, { children: t('next') }))] })) })) }));
74
+ };
75
+ export default React.memo(OTPSessionExpired);
@@ -0,0 +1,2 @@
1
+ import OTPSessionExpired from './OTPSessionExpired';
2
+ export default OTPSessionExpired;
@@ -0,0 +1,2 @@
1
+ import OTPSessionExpired from './OTPSessionExpired';
2
+ export default OTPSessionExpired;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ otp: 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
+ otp: 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
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,4 @@
1
+ import * as yup from 'yup';
2
+ export var OTPValidation = yup.object().shape({
3
+ otp: yup.string().min(6, 'otp_min_length').required('otp_required')
4
+ });
@@ -38,7 +38,7 @@ var OTPTitleContainerStyled = styled(Box)(function (_a) {
38
38
  });
39
39
  var OTPTitleStyled = styled(Text)(function (_a) {
40
40
  var theme = _a.theme;
41
- return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInline: theme.spacing(2.5), lineHeight: 1.75, whiteSpace: 'pre-line' }));
41
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInline: theme.spacing(2.5), lineHeight: 1.5, whiteSpace: 'pre-line', display: 'flex', flexDirection: 'column' }));
42
42
  });
43
43
  var FormStyled = styled(Form)(function () { return ({
44
44
  display: 'flex',
@@ -81,6 +81,6 @@ var OTPSessionExpired = function () {
81
81
  var code = "+".concat((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix, " ");
82
82
  var phone = data.mobileData.mobile ? data.mobileData.mobile : '';
83
83
  var title = t('session_expired_otp');
84
- 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 && (_jsxs("span", __assign({ dir: 'ltr', style: { display: 'block' } }, { children: [st('code_sent_to'), " ", code, " ", maskPhone(phone)] })))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: st(error || '') }, { children: t('next') }))] })) })) }));
84
+ 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 && phone && (_jsxs("span", { children: [st('code_sent_to'), _jsxs("span", __assign({ dir: 'ltr' }, { children: [code, " ", maskPhone(phone)] }))] }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: st(error || '') }, { children: t('next') }))] })) })) }));
85
85
  };
86
86
  export default React.memo(OTPSessionExpired);
@@ -39,7 +39,7 @@ var OTPTitleContainerStyled = styled(Box)(function (_a) {
39
39
  });
40
40
  var OTPTitleStyled = styled(Text)(function (_a) {
41
41
  var theme = _a.theme;
42
- return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInline: theme.spacing(2.5), lineHeight: 1.75, whiteSpace: 'pre-line' }));
42
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInline: theme.spacing(2.5), lineHeight: 1.5, whiteSpace: 'pre-line', display: 'flex', flexDirection: 'column' }));
43
43
  });
44
44
  var FormStyled = styled(Form)(function () { return ({
45
45
  display: 'flex',
@@ -80,6 +80,6 @@ var OTP = function () {
80
80
  var code = "+".concat((_a = data.mobileData.countryCode) === null || _a === void 0 ? void 0 : _a.idd_prefix, " ");
81
81
  var phone = data.mobileData.mobile ? data.mobileData.mobile : '';
82
82
  var title = t('session_expired_otp');
83
- 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 && (_jsxs("span", __assign({ dir: 'ltr', style: { display: 'block' } }, { children: [st('code_sent_to'), " ", code, " ", maskPhone(phone)] })))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: st(error || '') }, { children: t('next') }))] })) })) }));
83
+ 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 && phone && (_jsxs("span", { children: [st('code_sent_to'), _jsxs("span", __assign({ dir: 'ltr' }, { children: [code, " ", maskPhone(phone)] }))] }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: st(error || '') }, { children: t('next') }))] })) })) }));
84
84
  };
85
85
  export default React.memo(OTP);
@@ -23,7 +23,7 @@ var __rest = (this && this.__rest) || function (s, e) {
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
24
  import React, { memo } from 'react';
25
25
  import { createRoot } from 'react-dom/client';
26
- import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useVerifyToken, useAppDispatch } from '../../hooks';
26
+ import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useVerifyToken, useAppDispatch, useSessionExpiryHandler } from '../../hooks';
27
27
  import { handleOpen, settingsSelector } from '../../app/settings';
28
28
  import AnimationFlow from '../../components/AnimationFlow';
29
29
  import { store } from '../../app/store';
@@ -33,7 +33,7 @@ import { findOrCreateElementAndInject, initializeGTM, sendPageView } from '../..
33
33
  import { FeatureContainer } from '../shared/Containers';
34
34
  import { ENTITY_SCREENS_NAVIGATION } from '../../constants';
35
35
  import { entityFeatureScreens } from '../featuresScreens';
36
- import { entitySelector, verifyLeadToken } from '../app/entity/entityStore';
36
+ import { clearError, entitySelector, verifyLeadToken, verifyLeadTokenSessionExpired } from '../app/entity/entityStore';
37
37
  import Background from '../shared/Background';
38
38
  var Entity = memo(function (_a) {
39
39
  var _b, _c, _d;
@@ -45,6 +45,7 @@ var Entity = memo(function (_a) {
45
45
  useAppConfig(__assign(__assign({ navigation: ENTITY_SCREENS_NAVIGATION }, props), { disableSettingFetching: props.mode === 'content' ? false : !!verifyToken || !!configToken }));
46
46
  useErrorListener(entityError || error);
47
47
  useStepStartedListener();
48
+ useSessionExpiryHandler({ error: entityError, clearError: clearError, createAuthSession: verifyLeadTokenSessionExpired });
48
49
  var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open, featureScreensNavigation = data.featureScreensNavigation, merchant = data.merchant, isMaturityExpress = data.isMaturityExpress, appConfig = data.appConfig;
49
50
  var animationDirection = open ? (_b = appConfig.features) === null || _b === void 0 ? void 0 : _b.dialogStartTransition : (_c = appConfig.features) === null || _c === void 0 ? void 0 : _c.dialogEndTransition;
50
51
  useVerifyToken({
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ loading: boolean;
4
+ setLoading: (flag: boolean) => void;
5
+ }
6
+ declare const _default: React.MemoExoticComponent<({ loading }: OTPProps) => JSX.Element>;
7
+ export default _default;
@@ -0,0 +1,51 @@
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 } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import Box from '@mui/material/Box/Box';
15
+ import { styled } from '@mui/material/styles';
16
+ import OTPField from '../../../shared/OTP';
17
+ import { useController, useFormContext } from 'react-hook-form';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { DEFAULT_TIMER_VALUE } from '../../../../constants';
20
+ import { useAppDispatch, useAppSelector } from '../../../../hooks';
21
+ import { isTokenExpired } from '../../../../utils';
22
+ import { entitySelector, clearError, verifyLeadTokenSessionExpired } from '../../../app/entity/entityStore';
23
+ var BoxStyled = styled(Box)(function (_a) {
24
+ var theme = _a.theme;
25
+ return ({
26
+ display: 'flex',
27
+ flexDirection: 'column',
28
+ fontFamily: theme.typography.fontFamily
29
+ });
30
+ });
31
+ var OTPInput = function (_a) {
32
+ var loading = _a.loading;
33
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
34
+ var t = useTranslation().t;
35
+ var otpControl = useController({ name: 'otp', control: control });
36
+ var dispatch = useAppDispatch();
37
+ var error = useAppSelector(entitySelector).error;
38
+ var handleOnOTPChange = function (otp) {
39
+ if (error)
40
+ dispatch(clearError());
41
+ otpControl.field.onChange(otp);
42
+ };
43
+ var handleOnResendOTP = function () {
44
+ if (otpControl.field.value)
45
+ setValue('otp', '', { shouldValidate: true });
46
+ dispatch(verifyLeadTokenSessionExpired(false));
47
+ };
48
+ var otpValue = otpControl.field.value;
49
+ return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { loading: loading, timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, hasError: isTokenExpired(error), onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
50
+ };
51
+ export default React.memo(OTPInput);
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ }
4
+ declare const _default: React.MemoExoticComponent<({}: OTPProps) => JSX.Element>;
5
+ export default _default;
@@ -0,0 +1,75 @@
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 { useAppDispatch } from '../../../../hooks';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { useForm, FormProvider } from 'react-hook-form';
17
+ import { yupResolver } from '@hookform/resolvers/yup';
18
+ import Box from '@mui/material/Box/Box';
19
+ import { styled } from '@mui/material/styles';
20
+ import { useLanguage, useAppSelector, useSanitizedTranslation } from '../../../../hooks';
21
+ import { deepCopy, maskPhone } from '../../../../utils';
22
+ import Form from '../../../../components/Form';
23
+ import Text from '../../../../components/Text';
24
+ import { ScreenContainer } from '../../../shared/Containers';
25
+ import { entitySelector, clearError, resetOTPScreen, verifyEntityLeadOTPSessionExpired } from '../../../app/entity/entityStore';
26
+ import Button from '../../../shared/Button';
27
+ import { OTPValidation } from './validation';
28
+ import OTPInput from './OTPInput';
29
+ var OTPTitleContainerStyled = styled(Box)(function (_a) {
30
+ var theme = _a.theme;
31
+ return ({
32
+ background: theme.palette.common.white,
33
+ border: '1px solid',
34
+ borderColor: theme.palette.divider,
35
+ direction: theme.direction,
36
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25),
37
+ marginBottom: theme.spacing(5.75)
38
+ });
39
+ });
40
+ var OTPTitleStyled = styled(Text)(function (_a) {
41
+ var theme = _a.theme;
42
+ return (__assign(__assign({}, theme.typography.body1), { color: theme.palette.text.primary, fontWeight: theme.typography.fontWeightLight, marginBlock: theme.spacing(1.75), marginInlineStart: theme.spacing(2.5), lineHeight: 1.5, display: 'flex', flexDirection: 'column' }));
43
+ });
44
+ var FormStyled = styled(Form)(function () { return ({
45
+ display: 'flex',
46
+ flexDirection: 'column'
47
+ }); });
48
+ var OTPSessionExpired = function (_a) {
49
+ var _b, _c;
50
+ var dispatch = useAppDispatch();
51
+ var _d = useAppSelector(entitySelector), data = _d.data, loading = _d.loading, error = _d.error;
52
+ var methods = useForm({
53
+ resolver: yupResolver(OTPValidation),
54
+ defaultValues: data.otpData,
55
+ mode: 'onChange'
56
+ });
57
+ var t = useTranslation().t;
58
+ var st = useSanitizedTranslation();
59
+ var isAr = useLanguage().isAr;
60
+ var _e = React.useState(false), resendLoading = _e[0], setResendLoading = _e[1];
61
+ var phone = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.verification_by) === null || _c === void 0 ? void 0 : _c.sent_to;
62
+ React.useEffect(function () {
63
+ if (error && methods.formState.isValid && phone)
64
+ dispatch(clearError());
65
+ return function () {
66
+ dispatch(resetOTPScreen());
67
+ };
68
+ }, [methods.formState.isValid]);
69
+ var onSubmit = function (formData) {
70
+ dispatch(verifyEntityLeadOTPSessionExpired(deepCopy(formData)));
71
+ };
72
+ var disabled = !methods.formState.isValid || !!error || !phone || resendLoading;
73
+ 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') : st('session_expired_otp'), !loading && phone && (_jsxs("span", { children: [st('code_sent_to'), " ", _jsx("span", __assign({ dir: 'ltr' }, { children: maskPhone(phone) }))] }))] }) }), _jsx(OTPInput, { loading: resendLoading, setLoading: setResendLoading }), _jsx(Button, __assign({ disableBack: true, disabled: disabled, isAr: isAr, loading: loading, error: st(error || '') }, { children: t('next') }))] })) })) }));
74
+ };
75
+ export default React.memo(OTPSessionExpired);
@@ -0,0 +1,2 @@
1
+ import OTPSessionExpired from './OTPSessionExpired';
2
+ export default OTPSessionExpired;
@@ -0,0 +1,2 @@
1
+ import OTPSessionExpired from './OTPSessionExpired';
2
+ export default OTPSessionExpired;
@@ -0,0 +1,8 @@
1
+ import * as yup from 'yup';
2
+ export declare const OTPValidation: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ otp: 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
+ otp: 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
+ otp: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
8
+ }>>>;
@@ -0,0 +1,4 @@
1
+ import * as yup from 'yup';
2
+ export var OTPValidation = yup.object().shape({
3
+ otp: yup.string().min(6, 'otp_min_length').required('otp_required')
4
+ });
@@ -80,6 +80,7 @@ import BrandVerifyScreen from './business/screens/BrandDetails';
80
80
  import BusinessOperatorError from './business/screens/OperatorError';
81
81
  import BusinessCollectMobileOwnership from './business/screens/MobileOwnership';
82
82
  import BusinessOTPVerifySecurityError from './shared/OTPVerifySecurityError';
83
+ import BusinessOTPSessionExpired from './business/screens/OTPSessionExpired';
83
84
  import PasswordVerifyPage from './password/screens/Verify';
84
85
  import CreatePasswordPage from './password/screens/CreatePassword';
85
86
  import PasswordDataLoadingPage from './password/screens/PrepareDataLoading';
@@ -89,6 +90,7 @@ import PasswordSuccessWithFlowPage from './password/screens/SuccessWithFlowButto
89
90
  import PasswordResetPasswordSuccessPage from './password/screens/ResetPasswordSuccess';
90
91
  import PasswordOperatorError from './password/screens/OperatorError';
91
92
  import PasswordOTPVerifySecurityError from './shared/OTPVerifySecurityError';
93
+ import PasswordOTPSessionExpired from './password/screens/OTPSessionExpired';
92
94
  import IndividualVerifyPage from './individual/screens/Verify';
93
95
  import IndividualPhoneInfoPage from './individual/screens/IndividualPhoneInfo';
94
96
  import IndividualListPage from './individual/screens/IndividualList';
@@ -100,6 +102,7 @@ import IndividualResetPasswordSuccessPage from './individual/screens/ResetPasswo
100
102
  import IndividualDataLoadingPage from './individual/screens/PrepareDataLoading';
101
103
  import IndividualOperatorError from './individual/screens/OperatorError';
102
104
  import IndividualOTPVerifySecurityError from './shared/OTPVerifySecurityError';
105
+ import IndividualOTPSessionExpired from './individual/screens/OTPSessionExpired';
103
106
  import BankVerifyPage from './bank/screens/Verify';
104
107
  import BankDetailsPage from './bank/screens/BankDetails';
105
108
  import BankSuccessPage from './bank/screens/Success';
@@ -108,6 +111,7 @@ import BankResetPasswordSuccessPage from './bank/screens/ResetPasswordSuccess';
108
111
  import BankDataLoadingPage from './bank/screens/PrepareDataLoading';
109
112
  import BankOperatorError from './bank/screens/OperatorError';
110
113
  import BankOTPVerifySecurityError from './shared/OTPVerifySecurityError';
114
+ import BankOTPSessionExpired from './bank/screens/OTPSessionExpired';
111
115
  import TaxVerifyPage from './tax/screens/Verify';
112
116
  import TaxDetailsPage from './tax/screens/TaxDetails';
113
117
  import TaxSuccessPage from './tax/screens/Success';
@@ -116,6 +120,7 @@ import TaxResetPasswordSuccessPage from './tax/screens/ResetPasswordSuccess';
116
120
  import TaxDataLoadingPage from './tax/screens/PrepareDataLoading';
117
121
  import TaxOperatorError from './tax/screens/OperatorError';
118
122
  import TaxOTPVerifySecurityError from './shared/OTPVerifySecurityError';
123
+ import TaxOTPSessionExpired from './tax/screens/OTPSessionExpired';
119
124
  import SignInMobilePage from './signIn/screens/Mobile';
120
125
  import SignInEmailPage from './signIn/screens/Email';
121
126
  import SignInOTPPage from './signIn/screens/OTP';
@@ -130,6 +135,7 @@ import EntityResetPasswordSuccessPage from './entity/screens/ResetPasswordSucces
130
135
  import EntityDataLoadingPage from './entity/screens/PrepareDataLoading';
131
136
  import EntityOperatorError from './entity/screens/OperatorError';
132
137
  import EntityOTPVerifySecurityError from './shared/OTPVerifySecurityError';
138
+ import EntityOTPSessionExpired from './entity/screens/OTPSessionExpired';
133
139
  import BrandVerifyPage from './brand/screens/Verify';
134
140
  import BrandInfoPage from './brand/screens/BrandInfo';
135
141
  import BrandSegmentPage from './brand/screens/BrandSegmentInfo';
@@ -140,12 +146,14 @@ import BrandResetPasswordSuccessPage from './brand/screens/ResetPasswordSuccess'
140
146
  import BrandDataLoadingPage from './brand/screens/PrepareDataLoading';
141
147
  import BrandOperatorError from './brand/screens/OperatorError';
142
148
  import BrandOTPVerifySecurityError from './shared/OTPVerifySecurityError';
149
+ import BrandOTPSessionExpired from './brand/screens/OTPSessionExpired';
143
150
  import BoardVerifyPage from './board/screens/Verify';
144
151
  import BoardSuccessWithFlowPage from './board/screens/SuccessWithFlowButtons';
145
152
  import BoardResetPasswordSuccessPage from './board/screens/ResetPasswordSuccess';
146
153
  import BoardDataLoadingPage from './board/screens/PrepareDataLoading';
147
154
  import BoardOperatorError from './board/screens/OperatorError';
148
155
  import BoardOTPVerifySecurityError from './shared/OTPVerifySecurityError';
156
+ import BoardOTPSessionExpired from './board/screens/OTPSessionExpired';
149
157
  import KycLoadingPage from './kyc/screens/Loading';
150
158
  import KycTokenErrorPage from './kyc/screens/TokenError';
151
159
  import KycAlreadySubmittedPage from './kyc/screens/AlreadySubmitted';
@@ -169,6 +177,7 @@ import UnlinkedSuccessPage from './terminal/screens/UnlinkedSuccess';
169
177
  import TerminalBoardPage from './terminal/screens/SuccessWithFlowButtons';
170
178
  import TerminalResetPasswordSuccessPage from './terminal/screens/ResetPasswordSuccess';
171
179
  import TerminalOTPVerifySecurityError from './shared/OTPVerifySecurityError';
180
+ import TerminalOTPSessionExpired from './terminal/screens/OTPSessionExpired';
172
181
  export var connectFeatureScreens = [
173
182
  {
174
183
  name: 'CONNECT_BUSINESS_COUNTRY_STEP',
@@ -487,6 +496,10 @@ export var businessFeatureScreens = [
487
496
  {
488
497
  name: 'BUSINESS_OTP_VERIFY_SECURITY_ERROR_STEP',
489
498
  element: BusinessOTPVerifySecurityError
499
+ },
500
+ {
501
+ name: 'BUSINESS_SESSION_EXPIRED_OTP_STEP',
502
+ element: BusinessOTPSessionExpired
490
503
  }
491
504
  ];
492
505
  export var passwordFeatureScreens = [
@@ -522,6 +535,10 @@ export var passwordFeatureScreens = [
522
535
  {
523
536
  name: 'PASSWORD_OTP_VERIFY_SECURITY_ERROR_STEP',
524
537
  element: PasswordOTPVerifySecurityError
538
+ },
539
+ {
540
+ name: 'PASSWORD_SESSION_EXPIRED_OTP_STEP',
541
+ element: PasswordOTPSessionExpired
525
542
  }
526
543
  ];
527
544
  export var individualFeatureScreens = [
@@ -565,6 +582,10 @@ export var individualFeatureScreens = [
565
582
  {
566
583
  name: 'INDIVIDUAL_OTP_VERIFY_SECURITY_ERROR_STEP',
567
584
  element: IndividualOTPVerifySecurityError
585
+ },
586
+ {
587
+ name: 'INDIVIDUAL_SESSION_EXPIRED_OTP_STEP',
588
+ element: IndividualOTPSessionExpired
568
589
  }
569
590
  ];
570
591
  export var bankFeatureScreens = [
@@ -596,6 +617,10 @@ export var bankFeatureScreens = [
596
617
  {
597
618
  name: 'BANK_OTP_VERIFY_SECURITY_ERROR_STEP',
598
619
  element: BankOTPVerifySecurityError
620
+ },
621
+ {
622
+ name: 'BANK_SESSION_EXPIRED_OTP_STEP',
623
+ element: BankOTPSessionExpired
599
624
  }
600
625
  ];
601
626
  export var taxFeatureScreens = [
@@ -627,6 +652,10 @@ export var taxFeatureScreens = [
627
652
  {
628
653
  name: 'TAX_OTP_VERIFY_SECURITY_ERROR_STEP',
629
654
  element: TaxOTPVerifySecurityError
655
+ },
656
+ {
657
+ name: 'TAX_SESSION_EXPIRED_OTP_STEP',
658
+ element: TaxOTPSessionExpired
630
659
  }
631
660
  ];
632
661
  export var signInFeatureScreens = [
@@ -684,6 +713,10 @@ export var entityFeatureScreens = [
684
713
  {
685
714
  name: 'ENTITY_OTP_VERIFY_SECURITY_ERROR_STEP',
686
715
  element: EntityOTPVerifySecurityError
716
+ },
717
+ {
718
+ name: 'ENTITY_SESSION_EXPIRED_OTP_STEP',
719
+ element: EntityOTPSessionExpired
687
720
  }
688
721
  ];
689
722
  export var brandFeatureScreens = [
@@ -723,6 +756,10 @@ export var brandFeatureScreens = [
723
756
  {
724
757
  name: 'BRAND_OTP_VERIFY_SECURITY_ERROR_STEP',
725
758
  element: BrandOTPVerifySecurityError
759
+ },
760
+ {
761
+ name: 'BRAND_SESSION_EXPIRED_OTP_STEP',
762
+ element: BrandOTPSessionExpired
726
763
  }
727
764
  ];
728
765
  export var boardFeatureScreens = [
@@ -749,6 +786,10 @@ export var boardFeatureScreens = [
749
786
  {
750
787
  name: 'BOARD_OTP_VERIFY_SECURITY_ERROR_STEP',
751
788
  element: BoardOTPVerifySecurityError
789
+ },
790
+ {
791
+ name: 'BOARD_SESSION_EXPIRED_OTP_STEP',
792
+ element: BoardOTPSessionExpired
752
793
  }
753
794
  ];
754
795
  export var kycFeatureScreens = [
@@ -845,5 +886,9 @@ export var terminalFeatureScreens = [
845
886
  {
846
887
  name: CONNECT_FLOWS.terminal.otpVerifySecurityError,
847
888
  element: TerminalOTPVerifySecurityError
889
+ },
890
+ {
891
+ name: CONNECT_FLOWS.terminal.otpSessionExpired,
892
+ element: TerminalOTPSessionExpired
848
893
  }
849
894
  ];
@@ -23,7 +23,7 @@ var __rest = (this && this.__rest) || function (s, e) {
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
24
  import React, { memo } from 'react';
25
25
  import { createRoot } from 'react-dom/client';
26
- import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useVerifyToken, useAppDispatch } from '../../hooks';
26
+ import { useAppTheme, useAppSelector, useAppConfig, useErrorListener, useStepStartedListener, useVerifyToken, useAppDispatch, useSessionExpiryHandler } from '../../hooks';
27
27
  import { handleOpen, settingsSelector } from '../../app/settings';
28
28
  import AnimationFlow from '../../components/AnimationFlow';
29
29
  import { store } from '../../app/store';
@@ -33,7 +33,7 @@ import { findOrCreateElementAndInject, initializeGTM, sendPageView } from '../..
33
33
  import { FeatureContainer } from '../shared/Containers';
34
34
  import { INDIVIDUAL_SCREENS_NAVIGATION } from '../../constants';
35
35
  import { individualFeatureScreens } from '../featuresScreens';
36
- import { individualSelector, verifyLeadToken } from '../app/individual/individualStore';
36
+ import { clearError, individualSelector, verifyLeadToken, verifyTokenSessionExpired } from '../app/individual/individualStore';
37
37
  import Background from '../shared/Background';
38
38
  var Individual = memo(function (_a) {
39
39
  var _b, _c, _d;
@@ -45,6 +45,7 @@ var Individual = memo(function (_a) {
45
45
  useAppConfig(__assign(__assign({ navigation: INDIVIDUAL_SCREENS_NAVIGATION }, props), { disableSettingFetching: props.mode === 'content' ? false : !!verifyToken || !!configToken }));
46
46
  useErrorListener(individualError || error);
47
47
  useStepStartedListener();
48
+ useSessionExpiryHandler({ error: individualError, clearError: clearError, createAuthSession: verifyTokenSessionExpired });
48
49
  var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open, featureScreensNavigation = data.featureScreensNavigation, merchant = data.merchant, isMaturityExpress = data.isMaturityExpress, appConfig = data.appConfig;
49
50
  var animationDirection = open ? (_b = appConfig.features) === null || _b === void 0 ? void 0 : _b.dialogStartTransition : (_c = appConfig.features) === null || _c === void 0 ? void 0 : _c.dialogEndTransition;
50
51
  useVerifyToken({
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ export interface OTPProps {
3
+ loading: boolean;
4
+ setLoading: (flag: boolean) => void;
5
+ }
6
+ declare const _default: React.MemoExoticComponent<({ loading }: OTPProps) => JSX.Element>;
7
+ export default _default;