@tap-payments/auth-jsconnect 2.0.61 → 2.0.62

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.
@@ -9,17 +9,6 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
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
12
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
24
13
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
14
  if (ar || !(i in from)) {
@@ -29,31 +18,23 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
29
18
  }
30
19
  return to.concat(ar || Array.prototype.slice.call(from));
31
20
  };
32
- 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";
33
22
  import * as React from 'react';
34
- import { useTranslation } from 'react-i18next';
35
- import { useController, useFormContext } from 'react-hook-form';
36
23
  import Box from '@mui/material/Box';
37
24
  import { alpha, styled } from '@mui/material/styles';
38
- import InfoIcon from '@mui/icons-material/Info';
39
- import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
40
- import { sortActivitiesByName } from '../../../../utils';
41
- import Text from '../../../../components/Text';
42
- import Input from '../../../shared/Input';
43
- import Tooltip from '../../../../components/Tooltip';
25
+ import { useTranslation } from 'react-i18next';
26
+ import { useController, useFormContext } from 'react-hook-form';
44
27
  import { useLanguage, useAppSelector } from '../../../../hooks';
45
- import { BusinessType } from '../../../../@types';
46
- import Collapse from '../../../../components/Collapse';
47
28
  import SimpleList from '../../../../components/SimpleList';
29
+ import Collapse from '../../../../components/Collapse';
48
30
  import ExpandIcon from '../../../../components/ExpandIcon';
31
+ import Text from '../../../../components/Text';
32
+ import { isExist, groupSectionWithSelectedActivitiesAtBeginning, hasVerifiedValue, filterActivitiesByName } from '../../../../utils';
49
33
  import { ScreenContainer } from '../../../shared/Containers';
34
+ import Search from '../../../shared/Search';
35
+ import Input from '../../../shared/Input';
50
36
  import { businessSelector } from '../../../app/business/businessStore';
51
37
  import CheckIcon from '../../../shared/CheckIcon';
52
- import { MandatoryStyled } from './OperationStartDate';
53
- export var InputLabelStyled = styled(Text)(function (_a) {
54
- var theme = _a.theme;
55
- return (__assign({ color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
56
- });
57
38
  var InputStyled = styled(Input)(function (_a) {
58
39
  var theme = _a.theme, readOnly = _a.readOnly;
59
40
  return ({
@@ -63,99 +44,252 @@ var InputStyled = styled(Input)(function (_a) {
63
44
  }
64
45
  });
65
46
  });
66
- export var InfoOutlinedIconStyled = styled(InfoOutlinedIcon)(function (_a) {
67
- var theme = _a.theme;
47
+ var SelectedInputStyled = styled(InputStyled, { shouldForwardProp: function (prop) { return prop !== 'anchorEl'; } })(function (_a) {
48
+ var anchorEl = _a.anchorEl;
68
49
  return ({
69
- width: theme.spacing(2.75),
70
- height: theme.spacing(2.125),
71
- cursor: 'pointer',
72
- color: alpha(theme.palette.text.primary, 0.4)
50
+ '&.MuiInputBase-root': {
51
+ '&.MuiInput-root': __assign({ borderTop: 'none' }, (!anchorEl && {
52
+ borderBottom: 'none'
53
+ }))
54
+ }
73
55
  });
74
56
  });
75
- export var InfoIconStyled = styled(InfoIcon)(function (_a) {
57
+ export var NameContainer = styled(Text, { shouldForwardProp: function (prop) { return !['isSelected', 'isAr'].includes(prop.toString()); } })(function (_a) {
58
+ var theme = _a.theme, isSelected = _a.isSelected, isAr = _a.isAr;
59
+ 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) }));
60
+ });
61
+ export var InputLabelStyled = styled(Text)(function (_a) {
76
62
  var theme = _a.theme;
77
- return ({
78
- width: theme.spacing(2.75),
79
- height: theme.spacing(2.125),
80
- cursor: 'pointer',
81
- color: alpha(theme.palette.text.primary, 0.4)
82
- });
63
+ return (__assign({ margin: theme.spacing(2.5, 2.5, 1.5, 2.5), color: alpha(theme.palette.text.primary, 0.4) }, theme.typography.caption));
83
64
  });
84
- export var LabelContainerStyled = styled(Box)(function (_a) {
65
+ var ListItem = styled(Box)(function (_a) {
85
66
  var theme = _a.theme;
86
67
  return ({
87
68
  display: 'flex',
88
69
  justifyContent: 'space-between',
89
- margin: theme.spacing(2.5, 2.5, 1.5, 2.5)
70
+ width: '100%',
71
+ paddingInlineStart: theme.spacing(2.5),
72
+ paddingInlineEnd: theme.spacing(2.5),
73
+ paddingTop: theme.spacing(1.5),
74
+ paddingBottom: theme.spacing(1.5)
90
75
  });
91
76
  });
92
- var SimpleListStyled = styled((SimpleList))(function () { return ({}); });
93
- export var NameContainer = styled(Text, { shouldForwardProp: function (prop) { return prop !== 'isSelected'; } })(function (_a) {
94
- var theme = _a.theme, isSelected = _a.isSelected;
95
- 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' }));
96
- });
97
- var ActivitiesList = function (_a) {
98
- var _b;
99
- var rest = __rest(_a, []);
100
- var _c = React.useState([]), activitiesMenuList = _c[0], setActivitiesMenuList = _c[1];
101
- var _d = React.useState(null), anchorEl = _d[0], setAnchorEl = _d[1];
77
+ var ListItemContainer = styled(Box)(function () { return ({
78
+ display: 'flex',
79
+ flexDirection: 'column',
80
+ width: '100%'
81
+ }); });
82
+ var SimpleListStyled = styled((SimpleList))(function () { return ({
83
+ height: 'fit-content'
84
+ }); });
85
+ var DivisionListStyled = styled((SimpleList))(function () { return ({
86
+ height: 'fit-content'
87
+ }); });
88
+ var ActivityListStyled = styled((SimpleList))(function () { return ({
89
+ height: 'fit-content'
90
+ }); });
91
+ var ActivityList = function (_a) {
92
+ var onListClose = _a.onListClose, onListOpen = _a.onListOpen, readOnly = _a.readOnly;
93
+ var _b = React.useState([]), activities = _b[0], setActivities = _b[1];
94
+ var _c = React.useState(null), anchorEl = _c[0], setAnchorEl = _c[1];
95
+ var _d = React.useState(null), activityAnchorEl = _d[0], setActivityAnchorEl = _d[1];
96
+ var _e = React.useState(''), subIndex = _e[0], setSubIndex = _e[1];
97
+ var _f = React.useState(''), subItemIndex = _f[0], setSubItemIndex = _f[1];
102
98
  var t = useTranslation().t;
103
99
  var isAr = useLanguage().isAr;
104
- var control = useFormContext().control;
105
- var data = useAppSelector(businessSelector).data;
100
+ var _g = useFormContext(), control = _g.control, setValue = _g.setValue;
106
101
  var activitiesControl = useController({ name: 'activities', control: control });
102
+ var data = useAppSelector(businessSelector).data;
103
+ var entity = (data.verify.responseBody || {}).entity;
104
+ var activityList = (data.businessTypeData.responseBody || {}).activityList;
107
105
  var controlValue = activitiesControl.field.value;
108
- var _e = React.useState(false), isHovered = _e[0], setIsHovered = _e[1];
109
- var businessTypeData = data.businessTypeData;
110
- var activities = (businessTypeData.responseBody || {}).activities;
111
- var businessType = (_b = businessTypeData.selectedLicense) === null || _b === void 0 ? void 0 : _b.type;
112
- var isCR = businessType === BusinessType.CR;
113
- var setSelectedActivitiesBeginning = function (list) {
114
- 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);
115
- setActivitiesMenuList(mapSelectedListFirst);
116
- };
106
+ var selectedActivity = data.activitiesData.activities;
117
107
  React.useEffect(function () {
118
- if ((activities === null || activities === void 0 ? void 0 : activities.length) > 0) {
119
- var list = __spreadArray([], activities, true);
120
- var sortedList = sortActivitiesByName(list, isAr ? 'name.ar' : 'name.en');
121
- setSelectedActivitiesBeginning(sortedList);
108
+ if ((selectedActivity === null || selectedActivity === void 0 ? void 0 : selectedActivity.length) !== (controlValue === null || controlValue === void 0 ? void 0 : controlValue.length))
109
+ setValue('activities', selectedActivity);
110
+ }, [selectedActivity]);
111
+ var handleOpenActivityMenu = function (event) {
112
+ setActivityAnchorEl(event.currentTarget);
113
+ };
114
+ var handleCloseActivityMenu = function () {
115
+ var isSearchActive = !(activityList === null || activityList === void 0 ? void 0 : activityList.find(function (s) { var _a; return (_a = s.divisions) === null || _a === void 0 ? void 0 : _a.length; }));
116
+ if (isSearchActive) {
117
+ var list = groupSectionWithSelectedActivitiesAtBeginning(activityList, controlValue);
118
+ if ((list === null || list === void 0 ? void 0 : list.length) > 0) {
119
+ setActivities(list);
120
+ }
121
+ }
122
+ setActivityAnchorEl(null);
123
+ };
124
+ var handleOpenMainMenu = function (event) {
125
+ if (readOnly)
126
+ return;
127
+ var list = groupSectionWithSelectedActivitiesAtBeginning(activityList, controlValue);
128
+ if ((list === null || list === void 0 ? void 0 : list.length) > 0) {
129
+ setActivities(list);
122
130
  }
123
- }, [activities]);
124
- var onOpenList = function (event) {
125
- var _a;
126
131
  setAnchorEl(event.currentTarget);
127
- setSelectedActivitiesBeginning(activitiesMenuList);
128
- (_a = rest.onListOpen) === null || _a === void 0 ? void 0 : _a.call(rest);
132
+ onListOpen === null || onListOpen === void 0 ? void 0 : onListOpen();
129
133
  };
130
- var onCloseList = function () {
131
- var _a;
134
+ var handleCloseMainMenu = function () {
132
135
  setAnchorEl(null);
133
- (_a = rest.onListClose) === null || _a === void 0 ? void 0 : _a.call(rest);
136
+ onListClose === null || onListClose === void 0 ? void 0 : onListClose();
137
+ handleCloseSubMenu();
138
+ handleCloseSubItem();
139
+ if ((activityList === null || activityList === void 0 ? void 0 : activityList.length) > 0) {
140
+ setActivities(activityList);
141
+ }
142
+ };
143
+ var isActivityVerified = function (item) {
144
+ return hasVerifiedValue(entity === null || entity === void 0 ? void 0 : entity.data_verification, "activities.".concat(item.id));
145
+ };
146
+ var handleOpenSubMenu = function (index) {
147
+ if (subIndex === index)
148
+ setSubIndex('');
149
+ else
150
+ setSubIndex(index);
151
+ };
152
+ var handleCloseSubMenu = function () {
153
+ setSubIndex('');
134
154
  };
135
- var onSelectItem = function (item) {
136
- var isActivityExists = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === item.id; });
155
+ var handleOpenSubItem = function (index) {
156
+ if (subItemIndex === index)
157
+ setSubItemIndex('');
158
+ else
159
+ setSubItemIndex(index);
160
+ };
161
+ var handleCloseSubItem = function () {
162
+ setSubItemIndex('');
163
+ };
164
+ React.useEffect(function () {
165
+ if ((activityList === null || activityList === void 0 ? void 0 : activityList.length) > 0) {
166
+ setActivities(activityList);
167
+ }
168
+ }, [activityList]);
169
+ var onSelectItem = function (activity) {
170
+ var isActivityExists = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (ac) { return ac.id === activity.id; });
137
171
  if (isActivityExists) {
138
- 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); });
172
+ var updatedIdList = controlValue === null || controlValue === void 0 ? void 0 : controlValue.filter(function (ac) { return ac.id !== activity.id; });
173
+ if (!updatedIdList.length) {
174
+ activitiesControl.field.onChange([]);
175
+ return;
176
+ }
139
177
  if (updatedIdList.length >= 1)
140
178
  activitiesControl.field.onChange(updatedIdList);
141
179
  return;
142
180
  }
143
- activitiesControl.field.onChange(__spreadArray(__spreadArray([], controlValue, true), [item], false));
181
+ var activities = controlValue ? __spreadArray(__spreadArray([], controlValue, true), [activity], false) : [activity];
182
+ activitiesControl.field.onChange(activities);
144
183
  };
145
184
  var getSelectedActivities = function () {
146
- var _a, _b;
185
+ var _a, _b, _c;
147
186
  if ((controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) > 1) {
148
187
  return (controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) + ' ' + t('activities_selected');
149
188
  }
150
- var item = controlValue[0];
151
- 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;
189
+ var item = (controlValue || [])[0];
190
+ var code = item === null || item === void 0 ? void 0 : item.isic_code;
191
+ var name = 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;
192
+ return code ? "".concat(code, " - ").concat(name) : name;
193
+ };
194
+ var getSelectedActivityName = function (item) {
195
+ var _a, _b, _c;
196
+ var code = item === null || item === void 0 ? void 0 : item.isic_code;
197
+ var name = 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;
198
+ return code ? "".concat(code, " - ").concat(name) : name;
199
+ };
200
+ var getSelectedActivitySectionFlag = function (section) {
201
+ var findSection = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (_a) {
202
+ var id = _a.id;
203
+ return id === section.id;
204
+ });
205
+ var findDivision = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (_a) {
206
+ var _b;
207
+ var id = _a.id;
208
+ return (_b = section.divisions) === null || _b === void 0 ? void 0 : _b.find(function (division) { return division.id === id; });
209
+ });
210
+ var findActivity = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (_a) {
211
+ var _b;
212
+ var id = _a.id;
213
+ return (_b = section.divisions) === null || _b === void 0 ? void 0 : _b.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; }); });
214
+ });
215
+ if (findSection || findDivision || findActivity)
216
+ return section.id;
217
+ return '';
152
218
  };
153
- var getSelectedActivityFlag = function (item) {
154
- return controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (activity) { return activity.id === item.id; });
219
+ var getSelectedActivityDivisionFlag = function (division) {
220
+ var findDivision = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (_a) {
221
+ var id = _a.id;
222
+ return division.id === id;
223
+ });
224
+ var findActivity = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (_a) {
225
+ var _b;
226
+ var id = _a.id;
227
+ return (_b = division.activities) === null || _b === void 0 ? void 0 : _b.find(function (activity) { return activity.id === id; });
228
+ });
229
+ if (findDivision || findActivity)
230
+ return division.id;
231
+ return '';
155
232
  };
156
- return (_jsxs(ScreenContainer, { children: [_jsxs(LabelContainerStyled, { children: [_jsxs(InputLabelStyled, { children: [t(isCR ? 'activities' : 'category'), " ", _jsx(MandatoryStyled, { children: "*" })] }), _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, { value: getSelectedActivities() || '', placeholder: isCR ? t('choose_activities') : t('category_name'), onClick: !!anchorEl ? function () { return onCloseList(); } : onOpenList, endAdornment: _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) {
157
- var _a, _b, _c;
158
- 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(CheckIcon, {})] }));
159
- } }) }))] })] }));
233
+ var getSelectedActivityFlag = function (activity) {
234
+ var findActivity = controlValue === null || controlValue === void 0 ? void 0 : controlValue.find(function (_a) {
235
+ var id = _a.id;
236
+ return id === activity.id;
237
+ });
238
+ if (findActivity)
239
+ return activity.id;
240
+ return '';
241
+ };
242
+ var handleSearch = function (value) {
243
+ if (!value) {
244
+ var list = groupSectionWithSelectedActivitiesAtBeginning(activityList, controlValue);
245
+ if ((list === null || list === void 0 ? void 0 : list.length) > 0) {
246
+ setActivities(list);
247
+ return;
248
+ }
249
+ setActivities(activityList);
250
+ return;
251
+ }
252
+ var filteredList = filterActivitiesByName(activityList, value);
253
+ setActivities(filteredList);
254
+ };
255
+ React.useEffect(function () {
256
+ var item = isExist(activityList || [], controlValue === null || controlValue === void 0 ? void 0 : controlValue.id);
257
+ if (item)
258
+ setSubIndex(item.id);
259
+ }, [anchorEl, controlValue]);
260
+ return (_jsxs(ScreenContainer, { children: [_jsx(InputLabelStyled, { children: t('activities') }), _jsx(InputStyled, { readOnly: readOnly, value: getSelectedActivities() || '', onClick: !!anchorEl ? handleCloseMainMenu : handleOpenMainMenu, placeholder: t('choose_activities'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!anchorEl }) }), _jsxs(Collapse, __assign({ in: !!anchorEl }, { children: [_jsxs(Collapse, __assign({ in: !!(controlValue === null || controlValue === void 0 ? void 0 : controlValue.length) }, { children: [_jsx(SelectedInputStyled, { readOnly: readOnly, anchorEl: activityAnchorEl, value: t('selected_activities'), onClick: !!activityAnchorEl ? handleCloseActivityMenu : handleOpenActivityMenu, placeholder: t('choose_activities'), endAdornment: _jsx(ExpandIcon, { anchorEl: !!activityAnchorEl }) }), _jsx(Collapse, __assign({ in: !!activityAnchorEl }, { children: _jsx(ActivityListStyled, { sx: { pt: 0, pb: 0 }, list: controlValue || [], onSelectItem: function (activity, e) {
261
+ e.stopPropagation();
262
+ onSelectItem(activity);
263
+ }, listItemProps: { sx: { padding: 0, '&:last-child': { paddingBottom: 0 } } }, renderItem: function (activity, idx) {
264
+ 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(CheckIcon, { isVerified: isActivityVerified(activity) })] })));
265
+ } }) }))] })), _jsx(Search, { onSearchValue: handleSearch, placeholder: 'search_activities_placeholder' }), _jsx(SimpleListStyled, { sx: { maxHeight: '350px', paddingTop: 0 }, list: activities, listItemProps: { sx: { padding: 0 } }, onSelectItem: function (section) {
266
+ var isDivisionNotAvailable = !section.divisions || section.divisions.length === 0;
267
+ if (isDivisionNotAvailable)
268
+ onSelectItem(section);
269
+ else
270
+ handleOpenSubMenu(section.id);
271
+ }, renderItem: function (section) {
272
+ var _a;
273
+ var isDivisionNotAvailable = !section.divisions || ((_a = section.divisions) === null || _a === void 0 ? void 0 : _a.length) === 0;
274
+ var showCheck = section.id === getSelectedActivitySectionFlag(section) && isDivisionNotAvailable;
275
+ return (_jsxs(ListItemContainer, { children: [_jsxs(ListItem, __assign({ sx: __assign({ bgcolor: 'rgb(196 184 184 / 20%)', borderBottom: '1px solid rgba(227, 232, 238, 1)' }, (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(CheckIcon, { isVerified: isActivityVerified(section) })) : (!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) {
276
+ e.stopPropagation();
277
+ var isOnlyOneItem = !division.activities || division.activities.length <= 1;
278
+ if (isOnlyOneItem)
279
+ onSelectItem(division);
280
+ else
281
+ handleOpenSubItem(division.id);
282
+ }, listItemProps: { sx: { padding: 0, '&:last-child': { paddingBottom: 0 } } }, renderItem: function (division, idx) {
283
+ var _a;
284
+ var isOnlyOneItem = !division.activities || ((_a = division.activities) === null || _a === void 0 ? void 0 : _a.length) <= 1;
285
+ var showCheck = division.id === getSelectedActivityDivisionFlag(division) && isOnlyOneItem;
286
+ return (_jsxs(ListItemContainer, { children: [_jsxs(ListItem, __assign({ sx: __assign({ bgcolor: 'rgb(196 184 184 / 6%)', borderBottom: '1px solid rgba(227, 232, 238, 0.6)' }, (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(CheckIcon, { isVerified: isActivityVerified(division) })) : (!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) {
287
+ e.stopPropagation();
288
+ onSelectItem(activity);
289
+ }, listItemProps: { sx: { padding: 0, '&:last-child': { paddingBottom: 0 } } }, renderItem: function (activity, idx) {
290
+ 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(CheckIcon, { isVerified: isActivityVerified(activity) })] })));
291
+ } }) }))] }, idx));
292
+ } }) }))] }));
293
+ } })] }))] }));
160
294
  };
161
- export default ActivitiesList;
295
+ export default ActivityList;