@elevasis/ui 2.73.0 → 2.75.0
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/dist/api/index.js +3 -3
- package/dist/app/index.d.ts +58 -0
- package/dist/app/index.js +9 -10
- package/dist/auth/index.js +5 -6
- package/dist/charts/index.js +5 -6
- package/dist/chunk-2GIJBHZT.js +60 -0
- package/dist/{chunk-Z4ICFQXG.js → chunk-2ZRY3ARL.js} +1 -1
- package/dist/{chunk-5B2ZFO44.js → chunk-3H5DIJN7.js} +1 -1
- package/dist/{chunk-LZT2H2MA.js → chunk-47YJVIZE.js} +36 -43
- package/dist/{chunk-3TS5U5BL.js → chunk-5RH6NYZH.js} +1 -1
- package/dist/chunk-5SLRGUC4.js +224 -0
- package/dist/{chunk-JYBJMVNY.js → chunk-5VF5LPYS.js} +1 -1
- package/dist/{chunk-SWKAH2YM.js → chunk-6BJ5HMMC.js} +282 -553
- package/dist/{chunk-NI37YNRP.js → chunk-7OOFMEX6.js} +11 -5
- package/dist/{chunk-IBCEAVB2.js → chunk-A2SB32YV.js} +65 -5
- package/dist/{chunk-CJ2232PQ.js → chunk-CRPH5AAB.js} +1 -1
- package/dist/chunk-D3XXPCCK.js +69 -0
- package/dist/chunk-DMSTDZCJ.js +305 -0
- package/dist/chunk-DTEGVSJ6.js +645 -0
- package/dist/chunk-DVAOCHIF.js +165 -0
- package/dist/chunk-G7O4CBMC.js +231 -0
- package/dist/{chunk-IGBPWD6S.js → chunk-GDTK33QT.js} +5 -3
- package/dist/chunk-ICHDIVQO.js +54 -0
- package/dist/{chunk-U2H3TIHD.js → chunk-IYATYH5I.js} +2 -52
- package/dist/chunk-L3NBMLRN.js +49 -0
- package/dist/{chunk-LEPYXLJ2.js → chunk-LFLM723H.js} +1 -1
- package/dist/chunk-M6VAZAQW.js +45 -0
- package/dist/{chunk-AJOVWB47.js → chunk-MLHZUN2X.js} +6 -3
- package/dist/chunk-N6K2Q5BM.js +393 -0
- package/dist/chunk-NMHQAYZU.js +439 -0
- package/dist/chunk-NYIIRZSA.js +286 -0
- package/dist/{chunk-ETN3TTRT.js → chunk-OGHTJKBV.js} +115 -8
- package/dist/{chunk-M7WWRZ5Z.js → chunk-QFGNRKIE.js} +1 -78
- package/dist/chunk-QFS2GZMV.js +515 -0
- package/dist/{chunk-OCVSPAKM.js → chunk-SB3IHM5Y.js} +1150 -4346
- package/dist/{chunk-4CW2C5BD.js → chunk-SEYOVNS5.js} +1 -1
- package/dist/chunk-SN7X5N2A.js +116 -0
- package/dist/{chunk-PQ4B62HH.js → chunk-TX3UHDL5.js} +2 -2
- package/dist/chunk-VM2OWOXL.js +24 -0
- package/dist/{chunk-ZDKPHFTH.js → chunk-VWGCURZF.js} +5 -3
- package/dist/chunk-WDBNW44Z.js +49 -0
- package/dist/chunk-YQQ5GRUR.js +21 -0
- package/dist/{chunk-NHNTX6ZL.js → chunk-ZG6YJUT4.js} +3 -2
- package/dist/components/index.d.ts +228 -6
- package/dist/components/index.js +321 -35
- package/dist/components/navigation/index.js +6 -7
- package/dist/features/auth/index.d.ts +78 -2
- package/dist/features/auth/index.js +18 -9
- package/dist/features/clients/index.js +7 -7
- package/dist/features/content/index.d.ts +226 -5
- package/dist/features/content/index.js +270 -19
- package/dist/features/crm/index.d.ts +58 -0
- package/dist/features/crm/index.js +10 -8
- package/dist/features/dashboard/index.js +9 -8
- package/dist/features/delivery/index.d.ts +58 -0
- package/dist/features/delivery/index.js +23 -7
- package/dist/features/knowledge/index.js +5 -6
- package/dist/features/lead-gen/index.d.ts +9 -15
- package/dist/features/lead-gen/index.js +12 -8
- package/dist/features/monitoring/index.js +11 -9
- package/dist/features/monitoring/requests/index.js +8 -7
- package/dist/features/operations/index.js +15 -11
- package/dist/features/public-agent-chat/index.js +3 -1
- package/dist/features/settings/index.d.ts +66 -3
- package/dist/features/settings/index.js +9 -8
- package/dist/hooks/access/index.js +5 -6
- package/dist/hooks/delivery/index.d.ts +58 -0
- package/dist/hooks/delivery/index.js +3 -2
- package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +1 -1
- package/dist/hooks/published.d.ts +181 -5
- package/dist/hooks/published.js +22 -6
- package/dist/initialization/index.d.ts +58 -0
- package/dist/knowledge/index.js +167 -11
- package/dist/{knowledge-search-index-RZLIVWPJ.js → knowledge-search-index-6GQK55IQ.js} +1 -1
- package/dist/layout/index.js +8 -9
- package/dist/profile/index.d.ts +58 -0
- package/dist/provider/index.d.ts +77 -1
- package/dist/provider/index.js +5 -6
- package/dist/provider/published.d.ts +105 -1
- package/dist/provider/published.js +5 -6
- package/dist/test-utils/index.d.ts +16 -5
- package/dist/test-utils/index.js +17 -18
- package/dist/types/index.d.ts +73 -1
- package/dist/utils/index.d.ts +83 -3
- package/dist/utils/index.js +1 -1
- package/package.json +10 -5
- package/dist/chunk-6M6OLGQY.js +0 -36
- package/dist/chunk-MKH2KOAO.js +0 -39
- package/dist/hooks/index.css +0 -659
- package/dist/hooks/index.d.ts +0 -14073
- package/dist/hooks/index.js +0 -27
- package/dist/supabase/index.d.ts +0 -7118
- package/dist/supabase/index.js +0 -3
- package/dist/typeform/index.d.ts +0 -462
- package/dist/typeform/index.js +0 -2051
- package/dist/typeform/schemas.d.ts +0 -67
- package/dist/typeform/schemas.js +0 -2
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
import { projectKeys, noteKeys, taskKeys, milestoneKeys } from './chunk-IYATYH5I.js';
|
|
2
|
+
import { leadGenListMemberKeys } from './chunk-DVAOCHIF.js';
|
|
3
|
+
import { companyKeys, contactKeys } from './chunk-NYIIRZSA.js';
|
|
4
|
+
import { useErrorNotification } from './chunk-DMSTDZCJ.js';
|
|
5
|
+
import { useNotificationAdapter, dealKeys, acquisitionListKeys, useListsTelemetry, useOptionalElevasisSystems, useSSEConnection } from './chunk-SB3IHM5Y.js';
|
|
6
|
+
import { HTTP_HEADERS } from './chunk-ZG6YJUT4.js';
|
|
7
|
+
import { showApiErrorNotification, showSuccessNotification } from './chunk-ICHDIVQO.js';
|
|
8
|
+
import { OrganizationContext, useOrganization } from './chunk-DD3CCMCZ.js';
|
|
9
|
+
import { STALE_TIME_DEFAULT, STALE_TIME_ADMIN } from './chunk-A2SB32YV.js';
|
|
10
|
+
import { useElevasisServices } from './chunk-BI5VDO2K.js';
|
|
11
|
+
import { useAuthContext } from './chunk-BRJ3QZ4E.js';
|
|
12
|
+
import { useContext, useEffect, useState, useRef, useCallback, useMemo } from 'react';
|
|
13
|
+
import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
|
|
14
|
+
import { notifications } from '@mantine/notifications';
|
|
15
|
+
import { createClient } from '@supabase/supabase-js';
|
|
16
|
+
|
|
17
|
+
function useCreateOrgRole() {
|
|
18
|
+
const { apiRequest } = useElevasisServices();
|
|
19
|
+
const organization = useContext(OrganizationContext);
|
|
20
|
+
const orgId = organization?.currentSupabaseOrganizationId ?? null;
|
|
21
|
+
const queryClient = useQueryClient();
|
|
22
|
+
return useMutation({
|
|
23
|
+
mutationFn: (input) => apiRequest(`/organizations/${orgId}/roles`, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
body: JSON.stringify(input)
|
|
26
|
+
}),
|
|
27
|
+
onSettled: () => {
|
|
28
|
+
queryClient.invalidateQueries({ queryKey: ["org-roles", orgId] });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// src/hooks/settings/api-keys/apiKeyService.ts
|
|
34
|
+
var ApiKeyService = class {
|
|
35
|
+
constructor(apiRequest) {
|
|
36
|
+
this.apiRequest = apiRequest;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* List API keys for the current organization
|
|
40
|
+
*/
|
|
41
|
+
async listApiKeys() {
|
|
42
|
+
const response = await this.apiRequest("/api-keys");
|
|
43
|
+
return response.keys;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create a new API key
|
|
47
|
+
*/
|
|
48
|
+
async createApiKey(data) {
|
|
49
|
+
return await this.apiRequest("/api-keys", {
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: JSON.stringify(data)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Update an API key's name
|
|
56
|
+
*/
|
|
57
|
+
async updateApiKey(keyId, data) {
|
|
58
|
+
await this.apiRequest(`/api-keys/${keyId}`, {
|
|
59
|
+
method: "PATCH",
|
|
60
|
+
body: JSON.stringify(data)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Delete an API key
|
|
65
|
+
*/
|
|
66
|
+
async deleteApiKey(keyId) {
|
|
67
|
+
await this.apiRequest(`/api-keys/${keyId}`, {
|
|
68
|
+
method: "DELETE"
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
function useListApiKeys() {
|
|
73
|
+
const { apiRequest, workOSOrganizationId, isReady } = useElevasisServices();
|
|
74
|
+
return useQuery({
|
|
75
|
+
queryKey: ["api-keys", workOSOrganizationId],
|
|
76
|
+
queryFn: async () => {
|
|
77
|
+
const service = new ApiKeyService(apiRequest);
|
|
78
|
+
return await service.listApiKeys();
|
|
79
|
+
},
|
|
80
|
+
enabled: isReady
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function useCreateApiKey() {
|
|
84
|
+
const { apiRequest } = useElevasisServices();
|
|
85
|
+
const adapter = useNotificationAdapter();
|
|
86
|
+
const queryClient = useQueryClient();
|
|
87
|
+
return useMutation({
|
|
88
|
+
mutationFn: async (data) => {
|
|
89
|
+
const service = new ApiKeyService(apiRequest);
|
|
90
|
+
return await service.createApiKey(data);
|
|
91
|
+
},
|
|
92
|
+
onSuccess: () => {
|
|
93
|
+
queryClient.invalidateQueries({ queryKey: ["api-keys"] });
|
|
94
|
+
notifications.show({
|
|
95
|
+
title: "Success",
|
|
96
|
+
message: "API key created successfully. Please save it immediately!",
|
|
97
|
+
color: "teal"
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
onError: (error) => {
|
|
101
|
+
console.error("Failed to create API key:", error);
|
|
102
|
+
adapter.apiError(error);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function useDeleteApiKey() {
|
|
107
|
+
const { apiRequest } = useElevasisServices();
|
|
108
|
+
const adapter = useNotificationAdapter();
|
|
109
|
+
const queryClient = useQueryClient();
|
|
110
|
+
return useMutation({
|
|
111
|
+
mutationFn: async (keyId) => {
|
|
112
|
+
const service = new ApiKeyService(apiRequest);
|
|
113
|
+
return await service.deleteApiKey(keyId);
|
|
114
|
+
},
|
|
115
|
+
onSuccess: () => {
|
|
116
|
+
queryClient.invalidateQueries({ queryKey: ["api-keys"] });
|
|
117
|
+
notifications.show({
|
|
118
|
+
title: "Success",
|
|
119
|
+
message: "API key deleted successfully",
|
|
120
|
+
color: "teal"
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
onError: (error) => {
|
|
124
|
+
console.error("Failed to delete API key:", error);
|
|
125
|
+
adapter.apiError(error);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function useUpdateApiKey() {
|
|
130
|
+
const { apiRequest } = useElevasisServices();
|
|
131
|
+
const adapter = useNotificationAdapter();
|
|
132
|
+
const queryClient = useQueryClient();
|
|
133
|
+
return useMutation({
|
|
134
|
+
mutationFn: async ({ keyId, name }) => {
|
|
135
|
+
const service = new ApiKeyService(apiRequest);
|
|
136
|
+
return await service.updateApiKey(keyId, { name });
|
|
137
|
+
},
|
|
138
|
+
onSuccess: () => {
|
|
139
|
+
queryClient.invalidateQueries({ queryKey: ["api-keys"] });
|
|
140
|
+
notifications.show({
|
|
141
|
+
title: "Success",
|
|
142
|
+
message: "API key renamed successfully",
|
|
143
|
+
color: "teal"
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
onError: (error) => {
|
|
147
|
+
console.error("Failed to update API key:", error);
|
|
148
|
+
adapter.apiError(error);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// src/hooks/settings/deployments/deploymentService.ts
|
|
154
|
+
var DeploymentService = class {
|
|
155
|
+
constructor(apiRequest) {
|
|
156
|
+
this.apiRequest = apiRequest;
|
|
157
|
+
}
|
|
158
|
+
async listDeployments() {
|
|
159
|
+
const response = await this.apiRequest("/deployments");
|
|
160
|
+
return response.deployments;
|
|
161
|
+
}
|
|
162
|
+
async getDeployment(id) {
|
|
163
|
+
return await this.apiRequest(`/deployments/${id}`);
|
|
164
|
+
}
|
|
165
|
+
async activateDeployment(id) {
|
|
166
|
+
return await this.apiRequest(`/deployments/${id}/activate`, { method: "POST" });
|
|
167
|
+
}
|
|
168
|
+
async deactivateDeployment(id) {
|
|
169
|
+
return await this.apiRequest(`/deployments/${id}/deactivate`, { method: "POST" });
|
|
170
|
+
}
|
|
171
|
+
async deleteDeployment(id) {
|
|
172
|
+
await this.apiRequest(`/deployments/${id}`, { method: "DELETE" });
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/hooks/settings/deployments/useDeploymentActions.ts
|
|
177
|
+
function useActivateDeployment() {
|
|
178
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
179
|
+
const queryClient = useQueryClient();
|
|
180
|
+
const showError = useErrorNotification();
|
|
181
|
+
return useMutation({
|
|
182
|
+
mutationFn: (deploymentId) => {
|
|
183
|
+
const service = new DeploymentService(apiRequest);
|
|
184
|
+
return service.activateDeployment(deploymentId);
|
|
185
|
+
},
|
|
186
|
+
onSuccess: () => {
|
|
187
|
+
queryClient.invalidateQueries({ queryKey: ["deployments", workOSOrganizationId] });
|
|
188
|
+
notifications.show({ title: "Success", message: "Deployment activated", color: "teal" });
|
|
189
|
+
},
|
|
190
|
+
onError: (error) => {
|
|
191
|
+
console.error("Failed to activate deployment:", error);
|
|
192
|
+
showError(error);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function useDeactivateDeployment() {
|
|
197
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
198
|
+
const queryClient = useQueryClient();
|
|
199
|
+
const showError = useErrorNotification();
|
|
200
|
+
return useMutation({
|
|
201
|
+
mutationFn: (deploymentId) => {
|
|
202
|
+
const service = new DeploymentService(apiRequest);
|
|
203
|
+
return service.deactivateDeployment(deploymentId);
|
|
204
|
+
},
|
|
205
|
+
onSuccess: () => {
|
|
206
|
+
queryClient.invalidateQueries({ queryKey: ["deployments", workOSOrganizationId] });
|
|
207
|
+
notifications.show({ title: "Success", message: "Deployment deactivated", color: "teal" });
|
|
208
|
+
},
|
|
209
|
+
onError: (error) => {
|
|
210
|
+
console.error("Failed to deactivate deployment:", error);
|
|
211
|
+
showError(error);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function useDeleteDeployment() {
|
|
216
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
217
|
+
const queryClient = useQueryClient();
|
|
218
|
+
const showError = useErrorNotification();
|
|
219
|
+
return useMutation({
|
|
220
|
+
mutationFn: (deploymentId) => {
|
|
221
|
+
const service = new DeploymentService(apiRequest);
|
|
222
|
+
return service.deleteDeployment(deploymentId);
|
|
223
|
+
},
|
|
224
|
+
onSuccess: () => {
|
|
225
|
+
queryClient.invalidateQueries({ queryKey: ["deployments", workOSOrganizationId] });
|
|
226
|
+
notifications.show({ title: "Success", message: "Deployment deleted", color: "teal" });
|
|
227
|
+
},
|
|
228
|
+
onError: (error) => {
|
|
229
|
+
console.error("Failed to delete deployment:", error);
|
|
230
|
+
showError(error);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
function useListDeployments() {
|
|
235
|
+
const { apiRequest, workOSOrganizationId, isReady } = useElevasisServices();
|
|
236
|
+
return useQuery({
|
|
237
|
+
queryKey: ["deployments", workOSOrganizationId],
|
|
238
|
+
queryFn: async () => {
|
|
239
|
+
const service = new DeploymentService(apiRequest);
|
|
240
|
+
return await service.listDeployments();
|
|
241
|
+
},
|
|
242
|
+
enabled: isReady,
|
|
243
|
+
refetchInterval: (query) => {
|
|
244
|
+
const deployments = query.state.data ?? [];
|
|
245
|
+
return deployments.some((d) => d.status === "deploying") ? 5e3 : false;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function useTransitionItem() {
|
|
250
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
251
|
+
const queryClient = useQueryClient();
|
|
252
|
+
return useMutation({
|
|
253
|
+
mutationFn: async (input) => {
|
|
254
|
+
const { dealId, pipelineKey, stageKey, stateKey, reason, expectedUpdatedAt } = input;
|
|
255
|
+
await apiRequest(`/deals/${dealId}/transition`, {
|
|
256
|
+
method: "PATCH",
|
|
257
|
+
body: JSON.stringify({
|
|
258
|
+
pipelineKey,
|
|
259
|
+
stageKey,
|
|
260
|
+
...stateKey !== void 0 ? { stateKey } : {},
|
|
261
|
+
...reason !== void 0 ? { reason } : {},
|
|
262
|
+
...expectedUpdatedAt !== void 0 ? { expectedUpdatedAt } : {}
|
|
263
|
+
})
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
onSuccess: (_, variables) => {
|
|
267
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.lists() });
|
|
268
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.summaries() });
|
|
269
|
+
queryClient.invalidateQueries({ queryKey: ["deal-detail", workOSOrganizationId, variables.dealId] });
|
|
270
|
+
},
|
|
271
|
+
onError: (error) => {
|
|
272
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.all });
|
|
273
|
+
showApiErrorNotification(error);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
function getSupabaseConfig() {
|
|
278
|
+
const url = import.meta.env?.VITE_SUPABASE_URL;
|
|
279
|
+
const anonKey = import.meta.env?.VITE_SUPABASE_ANON_KEY;
|
|
280
|
+
if (!url || !anonKey) {
|
|
281
|
+
throw new Error("Missing Supabase environment variables (VITE_SUPABASE_URL, VITE_SUPABASE_ANON_KEY)");
|
|
282
|
+
}
|
|
283
|
+
return { url, anonKey };
|
|
284
|
+
}
|
|
285
|
+
var useSupabase = () => {
|
|
286
|
+
const { getAccessToken } = useAuthContext();
|
|
287
|
+
const { url, anonKey } = getSupabaseConfig();
|
|
288
|
+
return useMemo(
|
|
289
|
+
() => createClient(url, anonKey, {
|
|
290
|
+
global: {
|
|
291
|
+
headers: {
|
|
292
|
+
// Additional headers if needed
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
accessToken: async () => {
|
|
296
|
+
try {
|
|
297
|
+
const token = await getAccessToken();
|
|
298
|
+
if (!token) {
|
|
299
|
+
return null;
|
|
300
|
+
}
|
|
301
|
+
return token;
|
|
302
|
+
} catch {
|
|
303
|
+
return null;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}),
|
|
307
|
+
[getAccessToken, url, anonKey]
|
|
308
|
+
);
|
|
309
|
+
};
|
|
310
|
+
var projectActivityKeys = {
|
|
311
|
+
all: ["project-activities"],
|
|
312
|
+
list: (projectId) => [...projectActivityKeys.all, "list", projectId]
|
|
313
|
+
};
|
|
314
|
+
function useProjectActivities(projectId, enabled = true) {
|
|
315
|
+
const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
|
|
316
|
+
return useQuery({
|
|
317
|
+
queryKey: [...projectActivityKeys.list(projectId), workOSOrganizationId],
|
|
318
|
+
queryFn: async () => {
|
|
319
|
+
const params = new URLSearchParams();
|
|
320
|
+
params.set("entityType", "project");
|
|
321
|
+
params.set("entityId", projectId);
|
|
322
|
+
params.set("limit", "50");
|
|
323
|
+
const res = await apiRequest(`/activities?${params.toString()}`);
|
|
324
|
+
return res.activities.map((activity) => ({
|
|
325
|
+
...activity,
|
|
326
|
+
occurredAt: new Date(activity.occurredAt),
|
|
327
|
+
createdAt: new Date(activity.createdAt)
|
|
328
|
+
}));
|
|
329
|
+
},
|
|
330
|
+
enabled: isReady && !!projectId && enabled
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
function useUpdateOrgRole() {
|
|
334
|
+
const { apiRequest } = useElevasisServices();
|
|
335
|
+
const organization = useContext(OrganizationContext);
|
|
336
|
+
const orgId = organization?.currentSupabaseOrganizationId ?? null;
|
|
337
|
+
const queryClient = useQueryClient();
|
|
338
|
+
return useMutation({
|
|
339
|
+
mutationFn: ({ roleId, input }) => apiRequest(`/organizations/${orgId}/roles/${roleId}`, {
|
|
340
|
+
method: "PATCH",
|
|
341
|
+
body: JSON.stringify(input)
|
|
342
|
+
}),
|
|
343
|
+
onSettled: (_data, _error, { roleId }) => {
|
|
344
|
+
queryClient.invalidateQueries({ queryKey: ["org-roles", orgId] });
|
|
345
|
+
queryClient.invalidateQueries({ queryKey: ["org-role", orgId, roleId] });
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
function useDeleteOrgRole() {
|
|
350
|
+
const { apiRequest } = useElevasisServices();
|
|
351
|
+
const organization = useContext(OrganizationContext);
|
|
352
|
+
const orgId = organization?.currentSupabaseOrganizationId ?? null;
|
|
353
|
+
const queryClient = useQueryClient();
|
|
354
|
+
return useMutation({
|
|
355
|
+
mutationFn: (roleId) => apiRequest(`/organizations/${orgId}/roles/${roleId}`, {
|
|
356
|
+
method: "DELETE"
|
|
357
|
+
}),
|
|
358
|
+
onSettled: () => {
|
|
359
|
+
queryClient.invalidateQueries({ queryKey: ["org-roles", orgId] });
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function useEffectivePermissions(membershipId) {
|
|
364
|
+
const { apiRequest, isReady } = useElevasisServices();
|
|
365
|
+
const organization = useContext(OrganizationContext);
|
|
366
|
+
const orgId = organization?.currentSupabaseOrganizationId ?? null;
|
|
367
|
+
return useQuery({
|
|
368
|
+
queryKey: ["member-roles", orgId, membershipId],
|
|
369
|
+
queryFn: () => apiRequest(`/memberships/${membershipId}/effective-permissions`),
|
|
370
|
+
enabled: isReady && !!membershipId,
|
|
371
|
+
staleTime: STALE_TIME_DEFAULT
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
function useActivitiesRealtime(organizationId, enabled) {
|
|
375
|
+
const queryClient = useQueryClient();
|
|
376
|
+
const supabase = useSupabase();
|
|
377
|
+
useEffect(() => {
|
|
378
|
+
if (!enabled || !organizationId) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
const channel = supabase.channel(`activities-realtime-${organizationId}`).on(
|
|
382
|
+
"postgres_changes",
|
|
383
|
+
{
|
|
384
|
+
event: "INSERT",
|
|
385
|
+
schema: "public",
|
|
386
|
+
table: "activities",
|
|
387
|
+
filter: `organization_id=eq.${organizationId}`
|
|
388
|
+
},
|
|
389
|
+
() => {
|
|
390
|
+
queryClient.invalidateQueries({ queryKey: ["activities"] });
|
|
391
|
+
}
|
|
392
|
+
).subscribe();
|
|
393
|
+
return () => {
|
|
394
|
+
void supabase.removeChannel(channel);
|
|
395
|
+
};
|
|
396
|
+
}, [organizationId, enabled, queryClient, supabase]);
|
|
397
|
+
}
|
|
398
|
+
function useResourceErrors({ resourceId, timeRange, hasFailures }) {
|
|
399
|
+
const { apiRequest, workOSOrganizationId, isReady } = useElevasisServices();
|
|
400
|
+
return useQuery({
|
|
401
|
+
queryKey: ["resource-errors", workOSOrganizationId, resourceId, timeRange],
|
|
402
|
+
queryFn: async () => {
|
|
403
|
+
return apiRequest(
|
|
404
|
+
`/command-view/resource-errors?resourceId=${resourceId}&timeRange=${timeRange}`
|
|
405
|
+
);
|
|
406
|
+
},
|
|
407
|
+
// Only fetch when: org ready, resource selected, and resource has failures
|
|
408
|
+
enabled: isReady && !!resourceId && hasFailures,
|
|
409
|
+
staleTime: STALE_TIME_ADMIN
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function useTransitionState() {
|
|
413
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
414
|
+
const queryClient = useQueryClient();
|
|
415
|
+
return useMutation({
|
|
416
|
+
mutationFn: async (input) => {
|
|
417
|
+
const { dealId, stateKey, reason, expectedUpdatedAt } = input;
|
|
418
|
+
await apiRequest(`/deals/${dealId}/state`, {
|
|
419
|
+
method: "PATCH",
|
|
420
|
+
body: JSON.stringify({
|
|
421
|
+
stateKey,
|
|
422
|
+
...reason !== void 0 ? { reason } : {},
|
|
423
|
+
...expectedUpdatedAt !== void 0 ? { expectedUpdatedAt } : {}
|
|
424
|
+
})
|
|
425
|
+
});
|
|
426
|
+
},
|
|
427
|
+
onSuccess: (_, variables) => {
|
|
428
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.lists() });
|
|
429
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.summaries() });
|
|
430
|
+
queryClient.invalidateQueries({ queryKey: ["deal-detail", workOSOrganizationId, variables.dealId] });
|
|
431
|
+
},
|
|
432
|
+
onError: (error) => {
|
|
433
|
+
queryClient.invalidateQueries({ queryKey: dealKeys.all });
|
|
434
|
+
showApiErrorNotification(error);
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
var dealNoteKeys = {
|
|
439
|
+
all: ["deal-notes"],
|
|
440
|
+
list: (organizationId, dealId) => ["deal-notes", organizationId, dealId]
|
|
441
|
+
};
|
|
442
|
+
function useDealNotes(dealId) {
|
|
443
|
+
const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
|
|
444
|
+
return useQuery({
|
|
445
|
+
queryKey: dealNoteKeys.list(workOSOrganizationId, dealId),
|
|
446
|
+
queryFn: async () => {
|
|
447
|
+
return apiRequest(`/deals/${dealId}/notes`);
|
|
448
|
+
},
|
|
449
|
+
enabled: isReady && !!dealId
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
function useCreateDealNote() {
|
|
453
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
454
|
+
const queryClient = useQueryClient();
|
|
455
|
+
return useMutation({
|
|
456
|
+
mutationFn: async ({ dealId, body }) => {
|
|
457
|
+
return apiRequest(`/deals/${dealId}/notes`, {
|
|
458
|
+
method: "POST",
|
|
459
|
+
body: JSON.stringify({ body })
|
|
460
|
+
});
|
|
461
|
+
},
|
|
462
|
+
onSuccess: (_, variables) => {
|
|
463
|
+
queryClient.invalidateQueries({ queryKey: dealNoteKeys.list(workOSOrganizationId, variables.dealId) });
|
|
464
|
+
queryClient.invalidateQueries({ queryKey: ["recent-crm-activity", workOSOrganizationId] });
|
|
465
|
+
showSuccessNotification("Note added");
|
|
466
|
+
},
|
|
467
|
+
onError: (error) => {
|
|
468
|
+
showApiErrorNotification(error);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
function useAddCompaniesToList(listId) {
|
|
473
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
474
|
+
const queryClient = useQueryClient();
|
|
475
|
+
return useMutation({
|
|
476
|
+
mutationFn: (body) => apiRequest(`/acquisition/lists/${listId}/companies`, {
|
|
477
|
+
method: "POST",
|
|
478
|
+
body: JSON.stringify(body)
|
|
479
|
+
}),
|
|
480
|
+
onSuccess: () => {
|
|
481
|
+
queryClient.invalidateQueries({ queryKey: companyKeys.all });
|
|
482
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(workOSOrganizationId, listId) });
|
|
483
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.progress(workOSOrganizationId, listId) });
|
|
484
|
+
queryClient.invalidateQueries({ queryKey: leadGenListMemberKeys.list(workOSOrganizationId, listId) });
|
|
485
|
+
showSuccessNotification("Companies added to list");
|
|
486
|
+
},
|
|
487
|
+
onError: (error) => {
|
|
488
|
+
showApiErrorNotification(error);
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
function useRemoveCompaniesFromList(listId) {
|
|
493
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
494
|
+
const queryClient = useQueryClient();
|
|
495
|
+
return useMutation({
|
|
496
|
+
mutationFn: (body) => apiRequest(`/acquisition/lists/${listId}/companies`, {
|
|
497
|
+
method: "DELETE",
|
|
498
|
+
body: JSON.stringify(body)
|
|
499
|
+
}),
|
|
500
|
+
onSuccess: () => {
|
|
501
|
+
queryClient.invalidateQueries({ queryKey: companyKeys.all });
|
|
502
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(workOSOrganizationId, listId) });
|
|
503
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.progress(workOSOrganizationId, listId) });
|
|
504
|
+
queryClient.invalidateQueries({ queryKey: leadGenListMemberKeys.list(workOSOrganizationId, listId) });
|
|
505
|
+
showSuccessNotification("Companies removed from list");
|
|
506
|
+
},
|
|
507
|
+
onError: (error) => {
|
|
508
|
+
showApiErrorNotification(error);
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
function useAddContactsToList(listId) {
|
|
513
|
+
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
514
|
+
const queryClient = useQueryClient();
|
|
515
|
+
return useMutation({
|
|
516
|
+
mutationFn: (body) => apiRequest(`/acquisition/lists/${listId}/contacts`, {
|
|
517
|
+
method: "POST",
|
|
518
|
+
body: JSON.stringify(body)
|
|
519
|
+
}),
|
|
520
|
+
onSuccess: () => {
|
|
521
|
+
queryClient.invalidateQueries({ queryKey: contactKeys.all });
|
|
522
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.detail(workOSOrganizationId, listId) });
|
|
523
|
+
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.progress(workOSOrganizationId, listId) });
|
|
524
|
+
queryClient.invalidateQueries({ queryKey: leadGenListMemberKeys.list(workOSOrganizationId, listId) });
|
|
525
|
+
showSuccessNotification("Contacts added to list");
|
|
526
|
+
},
|
|
527
|
+
onError: (error) => {
|
|
528
|
+
showApiErrorNotification(error);
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// src/hooks/acquisition/useBatchTelemetry.ts
|
|
534
|
+
function useBatchTelemetry() {
|
|
535
|
+
return useListsTelemetry();
|
|
536
|
+
}
|
|
537
|
+
function useVisibleResources() {
|
|
538
|
+
const [visibleIds, setVisibleIds] = useState(/* @__PURE__ */ new Set());
|
|
539
|
+
const observerRef = useRef(null);
|
|
540
|
+
const containerRef = useRef(null);
|
|
541
|
+
useEffect(() => {
|
|
542
|
+
observerRef.current = new IntersectionObserver(
|
|
543
|
+
(entries) => {
|
|
544
|
+
setVisibleIds((prev) => {
|
|
545
|
+
const next = new Set(prev);
|
|
546
|
+
for (const entry of entries) {
|
|
547
|
+
const id = entry.target.dataset.resourceId;
|
|
548
|
+
if (!id) continue;
|
|
549
|
+
if (entry.isIntersecting) {
|
|
550
|
+
next.add(id);
|
|
551
|
+
} else {
|
|
552
|
+
next.delete(id);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return next;
|
|
556
|
+
});
|
|
557
|
+
},
|
|
558
|
+
{ threshold: 0.5 }
|
|
559
|
+
);
|
|
560
|
+
return () => {
|
|
561
|
+
observerRef.current?.disconnect();
|
|
562
|
+
};
|
|
563
|
+
}, []);
|
|
564
|
+
useEffect(() => {
|
|
565
|
+
const observer = observerRef.current;
|
|
566
|
+
const container = containerRef.current;
|
|
567
|
+
if (!observer || !container) return;
|
|
568
|
+
const cards = container.querySelectorAll("[data-resource-id]");
|
|
569
|
+
cards.forEach((card) => observer.observe(card));
|
|
570
|
+
return () => {
|
|
571
|
+
cards.forEach((card) => observer.unobserve(card));
|
|
572
|
+
};
|
|
573
|
+
});
|
|
574
|
+
const setContainerRef = useCallback((node) => {
|
|
575
|
+
containerRef.current = node;
|
|
576
|
+
}, []);
|
|
577
|
+
return { visibleIds, setContainerRef };
|
|
578
|
+
}
|
|
579
|
+
var noopSSEManager = {
|
|
580
|
+
subscribe: () => () => {
|
|
581
|
+
},
|
|
582
|
+
closeConnection: () => {
|
|
583
|
+
},
|
|
584
|
+
getConnectionInfo: () => /* @__PURE__ */ new Map()
|
|
585
|
+
};
|
|
586
|
+
function useProjectRealtime(projectId) {
|
|
587
|
+
const queryClient = useQueryClient();
|
|
588
|
+
const systems = useOptionalElevasisSystems();
|
|
589
|
+
const { isReady, workOSOrganizationId } = useElevasisServices();
|
|
590
|
+
const { currentMembership } = useOrganization();
|
|
591
|
+
const deliveryApiUrl = systems?.deliveryApiUrl;
|
|
592
|
+
const deliverySSEManager = systems?.deliverySSEManager ?? noopSSEManager;
|
|
593
|
+
const currentWorkOSOrganizationId = currentMembership?.organization?.workos_org_id;
|
|
594
|
+
const headers = useMemo(() => {
|
|
595
|
+
if (!currentWorkOSOrganizationId) {
|
|
596
|
+
return {};
|
|
597
|
+
}
|
|
598
|
+
const nextHeaders = {};
|
|
599
|
+
nextHeaders[HTTP_HEADERS.WORKOS_ORGANIZATION_ID] = currentWorkOSOrganizationId;
|
|
600
|
+
return nextHeaders;
|
|
601
|
+
}, [currentWorkOSOrganizationId]);
|
|
602
|
+
const handleMessage = useCallback(
|
|
603
|
+
(rawData) => {
|
|
604
|
+
try {
|
|
605
|
+
const event = JSON.parse(rawData);
|
|
606
|
+
if (event.type !== "entity_changed") {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
const { entityType, projectId: changedProjectId } = event.data;
|
|
610
|
+
queryClient.invalidateQueries({ queryKey: projectKeys.all });
|
|
611
|
+
queryClient.invalidateQueries({ queryKey: projectKeys.detail(changedProjectId) });
|
|
612
|
+
queryClient.invalidateQueries({ queryKey: projectActivityKeys.list(changedProjectId) });
|
|
613
|
+
switch (entityType) {
|
|
614
|
+
case "milestone":
|
|
615
|
+
queryClient.invalidateQueries({ queryKey: milestoneKeys.all });
|
|
616
|
+
queryClient.invalidateQueries({ queryKey: projectKeys.milestones(changedProjectId) });
|
|
617
|
+
break;
|
|
618
|
+
case "task":
|
|
619
|
+
queryClient.invalidateQueries({ queryKey: taskKeys.all });
|
|
620
|
+
queryClient.invalidateQueries({ queryKey: projectKeys.tasks(changedProjectId) });
|
|
621
|
+
break;
|
|
622
|
+
case "note":
|
|
623
|
+
queryClient.invalidateQueries({ queryKey: noteKeys.all });
|
|
624
|
+
break;
|
|
625
|
+
case "activity":
|
|
626
|
+
case "project":
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
} catch {
|
|
630
|
+
}
|
|
631
|
+
},
|
|
632
|
+
[queryClient]
|
|
633
|
+
);
|
|
634
|
+
useSSEConnection({
|
|
635
|
+
manager: deliverySSEManager,
|
|
636
|
+
connectionKey: `delivery-${currentWorkOSOrganizationId ?? workOSOrganizationId ?? projectId ?? "unknown"}`,
|
|
637
|
+
url: deliveryApiUrl ? `${deliveryApiUrl}/api/projects/sse` : "",
|
|
638
|
+
enabled: Boolean(deliveryApiUrl && systems?.deliverySSEManager && currentWorkOSOrganizationId && isReady),
|
|
639
|
+
headers,
|
|
640
|
+
onmessage: handleMessage,
|
|
641
|
+
onopen: (response) => response.status === 403 ? "Organization access denied" : void 0
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
export { ApiKeyService, DeploymentService, dealNoteKeys, projectActivityKeys, useActivateDeployment, useActivitiesRealtime, useAddCompaniesToList, useAddContactsToList, useBatchTelemetry, useCreateApiKey, useCreateDealNote, useCreateOrgRole, useDeactivateDeployment, useDealNotes, useDeleteApiKey, useDeleteDeployment, useDeleteOrgRole, useEffectivePermissions, useListApiKeys, useListDeployments, useProjectActivities, useProjectRealtime, useRemoveCompaniesFromList, useResourceErrors, useTransitionItem, useTransitionState, useUpdateApiKey, useUpdateOrgRole, useVisibleResources };
|