@tap-payments/auth-jsconnect 2.3.85-test → 2.3.87-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 (30) hide show
  1. package/build/@types/app.d.ts +33 -8
  2. package/build/@types/form.d.ts +2 -3
  3. package/build/api/data.d.ts +1 -0
  4. package/build/api/data.js +9 -1
  5. package/build/api/entity.d.ts +7 -0
  6. package/build/api/entity.js +10 -1
  7. package/build/api/index.d.ts +4 -3
  8. package/build/api/individual.d.ts +0 -1
  9. package/build/api/individual.js +1 -15
  10. package/build/api/lead.d.ts +0 -1
  11. package/build/assets/locales/ar.json +1 -5
  12. package/build/assets/locales/en.json +1 -5
  13. package/build/components/SimpleList/SimpleList.d.ts +1 -1
  14. package/build/components/SimpleList/SimpleList.js +2 -2
  15. package/build/constants/api.d.ts +1 -0
  16. package/build/constants/api.js +3 -1
  17. package/build/constants/dummy.d.ts +0 -8
  18. package/build/constants/dummy.js +0 -8
  19. package/build/features/app/connect/connectStore.js +35 -66
  20. package/build/features/app/entity/entityStore.js +26 -17
  21. package/build/features/connect/screens/Merchant/Merchant.js +6 -10
  22. package/build/features/connect/screens/Merchant/validation.d.ts +1 -4
  23. package/build/features/connect/screens/Merchant/validation.js +1 -4
  24. package/build/features/entity/screens/EntityCapital/ActivityList.d.ts +19 -54
  25. package/build/features/entity/screens/EntityCapital/ActivityList.js +165 -98
  26. package/build/features/entity/screens/EntityCapital/validation.d.ts +3 -48
  27. package/build/features/entity/screens/EntityCapital/validation.js +1 -7
  28. package/package.json +1 -1
  29. package/build/features/connect/screens/Merchant/BusinessList.d.ts +0 -10
  30. package/build/features/connect/screens/Merchant/BusinessList.js +0 -82
@@ -18,30 +18,24 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
18
  }
19
19
  return to.concat(ar || Array.prototype.slice.call(from));
20
20
  };
21
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
21
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
22
  import * as React from 'react';
23
- import { useTranslation } from 'react-i18next';
24
- import { useController, useFormContext } from 'react-hook-form';
25
23
  import Box from '@mui/material/Box';
26
24
  import { alpha, styled } from '@mui/material/styles';
27
- import InfoIcon from '@mui/icons-material/Info';
28
- import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
29
- import CheckIcon from '@mui/icons-material/Check';
30
- import { useLanguage, useAppSelector, useAppDispatch } from '../../../../hooks';
31
- import { BusinessType } from '../../../../@types';
32
- import { sortActivitiesByName } from '../../../../utils';
33
- import Text from '../../../../components/Text';
34
- import Input from '../../../shared/Input';
35
- import Tooltip from '../../../../components/Tooltip';
36
- import Collapse from '../../../../components/Collapse';
25
+ import { useTranslation } from 'react-i18next';
26
+ import { useController, useFormContext } from 'react-hook-form';
27
+ import { settingsSelector } from '../../../../app/settings';
28
+ import { useLanguage, useAppSelector } from '../../../../hooks';
37
29
  import SimpleList from '../../../../components/SimpleList';
30
+ import Collapse from '../../../../components/Collapse';
38
31
  import ExpandIcon from '../../../../components/ExpandIcon';
32
+ import CheckIcon from '@mui/icons-material/Check';
33
+ import Text from '../../../../components/Text';
34
+ import { findCurrencyByIso2, isExist } from '../../../../utils';
39
35
  import { ScreenContainer } from '../../../shared/Containers';
40
- import { clearError, entitySelector } from '../../../app/entity/entityStore';
41
- export var InputLabelStyled = styled(Text)(function (_a) {
42
- var theme = _a.theme;
43
- return (__assign({ color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
44
- });
36
+ import Search from '../../../shared/Search';
37
+ import Input from '../../../shared/Input';
38
+ import { entitySelector } from '../../../app/entity/entityStore';
45
39
  var InputStyled = styled(Input)(function (_a) {
46
40
  var theme = _a.theme, readOnly = _a.readOnly;
47
41
  return ({
@@ -51,120 +45,193 @@ var InputStyled = styled(Input)(function (_a) {
51
45
  }
52
46
  });
53
47
  });
54
- export var InfoOutlinedIconStyled = styled(InfoOutlinedIcon)(function (_a) {
55
- var theme = _a.theme;
56
- return ({
57
- width: theme.spacing(2.75),
58
- height: theme.spacing(2.125),
59
- cursor: 'pointer',
60
- color: alpha(theme.palette.text.primary, 0.4)
61
- });
48
+ export var NameContainer = styled(Text, { shouldForwardProp: function (prop) { return !['isSelected', 'isAr'].includes(prop.toString()); } })(function (_a) {
49
+ var theme = _a.theme, isSelected = _a.isSelected, isAr = _a.isAr;
50
+ return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { textAlign: isAr ? 'right' : 'left', fontWeight: isSelected ? theme.typography.fontWeightRegular : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25) }));
62
51
  });
63
- export var InfoIconStyled = styled(InfoIcon)(function (_a) {
52
+ export var InputLabelStyled = styled(Text)(function (_a) {
64
53
  var theme = _a.theme;
65
- return ({
66
- width: theme.spacing(2.75),
67
- height: theme.spacing(2.125),
68
- cursor: 'pointer',
69
- color: alpha(theme.palette.text.primary, 0.4)
70
- });
54
+ return (__assign({ margin: theme.spacing(2.5, 2.5, 1.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
71
55
  });
72
- export var LabelContainerStyled = styled(Box)(function (_a) {
56
+ export var CheckIconStyled = styled(CheckIcon)(function (_a) {
73
57
  var theme = _a.theme;
74
58
  return ({
59
+ color: theme.palette.success.main,
75
60
  display: 'flex',
76
- justifyContent: 'space-between',
77
- margin: theme.spacing(2.5, 2.5, 1.5, 2.5)
61
+ alignItems: 'flex-end'
78
62
  });
79
63
  });
80
- var SimpleListStyled = styled((SimpleList))(function () { return ({}); });
81
- export var CheckIconStyled = styled(CheckIcon)(function (_a) {
64
+ var ListItem = styled(Box)(function (_a) {
82
65
  var theme = _a.theme;
83
66
  return ({
84
- color: theme.palette.primary.main,
85
67
  display: 'flex',
86
- alignItems: 'flex-end'
68
+ justifyContent: 'space-between',
69
+ width: '100%',
70
+ paddingInlineStart: theme.spacing(2.5),
71
+ paddingInlineEnd: theme.spacing(2.5),
72
+ paddingTop: theme.spacing(1.5),
73
+ paddingBottom: theme.spacing(1.5)
87
74
  });
88
75
  });
89
- export var NameContainer = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
90
- var theme = _a.theme, isSelected = _a.isSelected;
91
- return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight, paddingInlineStart: theme.spacing(1.25), textAlign: 'start' }));
92
- });
93
- var ActivitiesList = function (props) {
94
- var _a;
95
- var _b = React.useState([]), activitiesMenuList = _b[0], setActivitiesMenuList = _b[1];
76
+ var ListItemContainer = styled(Box)(function () { return ({
77
+ display: 'flex',
78
+ flexDirection: 'column',
79
+ width: '100%'
80
+ }); });
81
+ var SimpleListStyled = styled((SimpleList))(function () { return ({
82
+ height: 'fit-content'
83
+ }); });
84
+ var DivisionListStyled = styled((SimpleList))(function () { return ({
85
+ height: 'fit-content'
86
+ }); });
87
+ var ActivityListStyled = styled((SimpleList))(function () { return ({
88
+ height: 'fit-content'
89
+ }); });
90
+ var ActivityList = function (_a) {
91
+ var onListClose = _a.onListClose, onListOpen = _a.onListOpen, readOnly = _a.readOnly;
92
+ var _b = React.useState([]), activities = _b[0], setActivities = _b[1];
96
93
  var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
94
+ var _d = React.useState(''), subIndex = _d[0], setSubIndex = _d[1];
95
+ var _e = React.useState(''), subItemIndex = _e[0], setSubItemIndex = _e[1];
97
96
  var t = useTranslation().t;
98
97
  var isAr = useLanguage().isAr;
99
98
  var control = useFormContext().control;
100
- var dispatch = useAppDispatch();
101
- var _d = useAppSelector(entitySelector), data = _d.data, error = _d.error;
102
99
  var activitiesControl = useController({ name: 'activities', control: control });
100
+ var data = useAppSelector(entitySelector).data;
101
+ var settingsData = useAppSelector(settingsSelector).data;
102
+ var activityList = (data.verify.responseBody || {}).activityList;
103
103
  var controlValue = activitiesControl.field.value;
104
- var _e = React.useState(false), isHovered = _e[0], setIsHovered = _e[1];
105
- var verify = data.verify;
106
- var _f = verify.responseBody || {}, activityList = _f.activityList, entity = _f.entity;
107
- var licenseType = (_a = entity === null || entity === void 0 ? void 0 : entity.license) === null || _a === void 0 ? void 0 : _a.type;
108
- var type = licenseType === 'freelance' ? BusinessType.FL : BusinessType.CR;
109
- var isCR = type === BusinessType.CR;
110
- var disabled = false;
111
- var setSelectedActivitiesBeginning = function (list) {
112
- var mapSelectedListFirst = __spreadArray(__spreadArray([], list.filter(function (a) { return (controlValue || []).some(function (c) { return a.id === c.id; }); }), true), list.filter(function (a) { return !(controlValue || []).some(function (c) { return a.id === c.id; }); }), true);
113
- setActivitiesMenuList(mapSelectedListFirst);
114
- };
115
- React.useEffect(function () {
116
- if ((activityList === null || activityList === void 0 ? void 0 : activityList.length) > 0) {
117
- var list = __spreadArray([], activityList, true);
118
- var sortedList = sortActivitiesByName(list, isAr ? 'name.ar' : 'name.en');
119
- setSelectedActivitiesBeginning(sortedList);
120
- }
121
- }, [activityList]);
122
- var onOpenList = function (event) {
123
- var _a, _b;
124
- if (props.readOnly)
104
+ var countryCode = settingsData.businessCountry;
105
+ var handleOpenMainMenu = function (event) {
106
+ if (readOnly)
125
107
  return;
126
- if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > ((_a = entity === null || entity === void 0 ? void 0 : entity.activities) === null || _a === void 0 ? void 0 : _a.length)) {
127
- var list = __spreadArray([], activitiesMenuList, true);
128
- setSelectedActivitiesBeginning(list);
129
- }
130
108
  setAnchorEl(event.currentTarget);
131
- (_b = props.onListOpen) === null || _b === void 0 ? void 0 : _b.call(props);
109
+ onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
132
110
  };
133
- var onCloseList = function () {
134
- var _a;
111
+ var handleCloseMainMenu = function () {
135
112
  setAnchorEl(null);
136
- (_a = props.onListClose) === null || _a === void 0 ? void 0 : _a.call(props);
113
+ onListClose === null || onListClose === void 0 ? void 0 : onListClose();
114
+ handleCloseSubMenu();
115
+ handleCloseSubItem();
116
+ if ((activityList === null || activityList === void 0 ? void 0 : activityList.length) > 0) {
117
+ setActivities(activityList);
118
+ }
137
119
  };
138
- var onSelectItem = function (item) {
139
- var _a;
140
- if (error)
141
- dispatch(clearError());
142
- var isActivityExistInBackend = (_a = entity === null || entity === void 0 ? void 0 : entity.activities) === null || _a === void 0 ? void 0 : _a.find(function (activity) { return activity.id === item.id; });
143
- if (isActivityExistInBackend)
144
- return;
145
- var isActivityExists = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === item.id; });
120
+ var handleOpenSubMenu = function (index) {
121
+ if (subIndex === index)
122
+ setSubIndex('');
123
+ else
124
+ setSubIndex(index);
125
+ };
126
+ var handleCloseSubMenu = function () {
127
+ setSubIndex('');
128
+ };
129
+ var handleOpenSubItem = function (index) {
130
+ if (subItemIndex === index)
131
+ setSubItemIndex('');
132
+ else
133
+ setSubItemIndex(index);
134
+ };
135
+ var handleCloseSubItem = function () {
136
+ setSubItemIndex('');
137
+ };
138
+ React.useEffect(function () {
139
+ if ((activityList === null || activityList === void 0 ? void 0 : activityList.length) > 0) {
140
+ setActivities(activityList);
141
+ }
142
+ }, [activityList]);
143
+ var onSelectItem = function (id) {
144
+ var isActivityExists = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activityId) { return activityId === id; });
146
145
  if (isActivityExists) {
147
- var updatedIdList = controlValue === null || controlValue === void 0 ? void 0 : controlValue.filter(function (activity) { return activity.id !== (item === null || item === void 0 ? void 0 : item.id); });
146
+ var updatedIdList = controlValue === null || controlValue === void 0 ? void 0 : controlValue.filter(function (activityId) { return activityId !== id; });
148
147
  if (updatedIdList.length >= 1)
149
148
  activitiesControl.field.onChange(updatedIdList);
150
149
  return;
151
150
  }
152
- activitiesControl.field.onChange(__spreadArray(__spreadArray([], controlValue, true), [item], false));
151
+ var ids = controlValue ? __spreadArray(__spreadArray([], controlValue, true), [id], false) : [id];
152
+ activitiesControl.field.onChange(ids);
153
153
  };
154
154
  var getSelectedActivities = function () {
155
- var _a, _b;
155
+ var _a, _b, _c;
156
156
  if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > 1) {
157
157
  return (controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) + ' ' + t('activities_selected');
158
158
  }
159
- var item = controlValue[0];
160
- return isAr ? (_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en;
159
+ var item = (controlValue || [])[0];
160
+ return isAr ? ((_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar) || ((_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en) : (_c = item === null || item === void 0 ? void 0 : item.name) === null || _c === void 0 ? void 0 : _c.en;
161
+ };
162
+ var getSelectedActivityName = function (item) {
163
+ var _a, _b, _c;
164
+ return isAr ? ((_a = item === null || item === void 0 ? void 0 : item.name) === null || _a === void 0 ? void 0 : _a.ar) || ((_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.en) : (_c = item === null || item === void 0 ? void 0 : item.name) === null || _c === void 0 ? void 0 : _c.en;
161
165
  };
162
- var getSelectedActivityFlag = function (item) {
163
- return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === item.id; });
166
+ var getSelectedActivitySectionFlag = function (section) {
167
+ var findSection = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (id) { return id === section.id; });
168
+ var findDivision = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (id) { var _a; return (_a = section.divisions) === null || _a === void 0 ? void 0 : _a.find(function (division) { return division.id === id; }); });
169
+ var findActivity = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (id) { var _a; return (_a = section.divisions) === null || _a === void 0 ? void 0 : _a.find(function (division) { var _a; return (_a = division === null || division === void 0 ? void 0 : division.activities) === null || _a === void 0 ? void 0 : _a.find(function (activity) { return activity.id === id; }); }); });
170
+ if (findSection || findDivision || findActivity)
171
+ return section.id;
172
+ return '';
164
173
  };
165
- return (_jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsx(InputLabelStyled, { children: t(isCR ? 'activities' : 'category') }), _jsx(Tooltip, __assign({ title: t('activities_name_hint'), onMouseOver: function () { return setIsHovered(true); }, onMouseLeave: function () { return setIsHovered(false); }, onTouchStartCapture: function () { return setIsHovered(true); } }, { children: isHovered ? _jsx(InfoIconStyled, {}) : _jsx(InfoOutlinedIconStyled, {}) }))] }), _jsxs(Box, { children: [_jsx(InputStyled, { readOnly: props.readOnly, disabled: disabled, value: getSelectedActivities() || '', placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: disabled ? undefined : !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: disabled ? _jsx(_Fragment, {}) : _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsx(Collapse, __assign({ in: !!anchorEl, timeout: 300 }, { children: _jsx(SimpleListStyled, { searchKeyPath: 'name.en', searchValuePath: ['name.ar', 'name.en'], list: activitiesMenuList, onSelectItem: onSelectItem, renderItem: function (item) {
166
- var _a, _b, _c;
167
- return (_jsxs(_Fragment, { children: [_jsx(Box, __assign({ display: 'flex' }, { children: _jsx(NameContainer, __assign({ isSelected: item.id === ((_a = getSelectedActivityFlag(item)) === null || _a === void 0 ? void 0 : _a.id) }, { children: isAr ? (_b = item === null || item === void 0 ? void 0 : item.name) === null || _b === void 0 ? void 0 : _b.ar : (_c = item === null || item === void 0 ? void 0 : item.name) === null || _c === void 0 ? void 0 : _c.en })) })), getSelectedActivityFlag(item) && _jsx(CheckIconStyled, {})] }));
168
- } }) }))] })] }));
174
+ var getSelectedActivityDivisionFlag = function (division) {
175
+ var findDivision = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (id) { var _a; return (_a = division.activities) === null || _a === void 0 ? void 0 : _a.find(function (activity) { return activity.id === id; }); });
176
+ if (findDivision)
177
+ return division.id;
178
+ return '';
179
+ };
180
+ var getSelectedActivityFlag = function (activity) {
181
+ var findActivity = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (id) { return id === activity.id; });
182
+ if (findActivity)
183
+ return activity.id;
184
+ return '';
185
+ };
186
+ var handleSearch = function (value) {
187
+ if (!value) {
188
+ setActivities(activityList);
189
+ return;
190
+ }
191
+ var filteredList = (activityList || [])
192
+ .flatMap(function (s) { return s.divisions; })
193
+ .flatMap(function (d) { return d.activities; })
194
+ .filter(function (a) {
195
+ var _a, _b, _c, _d;
196
+ return ((_b = (_a = a === null || a === void 0 ? void 0 : a.name) === null || _a === void 0 ? void 0 : _a.en) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(value.toLowerCase())) || ((_d = (_c = a === null || a === void 0 ? void 0 : a.name) === null || _c === void 0 ? void 0 : _c.ar) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes(value.toLowerCase()));
197
+ });
198
+ setActivities(filteredList);
199
+ };
200
+ React.useEffect(function () {
201
+ var item = isExist(activityList || [], controlValue === null || controlValue === void 0 ? void 0 : controlValue.id);
202
+ if (item)
203
+ setSubIndex(item.id);
204
+ }, [anchorEl, controlValue]);
205
+ return (_jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('expected_sales_monthly', {
206
+ currency: t(findCurrencyByIso2(countryCode.iso2))
207
+ }) }), _jsx(InputStyled, { readOnly: readOnly, value: getSelectedActivities() || '', onClick: !!anchorEl ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_expected_sales'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsx(Search, { onSearchValue: handleSearch }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: activities, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (section) {
208
+ var isDivisionNotAvailable = !section.divisions || section.divisions.length === 0;
209
+ if (isDivisionNotAvailable)
210
+ onSelectItem(section.id);
211
+ else
212
+ handleOpenSubMenu(section.id);
213
+ }, renderItem: function (section) {
214
+ var _a;
215
+ var isDivisionNotAvailable = !section.divisions || ((_a = section.divisions) === null || _a === void 0 ? void 0 : _a.length) === 0;
216
+ var showCheck = section.id === getSelectedActivitySectionFlag(section) && isDivisionNotAvailable;
217
+ return (_jsxs(ListItemContainer, { children: [_jsxs(ListItem, __assign({ sx: __assign({ bgcolor: 'rgb(196 184 184 / 8%)', borderBottom: '1px solid rgba(227, 232, 238, 0.8)' }, (isDivisionNotAvailable && { bgcolor: 'inherit', borderBottom: 'none' })) }, { children: [_jsx(NameContainer, __assign({ isAr: isAr, isSelected: section.id === getSelectedActivitySectionFlag(section), sx: __assign({}, (isDivisionNotAvailable && { paddingInlineStart: '5px' })) }, { children: getSelectedActivityName(section) })), showCheck ? _jsx(CheckIconStyled, {}) : !isDivisionNotAvailable && _jsx(ExpandIcon, { anchorEl: subIndex === section.id })] })), _jsx(Collapse, __assign({ in: section.id === subIndex && !isDivisionNotAvailable }, { children: _jsx(DivisionListStyled, { sx: { pt: 0, pb: 0 }, list: (!isDivisionNotAvailable && section.divisions) || [], onSelectItem: function (division, e) {
218
+ e.stopPropagation();
219
+ var isOnlyOneItem = !division.activities || division.activities.length === 1;
220
+ if (isOnlyOneItem)
221
+ onSelectItem(division.id);
222
+ else
223
+ handleOpenSubItem(division.id);
224
+ }, listItemProps: { sx: { padding: 0, '&:last-child': { paddingBottom: 0 } } }, renderItem: function (division, idx) {
225
+ var _a;
226
+ var isOnlyOneItem = !division.activities || ((_a = division.activities) === null || _a === void 0 ? void 0 : _a.length) === 1;
227
+ var showCheck = division.id === getSelectedActivityDivisionFlag(division) && isOnlyOneItem;
228
+ return (_jsxs(ListItemContainer, { children: [_jsxs(ListItem, __assign({ sx: __assign({ bgcolor: 'rgb(196 184 184 / 4%)', borderBottom: '1px solid rgba(227, 232, 238, 0.4)' }, (isOnlyOneItem && { bgcolor: 'inherit', borderBottom: 'none' })) }, { children: [_jsx(NameContainer, __assign({ isAr: isAr, isSelected: division.id === getSelectedActivityDivisionFlag(division), sx: __assign({}, (isOnlyOneItem && { paddingInlineStart: '5px' })) }, { children: getSelectedActivityName(division) })), showCheck ? _jsx(CheckIconStyled, {}) : !isOnlyOneItem && _jsx(ExpandIcon, { anchorEl: subItemIndex === division.id })] })), _jsx(Collapse, __assign({ in: division.id === subItemIndex && !isOnlyOneItem }, { children: _jsx(ActivityListStyled, { sx: { pt: 0, pb: 0 }, list: (!isOnlyOneItem && division.activities) || [], onSelectItem: function (activity, e) {
229
+ e.stopPropagation();
230
+ onSelectItem(activity.id);
231
+ }, listItemProps: { sx: { padding: 0, '&:last-child': { paddingBottom: 0 } } }, renderItem: function (activity, idx) {
232
+ return (_jsxs(ListItem, __assign({ sx: { mt: idx === 0 ? 1 : 0 } }, { children: [_jsx(NameContainer, __assign({ isAr: isAr, isSelected: activity.id === getSelectedActivityFlag(activity) }, { children: getSelectedActivityName(activity) })), activity.id === getSelectedActivityFlag(activity) && _jsx(CheckIconStyled, {})] })));
233
+ } }) }))] }, idx));
234
+ } }) }))] }));
235
+ } })] }))] }));
169
236
  };
170
- export default ActivitiesList;
237
+ export default ActivityList;
@@ -1,61 +1,16 @@
1
1
  import * as yup from 'yup';
2
2
  export declare const EntityCapitalValidationSchema: () => yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
- activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
4
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
5
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
6
- }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
8
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
9
- }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
10
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
11
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
12
- }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
13
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
14
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
15
- }>>[] | undefined, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
16
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
17
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
18
- }>>[] | undefined>;
3
+ activities: yup.ArraySchema<yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>, import("yup/lib/types").AnyObject, (string | undefined)[] | undefined, (string | undefined)[] | undefined>;
19
4
  capitalPaid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
20
5
  capitalShareCount: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
21
6
  capitalShareValue: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
22
7
  }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
23
- activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
24
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
25
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
26
- }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
27
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
28
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
29
- }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
30
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
31
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
32
- }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
33
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
34
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
35
- }>>[] | undefined, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
36
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
37
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
38
- }>>[] | undefined>;
8
+ activities: yup.ArraySchema<yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>, import("yup/lib/types").AnyObject, (string | undefined)[] | undefined, (string | undefined)[] | undefined>;
39
9
  capitalPaid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
40
10
  capitalShareCount: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
41
11
  capitalShareValue: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
42
12
  }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
43
- activities: yup.ArraySchema<yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
44
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
45
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
46
- }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
47
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
48
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
49
- }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
50
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
51
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
52
- }>>>, import("yup/lib/types").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
53
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
54
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
55
- }>>[] | undefined, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
56
- ar: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
57
- en: yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>;
58
- }>>[] | undefined>;
13
+ activities: yup.ArraySchema<yup.StringSchema<string | undefined, import("yup/lib/types").AnyObject, string | undefined>, import("yup/lib/types").AnyObject, (string | undefined)[] | undefined, (string | undefined)[] | undefined>;
59
14
  capitalPaid: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
60
15
  capitalShareCount: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
61
16
  capitalShareValue: import("yup/lib/string").RequiredStringSchema<string | undefined, import("yup/lib/types").AnyObject>;
@@ -1,13 +1,7 @@
1
1
  import * as yup from 'yup';
2
2
  export var EntityCapitalValidationSchema = function () {
3
3
  return yup.object().shape({
4
- activities: yup
5
- .array()
6
- .min(1, 'activities_list_alert')
7
- .of(yup.object().shape({
8
- ar: yup.string(),
9
- en: yup.string()
10
- })),
4
+ activities: yup.array().min(1, 'activities_list_alert').of(yup.string()),
11
5
  capitalPaid: yup.string().required('capital_paid_required'),
12
6
  capitalShareCount: yup.string().required('capital_share_count_required'),
13
7
  capitalShareValue: yup.string().required('capital_share_value_required')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/auth-jsconnect",
3
- "version": "2.3.85-test",
3
+ "version": "2.3.87-test",
4
4
  "description": "connect library, auth",
5
5
  "private": false,
6
6
  "main": "build/index.js",
@@ -1,10 +0,0 @@
1
- import * as React from 'react';
2
- import { BusinessInfo } from '../../../../@types';
3
- interface BusinessListProps {
4
- show: boolean;
5
- list: Array<BusinessInfo>;
6
- onListOpen?: () => void;
7
- onListClose?: () => void;
8
- }
9
- declare const _default: React.MemoExoticComponent<({ show, list, ...rest }: BusinessListProps) => JSX.Element>;
10
- export default _default;
@@ -1,82 +0,0 @@
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
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
24
- import * as React from 'react';
25
- import { useTranslation } from 'react-i18next';
26
- import { useFormContext, useController } from 'react-hook-form';
27
- import Box from '@mui/material/Box';
28
- import { styled } from '@mui/material/styles';
29
- import { useLanguage } from '../../../../hooks';
30
- import SimpleList from '../../../../components/SimpleList';
31
- import Text from '../../../../components/Text';
32
- import ExpandIcon from '../../../../components/ExpandIcon';
33
- import Collapse from '../../../../components/Collapse';
34
- import ScreenContainer from '../../../shared/Containers/ScreenContainer';
35
- import Input from '../../../shared/Input';
36
- import CheckIcon from '../../../shared/CheckIcon';
37
- var InputStyled = styled(Input)(function () { return ({
38
- '& .MuiInputBase-input': {
39
- cursor: 'pointer'
40
- }
41
- }); });
42
- var BusinessContainer = styled(Box)(function () { return ({
43
- display: 'flex'
44
- }); });
45
- var BusinessNameText = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
46
- var theme = _a.theme, isSelected = _a.isSelected;
47
- return (__assign(__assign({ color: theme.palette.text.primary }, theme.typography.body2), { fontWeight: isSelected ? theme.typography.fontWeightMedium : theme.typography.fontWeightLight }));
48
- });
49
- var BusinessList = function (_a) {
50
- var show = _a.show, list = _a.list, rest = __rest(_a, ["show", "list"]);
51
- var _b = React.useState(null), anchorEl = _b[0], setAnchorEl = _b[1];
52
- var t = useTranslation().t;
53
- var isAr = useLanguage().isAr;
54
- var control = useFormContext().control;
55
- var businessControl = useController({ control: control, name: 'business' });
56
- var business = businessControl.field.value;
57
- var onOpenBusinessList = function (event) {
58
- var _a;
59
- setAnchorEl(event.currentTarget);
60
- (_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
61
- };
62
- var onCloseBusinessList = function () {
63
- var _a;
64
- setAnchorEl(null);
65
- (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
66
- };
67
- var getBusinessName = function (business) {
68
- var _a, _b;
69
- return (isAr ? (_a = business === null || business === void 0 ? void 0 : business.name) === null || _a === void 0 ? void 0 : _a.ar : (_b = business === null || business === void 0 ? void 0 : business.name) === null || _b === void 0 ? void 0 : _b.en) || '';
70
- };
71
- var getBusinessId = function (item) {
72
- return (item === null || item === void 0 ? void 0 : item.id) || '';
73
- };
74
- var onSelectItem = function (business) {
75
- businessControl.field.onChange(business);
76
- onCloseBusinessList();
77
- };
78
- return (_jsx(Collapse, __assign({ in: show }, { children: _jsxs(ScreenContainer, __assign({ sx: { mt: 2.5, mb: 0 } }, { children: [_jsx(InputStyled, { label: t('select_business_label'), onClick: !!anchorEl ? onCloseBusinessList : onOpenBusinessList, endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }), placeholder: t('choose_business'), value: t(getBusinessName(business)) }), _jsx(Collapse, __assign({ in: !!anchorEl }, { children: _jsx(SimpleList, { searchKeyPath: 'id', searchValuePath: ['id', 'name.ar', 'name.en'], list: list, onSelectItem: onSelectItem, renderItem: function (item) {
79
- return (_jsxs(_Fragment, { children: [_jsx(BusinessContainer, { children: _jsx(BusinessNameText, __assign({ isSelected: getBusinessId(item) === getBusinessId(business) }, { children: t(getBusinessName(item)) })) }), getBusinessId(item) === getBusinessId(business) && _jsx(CheckIcon, {})] }));
80
- } }) }))] })) })));
81
- };
82
- export default React.memo(BusinessList);