@rh-support/manage 2.5.271 → 2.5.275
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.
- package/lib/esm/ManageTabs.d.ts.map +1 -1
- package/lib/esm/ManageTabs.js +46 -18
- package/lib/esm/Routes.d.ts +1 -0
- package/lib/esm/Routes.d.ts.map +1 -1
- package/lib/esm/Routes.js +6 -0
- package/lib/esm/components/Groups/AddMembersModal/AddMembersModal.d.ts +12 -0
- package/lib/esm/components/Groups/AddMembersModal/AddMembersModal.d.ts.map +1 -0
- package/lib/esm/components/Groups/AddMembersModal/AddMembersModal.js +80 -0
- package/lib/esm/components/Groups/AddMembersModal/index.d.ts +2 -0
- package/lib/esm/components/Groups/AddMembersModal/index.d.ts.map +1 -0
- package/lib/esm/components/Groups/AddMembersModal/index.js +1 -0
- package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.d.ts +5 -3
- package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.d.ts.map +1 -1
- package/lib/esm/components/Groups/DefualtGroupSwitch/DefaultGroupSwitch.js +21 -14
- package/lib/esm/components/Groups/GroupSelect/GroupSelect.d.ts +1 -0
- package/lib/esm/components/Groups/GroupSelect/GroupSelect.d.ts.map +1 -1
- package/lib/esm/components/Groups/GroupSelect/GroupSelect.js +160 -85
- package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.d.ts.map +1 -1
- package/lib/esm/components/Groups/ManageGroupUsers/ManageGroupUsers.js +163 -42
- package/lib/esm/components/ManageCaseLabels/AddEditCaseLabelModal.d.ts +19 -0
- package/lib/esm/components/ManageCaseLabels/AddEditCaseLabelModal.d.ts.map +1 -0
- package/lib/esm/components/ManageCaseLabels/AddEditCaseLabelModal.js +83 -0
- package/lib/esm/components/ManageCaseLabels/ManageCaseLabelsTab.d.ts +3 -0
- package/lib/esm/components/ManageCaseLabels/ManageCaseLabelsTab.d.ts.map +1 -0
- package/lib/esm/components/ManageCaseLabels/ManageCaseLabelsTab.js +217 -0
- package/lib/esm/components/ManageCaseLabels/index.d.ts +2 -0
- package/lib/esm/components/ManageCaseLabels/index.d.ts.map +1 -0
- package/lib/esm/components/ManageCaseLabels/index.js +1 -0
- package/lib/esm/components/ManageCaseLabels/types.d.ts +6 -0
- package/lib/esm/components/ManageCaseLabels/types.d.ts.map +1 -0
- package/lib/esm/components/ManageCaseLabels/types.js +1 -0
- package/lib/esm/components/ManagePreferences/sections/PreferencesACL.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesACL.js +3 -4
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseCreate.js +73 -58
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseView.d.ts.map +1 -1
- package/lib/esm/components/ManagePreferences/sections/PreferencesCaseView.js +43 -98
- package/lib/esm/constants/GroupSelectActions.d.ts +2 -1
- package/lib/esm/constants/GroupSelectActions.d.ts.map +1 -1
- package/lib/esm/constants/GroupSelectActions.js +1 -0
- package/lib/esm/hooks/useCaseGroupGraphQL.d.ts +42 -0
- package/lib/esm/hooks/useCaseGroupGraphQL.d.ts.map +1 -0
- package/lib/esm/hooks/useCaseGroupGraphQL.js +109 -0
- package/lib/esm/hooks/useCaseLabelGraphQL.d.ts +26 -0
- package/lib/esm/hooks/useCaseLabelGraphQL.d.ts.map +1 -0
- package/lib/esm/hooks/useCaseLabelGraphQL.js +100 -0
- package/lib/esm/hooks/useCurrentUserContact.d.ts +8 -0
- package/lib/esm/hooks/useCurrentUserContact.d.ts.map +1 -0
- package/lib/esm/hooks/useCurrentUserContact.js +74 -0
- package/lib/esm/hooks/useVersionsDiffer.d.ts.map +1 -1
- package/lib/esm/index.js +1 -0
- package/lib/esm/scss/_main.scss +77 -0
- package/lib/esm/utils/caseGroupMapper.d.ts +18 -0
- package/lib/esm/utils/caseGroupMapper.d.ts.map +1 -0
- package/lib/esm/utils/caseGroupMapper.js +50 -0
- package/package.json +11 -8
|
@@ -11,15 +11,14 @@ import { accounts } from '@cee-eng/hydrajs';
|
|
|
11
11
|
import { Card, CardBody, CardHeader, Spinner, Tooltip } from '@patternfly/react-core';
|
|
12
12
|
import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
|
|
13
13
|
import { useFetch } from '@rh-support/components';
|
|
14
|
-
import {
|
|
14
|
+
import { GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
15
15
|
import React, { useContext, useState } from 'react';
|
|
16
16
|
import { Trans, useTranslation } from 'react-i18next';
|
|
17
17
|
import { PreferenceSwitch } from '../components/PreferenceSwitch';
|
|
18
18
|
export function PreferencesACL() {
|
|
19
19
|
var _a;
|
|
20
20
|
const { t } = useTranslation();
|
|
21
|
-
const { globalMetadataState: { loggedInUsersAccount
|
|
22
|
-
const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
|
|
21
|
+
const { globalMetadataState: { loggedInUsersAccount }, } = useContext(GlobalMetadataStateContext);
|
|
23
22
|
const [isAclActivated, setIsAclActivated] = useState((_a = loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.hasGroupACLs);
|
|
24
23
|
const [isAclLoading, setIsAclLoading] = useState(false);
|
|
25
24
|
const { request: updateAcl } = useFetch(accounts.updateAcl);
|
|
@@ -27,7 +26,7 @@ export function PreferencesACL() {
|
|
|
27
26
|
try {
|
|
28
27
|
setIsAclLoading(true);
|
|
29
28
|
yield updateAcl(!isAclActivated, loggedInUsersAccount.data.accountNumber);
|
|
30
|
-
fetchLoggedInUsersAccount(dispatchToGlobalMetadataReducer, loggedInUserJwtToken, true);
|
|
29
|
+
// TODO: migrate to GraphQL - fetchLoggedInUsersAccount(dispatchToGlobalMetadataReducer, loggedInUserJwtToken, true, apolloClient);
|
|
31
30
|
setIsAclActivated(!isAclActivated);
|
|
32
31
|
}
|
|
33
32
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesCaseCreate.d.ts","sourceRoot":"","sources":["../../../../../src/components/ManagePreferences/sections/PreferencesCaseCreate.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PreferencesCaseCreate.d.ts","sourceRoot":"","sources":["../../../../../src/components/ManagePreferences/sections/PreferencesCaseCreate.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAkBhF,UAAU,MAAM;CAAG;AACnB,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,qBAwNlD"}
|
|
@@ -7,62 +7,74 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { useApolloClient } from '@apollo/client/react';
|
|
11
11
|
import { Card, CardBody, CardHeader, SelectOption } from '@patternfly/react-core';
|
|
12
|
-
import { ToastNotification
|
|
13
|
-
import { fetchLanguageMetadata, GlobalMetadataDispatchContext, GlobalMetadataReducerConstants, GlobalMetadataStateContext, } from '@rh-support/react-context';
|
|
12
|
+
import { ToastNotification } from '@rh-support/components';
|
|
13
|
+
import { fetchCaseGroupsForAccount, fetchCaseGroupsForSSO, fetchLanguageMetadata, GlobalMetadataDispatchContext, GlobalMetadataReducerConstants, GlobalMetadataStateContext, } from '@rh-support/react-context';
|
|
14
14
|
import { haventLoadedMetadata, PreferredLanguages } from '@rh-support/utils';
|
|
15
15
|
import isEmpty from 'lodash/isEmpty';
|
|
16
16
|
import map from 'lodash/map';
|
|
17
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
17
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
18
18
|
import { Trans, useTranslation } from 'react-i18next';
|
|
19
|
-
import {
|
|
19
|
+
import { useToggleDefaultGroup } from '../../../hooks/useCaseGroupGraphQL';
|
|
20
20
|
import { useUserPreferences } from '../../../hooks/useUserPreferences';
|
|
21
21
|
import { PreferenceSelect } from '../components/PreferenceSelect';
|
|
22
|
+
const UNGROUPED_CASE_LABEL = 'Ungrouped Case';
|
|
23
|
+
function resolveDefaultGroupLabel(defaultCaseGroupId, groupList) {
|
|
24
|
+
var _a;
|
|
25
|
+
if (!defaultCaseGroupId || defaultCaseGroupId === '-1') {
|
|
26
|
+
return UNGROUPED_CASE_LABEL;
|
|
27
|
+
}
|
|
28
|
+
const defaultGroup = groupList.find((group) => group.groupNum === defaultCaseGroupId);
|
|
29
|
+
return (_a = defaultGroup === null || defaultGroup === void 0 ? void 0 : defaultGroup.name) !== null && _a !== void 0 ? _a : UNGROUPED_CASE_LABEL;
|
|
30
|
+
}
|
|
22
31
|
export function PreferencesCaseCreate(props) {
|
|
32
|
+
var _a, _b, _c, _d, _e, _f;
|
|
23
33
|
const { t } = useTranslation();
|
|
24
|
-
const
|
|
25
|
-
const { globalMetadataState: { caseGroups, caseLanguages,
|
|
34
|
+
const apolloClient = useApolloClient();
|
|
35
|
+
const { globalMetadataState: { caseGroups, caseLanguages, loggedInUser, loggedInUserJwtToken, loggedInUsersAccount }, } = useContext(GlobalMetadataStateContext);
|
|
26
36
|
const dispatchToGlobalMetadataReducer = useContext(GlobalMetadataDispatchContext);
|
|
27
37
|
const languageConst = caseLanguages.data;
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
setOriginalDefaultGroup(filteredDefaultGroup[0].name);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
setOriginalDefaultGroup('Ungrouped Case');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
console.log(error);
|
|
38
|
+
const { toggleDefault } = useToggleDefaultGroup();
|
|
39
|
+
const groupList = useMemo(() => caseGroups.data || [], [caseGroups.data]);
|
|
40
|
+
const contactId = (_a = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _a === void 0 ? void 0 : _a.id;
|
|
41
|
+
const defaultCaseGroupId = (_c = (_b = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _b === void 0 ? void 0 : _b.defaultCaseGroup) !== null && _c !== void 0 ? _c : null;
|
|
42
|
+
const salesforceAccountId = (_d = loggedInUsersAccount.data) === null || _d === void 0 ? void 0 : _d.salesforceAccountId;
|
|
43
|
+
const loggedInContactId = (_e = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _e === void 0 ? void 0 : _e.id;
|
|
44
|
+
const loggedInIsOrgAdmin = (_f = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.data) === null || _f === void 0 ? void 0 : _f.isOrgAdmin;
|
|
45
|
+
const hasFetchedCaseGroups = useRef(false);
|
|
46
|
+
const updateDefaultGroupPref = (groupId) => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (!contactId) {
|
|
48
|
+
ToastNotification.addDangerMessage(t('Cannot update default group: contact information is missing'));
|
|
49
|
+
throw new Error('Missing contact id');
|
|
48
50
|
}
|
|
49
|
-
});
|
|
50
|
-
const updateDefaultGroupPref = (groupNum) => __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
var _a;
|
|
52
51
|
try {
|
|
53
|
-
yield
|
|
54
|
-
const updatedGroups =
|
|
52
|
+
yield toggleDefault(contactId, groupId);
|
|
53
|
+
const updatedGroups = groupList.map((group) => (Object.assign(Object.assign({}, group), { isDefault: groupId !== null && group.groupNum === groupId })));
|
|
55
54
|
dispatchToGlobalMetadataReducer({
|
|
56
55
|
type: GlobalMetadataReducerConstants.setCaseGroups,
|
|
57
56
|
payload: {
|
|
58
57
|
caseGroups: Object.assign(Object.assign({}, caseGroups), { data: updatedGroups }),
|
|
59
58
|
},
|
|
60
59
|
});
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const updatedLoggedInUserData = Object.assign(Object.assign({}, loggedInUser.data), { defaultCaseGroup: groupId });
|
|
61
|
+
dispatchToGlobalMetadataReducer({
|
|
62
|
+
type: GlobalMetadataReducerConstants.setLoggedInUser,
|
|
63
|
+
payload: {
|
|
64
|
+
loggedInUser: Object.assign(Object.assign({}, loggedInUser), { data: updatedLoggedInUserData }),
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
setOriginalDefaultGroup(resolveDefaultGroupLabel(groupId, updatedGroups));
|
|
63
68
|
}
|
|
64
69
|
catch (error) {
|
|
65
|
-
|
|
70
|
+
const message = String((error === null || error === void 0 ? void 0 : error.message) || '');
|
|
71
|
+
if (message.includes('insufficient access rights')) {
|
|
72
|
+
ToastNotification.addDangerMessage(t('You do not have permission to change the default group'));
|
|
73
|
+
}
|
|
74
|
+
else if (message !== 'Missing contact id') {
|
|
75
|
+
ToastNotification.addDangerMessage(t('Failed to update default group'));
|
|
76
|
+
}
|
|
77
|
+
throw error;
|
|
66
78
|
}
|
|
67
79
|
});
|
|
68
80
|
const languagesList = map(languageConst, (cl) => ({
|
|
@@ -71,7 +83,6 @@ export function PreferencesCaseCreate(props) {
|
|
|
71
83
|
}));
|
|
72
84
|
const [originalPreferredLanguage, setOriginalPreferredLanguage] = useState('');
|
|
73
85
|
const [originalDefaultGroup, setOriginalDefaultGroup] = useState('');
|
|
74
|
-
const [userDefaultGroupList, setUserDefaultGroupList] = useState();
|
|
75
86
|
const { getPreferredLanguage, updatePreferredLanguage } = useUserPreferences();
|
|
76
87
|
const preferredLangTitleId = 'preferred-language-select';
|
|
77
88
|
const defaultGroupTitleId = 'default-group-select';
|
|
@@ -95,18 +106,13 @@ export function PreferencesCaseCreate(props) {
|
|
|
95
106
|
}
|
|
96
107
|
});
|
|
97
108
|
const onDefaultGroupSelect = (event, selection) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
if (!isEmpty(userDefaultGroupList)) {
|
|
103
|
-
let filteredGroupSelect = userDefaultGroupList.filter((group) => group.name === selection);
|
|
104
|
-
yield updateDefaultGroupPref(filteredGroupSelect[0].groupNum);
|
|
105
|
-
setOriginalDefaultGroup(filteredGroupSelect[0].name);
|
|
106
|
-
}
|
|
109
|
+
if (selection === UNGROUPED_CASE_LABEL) {
|
|
110
|
+
yield updateDefaultGroupPref(null);
|
|
111
|
+
return;
|
|
107
112
|
}
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
const selectedGroup = groupList.find((group) => group.name === selection);
|
|
114
|
+
if (selectedGroup) {
|
|
115
|
+
yield updateDefaultGroupPref(selectedGroup.groupNum);
|
|
110
116
|
}
|
|
111
117
|
});
|
|
112
118
|
useEffect(() => {
|
|
@@ -124,22 +130,31 @@ export function PreferencesCaseCreate(props) {
|
|
|
124
130
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
125
131
|
}, [caseLanguages, caseGroups, dispatchToGlobalMetadataReducer, loggedInUserJwtToken]);
|
|
126
132
|
useEffect(() => {
|
|
127
|
-
|
|
128
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
-
}, [loggedInUserRights, caseGroups]);
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
if (location.pathname !== '/manage/preferences') {
|
|
133
|
+
if (loggedInUser.isFetching)
|
|
132
134
|
return;
|
|
135
|
+
setOriginalDefaultGroup(resolveDefaultGroupLabel(defaultCaseGroupId, groupList));
|
|
136
|
+
}, [defaultCaseGroupId, groupList, loggedInUser.isFetching]);
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
if (haventLoadedMetadata(caseLanguages)) {
|
|
139
|
+
fetchLanguageMetadata(dispatchToGlobalMetadataReducer, apolloClient);
|
|
133
140
|
}
|
|
134
|
-
grabDefaultGroupList(loggedInUserRights.data.getSSOUsername());
|
|
135
141
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
136
|
-
}, [
|
|
142
|
+
}, [caseLanguages, apolloClient]);
|
|
137
143
|
useEffect(() => {
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
var _a;
|
|
145
|
+
if (!salesforceAccountId || loggedInUser.isFetching || !contactId)
|
|
146
|
+
return;
|
|
147
|
+
if (hasFetchedCaseGroups.current)
|
|
148
|
+
return;
|
|
149
|
+
hasFetchedCaseGroups.current = true;
|
|
150
|
+
if ((_a = loggedInUsersAccount.data) === null || _a === void 0 ? void 0 : _a.isInternal) {
|
|
151
|
+
fetchCaseGroupsForAccount(dispatchToGlobalMetadataReducer, apolloClient, salesforceAccountId, defaultCaseGroupId, loggedInContactId, loggedInIsOrgAdmin);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
fetchCaseGroupsForSSO(dispatchToGlobalMetadataReducer, apolloClient, salesforceAccountId, defaultCaseGroupId, loggedInContactId, loggedInIsOrgAdmin);
|
|
140
155
|
}
|
|
141
156
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
142
|
-
}, [
|
|
157
|
+
}, [salesforceAccountId, loggedInUser.isFetching, contactId, defaultCaseGroupId]);
|
|
143
158
|
return (React.createElement(Card, { variant: "secondary", className: "preference-card" },
|
|
144
159
|
React.createElement(CardHeader, null,
|
|
145
160
|
React.createElement("h3", null,
|
|
@@ -151,5 +166,5 @@ export function PreferencesCaseCreate(props) {
|
|
|
151
166
|
React.createElement("p", { className: "form-instructions" },
|
|
152
167
|
React.createElement(Trans, null, "Preferred language will impact future cases, not existing ones."))),
|
|
153
168
|
React.createElement("div", { className: "form-group" },
|
|
154
|
-
React.createElement(PreferenceSelect, { label: "Default group", id: defaultGroupTitleId, onSelect: onDefaultGroupSelect, selections: originalDefaultGroup }, (
|
|
169
|
+
React.createElement(PreferenceSelect, { label: "Default group", id: defaultGroupTitleId, onSelect: onDefaultGroupSelect, selections: originalDefaultGroup }, [UNGROUPED_CASE_LABEL, ...groupList.map((group) => group.name)].map((name, index) => (React.createElement(SelectOption, { key: index, value: name })))))))));
|
|
155
170
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesCaseView.d.ts","sourceRoot":"","sources":["../../../../../src/components/ManagePreferences/sections/PreferencesCaseView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PreferencesCaseView.d.ts","sourceRoot":"","sources":["../../../../../src/components/ManagePreferences/sections/PreferencesCaseView.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAA0C,MAAM,OAAO,CAAC;AAO/D,UAAU,MAAM;CAAG;AAEnB,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,qBA0OhD"}
|
|
@@ -7,38 +7,37 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { accounts } from '@cee-eng/hydrajs';
|
|
11
|
-
import { Card, CardBody, CardHeader, Popover, PopoverPosition, SelectOption, Spinner, TextArea,
|
|
10
|
+
// import { accounts } from '@cee-eng/hydrajs';
|
|
11
|
+
import { Card, CardBody, CardHeader, Popover, PopoverPosition, SelectOption, Spinner, TextArea,
|
|
12
|
+
// Tooltip,
|
|
13
|
+
} from '@patternfly/react-core';
|
|
12
14
|
import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { ability, CaseListFields
|
|
15
|
+
import { ToastNotification /* , useFetch */ } from '@rh-support/components';
|
|
16
|
+
import { GlobalMetadataStateContext } from '@rh-support/react-context';
|
|
17
|
+
import { ability /* , CaseListFields */, resourceActions, resources } from '@rh-support/user-permissions';
|
|
16
18
|
import debounce from 'lodash/debounce';
|
|
17
19
|
import isEmpty from 'lodash/isEmpty';
|
|
18
20
|
import React, { useContext, useEffect, useState } from 'react';
|
|
19
21
|
import { Trans, useTranslation } from 'react-i18next';
|
|
20
22
|
import { useUserPreferences } from '../../../hooks/useUserPreferences';
|
|
21
23
|
import { PreferenceSelect } from '../components/PreferenceSelect';
|
|
22
|
-
import { PreferenceSwitch } from '../components/PreferenceSwitch';
|
|
23
24
|
export function PreferencesCaseView(props) {
|
|
24
25
|
const { t } = useTranslation();
|
|
25
|
-
const {
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const { getCommentSignature, updateCommentSignature, getOriginalCaseView, updateOriginalCaseView } = useUserPreferences();
|
|
27
|
+
const {
|
|
28
|
+
// globalMetadataState: { loggedInUsersAccount, loggedInUserRights },
|
|
29
|
+
globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
|
|
30
|
+
// const [isSharingHostNames, setIsSharingHostNames] = useState(false);
|
|
29
31
|
const [localCommentSignature, setLocalCommentSignature] = useState('');
|
|
30
|
-
const [originalCommentType, setOriginalCommentType] = useState('');
|
|
31
32
|
const [originalCommentSignature, setOriginalCommentSignature] = useState('');
|
|
32
33
|
const [commentValidated, setCommentValidated] = useState('default');
|
|
33
|
-
const [isHostnamesLoading, setIsHostnamesLoading] = useState(true);
|
|
34
|
+
// const [isHostnamesLoading, setIsHostnamesLoading] = useState(true);
|
|
34
35
|
const [isCommentSignatureLoading, setIsCommentSignatureLoading] = useState(false);
|
|
35
|
-
const commentTypes = [EditorMode.PLAIN, EditorMode.MARKDOWN];
|
|
36
|
-
const defaultCommentTitleID = 'default-comment-preference-select';
|
|
37
36
|
const defaultCaseViewID = 'default-case-view-select';
|
|
38
|
-
const canUseHostName = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.HOSTNAME);
|
|
37
|
+
// const canUseHostName = ability.can(resourceActions.PATCH, resources.CASE_CREATE, CaseListFields.HOSTNAME);
|
|
39
38
|
const isInternalUserPermission = ability.can(resourceActions.READ, resources.ACCOUNTS_FILTER);
|
|
40
|
-
const accountNumber = loggedInUsersAccount.data.accountNumber;
|
|
41
|
-
const { request: updateShareHostnames } = useFetch(accounts.updateIsSharingHostname);
|
|
39
|
+
// const accountNumber = loggedInUsersAccount.data.accountNumber;
|
|
40
|
+
// const { request: updateShareHostnames } = useFetch(accounts.updateIsSharingHostname);
|
|
42
41
|
const originalAccountPermission = loggedInUserRights.data.isInternal();
|
|
43
42
|
const [originalCaseView, setOriginalCaseView] = useState(+originalAccountPermission);
|
|
44
43
|
const caseViewTypes = [
|
|
@@ -50,7 +49,6 @@ export function PreferencesCaseView(props) {
|
|
|
50
49
|
];
|
|
51
50
|
useEffect(() => {
|
|
52
51
|
userOriginalCommentSignature();
|
|
53
|
-
userOriginalCommentType();
|
|
54
52
|
userOriginalCaseView();
|
|
55
53
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
54
|
}, []);
|
|
@@ -59,23 +57,19 @@ export function PreferencesCaseView(props) {
|
|
|
59
57
|
setCommentValidated('default');
|
|
60
58
|
}
|
|
61
59
|
}, [localCommentSignature, commentValidated]);
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
canUseHostName && userOriginalHostnameValue();
|
|
77
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
|
-
}, []);
|
|
60
|
+
// useEffect(() => {
|
|
61
|
+
// async function userOriginalHostnameValue() {
|
|
62
|
+
// try {
|
|
63
|
+
// loggedInUsersAccount.data?.shareHostnameWithRHT &&
|
|
64
|
+
// setIsSharingHostNames(loggedInUsersAccount.data?.shareHostnameWithRHT);
|
|
65
|
+
// } catch (error) {
|
|
66
|
+
// console.log(error);
|
|
67
|
+
// }
|
|
68
|
+
// setIsHostnamesLoading(false);
|
|
69
|
+
// }
|
|
70
|
+
// canUseHostName && userOriginalHostnameValue();
|
|
71
|
+
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
// }, []);
|
|
79
73
|
const userOriginalCaseView = () => __awaiter(this, void 0, void 0, function* () {
|
|
80
74
|
try {
|
|
81
75
|
const retrievedCaseView = yield getOriginalCaseView();
|
|
@@ -87,15 +81,6 @@ export function PreferencesCaseView(props) {
|
|
|
87
81
|
ToastNotification.addWarningMessage(t('Failed to fetch original preference'));
|
|
88
82
|
}
|
|
89
83
|
});
|
|
90
|
-
const userOriginalCommentType = () => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
try {
|
|
92
|
-
const retrievedComment = yield getCommentTypeFromPreference();
|
|
93
|
-
setOriginalCommentType(retrievedComment);
|
|
94
|
-
}
|
|
95
|
-
catch (_a) {
|
|
96
|
-
ToastNotification.addWarningMessage(t('Failed to fetch original preference'));
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
84
|
const userOriginalCommentSignature = () => __awaiter(this, void 0, void 0, function* () {
|
|
100
85
|
try {
|
|
101
86
|
const retrievedSignature = yield getCommentSignature();
|
|
@@ -137,48 +122,19 @@ export function PreferencesCaseView(props) {
|
|
|
137
122
|
console.log(error);
|
|
138
123
|
}
|
|
139
124
|
});
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
else if (option === EditorMode.MARKDOWN) {
|
|
155
|
-
return 'Markdown';
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const onCommentSelect = (event, selection) => __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
try {
|
|
161
|
-
const selectedComment = setOptionCase(selection, true);
|
|
162
|
-
yield updateCommentType(selectedComment);
|
|
163
|
-
setOriginalCommentType(selectedComment);
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
console.log(error);
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
const onShareHostNamesSwitch = () => __awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
try {
|
|
171
|
-
setIsHostnamesLoading(true);
|
|
172
|
-
yield updateShareHostnames(!isSharingHostNames, accountNumber);
|
|
173
|
-
fetchLoggedInUsersAccount(dispatchToGlobalMetadataReducer, loggedInUserJwtToken, true);
|
|
174
|
-
setIsSharingHostNames(!isSharingHostNames);
|
|
175
|
-
}
|
|
176
|
-
catch (error) {
|
|
177
|
-
console.log(error);
|
|
178
|
-
}
|
|
179
|
-
setIsHostnamesLoading(false);
|
|
180
|
-
});
|
|
181
|
-
const prefHostnameCopy = 'Red Hat Support cannot currently access hostnames that have been entered on a case. You can share this information at any time to improve your support experience.';
|
|
125
|
+
// const onShareHostNamesSwitch = async () => {
|
|
126
|
+
// try {
|
|
127
|
+
// setIsHostnamesLoading(true);
|
|
128
|
+
// await updateShareHostnames!(!isSharingHostNames, accountNumber!);
|
|
129
|
+
// // TODO: migrate to GraphQL - fetchLoggedInUsersAccount(dispatchToGlobalMetadataReducer, loggedInUserJwtToken, true, apolloClient);
|
|
130
|
+
// setIsSharingHostNames(!isSharingHostNames);
|
|
131
|
+
// } catch (error) {
|
|
132
|
+
// console.log(error);
|
|
133
|
+
// }
|
|
134
|
+
// setIsHostnamesLoading(false);
|
|
135
|
+
// };
|
|
136
|
+
// const prefHostnameCopy =
|
|
137
|
+
// 'Red Hat Support cannot currently access hostnames that have been entered on a case. You can share this information at any time to improve your support experience.';
|
|
182
138
|
const caseViewPrefSelection = () => {
|
|
183
139
|
if (!!originalCaseView) {
|
|
184
140
|
return caseViewTypes[+originalAccountPermission].value;
|
|
@@ -200,22 +156,11 @@ export function PreferencesCaseView(props) {
|
|
|
200
156
|
React.createElement("form", null,
|
|
201
157
|
isInternalUserPermission && (React.createElement("div", { className: "form-group" },
|
|
202
158
|
React.createElement(PreferenceSelect, { onSelect: (event, selection) => onPrefCaseViewSelect(event, selection), selections: caseViewPrefSelection(), id: defaultCaseViewID, label: prefCasePopover }, caseViewTypes.map((option, index) => (React.createElement(SelectOption, Object.assign({ "data-index": index, key: index, value: option.value }, (option.description && { description: option.description })))))))),
|
|
203
|
-
React.createElement("div", { className: "form-group" },
|
|
204
|
-
React.createElement(PreferenceSelect, { onSelect: onCommentSelect, selections: setOptionCase(originalCommentType, false), id: defaultCommentTitleID, label: "Default comment type" }, commentTypes.map((option, index) => (React.createElement(SelectOption, { key: index, value: setOptionCase(option, false) }))))),
|
|
205
159
|
React.createElement("div", { className: "form-group" },
|
|
206
160
|
React.createElement("label", { htmlFor: "comment-signature-textarea" },
|
|
207
161
|
React.createElement(Trans, null, "Comment signature")),
|
|
208
162
|
React.createElement(TextArea, { value: localCommentSignature, onChange: (_event, value) => handleCommentSignatureChange(value), "aria-label": "comment-signature-textarea", placeholder: originalCommentSignature || 'Add a comment signature', id: "comment-signature-textarea",
|
|
209
163
|
// @ts-ignore
|
|
210
164
|
validated: commentValidated, resizeOrientation: "vertical" }),
|
|
211
|
-
isCommentSignatureLoading && React.createElement(Spinner, { size: "md" }))
|
|
212
|
-
canUseHostName && (React.createElement("div", { className: "form-group" },
|
|
213
|
-
React.createElement("label", null,
|
|
214
|
-
React.createElement(Trans, null, "Case information")),
|
|
215
|
-
React.createElement("div", { className: "preference-page-switch-container" },
|
|
216
|
-
React.createElement(PreferenceSwitch, { id: "share-hostnames-switch", label: 'Share hostnames', isChecked: isSharingHostNames, onSwitchChange: onShareHostNamesSwitch }),
|
|
217
|
-
React.createElement("div", { className: "prefhostnameTooltip" },
|
|
218
|
-
React.createElement(Tooltip, { content: prefHostnameCopy, position: "right" },
|
|
219
|
-
React.createElement(InfoCircleIcon, { className: "pf-v6-u-ml-sm cursor-pointer", color: "#5e40be" })),
|
|
220
|
-
isHostnamesLoading && (React.createElement(Spinner, { size: "lg", className: "pf-v6-u-ml-sm hostnameSpinner", "aria-label": "Hostname loading" }))))))))));
|
|
165
|
+
isCommentSignatureLoading && React.createElement(Spinner, { size: "md" }))))));
|
|
221
166
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupSelectActions.d.ts","sourceRoot":"","sources":["../../../src/constants/GroupSelectActions.ts"],"names":[],"mappings":"AAAA,oBAAY,kBAAkB;IAC1B,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,MAAM,WAAW;
|
|
1
|
+
{"version":3,"file":"GroupSelectActions.d.ts","sourceRoot":"","sources":["../../../src/constants/GroupSelectActions.ts"],"names":[],"mappings":"AAAA,oBAAY,kBAAkB;IAC1B,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,UAAU,gBAAgB;CAC7B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type CreateCaseGroupMemberResponse, type CreateCaseGroupResponse, type DeleteCaseGroupMemberResponse, type DeleteCaseGroupResponse, type RenameCaseGroupResponse, type ToggleDefaultGroupResponse } from '@rh-support/utils';
|
|
2
|
+
import { type IGroupUserWithContactId } from '../utils/caseGroupMapper';
|
|
3
|
+
interface UseCaseGroupMembersResult {
|
|
4
|
+
data: IGroupUserWithContactId[];
|
|
5
|
+
loading: boolean;
|
|
6
|
+
error: Error | undefined;
|
|
7
|
+
refetch: () => void;
|
|
8
|
+
fetchMembers: (groupId: string) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function useCaseGroupMembers(): UseCaseGroupMembersResult;
|
|
11
|
+
interface UseCreateCaseGroupResult {
|
|
12
|
+
createGroup: (name: string, accountId: string) => Promise<CreateCaseGroupResponse>;
|
|
13
|
+
loading: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function useCreateCaseGroup(): UseCreateCaseGroupResult;
|
|
16
|
+
interface UseCreateCaseGroupMemberResult {
|
|
17
|
+
createMember: (contactId: string, groupId: string) => Promise<CreateCaseGroupMemberResponse>;
|
|
18
|
+
loading: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function useCreateCaseGroupMember(): UseCreateCaseGroupMemberResult;
|
|
21
|
+
interface UseRenameCaseGroupResult {
|
|
22
|
+
renameGroup: (id: string, newName: string) => Promise<RenameCaseGroupResponse>;
|
|
23
|
+
loading: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function useRenameCaseGroup(): UseRenameCaseGroupResult;
|
|
26
|
+
interface UseDeleteCaseGroupResult {
|
|
27
|
+
deleteGroup: (id: string) => Promise<DeleteCaseGroupResponse>;
|
|
28
|
+
loading: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function useDeleteCaseGroup(): UseDeleteCaseGroupResult;
|
|
31
|
+
interface UseToggleDefaultGroupResult {
|
|
32
|
+
toggleDefault: (contactId: string, groupId: string | null) => Promise<ToggleDefaultGroupResponse>;
|
|
33
|
+
loading: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function useToggleDefaultGroup(): UseToggleDefaultGroupResult;
|
|
36
|
+
interface UseDeleteCaseGroupMemberResult {
|
|
37
|
+
deleteMember: (memberId: string) => Promise<DeleteCaseGroupMemberResponse>;
|
|
38
|
+
loading: boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare function useDeleteCaseGroupMember(): UseDeleteCaseGroupMemberResult;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=useCaseGroupGraphQL.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCaseGroupGraphQL.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCaseGroupGraphQL.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,uBAAuB,EAE5B,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAQlC,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,KAAK,uBAAuB,EAAsC,MAAM,0BAA0B,CAAC;AAE5G,UAAU,yBAAyB;IAC/B,IAAI,EAAE,uBAAuB,EAAE,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED,wBAAgB,mBAAmB,IAAI,yBAAyB,CA6B/D;AAED,UAAU,wBAAwB;IAC9B,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACnF,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,CAW7D;AAED,UAAU,8BAA8B;IACpC,YAAY,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC7F,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,wBAAwB,IAAI,8BAA8B,CAgBzE;AAED,UAAU,wBAAwB;IAC9B,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC/E,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,CAW7D;AAED,UAAU,wBAAwB;IAC9B,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC9D,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,kBAAkB,IAAI,wBAAwB,CAW7D;AAED,UAAU,2BAA2B;IACjC,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAClG,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,qBAAqB,IAAI,2BAA2B,CAcnE;AAED,UAAU,8BAA8B;IACpC,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC3E,OAAO,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,wBAAwB,IAAI,8BAA8B,CAWzE"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { useMutation, useQuery } from '@apollo/client/react';
|
|
11
|
+
import { CREATE_CASE_GROUP, CREATE_CASE_GROUP_MEMBER, DELETE_CASE_GROUP, DELETE_CASE_GROUP_MEMBER, GET_CASE_GROUP_MEMBERS, RENAME_CASE_GROUP, TOGGLE_DEFAULT_GROUP, } from '@rh-support/utils';
|
|
12
|
+
import { useMemo, useState } from 'react';
|
|
13
|
+
import { mapCaseGroupMemberNodeToIGroupUser } from '../utils/caseGroupMapper';
|
|
14
|
+
export function useCaseGroupMembers() {
|
|
15
|
+
const [groupId, setGroupId] = useState(undefined);
|
|
16
|
+
const { data, loading, error, refetch } = useQuery(GET_CASE_GROUP_MEMBERS, {
|
|
17
|
+
variables: { where: { Group__c: { eq: groupId } }, first: 2000 },
|
|
18
|
+
skip: !groupId,
|
|
19
|
+
fetchPolicy: 'network-only',
|
|
20
|
+
});
|
|
21
|
+
const members = useMemo(() => {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
if (!data || !groupId)
|
|
24
|
+
return [];
|
|
25
|
+
const response = data;
|
|
26
|
+
const edges = ((_c = (_b = (_a = response.redhat_support_uiapi) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.RedHatSupportCaseGroupMember__c) === null || _c === void 0 ? void 0 : _c.edges) || [];
|
|
27
|
+
return edges
|
|
28
|
+
.filter(({ node }) => node.Contact__r !== null)
|
|
29
|
+
.map(({ node }) => mapCaseGroupMemberNodeToIGroupUser(node, groupId));
|
|
30
|
+
}, [data, groupId]);
|
|
31
|
+
const fetchMembers = (id) => {
|
|
32
|
+
setGroupId(id);
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
data: members,
|
|
36
|
+
loading,
|
|
37
|
+
error: error,
|
|
38
|
+
refetch,
|
|
39
|
+
fetchMembers,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function useCreateCaseGroup() {
|
|
43
|
+
const [mutate, { loading }] = useMutation(CREATE_CASE_GROUP);
|
|
44
|
+
const createGroup = (name, accountId) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const result = yield mutate({
|
|
46
|
+
variables: { name, accountId },
|
|
47
|
+
});
|
|
48
|
+
return result.data;
|
|
49
|
+
});
|
|
50
|
+
return { createGroup, loading };
|
|
51
|
+
}
|
|
52
|
+
export function useCreateCaseGroupMember() {
|
|
53
|
+
const [mutate, { loading }] = useMutation(CREATE_CASE_GROUP_MEMBER);
|
|
54
|
+
const createMember = (contactId, groupId) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const result = yield mutate({
|
|
56
|
+
variables: {
|
|
57
|
+
memberInput: {
|
|
58
|
+
Contact__c: contactId,
|
|
59
|
+
Group__c: groupId,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
return result.data;
|
|
64
|
+
});
|
|
65
|
+
return { createMember, loading };
|
|
66
|
+
}
|
|
67
|
+
export function useRenameCaseGroup() {
|
|
68
|
+
const [mutate, { loading }] = useMutation(RENAME_CASE_GROUP);
|
|
69
|
+
const renameGroup = (id, newName) => __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const result = yield mutate({
|
|
71
|
+
variables: { id, caseGroupPatch: { Name: newName } },
|
|
72
|
+
});
|
|
73
|
+
return result.data;
|
|
74
|
+
});
|
|
75
|
+
return { renameGroup, loading };
|
|
76
|
+
}
|
|
77
|
+
export function useDeleteCaseGroup() {
|
|
78
|
+
const [mutate, { loading }] = useMutation(DELETE_CASE_GROUP);
|
|
79
|
+
const deleteGroup = (id) => __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const result = yield mutate({
|
|
81
|
+
variables: { id },
|
|
82
|
+
});
|
|
83
|
+
return result.data;
|
|
84
|
+
});
|
|
85
|
+
return { deleteGroup, loading };
|
|
86
|
+
}
|
|
87
|
+
export function useToggleDefaultGroup() {
|
|
88
|
+
const [mutate, { loading }] = useMutation(TOGGLE_DEFAULT_GROUP);
|
|
89
|
+
const toggleDefault = (contactId, groupId) => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
const result = yield mutate({
|
|
91
|
+
variables: {
|
|
92
|
+
id: contactId,
|
|
93
|
+
contactPatch: { DefaultCaseGroup__c: groupId },
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
return result.data;
|
|
97
|
+
});
|
|
98
|
+
return { toggleDefault, loading };
|
|
99
|
+
}
|
|
100
|
+
export function useDeleteCaseGroupMember() {
|
|
101
|
+
const [mutate, { loading }] = useMutation(DELETE_CASE_GROUP_MEMBER);
|
|
102
|
+
const deleteMember = (memberId) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const result = yield mutate({
|
|
104
|
+
variables: { id: memberId },
|
|
105
|
+
});
|
|
106
|
+
return result.data;
|
|
107
|
+
});
|
|
108
|
+
return { deleteMember, loading };
|
|
109
|
+
}
|