@jsb188/graphql 1.1.10 → 1.1.11
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/cache/config.ts +64 -50
- package/cache/index.test.ts +671 -109
- package/cache/index.ts +1700 -1240
- package/cache/persist.ts +721 -0
- package/cache/store.ts +437 -0
- package/client/data-table-realtime-subscriptions.test.ts +740 -0
- package/client/data-table-realtime-subscriptions.ts +955 -0
- package/client/data-table-realtime.test.ts +792 -0
- package/client/data-table-realtime.ts +1218 -0
- package/client/fragment-realtime-sequence.ts +52 -0
- package/client/index.ts +2 -0
- package/client/open-sheet.ts +137 -0
- package/client/request-managed-session.test.ts +574 -0
- package/client/request-no-store.test.ts +157 -0
- package/client/request.ts +954 -163
- package/client/sse-ticket.test.ts +26 -0
- package/deno.lock +170 -0
- package/deno.test.json +8 -4
- package/drafts/index.ts +149 -0
- package/drafts/store.ts +397 -0
- package/gql/eagerQueryMap.ts +12 -0
- package/gql/fragments/accountAuthFragments.ts +5 -0
- package/gql/fragments/accountFragments.ts +0 -3
- package/gql/fragments/accountSessionFragments.ts +16 -0
- package/gql/fragments/agentDocFragments.ts +46 -0
- package/gql/fragments/agentMemoryFragments.ts +19 -0
- package/gql/fragments/aiChatFragments.ts +16 -0
- package/gql/fragments/billingFragments.ts +0 -11
- package/gql/fragments/campaignFragments.ts +277 -0
- package/gql/fragments/dataTableFragments.ts +18 -128
- package/gql/fragments/emailFragments.ts +19 -9
- package/gql/fragments/fieldDocFragments.ts +82 -0
- package/gql/fragments/logFragments.ts +20 -79
- package/gql/fragments/organizationFragments.ts +43 -5
- package/gql/fragments/scheduleFragments.ts +155 -0
- package/gql/fragments/sheetFragments.ts +552 -22
- package/gql/fragments/storageFragments.ts +21 -0
- package/gql/fragments/workflowFragments.ts +28 -4
- package/gql/mutations/accountMutations.ts +0 -2
- package/gql/mutations/agentDocMutations.ts +177 -0
- package/gql/mutations/agentMemoryMutations.ts +36 -0
- package/gql/mutations/aiChatMutations.ts +17 -4
- package/gql/mutations/authMutations.ts +158 -17
- package/gql/mutations/campaignMutations.ts +215 -0
- package/gql/mutations/dataTableMutations.ts +48 -26
- package/gql/mutations/fieldDocMutations.ts +24 -0
- package/gql/mutations/index.ts +6 -1
- package/gql/mutations/logMutations.ts +6 -29
- package/gql/mutations/organizationMutations.ts +13 -4
- package/gql/mutations/scheduleMutations.ts +423 -0
- package/gql/mutations/sheetMutations.ts +273 -56
- package/gql/mutations/storageMutations.ts +20 -0
- package/gql/mutations/workflowMutations.ts +42 -0
- package/gql/queries/agentDocQueries.ts +120 -0
- package/gql/queries/agentMemoryQueries.ts +22 -0
- package/gql/queries/aiChatQueries.ts +18 -2
- package/gql/queries/authQueries.ts +41 -0
- package/gql/queries/billingQueries.ts +23 -0
- package/gql/queries/campaignQueries.ts +127 -0
- package/gql/queries/dataTableQueries.ts +100 -11
- package/gql/queries/emailQueries.ts +55 -3
- package/gql/queries/fieldDocQueries.ts +158 -0
- package/gql/queries/index.ts +8 -2
- package/gql/queries/logQueries.ts +11 -28
- package/gql/queries/organizationQueries.ts +52 -1
- package/gql/queries/scheduleQueries.ts +315 -0
- package/gql/queries/sheetQueries.ts +336 -25
- package/gql/queries/storageQueries.ts +38 -0
- package/gql/queries/workflowQueries.ts +72 -3
- package/hooks/index.ts +2065 -971
- package/hooks/use-account-mtn.ts +76 -81
- package/hooks/use-agentDoc-mtn.ts +285 -0
- package/hooks/use-agentDoc-qry.ts +208 -0
- package/hooks/use-agentMemory-mtn.ts +73 -0
- package/hooks/use-agentMemory-qry.ts +44 -0
- package/hooks/use-aiChat-mtn.ts +232 -137
- package/hooks/use-aiChat-qry.ts +480 -222
- package/hooks/use-app-qry.ts +12 -9
- package/hooks/use-auth-mtn.ts +406 -252
- package/hooks/use-auth-qry.ts +51 -0
- package/hooks/use-campaign-mtn.ts +377 -0
- package/hooks/use-campaign-qry.ts +257 -0
- package/hooks/use-dataTable-mtn.ts +116 -33
- package/hooks/use-dataTable-qry.ts +859 -35
- package/hooks/use-email-qry.ts +194 -79
- package/hooks/use-fieldDoc-mtn.ts +50 -0
- package/hooks/use-fieldDoc-qry.ts +180 -0
- package/hooks/use-inboundContact-mtn.ts +19 -16
- package/hooks/use-inboundContact-qry.ts +63 -55
- package/hooks/use-integration-mtn.ts +56 -38
- package/hooks/use-integration-qry.ts +24 -9
- package/hooks/use-log-mtn.ts +72 -56
- package/hooks/use-log-qry.ts +93 -69
- package/hooks/use-organization-mtn.ts +334 -277
- package/hooks/use-organization-qry.ts +199 -129
- package/hooks/use-schedule-mtn.ts +416 -0
- package/hooks/use-schedule-qry.ts +157 -0
- package/hooks/use-sheet-mtn.ts +233 -47
- package/hooks/use-sheet-qry.ts +353 -70
- package/hooks/use-storage-mtn.ts +81 -41
- package/hooks/use-storage-qry.ts +104 -13
- package/hooks/use-workflow-mtn.ts +55 -0
- package/hooks/use-workflow-qry.ts +206 -48
- package/loaders/campaign.ts +137 -0
- package/package.json +94 -71
- package/sse.ts +157 -104
- package/tsconfig.json +11 -10
- package/types.d.ts +60 -30
- package/utils.ts +78 -49
- package/gql/fragments/productFragments.ts +0 -39
- package/gql/fragments/reportFragments.ts +0 -90
- package/gql/mutations/billingMutations.ts +0 -34
- package/gql/queries/productQueries.ts +0 -31
- package/gql/queries/reportQueries.ts +0 -134
- package/hooks/use-product-qry.ts +0 -67
- package/hooks/use-report-qry.ts +0 -153
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import type { UseMutationParams } from '@jsb188/graphql/types.d';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
checkACL,
|
|
4
|
+
type OperationName,
|
|
5
|
+
} from '@jsb188/mday/utils/organization.ts';
|
|
3
6
|
import { OpenModalPopUpFn, useCurrentAccount } from '@jsb188/react/states';
|
|
4
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
FRAGMENT_NAMES,
|
|
9
|
+
makeFragmentKey,
|
|
10
|
+
} from '@jsb188/mday/constants/graphqlReactivity.ts';
|
|
11
|
+
import { useMemo } from 'react';
|
|
5
12
|
import { updateFragment } from '../cache/index.ts';
|
|
6
|
-
import { graphqlRequest } from '../client/request.ts';
|
|
7
13
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
deleteChildOrganizationMtn,
|
|
15
|
+
deleteComplianceDocumentMtn,
|
|
16
|
+
editChildOrganizationMtn,
|
|
17
|
+
editComplianceDocumentMtn,
|
|
18
|
+
editMembershipMtn,
|
|
19
|
+
editOrganizationMtn,
|
|
20
|
+
editOrganizationInboundEmailMtn,
|
|
21
|
+
editOrganizationSettingsMtn,
|
|
22
|
+
editSiteLocationMtn,
|
|
23
|
+
removeMembershipMtn,
|
|
24
|
+
switchOrganizationMtn,
|
|
19
25
|
} from '../gql/mutations/organizationMutations.ts';
|
|
20
26
|
import { useMutation } from './index.ts';
|
|
21
27
|
import { useOrgRelFromMyOrganizations } from './use-organization-qry.ts';
|
|
@@ -25,85 +31,106 @@ import { useOrgRelFromMyOrganizations } from './use-organization-qry.ts';
|
|
|
25
31
|
* from cache first; only check server if cache is not found.
|
|
26
32
|
*/
|
|
27
33
|
|
|
28
|
-
export function useSwitchOrganization(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
34
|
+
export function useSwitchOrganization(
|
|
35
|
+
params: UseMutationParams = {},
|
|
36
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
37
|
+
) {
|
|
38
|
+
const { onCompleted, ...otherParams } = params;
|
|
39
|
+
// const navigate = useNavigate();
|
|
40
|
+
const { dispatchApp, account, primaryOrganizationId } = useCurrentAccount();
|
|
41
|
+
|
|
42
|
+
const [switchOrganization, mtnValues, mtnHandlers] = useMutation(
|
|
43
|
+
switchOrganizationMtn,
|
|
44
|
+
{
|
|
45
|
+
// checkMountedBeforeCallback: true,
|
|
46
|
+
openModalPopUp,
|
|
47
|
+
onCompleted: (data: any, error: any, variables: any) => {
|
|
48
|
+
const result = data?.switchOrganization;
|
|
49
|
+
if (result) {
|
|
50
|
+
// navigate('/app', { replace: true });
|
|
51
|
+
dispatchApp({
|
|
52
|
+
__type: 'APP_SWITCH_PRIMARY_ORGANIZATION',
|
|
53
|
+
data: {
|
|
54
|
+
primaryOrganizationId: variables.organizationId,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
onCompleted?.(result, error);
|
|
60
|
+
},
|
|
61
|
+
...otherParams,
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
switchOrganization,
|
|
67
|
+
...mtnValues,
|
|
68
|
+
...mtnHandlers,
|
|
69
|
+
};
|
|
58
70
|
}
|
|
59
71
|
|
|
60
72
|
/**
|
|
61
73
|
* Delete a compliance document
|
|
62
74
|
*/
|
|
63
75
|
|
|
64
|
-
export function useDeleteComplianceDocument(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
export function useDeleteComplianceDocument(
|
|
77
|
+
params: UseMutationParams = {},
|
|
78
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
79
|
+
) {
|
|
80
|
+
const { onCompleted, ...otherParams } = params;
|
|
81
|
+
|
|
82
|
+
const [deleteComplianceDocument, mtnValues, mtnHandlers, updateObservers] =
|
|
83
|
+
useMutation(deleteComplianceDocumentMtn, {
|
|
84
|
+
// checkMountedBeforeCallback: true,
|
|
85
|
+
openModalPopUp,
|
|
86
|
+
onCompleted: (data, error, variables) => {
|
|
87
|
+
const deleted = data?.deleteComplianceDocument;
|
|
88
|
+
if (deleted) {
|
|
89
|
+
updateFragment(
|
|
90
|
+
makeFragmentKey(
|
|
91
|
+
FRAGMENT_NAMES.organizationCompliance,
|
|
92
|
+
variables.complianceId,
|
|
93
|
+
),
|
|
94
|
+
{ __deleted: true },
|
|
95
|
+
null,
|
|
96
|
+
false,
|
|
97
|
+
updateObservers,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
onCompleted?.(deleted, error);
|
|
102
|
+
},
|
|
103
|
+
...otherParams,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
deleteComplianceDocument,
|
|
108
|
+
...mtnValues,
|
|
109
|
+
...mtnHandlers,
|
|
110
|
+
};
|
|
88
111
|
}
|
|
89
112
|
|
|
90
113
|
/**
|
|
91
114
|
* Edit a compliance document
|
|
92
115
|
*/
|
|
93
116
|
|
|
94
|
-
export function useEditComplianceDocument(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
export function useEditComplianceDocument(
|
|
118
|
+
params: UseMutationParams = {},
|
|
119
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
120
|
+
) {
|
|
121
|
+
const [editComplianceDocument, mtnValues, mtnHandlers] = useMutation(
|
|
122
|
+
editComplianceDocumentMtn,
|
|
123
|
+
{
|
|
124
|
+
openModalPopUp,
|
|
125
|
+
...params,
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
editComplianceDocument,
|
|
131
|
+
...mtnValues,
|
|
132
|
+
...mtnHandlers,
|
|
133
|
+
};
|
|
107
134
|
}
|
|
108
135
|
|
|
109
136
|
/**
|
|
@@ -111,20 +138,23 @@ export function useEditComplianceDocument(params: UseMutationParams = {}, openMo
|
|
|
111
138
|
*/
|
|
112
139
|
|
|
113
140
|
export function useEditOrganization(
|
|
114
|
-
|
|
115
|
-
|
|
141
|
+
params?: UseMutationParams | null,
|
|
142
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
116
143
|
) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
144
|
+
const [editOrganization, mtnValues, mtnHandlers] = useMutation(
|
|
145
|
+
editOrganizationMtn,
|
|
146
|
+
{
|
|
147
|
+
// checkMountedBeforeCallback: true,
|
|
148
|
+
openModalPopUp,
|
|
149
|
+
...params,
|
|
150
|
+
},
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
editOrganization,
|
|
155
|
+
...mtnValues,
|
|
156
|
+
...mtnHandlers,
|
|
157
|
+
};
|
|
128
158
|
}
|
|
129
159
|
|
|
130
160
|
/*
|
|
@@ -132,75 +162,63 @@ export function useEditOrganization(
|
|
|
132
162
|
*/
|
|
133
163
|
|
|
134
164
|
export function useEditOrganizationInboundEmail(
|
|
135
|
-
|
|
136
|
-
|
|
165
|
+
params: UseMutationParams = {},
|
|
166
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
137
167
|
) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
168
|
+
const { onCompleted, ...rest } = params;
|
|
169
|
+
|
|
170
|
+
const [
|
|
171
|
+
editOrganizationInboundEmail,
|
|
172
|
+
mtnValues,
|
|
173
|
+
mtnHandlers,
|
|
174
|
+
updateObservers,
|
|
175
|
+
] = useMutation(editOrganizationInboundEmailMtn, {
|
|
176
|
+
openModalPopUp,
|
|
177
|
+
onCompleted: (data, error, variables) => {
|
|
178
|
+
const updatedOrganization = data?.editOrganizationInboundEmail;
|
|
179
|
+
|
|
180
|
+
if (updatedOrganization?.id) {
|
|
181
|
+
updateFragment(
|
|
182
|
+
makeFragmentKey(FRAGMENT_NAMES.organization, updatedOrganization.id),
|
|
183
|
+
updatedOrganization,
|
|
184
|
+
null,
|
|
185
|
+
false,
|
|
186
|
+
updateObservers,
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
onCompleted?.(updatedOrganization, error, variables);
|
|
191
|
+
},
|
|
192
|
+
...rest,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
editOrganizationInboundEmail,
|
|
197
|
+
...mtnValues,
|
|
198
|
+
...mtnHandlers,
|
|
199
|
+
};
|
|
165
200
|
}
|
|
166
201
|
|
|
167
202
|
/*
|
|
168
203
|
* Edit an organization's settings.
|
|
169
204
|
*/
|
|
170
205
|
export function useEditOrganizationSettings(
|
|
171
|
-
|
|
172
|
-
|
|
206
|
+
params?: UseMutationParams | null,
|
|
207
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
173
208
|
) {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
* Return a non-reactive mutation function for background organization settings saves.
|
|
188
|
-
*/
|
|
189
|
-
export function useEditOrganizationSettingsRequest(openModalPopUp?: OpenModalPopUpFn) {
|
|
190
|
-
return useCallback((variables: {
|
|
191
|
-
organizationId: string;
|
|
192
|
-
sidebar?: any[] | null;
|
|
193
|
-
routeId?: string | null;
|
|
194
|
-
columnWidths?: string[] | null;
|
|
195
|
-
}) => {
|
|
196
|
-
return graphqlRequest(
|
|
197
|
-
editOrganizationSettingsMtn,
|
|
198
|
-
variables,
|
|
199
|
-
{
|
|
200
|
-
openModalPopUp,
|
|
201
|
-
},
|
|
202
|
-
);
|
|
203
|
-
}, [openModalPopUp]);
|
|
209
|
+
const [editOrganizationSettings, mtnValues, mtnHandlers] = useMutation(
|
|
210
|
+
editOrganizationSettingsMtn,
|
|
211
|
+
{
|
|
212
|
+
openModalPopUp,
|
|
213
|
+
...params,
|
|
214
|
+
},
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
editOrganizationSettings,
|
|
219
|
+
...mtnValues,
|
|
220
|
+
...mtnHandlers,
|
|
221
|
+
};
|
|
204
222
|
}
|
|
205
223
|
|
|
206
224
|
/**
|
|
@@ -208,19 +226,22 @@ export function useEditOrganizationSettingsRequest(openModalPopUp?: OpenModalPop
|
|
|
208
226
|
*/
|
|
209
227
|
|
|
210
228
|
export function useEditChildOrganization(
|
|
211
|
-
|
|
212
|
-
|
|
229
|
+
params?: UseMutationParams | null,
|
|
230
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
213
231
|
) {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
232
|
+
const [editChildOrganization, mtnValues, mtnHandlers] = useMutation(
|
|
233
|
+
editChildOrganizationMtn,
|
|
234
|
+
{
|
|
235
|
+
openModalPopUp,
|
|
236
|
+
...params,
|
|
237
|
+
},
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
return {
|
|
241
|
+
editChildOrganization,
|
|
242
|
+
...mtnValues,
|
|
243
|
+
...mtnHandlers,
|
|
244
|
+
};
|
|
224
245
|
}
|
|
225
246
|
|
|
226
247
|
/**
|
|
@@ -228,25 +249,39 @@ export function useEditChildOrganization(
|
|
|
228
249
|
*/
|
|
229
250
|
|
|
230
251
|
export function useDeleteChildOrganization(
|
|
231
|
-
|
|
232
|
-
|
|
252
|
+
params: UseMutationParams = {},
|
|
253
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
233
254
|
) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
255
|
+
const { onCompleted, ...rest } = params;
|
|
256
|
+
|
|
257
|
+
const [deleteChildOrganization, mtnValues, mtnHandlers, updateObservers] =
|
|
258
|
+
useMutation(deleteChildOrganizationMtn, {
|
|
259
|
+
openModalPopUp,
|
|
260
|
+
onCompleted: (data, error, variables) => {
|
|
261
|
+
const deleted = data?.deleteChildOrganization;
|
|
262
|
+
if (deleted && variables?.childId) {
|
|
263
|
+
updateFragment(
|
|
264
|
+
makeFragmentKey(
|
|
265
|
+
FRAGMENT_NAMES.organizationChild,
|
|
266
|
+
variables.childId,
|
|
267
|
+
),
|
|
268
|
+
{ __deleted: true },
|
|
269
|
+
null,
|
|
270
|
+
false,
|
|
271
|
+
updateObservers,
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
onCompleted?.(deleted, error, variables);
|
|
276
|
+
},
|
|
277
|
+
...rest,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
return {
|
|
281
|
+
deleteChildOrganization,
|
|
282
|
+
...mtnValues,
|
|
283
|
+
...mtnHandlers,
|
|
284
|
+
};
|
|
250
285
|
}
|
|
251
286
|
|
|
252
287
|
/**
|
|
@@ -254,36 +289,40 @@ export function useDeleteChildOrganization(
|
|
|
254
289
|
*/
|
|
255
290
|
|
|
256
291
|
export function useEditSiteLocation(
|
|
257
|
-
|
|
258
|
-
|
|
292
|
+
params: UseMutationParams = {},
|
|
293
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
259
294
|
) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
295
|
+
const { onCompleted, ...rest } = params;
|
|
296
|
+
|
|
297
|
+
const [editSiteLocation, mtnValues, mtnHandlers, updateObservers] =
|
|
298
|
+
useMutation(editSiteLocationMtn, {
|
|
299
|
+
openModalPopUp,
|
|
300
|
+
onCompleted: (data, error, variables) => {
|
|
301
|
+
const updatedSiteLocation = data?.editSiteLocation;
|
|
302
|
+
|
|
303
|
+
if (updatedSiteLocation?.id) {
|
|
304
|
+
updateFragment(
|
|
305
|
+
makeFragmentKey(
|
|
306
|
+
FRAGMENT_NAMES.organizationSite,
|
|
307
|
+
updatedSiteLocation.id,
|
|
308
|
+
),
|
|
309
|
+
updatedSiteLocation,
|
|
310
|
+
null,
|
|
311
|
+
false,
|
|
312
|
+
updateObservers,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
onCompleted?.(updatedSiteLocation, error, variables);
|
|
317
|
+
},
|
|
318
|
+
...rest,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
editSiteLocation,
|
|
323
|
+
...mtnValues,
|
|
324
|
+
...mtnHandlers,
|
|
325
|
+
};
|
|
287
326
|
}
|
|
288
327
|
|
|
289
328
|
/**
|
|
@@ -291,23 +330,25 @@ export function useEditSiteLocation(
|
|
|
291
330
|
*/
|
|
292
331
|
|
|
293
332
|
export function useEditOrganizationWithACL(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
333
|
+
params?: UseMutationParams | null,
|
|
334
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
335
|
+
aclOpName: OperationName = 'org_management',
|
|
297
336
|
) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
337
|
+
const { primaryOrganizationId } = useCurrentAccount();
|
|
338
|
+
const { organizationRelationship } = useOrgRelFromMyOrganizations(
|
|
339
|
+
primaryOrganizationId,
|
|
340
|
+
);
|
|
341
|
+
const mtnHook = useEditOrganization(params, openModalPopUp);
|
|
301
342
|
|
|
302
|
-
|
|
343
|
+
const allowEdit = useMemo(() => {
|
|
303
344
|
return checkACL(organizationRelationship, aclOpName);
|
|
304
|
-
|
|
345
|
+
}, [organizationRelationship?.acl, organizationRelationship?.role]);
|
|
305
346
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
347
|
+
return {
|
|
348
|
+
allowEdit,
|
|
349
|
+
organizationRelationship,
|
|
350
|
+
...mtnHook,
|
|
351
|
+
};
|
|
311
352
|
}
|
|
312
353
|
|
|
313
354
|
/**
|
|
@@ -315,36 +356,42 @@ export function useEditOrganizationWithACL(
|
|
|
315
356
|
*/
|
|
316
357
|
|
|
317
358
|
export function useEditMembership(
|
|
318
|
-
|
|
319
|
-
|
|
359
|
+
params: UseMutationParams = {},
|
|
360
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
320
361
|
) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
362
|
+
const { onCompleted, ...rest } = params;
|
|
363
|
+
|
|
364
|
+
const [editMembership, mtnValues, mtnHandlers, updateObservers] = useMutation(
|
|
365
|
+
editMembershipMtn,
|
|
366
|
+
{
|
|
367
|
+
openModalPopUp,
|
|
368
|
+
onCompleted: (data, error, variables) => {
|
|
369
|
+
const updatedMembership = data?.editMembership;
|
|
370
|
+
|
|
371
|
+
if (updatedMembership?.id) {
|
|
372
|
+
updateFragment(
|
|
373
|
+
makeFragmentKey(
|
|
374
|
+
FRAGMENT_NAMES.organizationRelationship,
|
|
375
|
+
updatedMembership.id,
|
|
376
|
+
),
|
|
377
|
+
updatedMembership,
|
|
378
|
+
null,
|
|
379
|
+
false,
|
|
380
|
+
updateObservers,
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
onCompleted?.(updatedMembership, error, variables);
|
|
385
|
+
},
|
|
386
|
+
...rest,
|
|
387
|
+
},
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
return {
|
|
391
|
+
editMembership,
|
|
392
|
+
...mtnValues,
|
|
393
|
+
...mtnHandlers,
|
|
394
|
+
};
|
|
348
395
|
}
|
|
349
396
|
|
|
350
397
|
/**
|
|
@@ -352,26 +399,36 @@ export function useEditMembership(
|
|
|
352
399
|
*/
|
|
353
400
|
|
|
354
401
|
export function useRemoveMembership(
|
|
355
|
-
|
|
356
|
-
|
|
402
|
+
params: UseMutationParams = {},
|
|
403
|
+
openModalPopUp?: OpenModalPopUpFn,
|
|
357
404
|
) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
405
|
+
const { onCompleted, ...rest } = params;
|
|
406
|
+
|
|
407
|
+
const [removeMembership, mtnValues, mtnHandlers, updateObservers] =
|
|
408
|
+
useMutation(removeMembershipMtn, {
|
|
409
|
+
openModalPopUp,
|
|
410
|
+
onCompleted: (data, error, variables) => {
|
|
411
|
+
const removed = data?.removeMembership;
|
|
412
|
+
if (removed) {
|
|
413
|
+
updateFragment(
|
|
414
|
+
makeFragmentKey(
|
|
415
|
+
FRAGMENT_NAMES.organizationRelationship,
|
|
416
|
+
variables.membershipId,
|
|
417
|
+
),
|
|
418
|
+
{ __deleted: true },
|
|
419
|
+
null,
|
|
420
|
+
false,
|
|
421
|
+
updateObservers,
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
onCompleted?.(removed, error, variables);
|
|
425
|
+
},
|
|
426
|
+
...rest,
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
return {
|
|
430
|
+
removeMembership,
|
|
431
|
+
...mtnValues,
|
|
432
|
+
...mtnHandlers,
|
|
433
|
+
};
|
|
377
434
|
}
|