@tap-payments/auth-jsconnect 1.0.94-test → 1.0.97-test

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/build/@types/app.d.ts +7 -2
  2. package/build/@types/form.d.ts +2 -1
  3. package/build/api/auth.d.ts +22 -3
  4. package/build/api/axios.d.ts +2 -2
  5. package/build/api/axios.js +62 -0
  6. package/build/api/country.d.ts +1 -2
  7. package/build/api/country.js +7 -8
  8. package/build/api/data.d.ts +1 -0
  9. package/build/api/data.js +9 -2
  10. package/build/api/entity.d.ts +3 -1
  11. package/build/api/entity.js +11 -2
  12. package/build/api/firebase.d.ts +1 -1
  13. package/build/api/firebase.js +5 -2
  14. package/build/api/index.d.ts +10 -9
  15. package/build/api/ip.d.ts +1 -1
  16. package/build/api/ip.js +5 -2
  17. package/build/api/lead.d.ts +4 -1
  18. package/build/api/lead.js +14 -2
  19. package/build/api/operator.d.ts +1 -1
  20. package/build/api/operator.js +60 -4
  21. package/build/app/settings.d.ts +6 -15
  22. package/build/app/settings.js +82 -142
  23. package/build/components/AnimationFlow/AnimationFlow.d.ts +2 -1
  24. package/build/components/AnimationFlow/AnimationFlow.js +2 -2
  25. package/build/components/AnimationFlow/BottomSheet.d.ts +2 -1
  26. package/build/components/AnimationFlow/BottomSheet.js +16 -4
  27. package/build/constants/api.d.ts +2 -1
  28. package/build/constants/api.js +5 -3
  29. package/build/constants/app.d.ts +6 -0
  30. package/build/constants/app.js +16 -4
  31. package/build/features/app/bank/bankStore.js +6 -4
  32. package/build/features/app/business/businessStore.d.ts +2 -4
  33. package/build/features/app/business/businessStore.js +66 -22
  34. package/build/features/app/connect/connectStore.d.ts +5 -10
  35. package/build/features/app/connect/connectStore.js +121 -27
  36. package/build/features/app/individual/individualStore.d.ts +3 -2
  37. package/build/features/app/individual/individualStore.js +27 -22
  38. package/build/features/app/password/passwordStore.d.ts +29 -1
  39. package/build/features/app/password/passwordStore.js +184 -8
  40. package/build/features/app/tax/taxStore.js +7 -5
  41. package/build/features/bank/Bank.js +4 -4
  42. package/build/features/bank/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +16 -4
  43. package/build/features/business/Business.js +4 -4
  44. package/build/features/business/screens/IDBOD/IDBOD.js +1 -1
  45. package/build/features/business/screens/OTP/OTPInput.js +3 -9
  46. package/build/features/business/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +17 -6
  47. package/build/features/connect/Connect.js +1 -1
  48. package/build/features/connect/screens/Mobile/Mobile.js +1 -1
  49. package/build/features/connect/screens/NID/NID.js +1 -1
  50. package/build/features/connect/screens/OTP/OTPInput.js +3 -13
  51. package/build/features/featuresScreens.js +5 -0
  52. package/build/features/individual/Individual.js +4 -4
  53. package/build/features/individual/screens/AdditionalIndividualInfo/AdditionalIndividualInfo.js +7 -1
  54. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.d.ts +10 -0
  55. package/build/features/individual/screens/AdditionalIndividualInfo/Occupation.js +89 -0
  56. package/build/features/individual/screens/AdditionalIndividualInfo/validation.d.ts +3 -0
  57. package/build/features/individual/screens/AdditionalIndividualInfo/validation.js +1 -0
  58. package/build/features/individual/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +16 -4
  59. package/build/features/password/Password.js +12 -6
  60. package/build/features/password/screens/CreatePassword/CreatePassword.js +9 -2
  61. package/build/features/password/screens/OTP/OTP.d.ts +8 -0
  62. package/build/features/password/screens/OTP/OTP.js +78 -0
  63. package/build/features/password/screens/OTP/OTPInput.d.ts +5 -0
  64. package/build/features/password/screens/OTP/OTPInput.js +46 -0
  65. package/build/features/password/screens/OTP/index.d.ts +3 -0
  66. package/build/features/password/screens/OTP/index.js +2 -0
  67. package/build/features/password/screens/OTP/validation.d.ts +8 -0
  68. package/build/features/password/screens/OTP/validation.js +4 -0
  69. package/build/features/password/screens/Success/Success.js +8 -2
  70. package/build/features/password/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +17 -5
  71. package/build/features/password/screens/Verify/OTPInput.d.ts +2 -2
  72. package/build/features/password/screens/Verify/OTPInput.js +1 -1
  73. package/build/features/shared/Button/FlowsButtons.d.ts +8 -2
  74. package/build/features/shared/Button/FlowsButtons.js +94 -6
  75. package/build/features/shared/Button/SuccessButton.js +17 -13
  76. package/build/features/tax/Tax.js +3 -3
  77. package/build/features/tax/screens/SuccessWithFlowButtons/SuccessWithFlowButtons.js +16 -4
  78. package/build/hooks/useAppConfig.d.ts +1 -4
  79. package/build/hooks/useAppConfig.js +13 -113
  80. package/build/hooks/useAppTheme.js +3 -2
  81. package/build/index.css +4 -0
  82. package/build/theme/theme.d.ts +1 -1
  83. package/build/theme/theme.js +1 -2
  84. package/build/utils/array.d.ts +3 -0
  85. package/build/utils/array.js +10 -0
  86. package/build/utils/string.d.ts +1 -0
  87. package/build/utils/string.js +4 -0
  88. package/package.json +1 -1
@@ -4,6 +4,7 @@ import { SxProps, Theme } from '@mui/material/styles';
4
4
  import { FlowsTypes } from '../../../@types';
5
5
  export declare type ButtonItemProps = {
6
6
  name: string;
7
+ status: string;
7
8
  title: string;
8
9
  href: string;
9
10
  src: string;
@@ -11,8 +12,13 @@ export declare type ButtonItemProps = {
11
12
  isCompleted: boolean;
12
13
  sx?: SxProps<Theme> | undefined;
13
14
  };
15
+ export interface DataProps {
16
+ flowName: FlowsTypes;
17
+ email: string;
18
+ emailUrl: string;
19
+ }
14
20
  export interface EmailProvidersButtonsProps extends ButtonProps {
15
21
  buttons: ButtonItemProps[];
16
- flowName: FlowsTypes;
22
+ data: DataProps;
17
23
  }
18
- export default function FlowsButtons({ buttons, flowName }: EmailProvidersButtonsProps): JSX.Element;
24
+ export default function FlowsButtons({ buttons, data }: EmailProvidersButtonsProps): JSX.Element;
@@ -9,16 +9,54 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { jsx as _jsx } from "react/jsx-runtime";
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
49
+ import { useState } from 'react';
13
50
  import Button from '../../../components/Button';
14
51
  import { alpha, styled } from '@mui/material/styles';
15
52
  import Box from '@mui/material/Box';
16
53
  import Link from '@mui/material/Link';
17
54
  import { ICONS_NAMES } from '../../../constants';
18
55
  import CheckIcon from '@mui/icons-material/Check';
19
- import { useAppDispatch } from '../../../hooks';
56
+ import { useAppDispatch, useLanguage } from '../../../hooks';
20
57
  import { handleOpen, handleCurrentActiveScreen } from '../../../app/settings';
21
58
  import { getScreenNameBasedOnFlow } from '../../../utils';
59
+ import API from '../../../api';
22
60
  var Image = styled('img')(function (_a) {
23
61
  var theme = _a.theme;
24
62
  return ({
@@ -85,8 +123,12 @@ var CheckIconStyled = styled(CheckIcon)(function (_a) {
85
123
  });
86
124
  });
87
125
  export default function FlowsButtons(_a) {
88
- var buttons = _a.buttons, flowName = _a.flowName;
126
+ var _this = this;
127
+ var buttons = _a.buttons, data = _a.data;
89
128
  var dispatch = useAppDispatch();
129
+ var flowName = data.flowName, email = data.email, emailUrl = data.emailUrl;
130
+ var _b = useState(false), loading = _b[0], setLoading = _b[1];
131
+ var isAr = useLanguage().isAr;
90
132
  var onRedirect = function (item) {
91
133
  if (item.isCompleted)
92
134
  return;
@@ -99,11 +141,57 @@ export default function FlowsButtons(_a) {
99
141
  window.location.href = item.href;
100
142
  }, 500);
101
143
  };
144
+ var isResetPassword = function (name, status) {
145
+ return name === 'password' && status === 'completed';
146
+ };
147
+ var onResetPassword = function () { return __awaiter(_this, void 0, void 0, function () {
148
+ var payload;
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0:
152
+ setLoading(true);
153
+ payload = {
154
+ user_credentail: {
155
+ email: email
156
+ },
157
+ auth_type: 7,
158
+ email_url: emailUrl,
159
+ step_name: 'reset_password_auth',
160
+ encryption_contract: ['user_credentail.email']
161
+ };
162
+ return [4, API.authService
163
+ .createAuth(payload)
164
+ .then(function (response) {
165
+ var _a;
166
+ setLoading(false);
167
+ var data = response.data;
168
+ var description = (((_a = data === null || data === void 0 ? void 0 : data.errors) === null || _a === void 0 ? void 0 : _a[0]) || {}).description;
169
+ if (description) {
170
+ alert(description);
171
+ return;
172
+ }
173
+ })
174
+ .catch(function (error) {
175
+ alert(error);
176
+ setLoading(false);
177
+ })
178
+ .finally(function () {
179
+ setLoading(false);
180
+ })];
181
+ case 1:
182
+ _a.sent();
183
+ return [2];
184
+ }
185
+ });
186
+ }); };
102
187
  return (_jsx(ButtonBoxStyled, { children: buttons.map(function (_a, idx) {
103
- var title = _a.title, href = _a.href, src = _a.src, hoverSrc = _a.hoverSrc, isCompleted = _a.isCompleted, sx = _a.sx, name = _a.name;
188
+ var title = _a.title, href = _a.href, src = _a.src, hoverSrc = _a.hoverSrc, isCompleted = _a.isCompleted, sx = _a.sx, name = _a.name, status = _a.status;
104
189
  var isLast = idx === buttons.length - 1;
105
190
  return (_jsx(Link, __assign({ underline: 'none', onClick: function () {
106
- onRedirect({ title: title, href: href, src: src, hoverSrc: hoverSrc, isCompleted: isCompleted, name: name });
107
- } }, { children: _jsx(ButtonStyled, __assign({ variant: 'outlined', isCompleted: isCompleted, sx: __assign({ mb: isLast ? 2.5 : 1.8 }, sx), endIcon: isCompleted ? (_jsx(CheckIconStyled, {})) : (_jsx(Image, { sx: { height: 15, transform: 'unset' }, src: ICONS_NAMES.Arrow_filled_right_icon })), startIcon: _jsx(Image, { src: src, alt: title }), type: 'button' }, { children: title })) }), idx));
191
+ if (isResetPassword(name, status))
192
+ onResetPassword();
193
+ else
194
+ onRedirect({ title: title, href: href, src: src, hoverSrc: hoverSrc, isCompleted: isCompleted, name: name, status: status });
195
+ } }, { children: _jsx(ButtonStyled, __assign({ variant: 'outlined', disabled: isResetPassword(name, status) && loading, isCompleted: isCompleted, sx: __assign({ mb: isLast ? 2.5 : 1.8 }, sx), endIcon: isResetPassword(name, status) && loading ? (_jsx(_Fragment, {})) : isCompleted ? (_jsx(CheckIconStyled, {})) : (_jsx(Image, { sx: { height: 15, transform: isAr ? 'scale(-1)' : 'scale(1)' }, src: ICONS_NAMES.Arrow_filled_right_icon })), startIcon: isResetPassword(name, status) && loading ? _jsx(_Fragment, {}) : _jsx(Image, { src: src, alt: title }), type: 'button' }, { children: title })) }), idx));
108
196
  }) }));
109
197
  }
@@ -25,25 +25,29 @@ import React from 'react';
25
25
  import Button from './Button';
26
26
  import { styled } from '@mui/material/styles';
27
27
  import Box from '@mui/material/Box';
28
- var ButtonStyled = styled(Button, {
29
- shouldForwardProp: function (prop) { return !['isLoading', 'isAr'].includes(prop); }
30
- })(function (_a) {
31
- var theme = _a.theme, isLoading = _a.isLoading;
28
+ var ButtonStyled = styled(Button)(function (_a) {
29
+ var theme = _a.theme;
32
30
  return ({
33
- '&.MuiButton-outlined': __assign({ width: '100%', textTransform: 'none', paddingInlineStart: theme.spacing(0.75), backgroundColor: theme.palette.common.white, color: theme.palette.primary.main, border: "1px solid ".concat(theme.palette.primary.main), '&:hover': {
31
+ '&.MuiButton-outlined': {
32
+ width: '100%',
33
+ textTransform: 'none',
34
+ paddingInlineStart: theme.spacing(0.75),
35
+ backgroundColor: theme.palette.common.white,
36
+ color: theme.palette.primary.main,
37
+ border: "1px solid ".concat(theme.palette.primary.main),
38
+ '&:hover': {
34
39
  backgroundColor: theme.palette.common.white,
35
40
  color: theme.palette.primary.main
36
- }, '&:disabled': {
41
+ },
42
+ '&:disabled': {
37
43
  backgroundColor: theme.palette.primary.main,
38
44
  color: theme.palette.common.white
39
- }, transition: theme.transitions.create(['width', 'padding'], {
45
+ },
46
+ transition: theme.transitions.create(['width', 'padding'], {
40
47
  easing: theme.transitions.easing.easeInOut,
41
48
  duration: theme.transitions.duration.complex * 2
42
- }) }, (isLoading && {
43
- minWidth: 0,
44
- width: theme.spacing(6),
45
- borderRadius: 30
46
- }))
49
+ })
50
+ }
47
51
  });
48
52
  });
49
53
  var ButtonBoxStyled = styled(Box)(function (_a) {
@@ -64,5 +68,5 @@ export default function SuccessButton(_a) {
64
68
  React.useEffect(function () {
65
69
  setBtnLoading(false);
66
70
  }, []);
67
- return (_jsx(ButtonBoxStyled, { children: _jsx(ButtonStyled, __assign({ isAr: isAr, isLoading: btnLoading, loading: btnLoading, disabled: disabled, type: 'button', variant: 'outlined' }, props, { children: children })) }));
71
+ return (_jsx(ButtonBoxStyled, { children: _jsx(ButtonStyled, __assign({ isAr: isAr, loading: btnLoading, disabled: disabled, type: 'button', variant: btnLoading ? 'contained' : 'outlined' }, props, { children: children })) }));
68
72
  }
@@ -27,9 +27,9 @@ import Background from '../shared/Background';
27
27
  var Tax = memo(function (props) {
28
28
  var theme = useAppTheme().theme;
29
29
  var dispatch = useAppDispatch();
30
- var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, settingLoading = _a.loading;
30
+ var _a = useAppSelector(settingsSelector), data = _a.data, error = _a.error, loading = _a.loading;
31
31
  var _b = useAppSelector(taxSelector), customLoading = _b.customLoading, taxError = _b.error;
32
- var loading = useAppConfig(__assign({ navigation: TAX_SCREENS_NAVIGATION }, props)).loading;
32
+ useAppConfig(__assign({ navigation: TAX_SCREENS_NAVIGATION }, props));
33
33
  useErrorListener(taxError || error);
34
34
  useStepStartedListener();
35
35
  var activeScreen = data.activeScreen, isTapOrigin = data.isTapOrigin, open = data.open;
@@ -47,7 +47,7 @@ var Tax = memo(function (props) {
47
47
  if (!loading)
48
48
  verifyToken();
49
49
  }, [loading]);
50
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: settingLoading || customLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, open: open, error: error, loading: settingLoading || customLoading, breakpoint: 'sm', footer: _jsx(CustomFooter, {}) }, { children: _jsx(FeatureContainer, { children: taxFeatureScreens.map(function (_a, index) {
50
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(Background, __assign({ isTapOrigin: isTapOrigin, loading: loading || customLoading }, { children: _jsx(AnimationFlow, __assign({ isTapOrigin: isTapOrigin, open: open, error: error, loading: loading || customLoading, breakpoint: 'sm', footer: _jsx(CustomFooter, {}), screenId: activeScreen.name }, { children: _jsx(FeatureContainer, { children: taxFeatureScreens.map(function (_a, index) {
51
51
  var Element = _a.element, name = _a.name;
52
52
  var isActive = activeScreen.name === name;
53
53
  return (_jsx(Collapse, __assign({ in: isActive, timeout: { enter: 1000, exit: 800 } }, { children: _jsx(Element, {}) }), index));
@@ -14,14 +14,15 @@ import React, { memo, useEffect, useState } from 'react';
14
14
  import { useTranslation } from 'react-i18next';
15
15
  import { styled } from '@mui/material/styles';
16
16
  import { FlowsButtons } from '../../../shared/Button';
17
- import { ICONS_NAMES } from '../../../../constants';
17
+ import { ICONS_NAMES, PASSWORD_OPERATION_TYPE } from '../../../../constants';
18
18
  import { useAppSelector, useLanguage } from '../../../../hooks';
19
- import { allAreTruthy, showLastFour } from '../../../../utils';
19
+ import { allAreTruthy, getResetFlowUrl, showLastFour } from '../../../../utils';
20
20
  import { taxSelector } from '../../../app/tax/taxStore';
21
21
  import Box from '@mui/material/Box';
22
22
  import Text from '../../../../components/Text';
23
23
  import Container from '../../../shared/Containers/ScreenContainer';
24
24
  import AcceptancePayouts from '../../../shared/AcceptancePayouts';
25
+ import { settingsSelector } from '../../../../app/settings';
25
26
  var TitleStyled = styled(Text)(function (_a) {
26
27
  var _b;
27
28
  var theme = _a.theme;
@@ -57,10 +58,16 @@ var SuccessWithFlowButtons = function () {
57
58
  var iban = showLastFour((bank === null || bank === void 0 ? void 0 : bank.iban) || '');
58
59
  var taxID = (entity === null || entity === void 0 ? void 0 : entity.tax_number) || '';
59
60
  var brandName = (isAr ? (_b = brand === null || brand === void 0 ? void 0 : brand.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = brand === null || brand === void 0 ? void 0 : brand.name) === null || _c === void 0 ? void 0 : _c.en) || '';
61
+ var settings = useAppSelector(settingsSelector);
62
+ var _h = data.verify.responseBody || { contact: {}, id: '' }, contact = _h.contact, id = _h.id;
63
+ var email = (contact || { email: '' }).email;
64
+ var url = getResetFlowUrl('/password', settings.data.language, PASSWORD_OPERATION_TYPE.RESET_PASSWORD, id);
60
65
  var reMapFlowData = function (flows) {
61
66
  if (flows === void 0) { flows = []; }
62
67
  var images = ICONS_NAMES;
63
- var mappedFlows = flows.map(function (_a) {
68
+ var mappedFlows = flows
69
+ .filter(function (item) { return item.name; })
70
+ .map(function (_a) {
64
71
  var name = _a.name, url = _a.url, status = _a.status;
65
72
  var type = status === 'initiated' ? 'pending' : 'completed';
66
73
  var title = t("".concat(name, "_flow_").concat(type), {
@@ -79,6 +86,7 @@ var SuccessWithFlowButtons = function () {
79
86
  var hoverSrc = "".concat(name, "_white_icon");
80
87
  return {
81
88
  name: name,
89
+ status: status,
82
90
  title: title,
83
91
  href: url,
84
92
  src: images[src],
@@ -96,6 +104,10 @@ var SuccessWithFlowButtons = function () {
96
104
  if ((flows === null || flows === void 0 ? void 0 : flows.length) > 0)
97
105
  reMapFlowData(flows);
98
106
  }, [flows, isAr]);
99
- return (_jsxs(ContainerStyled, { children: [_jsxs(TitleStyled, { children: [t('account_details'), " "] }), _jsx(AcceptancePayouts, { showAcceptance: isAcceptance, showPayout: isPayout }), _jsx(ButtonGroupStyled, { children: _jsx(FlowsButtons, { buttons: buttons, flowName: data.flowName }) })] }));
107
+ return (_jsxs(ContainerStyled, { children: [_jsxs(TitleStyled, { children: [t('account_details'), " "] }), _jsx(AcceptancePayouts, { showAcceptance: isAcceptance, showPayout: isPayout }), _jsx(ButtonGroupStyled, { children: _jsx(FlowsButtons, { buttons: buttons, data: {
108
+ flowName: data.flowName,
109
+ email: email,
110
+ emailUrl: url
111
+ } }) })] }));
100
112
  };
101
113
  export default memo(SuccessWithFlowButtons);
@@ -2,8 +2,5 @@ import { LibConfig, ScreenStepNavigation } from '../@types';
2
2
  interface AppConfigProps extends LibConfig {
3
3
  navigation: ScreenStepNavigation[];
4
4
  }
5
- export declare const useAppConfig: ({ appInfo, navigation, publicKey, ...rest }: AppConfigProps) => {
6
- loading: boolean;
7
- error: string | null;
8
- };
5
+ export declare const useAppConfig: ({ appInfo, navigation, publicKey, ...rest }: AppConfigProps) => void;
9
6
  export {};
@@ -9,42 +9,6 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (_) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
12
  var __rest = (this && this.__rest) || function (s, e) {
49
13
  var t = {};
50
14
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -56,20 +20,15 @@ var __rest = (this && this.__rest) || function (s, e) {
56
20
  }
57
21
  return t;
58
22
  };
59
- import { useEffect, useState } from 'react';
60
- import { handleActiveFlowScreens, settingsSelector, getClientIp, getLocale, getBrowserFingerPrint, getOperator, handleSetAppConfig, handleLanguage, handleOpen, handleIsTapOrigin, getCountries } from '../app/settings';
23
+ import { useEffect } from 'react';
24
+ import { handleActiveFlowScreens, handleSetAppConfig, handleLanguage, handleOpen, handleIsTapOrigin, fetchAppSettingsSync } from '../app/settings';
61
25
  import { useAppDispatch } from './useAppDispatch';
62
- import { useAppSelector } from './useAppSelector';
63
- import { setAxiosGlobalHeaders, axiosInstance } from '../api';
64
- import { getRequestHeaders, encryptString, isTapDomain } from '../utils';
26
+ import { axiosInstance } from '../api';
27
+ import { isTapDomain, removeRequestHeaders } from '../utils';
65
28
  import { ENDPOINT_PATHS } from '../constants';
66
29
  export var useAppConfig = function (_a) {
67
30
  var appInfo = _a.appInfo, navigation = _a.navigation, publicKey = _a.publicKey, rest = __rest(_a, ["appInfo", "navigation", "publicKey"]);
68
- var _b = useState(true), loading = _b[0], setLoading = _b[1];
69
31
  var dispatch = useAppDispatch();
70
- var _c = useAppSelector(settingsSelector), data = _c.data, error = _c.error;
71
- var deviceInfo = data.deviceInfo, language = data.language, appConfig = data.appConfig;
72
- var device = deviceInfo.device, browser = deviceInfo.browser, connection = deviceInfo.connection;
73
32
  var setBaseUrl = function () {
74
33
  var isProd = publicKey.includes('pk_live');
75
34
  if (isProd) {
@@ -78,82 +37,23 @@ export var useAppConfig = function (_a) {
78
37
  }
79
38
  axiosInstance.defaults.baseURL = ENDPOINT_PATHS.DEV_BASE_URL;
80
39
  };
81
- var addAxiosHeader = function () {
82
- setAxiosGlobalHeaders(__assign(__assign({}, getRequestHeaders(deviceInfo)), { authorization: encryptString(publicKey), mdn: encryptString(window.location.origin) }));
40
+ var setAppConfig = function () {
41
+ dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey }, rest)));
42
+ dispatch(handleActiveFlowScreens(navigation));
83
43
  };
84
- var handleAppConfig = function () { return __awaiter(void 0, void 0, void 0, function () {
85
- return __generator(this, function (_a) {
86
- dispatch(handleSetAppConfig(__assign({ appInfo: appInfo, publicKey: publicKey }, rest)));
87
- setBaseUrl();
88
- dispatch(handleActiveFlowScreens(navigation));
89
- return [2];
90
- });
91
- }); };
92
44
  var checkDomain = function () {
93
45
  var isTap = isTapDomain(rest.merchantDomain);
94
46
  dispatch(handleIsTapOrigin(isTap));
95
47
  };
96
- var handleAppApiConfig = function () { return __awaiter(void 0, void 0, void 0, function () {
97
- return __generator(this, function (_a) {
98
- switch (_a.label) {
99
- case 0:
100
- checkDomain();
101
- return [4, dispatch(getLocale())];
102
- case 1:
103
- _a.sent();
104
- return [4, dispatch(getClientIp())];
105
- case 2:
106
- _a.sent();
107
- return [4, dispatch(getBrowserFingerPrint(appInfo))];
108
- case 3:
109
- _a.sent();
110
- return [2];
111
- }
112
- });
113
- }); };
114
- var handleGetOperator = function () { return __awaiter(void 0, void 0, void 0, function () {
115
- var payload;
116
- var _a, _b;
117
- return __generator(this, function (_c) {
118
- switch (_c.label) {
119
- case 0:
120
- payload = {
121
- type: 'website',
122
- app_client_version: 'js-auth-connect',
123
- requirer_browser: "".concat(browser === null || browser === void 0 ? void 0 : browser.name, " , ").concat(browser === null || browser === void 0 ? void 0 : browser.version),
124
- os: "".concat((_a = device.os) === null || _a === void 0 ? void 0 : _a.name, " , ").concat((_b = device.os) === null || _b === void 0 ? void 0 : _b.version),
125
- locale: language
126
- };
127
- return [4, dispatch(getOperator(payload))];
128
- case 1:
129
- _c.sent();
130
- return [4, dispatch(getCountries())];
131
- case 2:
132
- _c.sent();
133
- setLoading(false);
134
- return [2];
135
- }
136
- });
137
- }); };
138
48
  useEffect(function () {
139
49
  dispatch(handleOpen(rest.open));
140
50
  }, [rest.open]);
141
51
  useEffect(function () {
142
- if (data.appConfig.language)
143
- dispatch(handleLanguage(data.appConfig.language));
144
- }, [data.appConfig.language]);
145
- useEffect(function () {
146
- handleAppConfig();
52
+ removeRequestHeaders();
53
+ checkDomain();
54
+ setBaseUrl();
55
+ setAppConfig();
56
+ dispatch(handleLanguage(rest.language));
57
+ dispatch(fetchAppSettingsSync());
147
58
  }, []);
148
- useEffect(function () {
149
- if (appConfig.publicKey)
150
- handleAppApiConfig();
151
- }, [appConfig]);
152
- useEffect(function () {
153
- if (connection.ip && browser.browser_id) {
154
- addAxiosHeader();
155
- handleGetOperator();
156
- }
157
- }, [connection, browser]);
158
- return { loading: loading, error: error };
159
59
  };
@@ -1,6 +1,7 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { LanguageMode, DirectionMode } from '../@types';
3
3
  import { settingsSelector } from '../app/settings';
4
+ import { isMobile } from 'react-device-detect';
4
5
  import { useAppSelector } from './useAppSelector';
5
6
  import { appTheme } from '../theme';
6
7
  export var useAppTheme = function () {
@@ -8,7 +9,7 @@ export var useAppTheme = function () {
8
9
  var data = useAppSelector(settingsSelector).data;
9
10
  useEffect(function () {
10
11
  var dir = data.language === LanguageMode.AR ? DirectionMode.RTL : DirectionMode.LTR;
11
- setTheme(appTheme(data.skin, dir));
12
- }, [data.skin, data.language]);
12
+ setTheme(appTheme(data.skin, isMobile, dir));
13
+ }, [data.skin, data.language, isMobile]);
13
14
  return { theme: theme };
14
15
  };
package/build/index.css CHANGED
@@ -133,3 +133,7 @@ table {
133
133
  border-collapse: collapse;
134
134
  border-spacing: 0;
135
135
  }
136
+
137
+ * {
138
+ box-sizing: border-box;
139
+ }
@@ -1,2 +1,2 @@
1
1
  import { DirectionMode, ThemeMode } from '../@types';
2
- export declare const appTheme: (mode: ThemeMode, dir: DirectionMode) => import("@mui/material/styles").Theme;
2
+ export declare const appTheme: (mode: ThemeMode, isMobile: boolean, dir: DirectionMode) => import("@mui/material/styles").Theme;
@@ -3,8 +3,7 @@ import { typography } from './typography';
3
3
  import { darkPalette, lightPalette } from './palette';
4
4
  import { components } from './components';
5
5
  import { shadows } from './shadows';
6
- import { isMobile } from 'react-device-detect';
7
- export var appTheme = function (mode, dir) {
6
+ export var appTheme = function (mode, isMobile, dir) {
8
7
  return createTheme({
9
8
  palette: mode === 'dark' ? darkPalette : lightPalette,
10
9
  direction: dir,
@@ -1,3 +1,4 @@
1
+ import { CountryCode } from '../@types';
1
2
  export declare const isArray: (value: any) => value is any[];
2
3
  export declare const joinArray: (items: Array<any>, joiner?: string) => string;
3
4
  export declare const replaceStringArrayItems: (items: Array<string>, include: string, withThis: string) => string[];
@@ -8,3 +9,5 @@ export declare const isInclude: (items: Array<string | number>, item: any) => bo
8
9
  export declare const findItem: (items: Array<string | number>, key: any) => string | number | undefined;
9
10
  export declare const isExist: (items: Array<any>, id: string) => any;
10
11
  export declare const allAreTruthy: (items: Array<any>, condition: boolean | string, key: string, exclude?: string) => boolean;
12
+ export declare const sortCountries: (countries: Array<CountryCode>) => CountryCode[];
13
+ export declare const findCountryByIso2: (countries: Array<CountryCode>, iso2: string) => CountryCode | undefined;
@@ -53,3 +53,13 @@ export var allAreTruthy = function (items, condition, key, exclude) {
53
53
  return item[key] === condition;
54
54
  });
55
55
  };
56
+ export var sortCountries = function (countries) {
57
+ return (countries || []).sort(function (cOne, cTwo) {
58
+ return cOne.name.english.localeCompare(cTwo.name.english);
59
+ });
60
+ };
61
+ export var findCountryByIso2 = function (countries, iso2) {
62
+ if (!iso2)
63
+ throw new Error('iso2 is required');
64
+ return countries.find(function (country) { return country.iso2.toLowerCase() === iso2.toLowerCase(); });
65
+ };
@@ -11,6 +11,7 @@ export declare const convertNumbers2English: (str: string) => string;
11
11
  export declare const getParameterByName: (name: string) => string | null;
12
12
  export declare const getClientEmailUrl: () => string;
13
13
  export declare const getFlowUrl: (path: string, lang: string) => string;
14
+ export declare const getResetFlowUrl: (path: string, lang: string, operationType: string, leadId: string) => string;
14
15
  export declare const capitalizeTheFirstLetterOfEachWord: (words: string) => string;
15
16
  export declare const getRequestHeaders: (deviceInfo: DeviceInfo) => {
16
17
  al: string;
@@ -62,6 +62,10 @@ export var getFlowUrl = function (path, lang) {
62
62
  var origin = window.location.origin;
63
63
  return origin + path + "?lang=".concat(lang, "&token=");
64
64
  };
65
+ export var getResetFlowUrl = function (path, lang, operationType, leadId) {
66
+ var origin = window.location.origin;
67
+ return origin + path + "?lang=".concat(lang, "&operation_type=").concat(operationType, "&lead_id=").concat(leadId, "&token=");
68
+ };
65
69
  export var capitalizeTheFirstLetterOfEachWord = function (words) {
66
70
  var separateWord = words.toLowerCase().split(' ');
67
71
  for (var i = 0; i < separateWord.length; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "1.0.94-test",
3
+ "version": "1.0.97-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",