@tap-payments/auth-jsconnect 1.0.52 → 1.0.53

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 (74) hide show
  1. package/build/@types/app.d.ts +2 -3
  2. package/build/@types/form.d.ts +16 -1
  3. package/build/api/entity.d.ts +5 -2
  4. package/build/api/index.d.ts +3 -3
  5. package/build/api/lead.d.ts +1 -1
  6. package/build/app/rootReducer.d.ts +3 -0
  7. package/build/app/rootReducer.js +7 -1
  8. package/build/app/store.d.ts +6 -0
  9. package/build/components/AnimationFlow/AnimationFlow.d.ts +3 -1
  10. package/build/components/AnimationFlow/AnimationFlow.js +5 -1
  11. package/build/components/AnimationFlow/Loader.d.ts +2 -0
  12. package/build/components/AnimationFlow/Loader.js +14 -0
  13. package/build/components/Loader/Loader.d.ts +1 -0
  14. package/build/components/Loader/Loader.js +1 -1
  15. package/build/constants/app.d.ts +18 -0
  16. package/build/constants/app.js +47 -11
  17. package/build/features/app/bank/bankStore.d.ts +1 -1
  18. package/build/features/app/bank/bankStore.js +5 -6
  19. package/build/features/app/business/businessStore.d.ts +1 -2
  20. package/build/features/app/business/businessStore.js +56 -56
  21. package/build/features/app/connect/connectStore.js +17 -30
  22. package/build/features/app/individual/individualStore.d.ts +36 -0
  23. package/build/features/app/individual/individualStore.js +222 -0
  24. package/build/features/app/password/passwordStore.d.ts +36 -0
  25. package/build/features/app/password/passwordStore.js +218 -0
  26. package/build/features/app/tax/taxStore.d.ts +36 -0
  27. package/build/features/app/tax/taxStore.js +217 -0
  28. package/build/features/bank/Bank.js +1 -1
  29. package/build/features/bank/screens/Verify/Verify.js +2 -2
  30. package/build/features/business/screens/Activities/Activities.js +8 -8
  31. package/build/features/business/screens/Activities/ActivitiesList.js +7 -7
  32. package/build/features/business/screens/Activities/SalesChannels.js +1 -1
  33. package/build/features/connect/Connect.js +2 -2
  34. package/build/features/connect/screens/Merchant/BrandList.js +1 -1
  35. package/build/features/connect/screens/Merchant/Merchant.js +32 -21
  36. package/build/features/connect/screens/Merchant/SocialMedia.d.ts +2 -1
  37. package/build/features/connect/screens/Merchant/SocialMedia.js +6 -2
  38. package/build/features/connect/screens/Merchant/validation.d.ts +6 -1
  39. package/build/features/connect/screens/Merchant/validation.js +67 -9
  40. package/build/features/connect/screens/Mobile/MobileNumber.js +1 -1
  41. package/build/features/featuresScreens.js +15 -5
  42. package/build/features/individual/Individual.d.ts +2 -1
  43. package/build/features/individual/Individual.js +15 -7
  44. package/build/features/individual/screens/Verify/OTPInput.d.ts +5 -0
  45. package/build/features/individual/screens/Verify/OTPInput.js +42 -0
  46. package/build/features/individual/screens/Verify/Verify.d.ts +5 -0
  47. package/build/features/individual/screens/Verify/Verify.js +78 -0
  48. package/build/features/individual/screens/Verify/index.d.ts +2 -0
  49. package/build/features/individual/screens/Verify/index.js +2 -0
  50. package/build/features/individual/screens/Verify/validation.d.ts +8 -0
  51. package/build/features/individual/screens/Verify/validation.js +4 -0
  52. package/build/features/password/Password.d.ts +2 -1
  53. package/build/features/password/Password.js +15 -7
  54. package/build/features/password/screens/Verify/OTPInput.d.ts +5 -0
  55. package/build/features/password/screens/Verify/OTPInput.js +42 -0
  56. package/build/features/password/screens/Verify/Verify.d.ts +5 -0
  57. package/build/features/password/screens/Verify/Verify.js +78 -0
  58. package/build/features/password/screens/Verify/index.d.ts +2 -0
  59. package/build/features/password/screens/Verify/index.js +2 -0
  60. package/build/features/password/screens/Verify/validation.d.ts +8 -0
  61. package/build/features/password/screens/Verify/validation.js +4 -0
  62. package/build/features/tax/Tax.d.ts +2 -1
  63. package/build/features/tax/Tax.js +15 -7
  64. package/build/features/tax/screens/Verify/OTPInput.d.ts +5 -0
  65. package/build/features/tax/screens/Verify/OTPInput.js +42 -0
  66. package/build/features/tax/screens/Verify/Verify.d.ts +5 -0
  67. package/build/features/tax/screens/Verify/Verify.js +78 -0
  68. package/build/features/tax/screens/Verify/index.d.ts +2 -0
  69. package/build/features/tax/screens/Verify/index.js +2 -0
  70. package/build/features/tax/screens/Verify/validation.d.ts +8 -0
  71. package/build/features/tax/screens/Verify/validation.js +4 -0
  72. package/build/hooks/useAppDispatch.d.ts +3 -0
  73. package/build/utils/string.js +0 -1
  74. package/package.json +1 -1
@@ -23,23 +23,23 @@ import { ScreenContainer } from '../../../shared/Containers';
23
23
  import Button from '../../../shared/Button';
24
24
  import { clearError, connectSelector, updateLeadBrand } from '../../../app/connect/connectStore';
25
25
  import { useLanguage } from '../../../../hooks';
26
- import { MerchantValidationSchema } from './validation';
26
+ import { MerchantValidationSchema, ValidationOptions } from './validation';
27
27
  import BrandName from './BrandName';
28
28
  import SocialMedia from './SocialMedia';
29
29
  import TAC from './TAC';
30
30
  import BrandList from './BrandList';
31
31
  var Merchant = function (_a) {
32
- var _b, _c, _d, _e, _f;
33
- var _g = React.useState(false), brandNameChecking = _g[0], setBrandNameChecking = _g[1];
34
- var _h = React.useState(false), isOtherBrand = _h[0], setIsOtherBrand = _h[1];
35
- var _j = React.useState(false), listActive = _j[0], setListActive = _j[1];
36
- var _k = useSelector(connectSelector), data = _k.data, loading = _k.loading, error = _k.error;
32
+ var _b, _c, _d;
33
+ var _e = React.useState(false), brandNameChecking = _e[0], setBrandNameChecking = _e[1];
34
+ var _f = React.useState(ValidationOptions.NEW_USER), userType = _f[0], setUserType = _f[1];
35
+ var _g = React.useState(false), listActive = _g[0], setListActive = _g[1];
36
+ var _h = useSelector(connectSelector), data = _h.data, loading = _h.loading, error = _h.error;
37
37
  var isNewUser = (_b = data.otpData.responseBody) === null || _b === void 0 ? void 0 : _b.new_user;
38
38
  var isAbsher = data.otpData.isAbsher;
39
39
  var brandList = ((_c = data.brandData.responseBody) === null || _c === void 0 ? void 0 : _c.brands) || [];
40
- var _l = data.brandData, brandName = _l.brandName, links = _l.links, selectedBrandItem = _l.selectedBrandItem, termAndConditionChecked = _l.termAndConditionChecked;
40
+ var _j = data.brandData, brandName = _j.brandName, links = _j.links, selectedBrandItem = _j.selectedBrandItem, termAndConditionChecked = _j.termAndConditionChecked, responseBody = _j.responseBody;
41
41
  var methods = useForm({
42
- resolver: yupResolver(MerchantValidationSchema(isOtherBrand)),
42
+ resolver: yupResolver(MerchantValidationSchema(userType)),
43
43
  defaultValues: {
44
44
  brandName: brandName,
45
45
  links: links,
@@ -66,22 +66,33 @@ var Merchant = function (_a) {
66
66
  dispatch(clearError());
67
67
  }, [methods.formState.isValid]);
68
68
  React.useEffect(function () {
69
- var _a, _b;
70
- if (((_b = (_a = data.brandData) === null || _a === void 0 ? void 0 : _a.responseBody) === null || _b === void 0 ? void 0 : _b.response_code) === '5')
69
+ if ((responseBody === null || responseBody === void 0 ? void 0 : responseBody.response_code) === '5')
71
70
  methods.setError('brandName', { message: 'Profile Name already exists' });
72
- }, [(_d = data.brandData) === null || _d === void 0 ? void 0 : _d.responseBody]);
71
+ }, [responseBody]);
73
72
  React.useEffect(function () {
74
- methods.setValue('links', __assign(__assign({}, links), { website: selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.website }), { shouldValidate: true });
75
- }, []);
73
+ if (isNewUser === true) {
74
+ setUserType(ValidationOptions.NEW_USER);
75
+ }
76
+ if (isNewUser === false && methods.getValues('selectedBrandItem').id === 'other') {
77
+ setUserType(ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND);
78
+ methods.clearErrors();
79
+ setTimeout(function () { return methods.setValue('brandName', '', { shouldValidate: true }); }, 100);
80
+ }
81
+ if (isNewUser === false && methods.getValues('selectedBrandItem').id !== 'other') {
82
+ setUserType(ValidationOptions.EXISTING_USER_WITH_EXIST_BRAND);
83
+ methods.clearErrors();
84
+ var sites_1 = __assign(__assign({}, links), { website: selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.website });
85
+ setTimeout(function () { return methods.setValue('links', sites_1, { shouldValidate: true }); }, 100);
86
+ }
87
+ }, [methods.getValues('selectedBrandItem'), isNewUser]);
76
88
  React.useEffect(function () {
77
- setIsOtherBrand(methods.getValues('selectedBrandItem').id === 'other');
78
- setTimeout(function () {
79
- methods.setValue('termAndConditionChecked', true, { shouldValidate: true });
80
- }, 300);
81
- }, [methods.getValues('selectedBrandItem')]);
89
+ if (selectedBrandItem === null || selectedBrandItem === void 0 ? void 0 : selectedBrandItem.id)
90
+ methods.setValue('selectedBrandItem', selectedBrandItem, { shouldValidate: true });
91
+ }, [selectedBrandItem]);
82
92
  var brandErrChecks = !methods.formState.isValid || !!methods.formState.errors.brandName || !!error;
83
- var disabled = brandErrChecks || brandNameChecking || ((_f = (_e = data.brandData) === null || _e === void 0 ? void 0 : _e.responseBody) === null || _f === void 0 ? void 0 : _f.response_code) === '5';
84
- var isBrandListAvailable = !isNewUser && brandList.length > 0;
85
- return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: isBrandListAvailable, list: brandList, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(BrandName, { show: !listActive && isOtherBrand, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(SocialMedia, { show: !listActive }), _jsx(TAC, { show: !listActive && isOtherBrand }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
93
+ var disabled = brandErrChecks || brandNameChecking || ((_d = data.brandData.responseBody) === null || _d === void 0 ? void 0 : _d.response_code) === '5';
94
+ var isBrandListAvailable = userType !== ValidationOptions.NEW_USER && brandList.length > 0;
95
+ var askingForBrandInfo = userType === ValidationOptions.NEW_USER || userType === ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND;
96
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(Form, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(BrandList, { show: isBrandListAvailable, list: brandList, onListOpen: function () { return setListActive(true); }, onListClose: function () { return setListActive(false); } }), _jsx(BrandName, { show: !listActive && askingForBrandInfo, brandNameChecking: brandNameChecking, fetchingBrandName: setBrandNameChecking }), _jsx(SocialMedia, { show: !listActive, isNewUser: isNewUser }), _jsx(TAC, { show: !listActive && askingForBrandInfo }), _jsx(Collapse, __assign({ in: !listActive, timeout: 500 }, { children: _jsx(Button, __assign({ onBackClicked: function () { return onBack(); }, disabled: disabled, isAr: isAr, error: t(error || ''), loading: loading }, { children: t('next') })) }))] })) })) }));
86
97
  };
87
98
  export default React.memo(Merchant);
@@ -3,6 +3,7 @@ import { Theme, SxProps } from '@mui/material/styles';
3
3
  interface SocialMediaProps {
4
4
  show: boolean;
5
5
  sx?: SxProps<Theme>;
6
+ isNewUser: boolean;
6
7
  }
7
- declare const _default: React.MemoExoticComponent<({ show, sx }: SocialMediaProps) => JSX.Element>;
8
+ declare const _default: React.MemoExoticComponent<({ show, sx, isNewUser }: SocialMediaProps) => JSX.Element>;
8
9
  export default _default;
@@ -57,7 +57,7 @@ var ClearIconStyled = styled(ClearIcon)(function (_a) {
57
57
  });
58
58
  var SocialMedia = function (_a) {
59
59
  var _b, _c, _d;
60
- var show = _a.show, sx = _a.sx;
60
+ var show = _a.show, sx = _a.sx, isNewUser = _a.isNewUser;
61
61
  var _e = React.useState(SocialMediaTypes.WEB), socialMediaType = _e[0], setSocialMediaType = _e[1];
62
62
  var t = useTranslation().t;
63
63
  var _f = useFormContext(), control = _f.control, setValue = _f.setValue, watch = _f.watch;
@@ -90,10 +90,14 @@ var SocialMedia = function (_a) {
90
90
  var website = "www.".concat(brandName.replace(' ', '-'), ".com");
91
91
  setValue('links', __assign(__assign({}, links), { website: website }), { shouldValidate: true });
92
92
  }
93
- if (!brandName) {
93
+ if (!brandName && isNewUser === false) {
94
94
  var website = "other.com";
95
95
  setValue('links', __assign(__assign({}, links), { website: website }), { shouldValidate: true });
96
96
  }
97
+ if (!brandName && isNewUser === true) {
98
+ var website = '';
99
+ setValue('links', __assign(__assign({}, links), { website: website }));
100
+ }
97
101
  }, [brandName]);
98
102
  var websiteValue = links.website || '';
99
103
  var twitterValue = links.twitter || '';
@@ -1,5 +1,10 @@
1
1
  import * as yup from 'yup';
2
- export declare const MerchantValidationSchema: (isOtherBrand: boolean) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
2
+ export declare enum ValidationOptions {
3
+ NEW_USER = "NEW_USER",
4
+ EXISTING_USER_WITH_EXIST_BRAND = "EXISTING_USER_WITH_EXIST_BRAND",
5
+ EXISTING_USER_WITH_OTHER_BRAND = "EXISTING_USER_WITH_OTHER_BRAND"
6
+ }
7
+ export declare const MerchantValidationSchema: (userType: ValidationOptions) => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
8
  brandName: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
4
9
  termAndConditionChecked: yup.BooleanSchema<boolean | undefined, import("yup/lib/types").AnyObject, boolean | undefined>;
5
10
  links: yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
@@ -1,17 +1,75 @@
1
1
  import { REGEX_WEBSITE } from '../../../../constants';
2
2
  import * as yup from 'yup';
3
- export var MerchantValidationSchema = function (isOtherBrand) {
4
- return yup.object().shape({
5
- brandName: isOtherBrand
6
- ? yup
3
+ export var ValidationOptions;
4
+ (function (ValidationOptions) {
5
+ ValidationOptions["NEW_USER"] = "NEW_USER";
6
+ ValidationOptions["EXISTING_USER_WITH_EXIST_BRAND"] = "EXISTING_USER_WITH_EXIST_BRAND";
7
+ ValidationOptions["EXISTING_USER_WITH_OTHER_BRAND"] = "EXISTING_USER_WITH_OTHER_BRAND";
8
+ })(ValidationOptions || (ValidationOptions = {}));
9
+ export var MerchantValidationSchema = function (userType) {
10
+ var askingForBrandInfo = userType === ValidationOptions.NEW_USER || userType === ValidationOptions.EXISTING_USER_WITH_OTHER_BRAND;
11
+ if (askingForBrandInfo) {
12
+ return yup.object().shape({
13
+ brandName: yup
7
14
  .string()
8
15
  .min(3, 'enter_brand_name_english_chars_numbers_space')
9
16
  .max(250, 'enter_brand_name_english_chars_numbers_space')
10
- .required('enter_valid_brand_name')
11
- : yup.string().optional(),
12
- termAndConditionChecked: isOtherBrand
13
- ? yup.boolean().required().isTrue('check_terms_cond')
14
- : yup.boolean().optional(),
17
+ .required('enter_valid_brand_name'),
18
+ termAndConditionChecked: yup.boolean().required().isTrue('check_terms_cond'),
19
+ links: yup.object().shape({
20
+ website: yup.string().when(['instagram', 'twitter'], function (instagram, twitter) {
21
+ if (!instagram && !twitter) {
22
+ return yup
23
+ .string()
24
+ .matches(REGEX_WEBSITE, 'ide_not_valid_url')
25
+ .transform(function (value) { return (!!value ? value : null); })
26
+ .nullable()
27
+ .required('enter_at_least_one');
28
+ }
29
+ else {
30
+ return yup
31
+ .string()
32
+ .matches(REGEX_WEBSITE, 'ide_not_valid_url')
33
+ .transform(function (value) { return (!!value ? value : null); })
34
+ .nullable()
35
+ .optional();
36
+ }
37
+ }),
38
+ instagram: yup
39
+ .string()
40
+ .nullable()
41
+ .transform(function (value) { return (!!value ? value : null); })
42
+ .when(['twitter', 'website'], function (twitter, website) {
43
+ if (!website && !twitter) {
44
+ return yup.string().min(2, 'enter_at_least_one').required('enter_at_least_one');
45
+ }
46
+ else {
47
+ return yup.string().optional();
48
+ }
49
+ }),
50
+ twitter: yup
51
+ .string()
52
+ .nullable()
53
+ .transform(function (value) { return (!!value ? value : null); })
54
+ .min(2, 'enter_at_least_one')
55
+ .when(['website', 'instagram'], function (website, instagram) {
56
+ if (!website && !instagram) {
57
+ return yup.string().min(2, 'enter_at_least_one').required('enter_at_least_one');
58
+ }
59
+ else {
60
+ return yup.string().optional();
61
+ }
62
+ })
63
+ }, [
64
+ ['instagram', 'website'],
65
+ ['twitter', 'website'],
66
+ ['instagram', 'twitter']
67
+ ])
68
+ });
69
+ }
70
+ return yup.object().shape({
71
+ brandName: yup.string().optional(),
72
+ termAndConditionChecked: yup.boolean().optional(),
15
73
  links: yup.object().shape({
16
74
  website: yup.string().when(['instagram', 'twitter'], function (instagram, twitter) {
17
75
  if (!instagram && !twitter) {
@@ -116,7 +116,7 @@ var MobileNumber = React.forwardRef(function (_a, ref) {
116
116
  setValue('mobile', '');
117
117
  countryCodeControl.field.onChange(country);
118
118
  };
119
- return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(Input, { sx: { direction: 'ltr' }, inputProps: { maxLength: requiredLen }, type: 'tel', onChange: onPhoneNumberChange, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () { return toggleCountryList(); } }, { children: ["+".concat(countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix), !anchorEl && _jsx(ExpandIconStyled, { anchorEl: !!anchorEl })] })), endAdornment: !!anchorEl ? (_jsx(ExpandIconStyled, { onClick: function () { return toggleCountryList(); }, anchorEl: !!anchorEl })) : !error && mobileValue ? (_jsx(CheckIcon, {})) : (mobileValue && _jsx(ClearIcon, { onClick: clearMobileNumber })), placeholder: "".concat(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: error && t(error, { length: requiredLen, number: '05|5' }) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
119
+ return (_jsx(Collapse, __assign({ in: rest.show }, { children: _jsxs(ScreenContainer, __assign({ ref: ref }, { children: [_jsx(LabelContainerStyled, { children: _jsx(InputLabelStyled, { children: t('signup_enter_mobile') }) }), _jsx(Input, { sx: { direction: 'ltr' }, inputProps: { maxLength: requiredLen }, type: 'tel', onChange: onPhoneNumberChange, value: !!anchorEl ? countryName : mobileValue, startAdornment: _jsxs(CountryCodeStyled, __assign({ onClick: function () { return toggleCountryList(); } }, { children: ["+".concat(countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix), !anchorEl && _jsx(ExpandIconStyled, { anchorEl: !!anchorEl })] })), endAdornment: !!anchorEl ? (_jsx(ExpandIconStyled, { onClick: function () { return toggleCountryList(); }, anchorEl: !!anchorEl })) : !error && mobileValue ? (_jsx(CheckIcon, {})) : (mobileValue && _jsx(ClearIcon, { onClick: clearMobileNumber })), placeholder: "".concat(isSA ? '5' : '0', "00000000"), warningType: 'alert', warningMessage: !anchorEl ? error && t(error, { length: requiredLen, number: '05|5' }) : undefined }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'name.english', list: countriesCode, onSelectItem: onSelectItem, renderItem: function (item) {
120
120
  return (_jsxs(_Fragment, { children: [_jsxs(CountryItemContainer, { children: [_jsxs(CountryCodeText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: ["+", item.idd_prefix] })), _jsx(CountryNameText, __assign({ isSelected: (item === null || item === void 0 ? void 0 : item.idd_prefix) === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) }, { children: isAr ? item.name.arabic : item.name.english }))] }), item.idd_prefix === (countryCodeValue === null || countryCodeValue === void 0 ? void 0 : countryCodeValue.idd_prefix) && _jsx(CheckIcon, {})] }));
121
121
  } }) }))] })) })));
122
122
  });
@@ -11,15 +11,17 @@ import BusinessOTPPage from './business/screens/OTP';
11
11
  import BusinessTypePage from './business/screens/BusinessType';
12
12
  import ActivitiesPage from './business/screens/Activities';
13
13
  import SuccessPage from './business/screens/Success';
14
- import ConfirmPage from './business/screens/Confirm';
14
+ import PasswordVerifyPage from './password/screens/Verify';
15
15
  import CreatePasswordPage from './password/screens/CreatePassword';
16
16
  import SuccessPasswordPage from './password/screens/Success';
17
+ import IndividualVerifyPage from './individual/screens/Verify';
17
18
  import ShowIndividualInfoPage from './individual/screens/ShowIndividualInfo';
18
19
  import AdditionalIndividualInfoPage from './individual/screens/AdditionalIndividualInfo';
19
20
  import SuccessOwnerPage from './individual/screens/Success';
20
21
  import BankVerifyPage from './bank/screens/Verify';
21
22
  import BankDetailsPage from './bank/screens/BankDetails';
22
23
  import BankSuccessPage from './bank/screens/Success';
24
+ import TaxVerifyPage from './tax/screens/Verify';
23
25
  import TaxDetailsPage from './tax/screens/TaxDetails';
24
26
  import TaxSuccessPage from './tax/screens/Success';
25
27
  export var connectFeatureScreens = [
@@ -65,10 +67,6 @@ export var businessFeatureScreens = [
65
67
  name: 'BUSINESS_BUSINESS_TYPE_STEP',
66
68
  element: BusinessTypePage
67
69
  },
68
- {
69
- name: 'BUSINESS_CONFIRM_STEP',
70
- element: ConfirmPage
71
- },
72
70
  {
73
71
  name: 'BUSINESS_ACTIVITIES_STEP',
74
72
  element: ActivitiesPage
@@ -80,6 +78,10 @@ export var businessFeatureScreens = [
80
78
  { name: 'BUSINESS_SUCCESS_STEP', element: SuccessPage }
81
79
  ];
82
80
  export var passwordFeatureScreens = [
81
+ {
82
+ name: 'PASSWORD_VERIFY_STEP',
83
+ element: PasswordVerifyPage
84
+ },
83
85
  {
84
86
  name: 'PASSWORD_CREATE_PASSWORD_STEP',
85
87
  element: CreatePasswordPage
@@ -90,6 +92,10 @@ export var passwordFeatureScreens = [
90
92
  }
91
93
  ];
92
94
  export var individualFeatureScreens = [
95
+ {
96
+ name: 'INDIVIDUAL_VERIFY_STEP',
97
+ element: IndividualVerifyPage
98
+ },
93
99
  {
94
100
  name: 'INDIVIDUAL_SHOW_INDIVIDUAL_INFO_STEP',
95
101
  element: ShowIndividualInfoPage
@@ -118,6 +124,10 @@ export var bankFeatureScreens = [
118
124
  }
119
125
  ];
120
126
  export var taxFeatureScreens = [
127
+ {
128
+ name: 'TAX_VERIFY_STEP',
129
+ element: TaxVerifyPage
130
+ },
121
131
  {
122
132
  name: 'TAX_TAX_DETAILS_STEP',
123
133
  element: TaxDetailsPage
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
- export interface IndividualLibProps {
2
+ import { LibConfig } from '../../@types';
3
+ export interface IndividualLibProps extends LibConfig {
3
4
  }
4
5
  export declare function IndividualLib(props: IndividualLibProps): JSX.Element;
5
6
  export declare function renderIndividualLib(config: IndividualLibProps, elementId: string): void;
@@ -11,28 +11,36 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import React, { memo, useEffect } from 'react';
14
- import { useTranslation } from 'react-i18next';
15
- import { useAppTheme, useAppDispatch, useAppSelector } from '../../hooks';
16
- import { handleActiveFlowScreens, settingsSelector } from '../../app/settings';
14
+ import { useAppTheme, useAppDispatch, useAppSelector, useAppConfig, useErrorListener } from '../../hooks';
15
+ import { settingsSelector } from '../../app/settings';
17
16
  import AnimationFlow from '../../components/AnimationFlow';
18
17
  import { store } from '../../app/store';
19
18
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
20
19
  import Collapse from '../../components/Collapse';
21
- import { reactElement } from '../../utils';
20
+ import { getParameterByName, reactElement } from '../../utils';
22
21
  import { FeatureContainer } from '../shared/Containers';
23
22
  import { INDIVIDUAL_SCREENS_NAVIGATION } from '../../constants';
24
23
  import { individualFeatureScreens } from '../featuresScreens';
24
+ import { verifyLeadToken } from '../app/individual/individualStore';
25
25
  import CustomFooter from '../shared/Footer';
26
26
  var Individual = memo(function (props) {
27
27
  var open = React.useState(true)[0];
28
- var t = useTranslation().t;
29
28
  var theme = useAppTheme().theme;
30
29
  var dispatch = useAppDispatch();
31
30
  var data = useAppSelector(settingsSelector).data;
31
+ var loading = useAppConfig(__assign({ navigation: INDIVIDUAL_SCREENS_NAVIGATION }, props)).loading;
32
+ useErrorListener();
32
33
  var activeScreen = data.activeScreen;
34
+ var verifyToken = function () {
35
+ var token = getParameterByName('token');
36
+ if (!token)
37
+ throw new Error('Auth token is not found!');
38
+ dispatch(verifyLeadToken(token));
39
+ };
33
40
  useEffect(function () {
34
- dispatch(handleActiveFlowScreens(INDIVIDUAL_SCREENS_NAVIGATION));
35
- }, []);
41
+ if (!loading)
42
+ verifyToken();
43
+ }, [loading]);
36
44
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AnimationFlow, __assign({ open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: individualFeatureScreens.map(function (_a, index) {
37
45
  var Element = _a.element, name = _a.name;
38
46
  var isActive = activeScreen.name === name;
@@ -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,42 @@
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
+ var BoxStyled = styled(Box)(function (_a) {
21
+ var theme = _a.theme;
22
+ return ({
23
+ display: 'flex',
24
+ flexDirection: 'column',
25
+ fontFamily: theme.typography.fontFamily
26
+ });
27
+ });
28
+ var OTPInput = function (_a) {
29
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
30
+ var t = useTranslation().t;
31
+ var otpControl = useController({ name: 'otp', control: control });
32
+ var handleOnOTPChange = function (otp) {
33
+ otpControl.field.onChange(otp);
34
+ };
35
+ var handleOnResendOTP = function () {
36
+ if (otpControl.field.value)
37
+ setValue('otp', '', { shouldValidate: true });
38
+ };
39
+ var otpValue = otpControl.field.value;
40
+ return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
41
+ };
42
+ 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,78 @@
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 { useSelector } from 'react-redux';
17
+ import { useForm, FormProvider } from 'react-hook-form';
18
+ import { yupResolver } from '@hookform/resolvers/yup';
19
+ import Box from '@mui/material/Box/Box';
20
+ import { styled } from '@mui/material/styles';
21
+ import { handlePrevScreenStep } from '../../../../app/settings';
22
+ import { useLanguage } from '../../../../hooks';
23
+ import { maskPhone } from '../../../../utils';
24
+ import Form from '../../../../components/Form';
25
+ import Text from '../../../../components/Text';
26
+ import { ScreenContainer } from '../../../shared/Containers';
27
+ import { individualSelector, clearError, resetOTPScreen, verifyLeadOTP } from '../../../app/individual/individualStore';
28
+ import Button from '../../../shared/Button';
29
+ import { OTPValidation } from './validation';
30
+ import OTPInput from './OTPInput';
31
+ var OTPTitleContainerStyled = styled(Box)(function (_a) {
32
+ var theme = _a.theme;
33
+ return ({
34
+ background: theme.palette.common.white,
35
+ border: '1px solid',
36
+ borderColor: theme.palette.divider,
37
+ direction: theme.direction,
38
+ borderRadius: theme.spacing(0, 0, 1.25, 1.25),
39
+ marginBottom: theme.spacing(5.75)
40
+ });
41
+ });
42
+ var OTPTitleStyled = styled(Text)(function (_a) {
43
+ var theme = _a.theme;
44
+ 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.75 }));
45
+ });
46
+ var FormStyled = styled(Form)(function () { return ({
47
+ display: 'flex',
48
+ flexDirection: 'column'
49
+ }); });
50
+ var VerifyNumber = function (_a) {
51
+ var _b, _c, _d;
52
+ var dispatch = useAppDispatch();
53
+ var _e = useSelector(individualSelector), data = _e.data, loading = _e.loading, error = _e.error;
54
+ var methods = useForm({
55
+ resolver: yupResolver(OTPValidation),
56
+ defaultValues: data.otpData,
57
+ mode: 'onChange'
58
+ });
59
+ var t = useTranslation().t;
60
+ var isAr = useLanguage().isAr;
61
+ React.useEffect(function () {
62
+ if (error)
63
+ dispatch(clearError());
64
+ return function () {
65
+ dispatch(resetOTPScreen());
66
+ };
67
+ }, [methods.formState.isValid]);
68
+ var onSubmit = function (formData) {
69
+ dispatch(verifyLeadOTP(formData));
70
+ };
71
+ var onBack = function () {
72
+ dispatch(handlePrevScreenStep());
73
+ };
74
+ var phone = (_d = (_c = (_b = data.verify.responseBody) === null || _b === void 0 ? void 0 : _b.contact) === null || _c === void 0 ? void 0 : _c.phone) === null || _d === void 0 ? void 0 : _d.number;
75
+ var disabled = !methods.formState.isValid || !!error || !phone;
76
+ return (_jsx(ScreenContainer, { children: _jsx(FormProvider, __assign({}, methods, { children: _jsxs(FormStyled, __assign({ onSubmit: methods.handleSubmit(onSubmit) }, { children: [_jsx(OTPTitleContainerStyled, { children: _jsxs(OTPTitleStyled, { children: [loading ? t('ide_otp_waiting_title') : t('ide_opt_sent_title'), !loading && phone && _jsx("span", __assign({ dir: 'ltr' }, { children: "".concat(maskPhone(phone || '')) }))] }) }), _jsx(OTPInput, {}), _jsx(Button, __assign({ disableBack: true, onBackClicked: function () { return onBack(); }, disabled: disabled, type: 'submit', isAr: isAr, loading: loading, error: t(error || '') }, { children: t('next') }))] })) })) }));
77
+ };
78
+ export default React.memo(VerifyNumber);
@@ -0,0 +1,2 @@
1
+ import OTP from './Verify';
2
+ export default OTP;
@@ -0,0 +1,2 @@
1
+ import OTP from './Verify';
2
+ export default OTP;
@@ -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
+ });
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
- export interface PasswordLibProps {
2
+ import { LibConfig } from '../../@types';
3
+ export interface PasswordLibProps extends LibConfig {
3
4
  }
4
5
  export declare function PasswordLib(props: PasswordLibProps): JSX.Element;
5
6
  export declare function renderPasswordLib(config: PasswordLibProps, elementId: string): void;
@@ -11,28 +11,36 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import React, { memo, useEffect } from 'react';
14
- import { useTranslation } from 'react-i18next';
15
- import { useAppTheme, useAppDispatch, useAppSelector } from '../../hooks';
16
- import { handleActiveFlowScreens, settingsSelector } from '../../app/settings';
14
+ import { useAppTheme, useAppDispatch, useAppSelector, useAppConfig, useErrorListener } from '../../hooks';
15
+ import { settingsSelector } from '../../app/settings';
17
16
  import AnimationFlow from '../../components/AnimationFlow';
18
17
  import { store } from '../../app/store';
19
18
  import { ReduxProvider, ThemeProvider } from '../../components/Providers';
20
19
  import Collapse from '../../components/Collapse';
21
20
  import { FeatureContainer } from '../shared/Containers';
22
- import { reactElement } from '../../utils';
21
+ import { getParameterByName, reactElement } from '../../utils';
23
22
  import { PASSWORD_SCREENS_NAVIGATION } from '../../constants';
24
23
  import { passwordFeatureScreens } from '../featuresScreens';
24
+ import { verifyLeadToken } from '../app/password/passwordStore';
25
25
  import CustomFooter from '../shared/Footer';
26
26
  var Password = memo(function (props) {
27
27
  var open = React.useState(true)[0];
28
- var t = useTranslation().t;
29
28
  var theme = useAppTheme().theme;
30
29
  var dispatch = useAppDispatch();
31
30
  var data = useAppSelector(settingsSelector).data;
31
+ var loading = useAppConfig(__assign({ navigation: PASSWORD_SCREENS_NAVIGATION }, props)).loading;
32
+ useErrorListener();
32
33
  var activeScreen = data.activeScreen;
34
+ var verifyToken = function () {
35
+ var token = getParameterByName('token');
36
+ if (!token)
37
+ throw new Error('Auth token is not found!');
38
+ dispatch(verifyLeadToken(token));
39
+ };
33
40
  useEffect(function () {
34
- dispatch(handleActiveFlowScreens(PASSWORD_SCREENS_NAVIGATION));
35
- }, []);
41
+ if (!loading)
42
+ verifyToken();
43
+ }, [loading]);
36
44
  return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(AnimationFlow, __assign({ open: open, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: passwordFeatureScreens.map(function (_a, index) {
37
45
  var Element = _a.element, name = _a.name;
38
46
  var isActive = activeScreen.name === name;
@@ -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,42 @@
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
+ var BoxStyled = styled(Box)(function (_a) {
21
+ var theme = _a.theme;
22
+ return ({
23
+ display: 'flex',
24
+ flexDirection: 'column',
25
+ fontFamily: theme.typography.fontFamily
26
+ });
27
+ });
28
+ var OTPInput = function (_a) {
29
+ var _b = useFormContext(), control = _b.control, setValue = _b.setValue;
30
+ var t = useTranslation().t;
31
+ var otpControl = useController({ name: 'otp', control: control });
32
+ var handleOnOTPChange = function (otp) {
33
+ otpControl.field.onChange(otp);
34
+ };
35
+ var handleOnResendOTP = function () {
36
+ if (otpControl.field.value)
37
+ setValue('otp', '', { shouldValidate: true });
38
+ };
39
+ var otpValue = otpControl.field.value;
40
+ return (_jsx(BoxStyled, __assign({ dir: 'ltr' }, { children: _jsx(OTPField, { timeEndLabel: t('ide_otp_resend_label'), timerInSeconds: DEFAULT_TIMER_VALUE, onResetClick: handleOnResendOTP, value: otpValue, onChange: function (number) { return handleOnOTPChange(number.toString()); } }) })));
41
+ };
42
+ 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;