@bigbinary/neeto-team-members-frontend 5.0.64 → 5.0.65

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 (63) hide show
  1. package/dist/.ready +1 -1
  2. package/dist/Groups.js +1 -1
  3. package/dist/ManageMember.js +50 -991
  4. package/dist/ManageMember.js.map +1 -1
  5. package/dist/TeamMembers.js +172 -12
  6. package/dist/TeamMembers.js.map +1 -1
  7. package/dist/cjs/ManageMember.js +51 -1015
  8. package/dist/cjs/ManageMember.js.map +1 -1
  9. package/dist/cjs/TeamMembers.js +184 -23
  10. package/dist/cjs/TeamMembers.js.map +1 -1
  11. package/dist/cjs/index.js +2 -4
  12. package/dist/cjs/index.js.map +1 -1
  13. package/dist/cjs/v2/ManageMember.js +43 -1048
  14. package/dist/cjs/v2/ManageMember.js.map +1 -1
  15. package/dist/cjs/v2/TeamMembers.js +21 -27
  16. package/dist/cjs/v2/TeamMembers.js.map +1 -1
  17. package/dist/cjs/v2/hooks.js +15 -185
  18. package/dist/cjs/v2/hooks.js.map +1 -1
  19. package/dist/cjs/v2/index.js +6 -12
  20. package/dist/cjs/v2/index.js.map +1 -1
  21. package/dist/constants-FEDmfINW.js +29 -0
  22. package/dist/constants-FEDmfINW.js.map +1 -0
  23. package/dist/constants-il7hAfM-.js +34 -0
  24. package/dist/constants-il7hAfM-.js.map +1 -0
  25. package/dist/hooks.js +1 -1
  26. package/dist/index-BV7WfESJ.js +1331 -0
  27. package/dist/index-BV7WfESJ.js.map +1 -0
  28. package/dist/index-CXQ1YglX.js +1287 -0
  29. package/dist/index-CXQ1YglX.js.map +1 -0
  30. package/dist/index-DDd97MZJ.js +1253 -0
  31. package/dist/index-DDd97MZJ.js.map +1 -0
  32. package/dist/index-DP1rSXzI.js +1272 -0
  33. package/dist/index-DP1rSXzI.js.map +1 -0
  34. package/dist/index.js +2 -4
  35. package/dist/index.js.map +1 -1
  36. package/dist/{useTeams-C9N2TJY-.js → useTeams-DDkhfivj.js} +81 -13
  37. package/dist/useTeams-DDkhfivj.js.map +1 -0
  38. package/dist/{useTeams-Bw4eltN1.js → useTeams-DpZbszj9.js} +73 -6
  39. package/dist/useTeams-DpZbszj9.js.map +1 -0
  40. package/dist/{useTeamsApi-DkgWqw-g.js → useTeamsApi-CGY9oJqn.js} +2 -2
  41. package/dist/{useTeamsApi-DkgWqw-g.js.map → useTeamsApi-CGY9oJqn.js.map} +1 -1
  42. package/dist/utils.js +1 -1
  43. package/dist/v2/Groups.js +1 -1
  44. package/dist/v2/ManageMember.js +42 -1041
  45. package/dist/v2/ManageMember.js.map +1 -1
  46. package/dist/v2/TeamMembers.js +6 -12
  47. package/dist/v2/TeamMembers.js.map +1 -1
  48. package/dist/v2/hooks.js +14 -183
  49. package/dist/v2/hooks.js.map +1 -1
  50. package/dist/v2/index.js +6 -12
  51. package/dist/v2/index.js.map +1 -1
  52. package/dist/v2/utils.js +1 -1
  53. package/package.json +1 -1
  54. package/dist/useTeams-Bw4eltN1.js.map +0 -1
  55. package/dist/useTeams-C9N2TJY-.js.map +0 -1
  56. package/dist/utils-3WlshQ9e.js +0 -312
  57. package/dist/utils-3WlshQ9e.js.map +0 -1
  58. package/dist/utils-BFRNzhia.js +0 -318
  59. package/dist/utils-BFRNzhia.js.map +0 -1
  60. package/dist/utils-CgwJI9pk.js +0 -334
  61. package/dist/utils-CgwJI9pk.js.map +0 -1
  62. package/dist/utils-DEOuQRcK.js +0 -300
  63. package/dist/utils-DEOuQRcK.js.map +0 -1
@@ -1,1005 +1,64 @@
1
- import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
2
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
- import _regeneratorRuntime from '@babel/runtime/regenerator';
5
- import { useState, useEffect, useRef } from 'react';
6
- import classnames from 'classnames';
7
- import { globalProps, taxonomies } from '@bigbinary/neeto-commons-frontend/initializers';
8
- import { showThumbsUpToastr } from '@bigbinary/neeto-commons-frontend/utils';
9
- import Info from '@bigbinary/neeto-icons/Info';
10
- import LeftArrow from '@bigbinary/neeto-icons/LeftArrow';
11
- import { useProfileImageUpload } from '@bigbinary/neeto-image-uploader-frontend/hooks';
12
- import Button from '@bigbinary/neetoui/Button';
13
- import Typography from '@bigbinary/neetoui/Typography';
14
- import Toastr from '@bigbinary/neetoui/Toastr';
15
- import Callout from '@bigbinary/neetoui/Callout';
16
- import Spinner from '@bigbinary/neetoui/Spinner';
17
- import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
18
- import Form from '@bigbinary/neetoui/formik/Form';
19
- import { pluck, not, isEmpty, head, reverse, groupBy, prop } from 'ramda';
20
- import { useTranslation, Trans } from 'react-i18next';
21
- import { S as ScrollToErrorField } from './index-BISwUwuE.js';
22
- import { u as useCountries, a as ProfileImage } from './ProfileImage-OoIOAGCe.js';
23
- import { u as useFetchRoles, a as useFetchGlobalRoles } from './useRolesApi-93OoRU1s.js';
24
- import { u as useFetchMembers, c as useFetchMember, d as useCreateMember, e as useMembersCreationStatus, r as refetchMembers, f as useUpdateMember } from './useTeamsApi-DkgWqw-g.js';
25
- import { n } from './inject-css-C2dztUxs.js';
26
- import { useFormikContext } from 'formik';
27
- import { toLabelAndValue, filterBy, findBy } from '@bigbinary/neeto-cist';
28
- import Checkbox from '@bigbinary/neetoui/Checkbox';
29
- import Tooltip from '@bigbinary/neetoui/Tooltip';
30
- import Select from '@bigbinary/neetoui/formik/Select';
31
- import Switch from '@bigbinary/neetoui/formik/Switch';
32
- import { N as NEETO_AUTH_MANAGE_PRODUCT_URL, g as getSingleInvitationTranslationProps, a as getInviteURL, r as remainingExpiryDays, F as FORM_PAGES, b as FILTER_INVALID_EMAILS, C as COUNTER_PROPS, E as EMAIL_REGEX, D as DEFAULT_COMPONENT_CONFIG, M as MEMBERS_FORM_COMPONENT_MAPPER, c as buildValidationSchema, d as renderInitialValues, e as renderPayload, R as RolesRadioGroup } from './RolesRadioGroup-BusIs5tc.js';
33
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
34
- import { SINGULAR, PLURAL, LANGUAGE_OPTIONS } from '@bigbinary/neeto-commons-frontend/constants';
35
- import { withT } from '@bigbinary/neeto-commons-frontend/react-utils';
36
- import MenuHorizontal from '@bigbinary/neeto-icons/MenuHorizontal';
37
- import CopyToClipboardButton from '@bigbinary/neeto-molecules/CopyToClipboardButton';
38
- import Dropdown from '@bigbinary/neetoui/Dropdown';
39
- import { u as useCreateInviteLinks, a as useRegenerateInviteLink, b as useFetchInviteLinks } from './useInviteLinksApi-gn-AP0Yx.js';
40
- import Label from '@bigbinary/neetoui/Label';
41
- import MultiEmailInput from '@bigbinary/neetoui/formik/MultiEmailInput';
42
- import Input from '@bigbinary/neetoui/formik/Input';
43
- import { isNeetoAuthApp } from './utils.js';
44
- import { NeetoTimezoneSelector } from '@bigbinary/neeto-time-zones';
45
- import { FormikPhoneNumberInput } from '@bigbinary/neeto-molecules/PhoneNumber';
46
- import { T as TIME_FORMAT_OPTIONS, D as DATE_FORMAT_OPTIONS } from './constants-CXdiW8NZ.js';
47
- import { g as getFilteredRoles } from './utils-3WlshQ9e.js';
1
+ import '@babel/runtime/helpers/asyncToGenerator';
2
+ import '@babel/runtime/helpers/defineProperty';
3
+ import '@babel/runtime/helpers/slicedToArray';
4
+ import '@babel/runtime/regenerator';
5
+ import 'react';
6
+ import 'classnames';
7
+ import '@bigbinary/neeto-commons-frontend/initializers';
8
+ import '@bigbinary/neeto-commons-frontend/utils';
9
+ import '@bigbinary/neeto-icons/Info';
10
+ import '@bigbinary/neeto-icons/LeftArrow';
11
+ import '@bigbinary/neeto-image-uploader-frontend/hooks';
12
+ import '@bigbinary/neetoui/Button';
13
+ import '@bigbinary/neetoui/Typography';
14
+ import '@bigbinary/neetoui/Toastr';
15
+ import '@bigbinary/neetoui/Callout';
16
+ import '@bigbinary/neetoui/Spinner';
17
+ import '@bigbinary/neetoui/formik/ActionBlock';
18
+ import '@bigbinary/neetoui/formik/Form';
19
+ import 'ramda';
20
+ import 'react-i18next';
21
+ import './index-BISwUwuE.js';
22
+ import './ProfileImage-OoIOAGCe.js';
23
+ import './useRolesApi-93OoRU1s.js';
24
+ import './useTeamsApi-CGY9oJqn.js';
25
+ export { M as default } from './index-CXQ1YglX.js';
26
+ import './RolesRadioGroup-BusIs5tc.js';
27
+ import 'react/jsx-runtime';
48
28
  import '@babel/runtime/helpers/toConsumableArray';
29
+ import 'formik';
30
+ import '@bigbinary/neeto-cist';
49
31
  import './useCountriesApi-DK00167T.js';
50
32
  import '@tanstack/react-query';
33
+ import '@bigbinary/neeto-commons-frontend/constants';
51
34
  import 'axios';
35
+ import './constants-CXdiW8NZ.js';
36
+ import 'i18next';
52
37
  import '@bigbinary/neeto-icons/Edit';
53
38
  import '@bigbinary/neetoui/Avatar';
54
- import 'i18next';
39
+ import '@bigbinary/neetoui/Dropdown';
40
+ import '@bigbinary/neeto-molecules/PhoneNumber';
55
41
  import 'yup';
56
42
  import '@babel/runtime/helpers/objectWithoutProperties';
43
+ import '@bigbinary/neeto-commons-frontend/react-utils';
57
44
  import 'qs';
58
45
  import './queryClient-Dsu-gu4Y.js';
46
+ import './inject-css-C2dztUxs.js';
47
+ import '@bigbinary/neetoui/Checkbox';
48
+ import '@bigbinary/neetoui/Tooltip';
49
+ import '@bigbinary/neetoui/formik/Select';
50
+ import '@bigbinary/neetoui/formik/Switch';
51
+ import '@bigbinary/neeto-icons/MenuHorizontal';
52
+ import '@bigbinary/neeto-molecules/CopyToClipboardButton';
53
+ import './useInviteLinksApi-gn-AP0Yx.js';
54
+ import '@bigbinary/neetoui/Label';
55
+ import '@bigbinary/neetoui/formik/MultiEmailInput';
56
+ import '@bigbinary/neetoui/formik/Input';
57
+ import './utils.js';
58
+ import './_commonjsHelpers-BFTU3MAI.js';
59
+ import '@bigbinary/neeto-time-zones';
60
+ import '@bigbinary/neeto-molecules/MoreDropdown';
59
61
  import '@bigbinary/neetoui/formik/Radio';
60
62
  import '@bigbinary/neetoui/Pane';
61
63
  import '@bigbinary/neetoui/Modal';
62
- import './_commonjsHelpers-BFTU3MAI.js';
63
- import '@bigbinary/neeto-molecules/MoreDropdown';
64
-
65
- var css = ".ntm-manage-members__header{align-items:flex-start;display:flex}.ntm-manage-members__header>*+*{margin-inline-start:.5rem}.ntm-product-roles-table th{color:rgb(var(--neeto-ui-gray-700));font-size:var(--neeto-ui-text-xs);font-weight:var(--neeto-ui-font-bold);text-transform:uppercase;vertical-align:middle}.ntm-product-roles-table td,.ntm-product-roles-table th{border:1px solid rgb(var(--neeto-ui-gray-200));padding:.5rem;text-align:start}.ntm-manage-members__app-roles{align-items:center;display:flex;justify-content:space-between;padding:.5rem 0;width:100%}.ntm-manage-members-app-roles__select-wrapper{max-width:250px;width:50%}.ntm-manage-members-effective-app-roles{align-items:center;display:flex;justify-content:space-between;padding:.25rem 0}.ntm-manage-members-effective-app-roles__role-name{max-width:300px;width:67%}.ntm-manage-members__checkbox-align-start.neeto-ui-checkbox__wrapper .neeto-ui-checkbox__container{align-items:flex-start}.ntm-manage-members__checkbox-align-start.neeto-ui-checkbox__wrapper .neeto-ui-checkbox[type=checkbox]{margin-top:.25rem}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3NyYy9zdHlsZXNoZWV0cy9jb21wb25lbnRzL21hbmFnZS1tZW1iZXJzLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSw0QkFFRSxzQkFBdUIsQ0FEdkIsWUFFRixDQUVBLGdDQUNFLHlCQUNGLENBRUEsNEJBQ0UsbUNBQW9DLENBQ3BDLGlDQUFrQyxDQUVsQyxxQ0FBc0MsQ0FDdEMsd0JBQXlCLENBRnpCLHFCQUdGLENBRUEsd0RBRUUsOENBQStDLENBRS9DLGFBQWUsQ0FEZixnQkFFRixDQUVBLCtCQUVFLGtCQUFtQixDQURuQixZQUFhLENBRWIsNkJBQThCLENBRTlCLGVBQWlCLENBRGpCLFVBRUYsQ0FFQSw4Q0FFRSxlQUFnQixDQURoQixTQUVGLENBRUEsd0NBRUUsa0JBQW1CLENBRG5CLFlBQWEsQ0FFYiw2QkFBOEIsQ0FDOUIsZ0JBQ0YsQ0FFQSxtREFFRSxlQUFnQixDQURoQixTQUVGLENBRUEsbUdBQ0Usc0JBQ0YsQ0FFQSx1R0FDRSxpQkFDRiIsInNvdXJjZXNDb250ZW50IjpbIi5udG0tbWFuYWdlLW1lbWJlcnNfX2hlYWRlciB7XG4gIGRpc3BsYXk6IGZsZXg7XG4gIGFsaWduLWl0ZW1zOiBmbGV4LXN0YXJ0O1xufVxuXG4ubnRtLW1hbmFnZS1tZW1iZXJzX19oZWFkZXIgPiAqICsgKiB7XG4gIG1hcmdpbi1pbmxpbmUtc3RhcnQ6IDAuNXJlbTtcbn1cblxuLm50bS1wcm9kdWN0LXJvbGVzLXRhYmxlIHRoIHtcbiAgY29sb3I6IHJnYih2YXIoLS1uZWV0by11aS1ncmF5LTcwMCkpO1xuICBmb250LXNpemU6IHZhcigtLW5lZXRvLXVpLXRleHQteHMpO1xuICB2ZXJ0aWNhbC1hbGlnbjogbWlkZGxlO1xuICBmb250LXdlaWdodDogdmFyKC0tbmVldG8tdWktZm9udC1ib2xkKTtcbiAgdGV4dC10cmFuc2Zvcm06IHVwcGVyY2FzZTtcbn1cblxuLm50bS1wcm9kdWN0LXJvbGVzLXRhYmxlIHRkLFxuLm50bS1wcm9kdWN0LXJvbGVzLXRhYmxlIHRoIHtcbiAgYm9yZGVyOiAxcHggc29saWQgcmdiKHZhcigtLW5lZXRvLXVpLWdyYXktMjAwKSk7XG4gIHRleHQtYWxpZ246IHN0YXJ0O1xuICBwYWRkaW5nOiAwLjVyZW07XG59XG5cbi5udG0tbWFuYWdlLW1lbWJlcnNfX2FwcC1yb2xlcyB7XG4gIGRpc3BsYXk6IGZsZXg7XG4gIGFsaWduLWl0ZW1zOiBjZW50ZXI7XG4gIGp1c3RpZnktY29udGVudDogc3BhY2UtYmV0d2VlbjtcbiAgd2lkdGg6IDEwMCU7XG4gIHBhZGRpbmc6IDAuNXJlbSAwO1xufVxuXG4ubnRtLW1hbmFnZS1tZW1iZXJzLWFwcC1yb2xlc19fc2VsZWN0LXdyYXBwZXIge1xuICB3aWR0aDogNTAlO1xuICBtYXgtd2lkdGg6IDI1MHB4O1xufVxuXG4ubnRtLW1hbmFnZS1tZW1iZXJzLWVmZmVjdGl2ZS1hcHAtcm9sZXMge1xuICBkaXNwbGF5OiBmbGV4O1xuICBhbGlnbi1pdGVtczogY2VudGVyO1xuICBqdXN0aWZ5LWNvbnRlbnQ6IHNwYWNlLWJldHdlZW47XG4gIHBhZGRpbmc6IDAuMjVyZW0gMDtcbn1cblxuLm50bS1tYW5hZ2UtbWVtYmVycy1lZmZlY3RpdmUtYXBwLXJvbGVzX19yb2xlLW5hbWUge1xuICB3aWR0aDogNjclO1xuICBtYXgtd2lkdGg6IDMwMHB4O1xufVxuXG4ubnRtLW1hbmFnZS1tZW1iZXJzX19jaGVja2JveC1hbGlnbi1zdGFydC5uZWV0by11aS1jaGVja2JveF9fd3JhcHBlciAubmVldG8tdWktY2hlY2tib3hfX2NvbnRhaW5lciB7XG4gIGFsaWduLWl0ZW1zOiBmbGV4LXN0YXJ0O1xufVxuXG4ubnRtLW1hbmFnZS1tZW1iZXJzX19jaGVja2JveC1hbGlnbi1zdGFydC5uZWV0by11aS1jaGVja2JveF9fd3JhcHBlciAubmVldG8tdWktY2hlY2tib3hbdHlwZT1cImNoZWNrYm94XCJdIHtcbiAgbWFyZ2luLXRvcDogMC4yNXJlbTtcbn1cbiJdfQ== */";
66
- n(css,{});
67
-
68
- var AppList = function AppList(_ref) {
69
- var _globalProps$user;
70
- var globalRoles = _ref.globalRoles,
71
- savedStateRef = _ref.savedStateRef;
72
- var _useTranslation = useTranslation(),
73
- t = _useTranslation.t;
74
- var _useState = useState(savedStateRef.current.isAppListEnabled),
75
- _useState2 = _slicedToArray(_useState, 2),
76
- isAppListEnabled = _useState2[0],
77
- setIsAppListEnabled = _useState2[1];
78
- var _useFormikContext = useFormikContext(),
79
- _useFormikContext$val = _useFormikContext.values,
80
- _useFormikContext$val2 = _useFormikContext$val.emails,
81
- emails = _useFormikContext$val2 === void 0 ? [] : _useFormikContext$val2,
82
- _useFormikContext$val3 = _useFormikContext$val.appRoles,
83
- appRoles = _useFormikContext$val3 === void 0 ? [] : _useFormikContext$val3,
84
- setFieldValue = _useFormikContext.setFieldValue;
85
- var selectedEmail = pluck("value", emails);
86
- var isManageProductsLinkEnabled = ((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.isOwner) && Object.keys(globalRoles).length >= 3;
87
- useEffect(function () {
88
- if (savedStateRef.current.isAppListEnabled !== isAppListEnabled) {
89
- appRoles === null || appRoles === void 0 || appRoles.forEach(function (appRole, index) {
90
- var _globalProps$appName;
91
- if ((appRole === null || appRole === void 0 ? void 0 : appRole.appName) === ((_globalProps$appName = globalProps.appName) === null || _globalProps$appName === void 0 ? void 0 : _globalProps$appName.substring(5))) {
92
- setFieldValue("appRoles[".concat(index, "].isEnabled"), true);
93
- return;
94
- }
95
- setFieldValue("appRoles[".concat(index, "].isEnabled"), isAppListEnabled);
96
- });
97
- }
98
- savedStateRef.current.isAppListEnabled = isAppListEnabled;
99
- }, [isAppListEnabled]); // eslint-disable-line react-hooks/exhaustive-deps
100
-
101
- var buildRoleOptions = function buildRoleOptions(roles) {
102
- return roles.map(function (role) {
103
- return toLabelAndValue(role.name);
104
- });
105
- };
106
- return /*#__PURE__*/jsxs("div", {
107
- className: "neeto-ui-flex neeto-ui-flex-col neeto-ui-gap-6",
108
- children: [/*#__PURE__*/jsxs("div", {
109
- className: "neeto-ui-w-full space-y-3",
110
- children: [/*#__PURE__*/jsx(Checkbox, {
111
- checked: isAppListEnabled,
112
- className: "ntm-manage-members__checkbox-align-start",
113
- "data-testid": "ntm-manage-members-app-list-checkbox",
114
- label: /*#__PURE__*/jsx(Typography, {
115
- component: "span",
116
- lineHeight: "relaxed",
117
- style: "body2",
118
- children: /*#__PURE__*/jsx(Trans, {
119
- i18nKey: "neetoTeamMembers.helpers.addMembersToNeetoProducts",
120
- values: {
121
- emails: selectedEmail
122
- }
123
- })
124
- }),
125
- onChange: function onChange() {
126
- return setIsAppListEnabled(not);
127
- }
128
- }), isManageProductsLinkEnabled && /*#__PURE__*/jsx(Typography, {
129
- style: "body2",
130
- children: /*#__PURE__*/jsx(Trans, {
131
- i18nKey: "neetoTeamMembers.helpers.manageProducts",
132
- components: {
133
- button: /*#__PURE__*/jsx(Button, {
134
- href: NEETO_AUTH_MANAGE_PRODUCT_URL,
135
- style: "link"
136
- })
137
- }
138
- })
139
- })]
140
- }), /*#__PURE__*/jsx("div", {
141
- className: "neeto-ui-w-full",
142
- children: appRoles.map(function (_ref2, index) {
143
- var _globalProps$appName2;
144
- var appName = _ref2.appName,
145
- isEnabled = _ref2.isEnabled;
146
- var isCurrentApp = appName === ((_globalProps$appName2 = globalProps.appName) === null || _globalProps$appName2 === void 0 ? void 0 : _globalProps$appName2.substring(5));
147
- var isAppRoleSelectionChecked = isCurrentApp || isEnabled;
148
- return /*#__PURE__*/jsxs("div", {
149
- className: "ntm-manage-members__app-roles",
150
- children: [/*#__PURE__*/jsx(Tooltip, {
151
- content: t("neetoTeamMembers.tooltips.hostAppIsRequired"),
152
- disabled: !isCurrentApp,
153
- position: "left",
154
- children: /*#__PURE__*/jsx("span", {
155
- children: /*#__PURE__*/jsx(Switch, {
156
- checked: isAppRoleSelectionChecked,
157
- disabled: isCurrentApp,
158
- name: "appsRoles[".concat(index, "].isEnabled"),
159
- label: t("neetoTeamMembers.labels.neeto_", {
160
- product: appName
161
- }),
162
- onChange: function onChange(_ref3) {
163
- var target = _ref3.target;
164
- setFieldValue("appRoles[".concat(index, "].isEnabled"), target.checked);
165
- }
166
- })
167
- })
168
- }), /*#__PURE__*/jsx(Tooltip, {
169
- content: t("neetoTeamMembers.tooltips.goBackToChangeRole"),
170
- disabled: !isCurrentApp,
171
- position: "top",
172
- children: /*#__PURE__*/jsx("span", {
173
- className: "ntm-manage-members-app-roles__select-wrapper",
174
- children: /*#__PURE__*/jsx(Select, {
175
- dataTestid: "ntm-manage-members-app-roles",
176
- isDisabled: isCurrentApp || !isEnabled,
177
- name: "appRoles[".concat(index, "].activeRole"),
178
- options: buildRoleOptions(globalRoles[appName]),
179
- size: "small",
180
- strategy: "fixed",
181
- onChange: function onChange(_ref4) {
182
- var value = _ref4.value;
183
- setFieldValue("appRoles[".concat(index, "].activeRole"), value);
184
- }
185
- })
186
- })
187
- })]
188
- }, appName);
189
- })
190
- })]
191
- });
192
- };
193
-
194
- var Confirmation = function Confirmation() {
195
- var _globalProps$organiza;
196
- var _useTranslation = useTranslation(),
197
- t = _useTranslation.t;
198
- var _useFormikContext = useFormikContext(),
199
- _useFormikContext$val = _useFormikContext.values,
200
- emails = _useFormikContext$val.emails,
201
- role = _useFormikContext$val.role,
202
- appRoles = _useFormikContext$val.appRoles;
203
- var selectedEmail = pluck("value", emails);
204
- var activeAppRoles = filterBy({
205
- isEnabled: true
206
- }, appRoles);
207
- return activeAppRoles.length > 1 ? /*#__PURE__*/jsxs("div", {
208
- className: "neeto-ui-flex neeto-ui-flex-col neeto-ui-gap-6",
209
- children: [/*#__PURE__*/jsx("div", {
210
- className: "neeto-ui-w-full",
211
- children: /*#__PURE__*/jsx(Typography, {
212
- component: "span",
213
- lineHeight: "relaxed",
214
- style: "body2",
215
- children: /*#__PURE__*/jsx(Trans, {
216
- i18nKey: "neetoTeamMembers.helpers.multipleProductInvitation",
217
- values: {
218
- count: selectedEmail.length,
219
- emails: selectedEmail,
220
- orgName: (_globalProps$organiza = globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.name
221
- }
222
- })
223
- })
224
- }), /*#__PURE__*/jsxs("table", {
225
- className: "neeto-ui-w-full ntm-product-roles-table",
226
- children: [/*#__PURE__*/jsx("thead", {
227
- children: /*#__PURE__*/jsxs("tr", {
228
- children: [/*#__PURE__*/jsx("th", {
229
- children: t("neetoTeamMembers.common.productName")
230
- }), /*#__PURE__*/jsx("th", {
231
- children: t("neetoTeamMembers.common.role", SINGULAR)
232
- })]
233
- })
234
- }), /*#__PURE__*/jsx("tbody", {
235
- children: activeAppRoles.map(function (_ref) {
236
- var appName = _ref.appName,
237
- activeRole = _ref.activeRole;
238
- return /*#__PURE__*/jsxs("tr", {
239
- children: [/*#__PURE__*/jsx("td", {
240
- children: /*#__PURE__*/jsx(Typography, {
241
- component: "span",
242
- lineHeight: "relaxed",
243
- style: "body2",
244
- children: t("neetoTeamMembers.labels.neeto_", {
245
- product: appName
246
- })
247
- })
248
- }), /*#__PURE__*/jsx("td", {
249
- children: /*#__PURE__*/jsx(Typography, {
250
- component: "span",
251
- lineHeight: "relaxed",
252
- style: "body2",
253
- children: activeRole
254
- })
255
- })]
256
- }, appName);
257
- })
258
- })]
259
- })]
260
- }) : /*#__PURE__*/jsx(Typography, {
261
- component: "span",
262
- lineHeight: "relaxed",
263
- style: "body2",
264
- children: /*#__PURE__*/jsx(Trans, {
265
- i18nKey: "neetoTeamMembers.helpers.singleProductInvitation",
266
- values: getSingleInvitationTranslationProps({
267
- activeAppRoles: activeAppRoles,
268
- role: role,
269
- selectedEmail: selectedEmail
270
- })
271
- })
272
- });
273
- };
274
-
275
- var Menu = Dropdown.Menu,
276
- MenuItem = Dropdown.MenuItem;
277
- var MenuItemButton = MenuItem.Button;
278
- var InviteLink$1 = function InviteLink(_ref) {
279
- var _inviteLinks$, _inviteLinks$2, _inviteLinks$3, _inviteLinks$4, _inviteLinks$5, _inviteLinks$6;
280
- var t = _ref.t,
281
- roles = _ref.roles;
282
- var _useCreateInviteLinks = useCreateInviteLinks(),
283
- createInviteLink = _useCreateInviteLinks.mutate,
284
- isCreateLinkPending = _useCreateInviteLinks.isPending;
285
- var _useRegenerateInviteL = useRegenerateInviteLink(),
286
- regenerateLink = _useRegenerateInviteL.mutate;
287
- var _useFetchInviteLinks = useFetchInviteLinks(),
288
- _useFetchInviteLinks$ = _useFetchInviteLinks.data,
289
- _useFetchInviteLinks$2 = _useFetchInviteLinks$ === void 0 ? {} : _useFetchInviteLinks$,
290
- _useFetchInviteLinks$3 = _useFetchInviteLinks$2.inviteLinks,
291
- inviteLinks = _useFetchInviteLinks$3 === void 0 ? [] : _useFetchInviteLinks$3,
292
- isFetchLinkLoading = _useFetchInviteLinks.isLoading;
293
- var _useFormikContext = useFormikContext(),
294
- values = _useFormikContext.values;
295
- var isInviteLinkEmpty = !isFetchLinkLoading && isEmpty(inviteLinks);
296
- var handleRegenerate = function handleRegenerate() {
297
- var _findBy = findBy({
298
- name: values.role
299
- }, roles),
300
- roleId = _findBy.id;
301
- if (isEmpty(inviteLinks)) {
302
- createInviteLink({
303
- organizationRoleId: roleId
304
- });
305
- return;
306
- }
307
- regenerateLink({
308
- inviteLinkId: inviteLinks[0].id,
309
- payload: {
310
- organizationRoleId: roleId
311
- }
312
- });
313
- };
314
- if (isFetchLinkLoading || isCreateLinkPending) {
315
- return /*#__PURE__*/jsx("div", {
316
- className: "neeto-ui-w-full flex justify-center items-center",
317
- children: /*#__PURE__*/jsx(Spinner, {
318
- size: "large"
319
- })
320
- });
321
- }
322
- return /*#__PURE__*/jsxs("div", {
323
- className: "neeto-ui-w-full space-y-2",
324
- children: [/*#__PURE__*/jsxs("div", {
325
- className: "flex items-center gap-2 pt-1",
326
- children: [/*#__PURE__*/jsxs("div", {
327
- className: "neeto-ui-rounded-md neeto-ui-border-gray-300 neeto-ui-bg-gray-50 relative flex min-w-0 grow items-center truncate border leading-none",
328
- children: [/*#__PURE__*/jsx("div", {
329
- className: "relative min-w-0 grow truncate p-2 leading-none",
330
- children: !isInviteLinkEmpty && getInviteURL(inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$ = inviteLinks[0]) === null || _inviteLinks$ === void 0 ? void 0 : _inviteLinks$.token)
331
- }), isInviteLinkEmpty ? /*#__PURE__*/jsx(Button, {
332
- className: "rounded-ss-none rounded-es-none",
333
- label: t("neetoTeamMembers.buttons.generateLink"),
334
- onClick: handleRegenerate
335
- }) : /*#__PURE__*/jsx(CopyToClipboardButton, {
336
- className: "rounded-ss-none rounded-es-none",
337
- label: t("neetoTeamMembers.buttons.copyLink"),
338
- value: getInviteURL(inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$2 = inviteLinks[0]) === null || _inviteLinks$2 === void 0 ? void 0 : _inviteLinks$2.token)
339
- })]
340
- }), !isInviteLinkEmpty && /*#__PURE__*/jsx(Dropdown, {
341
- buttonProps: {
342
- className: "shrink-0"
343
- },
344
- buttonStyle: "text",
345
- icon: MenuHorizontal,
346
- children: /*#__PURE__*/jsx(Menu, {
347
- children: /*#__PURE__*/jsx(MenuItem, {
348
- children: /*#__PURE__*/jsx(MenuItemButton, {
349
- onClick: handleRegenerate,
350
- children: t("neetoTeamMembers.buttons.regenerateLink")
351
- })
352
- })
353
- })
354
- })]
355
- }), /*#__PURE__*/jsx("div", {
356
- children: !isInviteLinkEmpty && /*#__PURE__*/jsx(Typography, {
357
- className: "leading-relaxed neeto-ui-text-gray-500",
358
- style: "body3",
359
- children: /*#__PURE__*/jsx(Trans, {
360
- components: {
361
- strong: /*#__PURE__*/jsx("strong", {})
362
- },
363
- i18nKey: "neetoTeamMembers.alerts.messages.inviteLink",
364
- values: {
365
- expiryDays: remainingExpiryDays(inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$3 = inviteLinks[0]) === null || _inviteLinks$3 === void 0 ? void 0 : _inviteLinks$3.expiresAt),
366
- role: inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$4 = inviteLinks[0]) === null || _inviteLinks$4 === void 0 || (_inviteLinks$4 = _inviteLinks$4.organizationRole) === null || _inviteLinks$4 === void 0 ? void 0 : _inviteLinks$4.name,
367
- inviteLimit: inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$5 = inviteLinks[0]) === null || _inviteLinks$5 === void 0 ? void 0 : _inviteLinks$5.inviteLimit,
368
- appName: globalProps.appName,
369
- emailDomain: inviteLinks === null || inviteLinks === void 0 || (_inviteLinks$6 = inviteLinks[0]) === null || _inviteLinks$6 === void 0 ? void 0 : _inviteLinks$6.domain
370
- }
371
- })
372
- })
373
- })]
374
- });
375
- };
376
- var InviteLink = withT(InviteLink$1);
377
-
378
- var MultipleEmailInput = function MultipleEmailInput(_ref) {
379
- var _head;
380
- var _ref$emails = _ref.emails,
381
- emails = _ref$emails === void 0 ? [] : _ref$emails,
382
- innerRef = _ref.innerRef,
383
- _ref$selectedMember = _ref.selectedMember,
384
- selectedMember = _ref$selectedMember === void 0 ? null : _ref$selectedMember,
385
- setCurrentPage = _ref.setCurrentPage;
386
- var isInviteLinkFeatureEnabled = !isNeetoAuthApp();
387
- var _useTranslation = useTranslation(),
388
- t = _useTranslation.t;
389
- var _useFormikContext = useFormikContext(),
390
- setFieldValue = _useFormikContext.setFieldValue;
391
- var handleInputChange = function handleInputChange(event) {
392
- var email = event.target.value;
393
- var emailList = [{
394
- label: email,
395
- value: email,
396
- valid: EMAIL_REGEX.test(email)
397
- }];
398
- setFieldValue("emails", emailList);
399
- };
400
- return /*#__PURE__*/jsx("div", {
401
- className: "neeto-ui-w-full",
402
- children: selectedMember ? /*#__PURE__*/jsx(Input, {
403
- "data-testid": "ntm-manage-member-email-input",
404
- name: "emails",
405
- size: "medium",
406
- type: "email",
407
- value: (_head = head(emails)) === null || _head === void 0 ? void 0 : _head.value,
408
- label: /*#__PURE__*/jsx("span", {
409
- className: "neeto-ui-w-full neeto-ui-flex neeto-ui-justify-between",
410
- children: /*#__PURE__*/jsx(Typography, {
411
- component: "span",
412
- style: "body2",
413
- children: t("neetoTeamMembers.common.email", SINGULAR)
414
- })
415
- }),
416
- onChange: handleInputChange
417
- }) : /*#__PURE__*/jsxs("div", {
418
- children: [/*#__PURE__*/jsxs("div", {
419
- className: "flex items-center justify-between pb-2",
420
- children: [/*#__PURE__*/jsx(Label, {
421
- required: true,
422
- children: t("neetoTeamMembers.common.email", PLURAL)
423
- }), isInviteLinkFeatureEnabled && /*#__PURE__*/jsx(Button, {
424
- label: t("neetoTeamMembers.buttons.inviteLink"),
425
- style: "link",
426
- onClick: function onClick() {
427
- return setCurrentPage(FORM_PAGES.INVITE_LINK);
428
- }
429
- })]
430
- }), /*#__PURE__*/jsx(MultiEmailInput, {
431
- required: true,
432
- counter: COUNTER_PROPS,
433
- "data-testid": "ntm-manage-member-email-input",
434
- filterInvalidEmails: FILTER_INVALID_EMAILS,
435
- helpText: t("neetoTeamMembers.helpers.enterMultipleEmails"),
436
- label: "",
437
- name: "emails",
438
- placeholder: t("neetoTeamMembers.placeholders.email"),
439
- ref: innerRef
440
- })]
441
- })
442
- });
443
- };
444
-
445
- var NameInputs = withT(function (_ref) {
446
- var t = _ref.t,
447
- innerRef = _ref.innerRef;
448
- return /*#__PURE__*/jsxs("div", {
449
- className: "neeto-ui-flex neeto-ui-w-full neeto-ui-gap-4 pt-4 border-t mt-0 neeto-ui-border-gray-200",
450
- children: [/*#__PURE__*/jsx(Input, {
451
- "data-testid": "ntm-edit-member-first-name-text-field",
452
- label: t("neetoTeamMembers.labels.firstName"),
453
- name: "firstName",
454
- ref: innerRef
455
- }), /*#__PURE__*/jsx(Input, {
456
- "data-testid": "ntm-edit-member-last-name-text-field",
457
- label: t("neetoTeamMembers.labels.lastName"),
458
- name: "lastName"
459
- })]
460
- });
461
- });
462
-
463
- var ProfileSettings = function ProfileSettings(_ref) {
464
- var member = _ref.member,
465
- setFieldValue = _ref.setFieldValue;
466
- var _useTranslation = useTranslation(),
467
- t = _useTranslation.t;
468
- var setFieldValueRef = useRef(setFieldValue);
469
- useEffect(function () {
470
- setFieldValueRef.current = setFieldValue;
471
- }, [setFieldValue]);
472
- var _useCountries = useCountries(),
473
- countryDropdownOptions = _useCountries.countryDropdownOptions,
474
- selectedCountryOption = _useCountries.selectedCountryOption,
475
- isFetchingCountriesList = _useCountries.isFetchingCountriesList,
476
- handleCountryChange = _useCountries.handleCountryChange;
477
- var timezoneContainerRef = useRef(null);
478
- useEffect(function () {
479
- var node = timezoneContainerRef.current;
480
- if (!node) return undefined;
481
- new NeetoTimezoneSelector(node, {
482
- isTimeFormat24H: member.timeFormat === "24h",
483
- className: "w-full z-10",
484
- position: "bottom",
485
- initialValue: member.timeZone,
486
- onChange: function onChange(_ref2) {
487
- var main = _ref2.main;
488
- return setFieldValueRef.current("timeZone", main);
489
- }
490
- });
491
- return function () {
492
- node.innerHTML = "";
493
- };
494
- }, [member.timeZone, member.timeFormat]);
495
- useEffect(function () {
496
- var country = findBy({
497
- value: member.countryIdentifier
498
- }, countryDropdownOptions);
499
- if (country) handleCountryChange(country);
500
- }, [member.countryIdentifier, countryDropdownOptions, handleCountryChange]);
501
- return /*#__PURE__*/jsxs("div", {
502
- className: "w-full space-y-4",
503
- "data-cy": "ntm-profile-settings",
504
- children: [/*#__PURE__*/jsx(FormikPhoneNumberInput, {
505
- "data-cy": "ntm-edit-member-phonenumber-field",
506
- label: t("neetoTeamMembers.profile.inputs.label.phonenumber"),
507
- name: "phonenumber"
508
- }), /*#__PURE__*/jsx(Select, {
509
- "data-cy": "ntm-edit-member-country-select",
510
- isLoading: isFetchingCountriesList,
511
- label: t("neetoTeamMembers.profile.inputs.label.country"),
512
- name: "countryId",
513
- options: countryDropdownOptions,
514
- value: selectedCountryOption,
515
- onChange: function onChange(option) {
516
- var dependentFields = handleCountryChange(option);
517
- setFieldValue("dateFormat", dependentFields === null || dependentFields === void 0 ? void 0 : dependentFields.dateFormat);
518
- setFieldValue("countryId", option === null || option === void 0 ? void 0 : option.value);
519
- }
520
- }), /*#__PURE__*/jsx(Select, {
521
- "data-cy": "ntm-edit-member-language-select",
522
- label: t("neetoTeamMembers.profile.inputs.label.language"),
523
- name: "language",
524
- options: LANGUAGE_OPTIONS,
525
- onChange: function onChange(option) {
526
- return setFieldValue("language", option.value);
527
- }
528
- }), /*#__PURE__*/jsxs("div", {
529
- className: "space-y-2",
530
- children: [/*#__PURE__*/jsx(Label, {
531
- children: t("neetoTeamMembers.profile.inputs.label.timeZone")
532
- }), /*#__PURE__*/jsx("div", {
533
- className: "w-full grow",
534
- "data-cy": "ntm-edit-member-timezone-select",
535
- ref: timezoneContainerRef
536
- })]
537
- }), /*#__PURE__*/jsx(Select, {
538
- "data-cy": "ntm-edit-member-time-format-select",
539
- label: t("neetoTeamMembers.profile.inputs.label.preferredTimeFormat"),
540
- name: "timeFormat",
541
- options: TIME_FORMAT_OPTIONS,
542
- onChange: function onChange(option) {
543
- return setFieldValue("timeFormat", option.value);
544
- }
545
- }), /*#__PURE__*/jsx(Select, {
546
- "data-cy": "ntm-edit-member-date-format-select",
547
- label: t("neetoTeamMembers.profile.inputs.label.preferredDateFormat"),
548
- name: "dateFormat",
549
- options: DATE_FORMAT_OPTIONS,
550
- onChange: function onChange(option) {
551
- return setFieldValue("dateFormat", option.value);
552
- }
553
- })]
554
- });
555
- };
556
-
557
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
558
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
559
- var ManageMember = function ManageMember(_ref) {
560
- var _manageMemberComponen, _config$additionalFie2;
561
- var config = _ref.config,
562
- onComplete = _ref.onComplete,
563
- _ref$roles = _ref.roles,
564
- roles = _ref$roles === void 0 ? [] : _ref$roles,
565
- _ref$selectedMember = _ref.selectedMember,
566
- selectedMember = _ref$selectedMember === void 0 ? null : _ref$selectedMember,
567
- _ref$componentConfig = _ref.componentConfig,
568
- componentConfig = _ref$componentConfig === void 0 ? {} : _ref$componentConfig;
569
- var _useTranslation = useTranslation(),
570
- t = _useTranslation.t;
571
- var _useState = useState(false),
572
- _useState2 = _slicedToArray(_useState, 2),
573
- isCreationStatusPollingEnabled = _useState2[0],
574
- setIsCreationStatusPollingEnabled = _useState2[1];
575
- var isViewPermissionGranted = config.permissions.view;
576
- var isNotDevelopment = globalProps.railsEnv !== "development";
577
- var _useFetchMembers = useFetchMembers({
578
- enabled: isViewPermissionGranted
579
- }),
580
- team = _useFetchMembers.data;
581
- var isManageMemberOpen = !!componentConfig.isOpen;
582
- var _useFetchMember = useFetchMember(selectedMember === null || selectedMember === void 0 ? void 0 : selectedMember.id, {
583
- enabled: !!selectedMember && isManageMemberOpen
584
- }),
585
- memberShowData = _useFetchMember.data,
586
- isMemberDetailLoading = _useFetchMember.isLoading;
587
- var _useState3 = useState(FORM_PAGES.MAIN),
588
- _useState4 = _slicedToArray(_useState3, 2),
589
- currentPage = _useState4[0],
590
- setCurrentPage = _useState4[1];
591
- var formReference = useRef(null);
592
- var inputReference = useRef(null);
593
- var appListSavedStateReference = useRef({
594
- isAppListEnabled: true
595
- });
596
- var shouldSkipAppListPage = useRef(false);
597
- var formikValues = useRef(null);
598
- var manageMemberComponentConfig = _objectSpread(_objectSpread({}, DEFAULT_COMPONENT_CONFIG), {}, {
599
- initialFocusRef: inputReference
600
- }, componentConfig);
601
- var Component = MEMBERS_FORM_COMPONENT_MAPPER[manageMemberComponentConfig.type || "pane"];
602
- var haveToFetchRoles = isEmpty(roles) && isViewPermissionGranted;
603
- var isEditForm = !!selectedMember;
604
- var isLastPage = currentPage === FORM_PAGES.CONFIRMATION || isEditForm;
605
- var _useFetchRoles = useFetchRoles({
606
- select: function select(response) {
607
- var _response$organizatio;
608
- return reverse((_response$organizatio = response.organizationRoles) !== null && _response$organizatio !== void 0 ? _response$organizatio : []);
609
- },
610
- enabled: haveToFetchRoles
611
- }),
612
- _useFetchRoles$data = _useFetchRoles.data,
613
- rolesList = _useFetchRoles$data === void 0 ? roles : _useFetchRoles$data,
614
- isRolesLoading = _useFetchRoles.isLoading;
615
- var _useFetchGlobalRoles = useFetchGlobalRoles({
616
- select: function select(response) {
617
- return groupBy(prop("appName"), response !== null && response !== void 0 ? response : []);
618
- },
619
- enabled: isNotDevelopment && !selectedMember && isViewPermissionGranted
620
- }),
621
- _useFetchGlobalRoles$ = _useFetchGlobalRoles.data,
622
- globalRoles = _useFetchGlobalRoles$ === void 0 ? {} : _useFetchGlobalRoles$,
623
- isGlobalRolesLoading = _useFetchGlobalRoles.isLoading;
624
- var filteredRoles = getFilteredRoles(rolesList, config);
625
- var _useCreateMember = useCreateMember({
626
- onSuccess: function onSuccess() {
627
- return setIsCreationStatusPollingEnabled(true);
628
- }
629
- }),
630
- _useCreateMember$data = _useCreateMember.data,
631
- _useCreateMember$data2 = _useCreateMember$data === void 0 ? {} : _useCreateMember$data,
632
- jobId = _useCreateMember$data2.jobId,
633
- createMember = _useCreateMember.mutate,
634
- isCreatingMember = _useCreateMember.isPending;
635
- var refetchInterval = function refetchInterval(query) {
636
- var _ref2 = query.state.data || {},
637
- isCompleted = _ref2.isCompleted;
638
- if (isCompleted) {
639
- setIsCreationStatusPollingEnabled(false);
640
- return false;
641
- }
642
- return 2000;
643
- };
644
- var _useMembersCreationSt = useMembersCreationStatus(jobId, {
645
- refetchInterval: refetchInterval,
646
- enabled: isCreationStatusPollingEnabled
647
- }),
648
- creationStatus = _useMembersCreationSt.data;
649
- useEffect(function () {
650
- var _config$createMember;
651
- var _ref3 = creationStatus || {},
652
- isCompleted = _ref3.isCompleted,
653
- isSuccessful = _ref3.isSuccessful,
654
- users = _ref3.users,
655
- error = _ref3.error;
656
- if (!isCompleted) return;
657
- handleClose();
658
- config === null || config === void 0 || (_config$createMember = config.createMember) === null || _config$createMember === void 0 || (_config$createMember = _config$createMember.onSuccess) === null || _config$createMember === void 0 || _config$createMember.callback({
659
- users: users
660
- });
661
- if (isSuccessful) {
662
- showThumbsUpToastr();
663
- } else {
664
- Toastr.error(error);
665
- }
666
- refetchMembers();
667
- }, [creationStatus]);
668
- var _useUpdateMember = useUpdateMember({
669
- onSuccess: function onSuccess() {
670
- var _config$updateMember, _globalProps$user;
671
- handleClose(true);
672
- config === null || config === void 0 || (_config$updateMember = config.updateMember) === null || _config$updateMember === void 0 || (_config$updateMember = _config$updateMember.onSuccess) === null || _config$updateMember === void 0 || _config$updateMember.callback();
673
- if ((selectedMember === null || selectedMember === void 0 ? void 0 : selectedMember.id) === ((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.id)) {
674
- window.location.reload();
675
- }
676
- }
677
- }),
678
- updateMember = _useUpdateMember.mutate,
679
- isUpdatingMember = _useUpdateMember.isPending;
680
- var hasRoleChanged = function hasRoleChanged(_ref4) {
681
- var submitted = _ref4.submitted,
682
- values = _ref4.values;
683
- return submitted && (values === null || values === void 0 ? void 0 : values.role) !== (selectedMember === null || selectedMember === void 0 ? void 0 : selectedMember.role);
684
- };
685
- var handleClose = function handleClose() {
686
- var submitted = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
687
- onComplete({
688
- submitted: hasRoleChanged({
689
- submitted: submitted,
690
- values: formikValues.current
691
- })
692
- });
693
- setCurrentPage(FORM_PAGES.MAIN);
694
- appListSavedStateReference.current = {
695
- isAppListEnabled: true
696
- };
697
- setIsCreationStatusPollingEnabled(false);
698
- };
699
- var _useProfileImageUploa = useProfileImageUpload({
700
- uploadConfig: {
701
- folder: "Auth",
702
- customMetadata: {
703
- appName: "neetoAuth"
704
- }
705
- }
706
- }),
707
- uploadImage = _useProfileImageUploa.uploadImage,
708
- isUploading = _useProfileImageUploa.isUploading;
709
- var handleUploadImage = /*#__PURE__*/function () {
710
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
711
- var result, didUpload;
712
- return _regeneratorRuntime.wrap(function _callee$(_context) {
713
- while (1) switch (_context.prev = _context.next) {
714
- case 0:
715
- didUpload = false;
716
- _context.next = 3;
717
- return uploadImage(image, function (uploadedImageData) {
718
- didUpload = true;
719
- result = uploadedImageData;
720
- });
721
- case 3:
722
- if (didUpload) {
723
- _context.next = 5;
724
- break;
725
- }
726
- throw new Error(t("neetoTeamMembers.common.imageUploadFailed"));
727
- case 5:
728
- return _context.abrupt("return", result);
729
- case 6:
730
- case "end":
731
- return _context.stop();
732
- }
733
- }, _callee);
734
- }));
735
- return function handleUploadImage(_x) {
736
- return _ref5.apply(this, arguments);
737
- };
738
- }();
739
- var isProcessing = isCreatingMember || isUpdatingMember || isUploading || isRolesLoading || isGlobalRolesLoading || isMemberDetailLoading;
740
- var handleAddMember = /*#__PURE__*/function () {
741
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(values) {
742
- var _values$avatar, payload, _yield$handleUploadIm, fileId, filePath, url;
743
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
744
- while (1) switch (_context2.prev = _context2.next) {
745
- case 0:
746
- if (!selectedMember) {
747
- _context2.next = 25;
748
- break;
749
- }
750
- payload = renderPayload(values, selectedMember);
751
- if (!((_values$avatar = values.avatar) !== null && _values$avatar !== void 0 && _values$avatar.file)) {
752
- _context2.next = 22;
753
- break;
754
- }
755
- if (!payload.profile) payload.profile = {};
756
- if (!(values.avatar.file === "_destroy")) {
757
- _context2.next = 8;
758
- break;
759
- }
760
- payload.profile.avatar = {
761
- fileId: "_destroy",
762
- filePath: "",
763
- url: ""
764
- };
765
- _context2.next = 22;
766
- break;
767
- case 8:
768
- _context2.prev = 8;
769
- _context2.next = 11;
770
- return handleUploadImage(values.avatar.file);
771
- case 11:
772
- _yield$handleUploadIm = _context2.sent;
773
- fileId = _yield$handleUploadIm.fileId;
774
- filePath = _yield$handleUploadIm.filePath;
775
- url = _yield$handleUploadIm.url;
776
- payload.profile.avatar = {
777
- fileId: fileId,
778
- filePath: filePath,
779
- url: url
780
- };
781
- _context2.next = 22;
782
- break;
783
- case 18:
784
- _context2.prev = 18;
785
- _context2.t0 = _context2["catch"](8);
786
- Toastr.error(_context2.t0.message);
787
- return _context2.abrupt("return");
788
- case 22:
789
- updateMember({
790
- id: selectedMember.id,
791
- payload: payload
792
- });
793
- _context2.next = 26;
794
- break;
795
- case 25:
796
- createMember(renderPayload(values));
797
- case 26:
798
- case "end":
799
- return _context2.stop();
800
- }
801
- }, _callee2, null, [[8, 18]]);
802
- }));
803
- return function handleAddMember(_x2) {
804
- return _ref6.apply(this, arguments);
805
- };
806
- }();
807
- var handleOnSubmit = /*#__PURE__*/function () {
808
- var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(values, _ref7) {
809
- var setSubmitting;
810
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
811
- while (1) switch (_context3.prev = _context3.next) {
812
- case 0:
813
- setSubmitting = _ref7.setSubmitting;
814
- shouldSkipAppListPage.current = isEmpty(values.appRoles);
815
- if (!isLastPage) {
816
- _context3.next = 7;
817
- break;
818
- }
819
- _context3.next = 5;
820
- return handleAddMember(values);
821
- case 5:
822
- _context3.next = 8;
823
- break;
824
- case 7:
825
- if (currentPage === FORM_PAGES.APP_LIST || shouldSkipAppListPage.current) {
826
- setCurrentPage(FORM_PAGES.CONFIRMATION);
827
- setSubmitting(false);
828
- } else if (currentPage === FORM_PAGES.MAIN) {
829
- setCurrentPage(FORM_PAGES.APP_LIST);
830
- setSubmitting(false);
831
- }
832
- case 8:
833
- case "end":
834
- return _context3.stop();
835
- }
836
- }, _callee3);
837
- }));
838
- return function handleOnSubmit(_x3, _x4) {
839
- return _ref8.apply(this, arguments);
840
- };
841
- }();
842
- var handleBackButton = function handleBackButton() {
843
- if (currentPage === FORM_PAGES.APP_LIST || shouldSkipAppListPage.current || currentPage === FORM_PAGES.INVITE_LINK) {
844
- setCurrentPage(FORM_PAGES.MAIN);
845
- } else if (currentPage === FORM_PAGES.CONFIRMATION) {
846
- setCurrentPage(FORM_PAGES.APP_LIST);
847
- }
848
- };
849
- var getTitle = function getTitle() {
850
- var memberLabel = taxonomies.member.singular;
851
- if (selectedMember) {
852
- return t("neetoTeamMembers.common.edit_", {
853
- what: memberLabel
854
- });
855
- }
856
- return currentPage === FORM_PAGES.INVITE_LINK ? t("neetoTeamMembers.common.inviteViaLink") : t("neetoTeamMembers.common.addNew_", {
857
- what: memberLabel
858
- });
859
- };
860
- var renderRolesRadioGroup = function renderRolesRadioGroup(role) {
861
- return /*#__PURE__*/jsx("div", {
862
- className: "pt-4 border-t neeto-ui-border-gray-200 w-full",
863
- children: /*#__PURE__*/jsx(RolesRadioGroup, {
864
- config: config,
865
- globalRoles: globalRoles,
866
- role: role,
867
- isEdit: !!selectedMember,
868
- roles: filteredRoles
869
- })
870
- });
871
- };
872
- var renderFormPage = function renderFormPage(page, emails, role, setFieldValue) {
873
- var _memberShowData$membe, _memberShowData$membe2, _config$additionalFie;
874
- switch (page) {
875
- case FORM_PAGES.MAIN:
876
- return /*#__PURE__*/jsxs(Fragment, {
877
- children: [selectedMember && /*#__PURE__*/jsx(ProfileImage, {}), selectedMember && /*#__PURE__*/jsx(NameInputs, {
878
- innerRef: inputReference
879
- }), /*#__PURE__*/jsx(MultipleEmailInput, {
880
- emails: emails,
881
- selectedMember: selectedMember,
882
- setCurrentPage: setCurrentPage,
883
- innerRef: inputReference
884
- }), selectedMember && /*#__PURE__*/jsx(ProfileSettings, {
885
- setFieldValue: setFieldValue,
886
- member: _objectSpread(_objectSpread({}, selectedMember), {}, {
887
- countryIdentifier: (_memberShowData$membe = memberShowData === null || memberShowData === void 0 || (_memberShowData$membe2 = memberShowData.member) === null || _memberShowData$membe2 === void 0 ? void 0 : _memberShowData$membe2.countryIdentifier) !== null && _memberShowData$membe !== void 0 ? _memberShowData$membe : selectedMember.countryIdentifier
888
- })
889
- }), renderRolesRadioGroup(role), (_config$additionalFie = config.additionalFields) === null || _config$additionalFie === void 0 ? void 0 : _config$additionalFie.component]
890
- });
891
- case FORM_PAGES.APP_LIST:
892
- return /*#__PURE__*/jsx(AppList, {
893
- globalRoles: globalRoles,
894
- savedStateRef: appListSavedStateReference
895
- });
896
- case FORM_PAGES.CONFIRMATION:
897
- return /*#__PURE__*/jsx(Confirmation, {});
898
- case FORM_PAGES.INVITE_LINK:
899
- return /*#__PURE__*/jsxs(Fragment, {
900
- children: [/*#__PURE__*/jsx(InviteLink, {
901
- roles: filteredRoles
902
- }), renderRolesRadioGroup(role)]
903
- });
904
- default:
905
- return null;
906
- }
907
- };
908
- return /*#__PURE__*/jsxs(Component, {
909
- className: manageMemberComponentConfig.className,
910
- "data-testid": "ntm-manage-members-pane-wrapper",
911
- initialFocusRef: manageMemberComponentConfig.initialFocusRef,
912
- isOpen: manageMemberComponentConfig.isOpen,
913
- onClose: function onClose() {
914
- return handleClose(false);
915
- },
916
- children: [/*#__PURE__*/jsxs(Component.Header, _objectSpread(_objectSpread({}, manageMemberComponentConfig.headerProps), {}, {
917
- className: classnames([{
918
- "ntm-manage-members__header": currentPage !== FORM_PAGES.MAIN
919
- }, (_manageMemberComponen = manageMemberComponentConfig.headerProps) === null || _manageMemberComponen === void 0 ? void 0 : _manageMemberComponen.className]),
920
- children: [currentPage !== FORM_PAGES.MAIN && /*#__PURE__*/jsx(Button, {
921
- "aria-label": "Back",
922
- icon: LeftArrow,
923
- size: "medium",
924
- style: "text",
925
- tooltipProps: {
926
- content: t("neetoTeamMembers.buttons.back"),
927
- position: "bottom"
928
- },
929
- onClick: handleBackButton
930
- }), /*#__PURE__*/jsx(Typography, {
931
- className: "ntm-members-form__header",
932
- "data-testid": "ntm-manage-members-pane-header",
933
- style: "h2",
934
- weight: "semibold",
935
- children: getTitle()
936
- }), selectedMember && /*#__PURE__*/jsx(Typography, {
937
- className: "neeto-ui-text-gray-600",
938
- style: "body2",
939
- children: t("neetoTeamMembers.helpers.editPaneSubtitle")
940
- })]
941
- })), /*#__PURE__*/jsx(Form, {
942
- ref: formReference,
943
- formikProps: {
944
- enableReinitialize: true,
945
- initialValues: renderInitialValues({
946
- additionalFieldsInitialValues: (_config$additionalFie2 = config.additionalFields) === null || _config$additionalFie2 === void 0 ? void 0 : _config$additionalFie2.initialValues,
947
- globalRoles: globalRoles,
948
- memberShowData: memberShowData,
949
- roles: filteredRoles,
950
- selectedMember: selectedMember
951
- }),
952
- onSubmit: handleOnSubmit,
953
- validationSchema: buildValidationSchema(_objectSpread({
954
- selectedMember: selectedMember
955
- }, team))
956
- },
957
- children: function children(_ref9) {
958
- var _manageMemberComponen2, _manageMemberComponen3;
959
- var values = _ref9.values,
960
- isValid = _ref9.isValid,
961
- dirty = _ref9.dirty,
962
- setFieldValue = _ref9.setFieldValue;
963
- var emails = values.emails,
964
- role = values.role;
965
- formikValues.current = values;
966
- return /*#__PURE__*/jsxs(Fragment, {
967
- children: [/*#__PURE__*/jsx(ScrollToErrorField, {
968
- formRef: formReference
969
- }), /*#__PURE__*/jsxs(Component.Body, _objectSpread(_objectSpread({}, manageMemberComponentConfig.bodyProps), {}, {
970
- className: classnames(["ntm-members-form__body", (_manageMemberComponen2 = manageMemberComponentConfig.bodyProps) === null || _manageMemberComponen2 === void 0 ? void 0 : _manageMemberComponen2.className]),
971
- children: [isCreationStatusPollingEnabled && /*#__PURE__*/jsxs(Callout, {
972
- className: "w-full",
973
- icon: Info,
974
- style: "info",
975
- children: [/*#__PURE__*/jsx(Spinner, {
976
- size: "small"
977
- }), t("neetoTeamMembers.helpers.memberCreationStatus", {
978
- count: emails.length
979
- })]
980
- }), renderFormPage(currentPage, emails, role, setFieldValue)]
981
- })), currentPage !== FORM_PAGES.INVITE_LINK && /*#__PURE__*/jsx(Component.Footer, _objectSpread(_objectSpread({}, manageMemberComponentConfig.footerProps), {}, {
982
- className: classnames(["ntm-members-form__footer", (_manageMemberComponen3 = manageMemberComponentConfig.footerProps) === null || _manageMemberComponen3 === void 0 ? void 0 : _manageMemberComponen3.className]),
983
- children: /*#__PURE__*/jsx(ActionBlock, {
984
- cancelButtonProps: {
985
- "data-testid": "ntm-manage-member-cancel-button",
986
- onClick: function onClick() {
987
- return handleClose(false);
988
- }
989
- },
990
- isSubmitting: isProcessing || isCreationStatusPollingEnabled,
991
- submitButtonProps: {
992
- "data-testid": isLastPage ? "ntm-manage-member-submit-button" : "ntm-manage-member-continue-button",
993
- label: isLastPage ? t("neetoTeamMembers.buttons.saveChanges") : t("neetoTeamMembers.buttons.continue"),
994
- disabled: !isValid || isProcessing || !dirty || isCreationStatusPollingEnabled
995
- }
996
- })
997
- }))]
998
- });
999
- }
1000
- })]
1001
- });
1002
- };
1003
-
1004
- export { ManageMember as default };
1005
64
  //# sourceMappingURL=ManageMember.js.map