@sudobility/shapeshyft_client 0.0.54 → 0.0.55

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 (36) hide show
  1. package/dist/hooks/useAiExecute.d.ts.map +1 -1
  2. package/dist/hooks/useAiExecute.js +51 -60
  3. package/dist/hooks/useAiExecute.js.map +1 -1
  4. package/dist/hooks/useAnalytics.d.ts +6 -2
  5. package/dist/hooks/useAnalytics.d.ts.map +1 -1
  6. package/dist/hooks/useAnalytics.js +27 -33
  7. package/dist/hooks/useAnalytics.js.map +1 -1
  8. package/dist/hooks/useEndpoints.d.ts +10 -6
  9. package/dist/hooks/useEndpoints.d.ts.map +1 -1
  10. package/dist/hooks/useEndpoints.js +87 -121
  11. package/dist/hooks/useEndpoints.js.map +1 -1
  12. package/dist/hooks/useEntities.d.ts +18 -15
  13. package/dist/hooks/useEntities.d.ts.map +1 -1
  14. package/dist/hooks/useEntities.js +235 -332
  15. package/dist/hooks/useEntities.js.map +1 -1
  16. package/dist/hooks/useKeys.d.ts +9 -6
  17. package/dist/hooks/useKeys.d.ts.map +1 -1
  18. package/dist/hooks/useKeys.js +82 -117
  19. package/dist/hooks/useKeys.js.map +1 -1
  20. package/dist/hooks/useProjects.d.ts +12 -8
  21. package/dist/hooks/useProjects.d.ts.map +1 -1
  22. package/dist/hooks/useProjects.js +103 -157
  23. package/dist/hooks/useProjects.js.map +1 -1
  24. package/dist/hooks/useSettings.d.ts +6 -3
  25. package/dist/hooks/useSettings.d.ts.map +1 -1
  26. package/dist/hooks/useSettings.js +53 -56
  27. package/dist/hooks/useSettings.js.map +1 -1
  28. package/dist/hooks/useStorageConfig.d.ts +8 -5
  29. package/dist/hooks/useStorageConfig.d.ts.map +1 -1
  30. package/dist/hooks/useStorageConfig.js +93 -119
  31. package/dist/hooks/useStorageConfig.js.map +1 -1
  32. package/dist/types.d.ts +8 -6
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/types.js +8 -6
  35. package/dist/types.js.map +1 -1
  36. package/package.json +1 -1
@@ -1,395 +1,298 @@
1
- import { useCallback, useMemo, useState } from 'react';
1
+ import { useCallback, useMemo } from 'react';
2
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
2
3
  import { ShapeshyftClient } from '../network/ShapeshyftClient';
3
- export const useEntities = (networkClient, baseUrl, testMode = false) => {
4
+ import { QUERY_KEYS } from '../types';
5
+ const EMPTY_ENTITIES = [];
6
+ const EMPTY_MEMBERS = [];
7
+ const EMPTY_INVITATIONS = [];
8
+ export const useEntities = (networkClient, baseUrl, token, entitySlug, options) => {
9
+ const testMode = options?.testMode ?? false;
10
+ const enabled = (options?.enabled ?? true) && !!token;
11
+ const entityEnabled = enabled && !!entitySlug;
4
12
  const client = useMemo(() => new ShapeshyftClient({ baseUrl, networkClient, testMode }), [baseUrl, networkClient, testMode]);
5
- const [entities, setEntities] = useState([]);
6
- const [currentEntity, setCurrentEntity] = useState(null);
7
- const [members, setMembers] = useState([]);
8
- const [invitations, setInvitations] = useState([]);
9
- const [myInvitations, setMyInvitations] = useState([]);
10
- const [isLoading, setIsLoading] = useState(false);
11
- const [error, setError] = useState(null);
12
- const refreshEntities = useCallback(async (token) => {
13
- setIsLoading(true);
14
- setError(null);
15
- try {
13
+ const queryClient = useQueryClient();
14
+ const { data: entitiesData, isLoading: entitiesLoading, error: entitiesError, refetch: refetchEntities, } = useQuery({
15
+ queryKey: QUERY_KEYS.entities(),
16
+ queryFn: async () => {
16
17
  const response = await client.getEntities(token);
17
- if (response.success && response.data) {
18
- setEntities(response.data);
18
+ if (!response.success || !response.data) {
19
+ throw new Error(response.error || 'Failed to fetch entities');
19
20
  }
20
- else {
21
- setError(response.error || 'Failed to fetch entities');
21
+ return response.data;
22
+ },
23
+ enabled,
24
+ staleTime: 5 * 60 * 1000,
25
+ gcTime: 30 * 60 * 1000,
26
+ });
27
+ const { data: membersData, isLoading: membersLoading, refetch: refetchMembers, } = useQuery({
28
+ queryKey: QUERY_KEYS.entityMembers(entitySlug ?? ''),
29
+ queryFn: async () => {
30
+ const response = await client.getEntityMembers(entitySlug, token);
31
+ if (!response.success || !response.data) {
32
+ throw new Error(response.error || 'Failed to fetch members');
22
33
  }
23
- }
24
- catch (err) {
25
- const errorMessage = err instanceof Error ? err.message : 'Failed to fetch entities';
26
- setError(errorMessage);
27
- console.error('[useEntities] refreshEntities error:', errorMessage, err);
28
- }
29
- finally {
30
- setIsLoading(false);
31
- }
32
- }, [client]);
33
- const getEntity = useCallback(async (entitySlug, token) => {
34
- setIsLoading(true);
35
- setError(null);
36
- try {
37
- const response = await client.getEntity(entitySlug, token);
38
- if (response.success && response.data) {
39
- setCurrentEntity(response.data);
34
+ return response.data;
35
+ },
36
+ enabled: entityEnabled,
37
+ staleTime: 5 * 60 * 1000,
38
+ gcTime: 30 * 60 * 1000,
39
+ });
40
+ const { data: invitationsData, isLoading: invitationsLoading, refetch: refetchInvitations, } = useQuery({
41
+ queryKey: QUERY_KEYS.entityInvitations(entitySlug ?? ''),
42
+ queryFn: async () => {
43
+ const response = await client.getEntityInvitations(entitySlug, token);
44
+ if (!response.success || !response.data) {
45
+ throw new Error(response.error || 'Failed to fetch invitations');
40
46
  }
41
- return response;
42
- }
43
- catch (err) {
44
- const errorMessage = err instanceof Error ? err.message : 'Failed to get entity';
45
- setError(errorMessage);
46
- console.error('[useEntities] getEntity error:', errorMessage, err);
47
- return {
48
- success: false,
49
- error: errorMessage,
50
- timestamp: new Date().toISOString(),
51
- };
52
- }
53
- finally {
54
- setIsLoading(false);
55
- }
56
- }, [client]);
57
- const createEntity = useCallback(async (data, token) => {
58
- setIsLoading(true);
59
- setError(null);
60
- try {
61
- const response = await client.createEntity(data, token);
62
- if (response.success) {
63
- await refreshEntities(token);
47
+ return response.data;
48
+ },
49
+ enabled: entityEnabled,
50
+ staleTime: 5 * 60 * 1000,
51
+ gcTime: 30 * 60 * 1000,
52
+ });
53
+ const { data: myInvitationsData, isLoading: myInvitationsLoading, refetch: refetchMyInvitations, } = useQuery({
54
+ queryKey: QUERY_KEYS.myInvitations(),
55
+ queryFn: async () => {
56
+ const response = await client.getMyInvitations(token);
57
+ if (!response.success || !response.data) {
58
+ throw new Error(response.error || 'Failed to fetch my invitations');
64
59
  }
65
- return response;
66
- }
67
- catch (err) {
68
- const errorMessage = err instanceof Error ? err.message : 'Failed to create entity';
69
- setError(errorMessage);
70
- console.error('[useEntities] createEntity error:', errorMessage, err);
71
- return {
72
- success: false,
73
- error: errorMessage,
74
- timestamp: new Date().toISOString(),
75
- };
76
- }
77
- finally {
78
- setIsLoading(false);
79
- }
80
- }, [client, refreshEntities]);
81
- const updateEntity = useCallback(async (entitySlug, data, token) => {
82
- setIsLoading(true);
83
- setError(null);
84
- try {
85
- const response = await client.updateEntity(entitySlug, data, token);
60
+ return response.data;
61
+ },
62
+ enabled,
63
+ staleTime: 5 * 60 * 1000,
64
+ gcTime: 30 * 60 * 1000,
65
+ });
66
+ const createEntityMutation = useMutation({
67
+ mutationFn: async (data) => {
68
+ return client.createEntity(data, token);
69
+ },
70
+ onSuccess: response => {
86
71
  if (response.success) {
87
- await refreshEntities(token);
72
+ queryClient.invalidateQueries({ queryKey: QUERY_KEYS.entities() });
88
73
  }
89
- return response;
90
- }
91
- catch (err) {
92
- const errorMessage = err instanceof Error ? err.message : 'Failed to update entity';
93
- setError(errorMessage);
94
- console.error('[useEntities] updateEntity error:', errorMessage, err);
95
- return {
96
- success: false,
97
- error: errorMessage,
98
- timestamp: new Date().toISOString(),
99
- };
100
- }
101
- finally {
102
- setIsLoading(false);
103
- }
104
- }, [client, refreshEntities]);
105
- const deleteEntity = useCallback(async (entitySlug, token) => {
106
- setIsLoading(true);
107
- setError(null);
108
- try {
109
- const response = await client.deleteEntity(entitySlug, token);
74
+ },
75
+ });
76
+ const updateEntityMutation = useMutation({
77
+ mutationFn: async ({ slug, data, }) => {
78
+ return client.updateEntity(slug, data, token);
79
+ },
80
+ onSuccess: response => {
110
81
  if (response.success) {
111
- await refreshEntities(token);
112
- }
113
- return response;
114
- }
115
- catch (err) {
116
- const errorMessage = err instanceof Error ? err.message : 'Failed to delete entity';
117
- setError(errorMessage);
118
- console.error('[useEntities] deleteEntity error:', errorMessage, err);
119
- return {
120
- success: false,
121
- error: errorMessage,
122
- timestamp: new Date().toISOString(),
123
- };
124
- }
125
- finally {
126
- setIsLoading(false);
127
- }
128
- }, [client, refreshEntities]);
129
- const refreshMembers = useCallback(async (entitySlug, token) => {
130
- setIsLoading(true);
131
- setError(null);
132
- try {
133
- const response = await client.getEntityMembers(entitySlug, token);
134
- if (response.success && response.data) {
135
- setMembers(response.data);
82
+ queryClient.invalidateQueries({ queryKey: QUERY_KEYS.entities() });
136
83
  }
137
- else {
138
- setError(response.error || 'Failed to fetch members');
139
- }
140
- }
141
- catch (err) {
142
- const errorMessage = err instanceof Error ? err.message : 'Failed to fetch members';
143
- setError(errorMessage);
144
- console.error('[useEntities] refreshMembers error:', errorMessage, err);
145
- }
146
- finally {
147
- setIsLoading(false);
148
- }
149
- }, [client]);
150
- const updateMemberRole = useCallback(async (entitySlug, memberId, role, token) => {
151
- setIsLoading(true);
152
- setError(null);
153
- try {
154
- const response = await client.updateEntityMemberRole(entitySlug, memberId, role, token);
84
+ },
85
+ });
86
+ const deleteEntityMutation = useMutation({
87
+ mutationFn: async (slug) => {
88
+ return client.deleteEntity(slug, token);
89
+ },
90
+ onSuccess: response => {
155
91
  if (response.success) {
156
- await refreshMembers(entitySlug, token);
92
+ queryClient.invalidateQueries({ queryKey: QUERY_KEYS.entities() });
157
93
  }
158
- return response;
159
- }
160
- catch (err) {
161
- const errorMessage = err instanceof Error ? err.message : 'Failed to update member role';
162
- setError(errorMessage);
163
- console.error('[useEntities] updateMemberRole error:', errorMessage, err);
164
- return {
165
- success: false,
166
- error: errorMessage,
167
- timestamp: new Date().toISOString(),
168
- };
169
- }
170
- finally {
171
- setIsLoading(false);
172
- }
173
- }, [client, refreshMembers]);
174
- const removeMember = useCallback(async (entitySlug, memberId, token) => {
175
- setIsLoading(true);
176
- setError(null);
177
- try {
178
- const response = await client.removeEntityMember(entitySlug, memberId, token);
179
- if (response.success) {
180
- await refreshMembers(entitySlug, token);
94
+ },
95
+ });
96
+ const updateMemberRoleMutation = useMutation({
97
+ mutationFn: async ({ memberId, role, }) => {
98
+ return client.updateEntityMemberRole(entitySlug, memberId, role, token);
99
+ },
100
+ onSuccess: response => {
101
+ if (response.success && entitySlug) {
102
+ queryClient.invalidateQueries({
103
+ queryKey: QUERY_KEYS.entityMembers(entitySlug),
104
+ });
181
105
  }
182
- return response;
183
- }
184
- catch (err) {
185
- const errorMessage = err instanceof Error ? err.message : 'Failed to remove member';
186
- setError(errorMessage);
187
- console.error('[useEntities] removeMember error:', errorMessage, err);
188
- return {
189
- success: false,
190
- error: errorMessage,
191
- timestamp: new Date().toISOString(),
192
- };
193
- }
194
- finally {
195
- setIsLoading(false);
196
- }
197
- }, [client, refreshMembers]);
198
- const refreshInvitations = useCallback(async (entitySlug, token) => {
199
- setIsLoading(true);
200
- setError(null);
201
- try {
202
- const response = await client.getEntityInvitations(entitySlug, token);
203
- if (response.success && response.data) {
204
- setInvitations(response.data);
106
+ },
107
+ });
108
+ const removeMemberMutation = useMutation({
109
+ mutationFn: async (memberId) => {
110
+ return client.removeEntityMember(entitySlug, memberId, token);
111
+ },
112
+ onSuccess: response => {
113
+ if (response.success && entitySlug) {
114
+ queryClient.invalidateQueries({
115
+ queryKey: QUERY_KEYS.entityMembers(entitySlug),
116
+ });
205
117
  }
206
- else {
207
- setError(response.error || 'Failed to fetch invitations');
118
+ },
119
+ });
120
+ const createInvitationMutation = useMutation({
121
+ mutationFn: async (data) => {
122
+ return client.createEntityInvitation(entitySlug, data, token);
123
+ },
124
+ onSuccess: response => {
125
+ if (response.success && entitySlug) {
126
+ queryClient.invalidateQueries({
127
+ queryKey: QUERY_KEYS.entityInvitations(entitySlug),
128
+ });
208
129
  }
209
- }
210
- catch (err) {
211
- const errorMessage = err instanceof Error ? err.message : 'Failed to fetch invitations';
212
- setError(errorMessage);
213
- console.error('[useEntities] refreshInvitations error:', errorMessage, err);
214
- }
215
- finally {
216
- setIsLoading(false);
217
- }
218
- }, [client]);
219
- const createInvitation = useCallback(async (entitySlug, data, token) => {
220
- setIsLoading(true);
221
- setError(null);
222
- try {
223
- const response = await client.createEntityInvitation(entitySlug, data, token);
224
- if (response.success) {
225
- await refreshInvitations(entitySlug, token);
130
+ },
131
+ });
132
+ const cancelInvitationMutation = useMutation({
133
+ mutationFn: async (invitationId) => {
134
+ return client.cancelEntityInvitation(entitySlug, invitationId, token);
135
+ },
136
+ onSuccess: response => {
137
+ if (response.success && entitySlug) {
138
+ queryClient.invalidateQueries({
139
+ queryKey: QUERY_KEYS.entityInvitations(entitySlug),
140
+ });
226
141
  }
227
- return response;
228
- }
229
- catch (err) {
230
- const errorMessage = err instanceof Error ? err.message : 'Failed to create invitation';
231
- setError(errorMessage);
232
- console.error('[useEntities] createInvitation error:', errorMessage, err);
233
- return {
234
- success: false,
235
- error: errorMessage,
236
- timestamp: new Date().toISOString(),
237
- };
238
- }
239
- finally {
240
- setIsLoading(false);
241
- }
242
- }, [client, refreshInvitations]);
243
- const cancelInvitation = useCallback(async (entitySlug, invitationId, token) => {
244
- setIsLoading(true);
245
- setError(null);
246
- try {
247
- const response = await client.cancelEntityInvitation(entitySlug, invitationId, token);
142
+ },
143
+ });
144
+ const acceptInvitationMutation = useMutation({
145
+ mutationFn: async (invitationToken) => {
146
+ return client.acceptInvitation(invitationToken, token);
147
+ },
148
+ onSuccess: response => {
248
149
  if (response.success) {
249
- await refreshInvitations(entitySlug, token);
150
+ queryClient.invalidateQueries({ queryKey: QUERY_KEYS.myInvitations() });
151
+ queryClient.invalidateQueries({ queryKey: QUERY_KEYS.entities() });
250
152
  }
251
- return response;
252
- }
253
- catch (err) {
254
- const errorMessage = err instanceof Error ? err.message : 'Failed to cancel invitation';
255
- setError(errorMessage);
256
- console.error('[useEntities] cancelInvitation error:', errorMessage, err);
257
- return {
258
- success: false,
259
- error: errorMessage,
260
- timestamp: new Date().toISOString(),
261
- };
262
- }
263
- finally {
264
- setIsLoading(false);
265
- }
266
- }, [client, refreshInvitations]);
267
- const refreshMyInvitations = useCallback(async (token) => {
268
- setIsLoading(true);
269
- setError(null);
270
- try {
271
- const response = await client.getMyInvitations(token);
272
- if (response.success && response.data) {
273
- setMyInvitations(response.data);
274
- }
275
- else {
276
- setError(response.error || 'Failed to fetch my invitations');
277
- }
278
- }
279
- catch (err) {
280
- const errorMessage = err instanceof Error ? err.message : 'Failed to fetch my invitations';
281
- setError(errorMessage);
282
- console.error('[useEntities] refreshMyInvitations error:', errorMessage, err);
283
- }
284
- finally {
285
- setIsLoading(false);
286
- }
287
- }, [client]);
288
- const acceptInvitation = useCallback(async (invitationToken, token) => {
289
- setIsLoading(true);
290
- setError(null);
291
- try {
292
- const response = await client.acceptInvitation(invitationToken, token);
153
+ },
154
+ });
155
+ const declineInvitationMutation = useMutation({
156
+ mutationFn: async (invitationToken) => {
157
+ return client.declineInvitation(invitationToken, token);
158
+ },
159
+ onSuccess: response => {
293
160
  if (response.success) {
294
- await refreshMyInvitations(token);
295
- await refreshEntities(token);
161
+ queryClient.invalidateQueries({ queryKey: QUERY_KEYS.myInvitations() });
296
162
  }
297
- return response;
298
- }
299
- catch (err) {
300
- const errorMessage = err instanceof Error ? err.message : 'Failed to accept invitation';
301
- setError(errorMessage);
302
- console.error('[useEntities] acceptInvitation error:', errorMessage, err);
303
- return {
304
- success: false,
305
- error: errorMessage,
306
- timestamp: new Date().toISOString(),
307
- };
308
- }
309
- finally {
310
- setIsLoading(false);
311
- }
312
- }, [client, refreshMyInvitations, refreshEntities]);
313
- const declineInvitation = useCallback(async (invitationToken, token) => {
314
- setIsLoading(true);
315
- setError(null);
163
+ },
164
+ });
165
+ const getEntity = useCallback(async (slug) => {
316
166
  try {
317
- const response = await client.declineInvitation(invitationToken, token);
318
- if (response.success) {
319
- await refreshMyInvitations(token);
320
- }
321
- return response;
167
+ return await client.getEntity(slug, token);
322
168
  }
323
169
  catch (err) {
324
- const errorMessage = err instanceof Error ? err.message : 'Failed to decline invitation';
325
- setError(errorMessage);
326
- console.error('[useEntities] declineInvitation error:', errorMessage, err);
170
+ const errorMessage = err instanceof Error ? err.message : 'Failed to get entity';
327
171
  return {
328
172
  success: false,
329
173
  error: errorMessage,
330
174
  timestamp: new Date().toISOString(),
331
175
  };
332
176
  }
333
- finally {
334
- setIsLoading(false);
335
- }
336
- }, [client, refreshMyInvitations]);
177
+ }, [client, token]);
178
+ const createEntity = useCallback((data) => createEntityMutation.mutateAsync(data), [createEntityMutation]);
179
+ const updateEntity = useCallback((slug, data) => updateEntityMutation.mutateAsync({ slug, data }), [updateEntityMutation]);
180
+ const deleteEntity = useCallback((slug) => deleteEntityMutation.mutateAsync(slug), [deleteEntityMutation]);
181
+ const updateMemberRole = useCallback((memberId, role) => updateMemberRoleMutation.mutateAsync({ memberId, role }), [updateMemberRoleMutation]);
182
+ const removeMember = useCallback((memberId) => removeMemberMutation.mutateAsync(memberId), [removeMemberMutation]);
183
+ const createInvitation = useCallback((data) => createInvitationMutation.mutateAsync(data), [createInvitationMutation]);
184
+ const cancelInvitation = useCallback((invitationId) => cancelInvitationMutation.mutateAsync(invitationId), [cancelInvitationMutation]);
185
+ const acceptInvitation = useCallback((invitationToken) => acceptInvitationMutation.mutateAsync(invitationToken), [acceptInvitationMutation]);
186
+ const declineInvitation = useCallback((invitationToken) => declineInvitationMutation.mutateAsync(invitationToken), [declineInvitationMutation]);
187
+ const isLoading = entitiesLoading ||
188
+ membersLoading ||
189
+ invitationsLoading ||
190
+ myInvitationsLoading ||
191
+ createEntityMutation.isPending ||
192
+ updateEntityMutation.isPending ||
193
+ deleteEntityMutation.isPending ||
194
+ updateMemberRoleMutation.isPending ||
195
+ removeMemberMutation.isPending ||
196
+ createInvitationMutation.isPending ||
197
+ cancelInvitationMutation.isPending ||
198
+ acceptInvitationMutation.isPending ||
199
+ declineInvitationMutation.isPending;
200
+ const queryError = entitiesError;
201
+ const mutationError = createEntityMutation.error ??
202
+ updateEntityMutation.error ??
203
+ deleteEntityMutation.error ??
204
+ updateMemberRoleMutation.error ??
205
+ removeMemberMutation.error ??
206
+ createInvitationMutation.error ??
207
+ cancelInvitationMutation.error ??
208
+ acceptInvitationMutation.error ??
209
+ declineInvitationMutation.error;
210
+ const error = queryError instanceof Error
211
+ ? queryError.message
212
+ : mutationError instanceof Error
213
+ ? mutationError.message
214
+ : null;
337
215
  const clearError = useCallback(() => {
338
- setError(null);
339
- }, []);
216
+ createEntityMutation.reset();
217
+ updateEntityMutation.reset();
218
+ deleteEntityMutation.reset();
219
+ updateMemberRoleMutation.reset();
220
+ removeMemberMutation.reset();
221
+ createInvitationMutation.reset();
222
+ cancelInvitationMutation.reset();
223
+ acceptInvitationMutation.reset();
224
+ declineInvitationMutation.reset();
225
+ }, [
226
+ createEntityMutation,
227
+ updateEntityMutation,
228
+ deleteEntityMutation,
229
+ updateMemberRoleMutation,
230
+ removeMemberMutation,
231
+ createInvitationMutation,
232
+ cancelInvitationMutation,
233
+ acceptInvitationMutation,
234
+ declineInvitationMutation,
235
+ ]);
340
236
  const reset = useCallback(() => {
341
- setEntities([]);
342
- setCurrentEntity(null);
343
- setMembers([]);
344
- setInvitations([]);
345
- setMyInvitations([]);
346
- setError(null);
347
- setIsLoading(false);
348
- }, []);
237
+ queryClient.removeQueries({ queryKey: QUERY_KEYS.entities() });
238
+ queryClient.removeQueries({ queryKey: QUERY_KEYS.myInvitations() });
239
+ if (entitySlug) {
240
+ queryClient.removeQueries({
241
+ queryKey: QUERY_KEYS.entityMembers(entitySlug),
242
+ });
243
+ queryClient.removeQueries({
244
+ queryKey: QUERY_KEYS.entityInvitations(entitySlug),
245
+ });
246
+ }
247
+ clearError();
248
+ }, [queryClient, entitySlug, clearError]);
249
+ const currentEntity = useMemo(() => entitySlug
250
+ ? ((entitiesData ?? []).find(e => e.entitySlug === entitySlug) ?? null)
251
+ : null, [entitiesData, entitySlug]);
349
252
  return useMemo(() => ({
350
- entities,
253
+ entities: entitiesData ?? EMPTY_ENTITIES,
351
254
  currentEntity,
352
- members,
353
- invitations,
354
- myInvitations,
255
+ members: membersData ?? EMPTY_MEMBERS,
256
+ invitations: invitationsData ?? EMPTY_INVITATIONS,
257
+ myInvitations: myInvitationsData ?? EMPTY_INVITATIONS,
355
258
  isLoading,
356
259
  error,
357
- refreshEntities,
260
+ refetchEntities,
358
261
  getEntity,
359
262
  createEntity,
360
263
  updateEntity,
361
264
  deleteEntity,
362
- refreshMembers,
265
+ refetchMembers,
363
266
  updateMemberRole,
364
267
  removeMember,
365
- refreshInvitations,
268
+ refetchInvitations,
366
269
  createInvitation,
367
270
  cancelInvitation,
368
- refreshMyInvitations,
271
+ refetchMyInvitations,
369
272
  acceptInvitation,
370
273
  declineInvitation,
371
274
  clearError,
372
275
  reset,
373
276
  }), [
374
- entities,
277
+ entitiesData,
375
278
  currentEntity,
376
- members,
377
- invitations,
378
- myInvitations,
279
+ membersData,
280
+ invitationsData,
281
+ myInvitationsData,
379
282
  isLoading,
380
283
  error,
381
- refreshEntities,
284
+ refetchEntities,
382
285
  getEntity,
383
286
  createEntity,
384
287
  updateEntity,
385
288
  deleteEntity,
386
- refreshMembers,
289
+ refetchMembers,
387
290
  updateMemberRole,
388
291
  removeMember,
389
- refreshInvitations,
292
+ refetchInvitations,
390
293
  createInvitation,
391
294
  cancelInvitation,
392
- refreshMyInvitations,
295
+ refetchMyInvitations,
393
296
  acceptInvitation,
394
297
  declineInvitation,
395
298
  clearError,