@elevasis/ui 2.33.2 → 2.35.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.
Files changed (116) hide show
  1. package/dist/api/index.d.ts +9 -2
  2. package/dist/api/index.js +3 -3
  3. package/dist/app/index.css +452 -0
  4. package/dist/app/index.d.ts +1255 -8
  5. package/dist/app/index.js +151 -13
  6. package/dist/charts/index.js +3 -6
  7. package/dist/chunk-26HFM4MH.js +41449 -0
  8. package/dist/{chunk-52K5RFDH.js → chunk-4U3XAWCN.js} +1328 -2492
  9. package/dist/{chunk-ND5TDV2J.js → chunk-57OZ3AEG.js} +1 -1
  10. package/dist/{chunk-E4WQGJNS.js → chunk-7FPLLSHN.js} +14 -1
  11. package/dist/{chunk-RQA2EVN3.js → chunk-AKW7KISS.js} +39 -3
  12. package/dist/chunk-AUDNF2Q7.js +2050 -0
  13. package/dist/{chunk-TYRUKGGD.js → chunk-GX6XBRRF.js} +1 -2
  14. package/dist/{chunk-V6SZ4ECN.js → chunk-LUYVRATI.js} +257 -6
  15. package/dist/{chunk-X4WBGKJQ.js → chunk-R3VCBZDC.js} +50 -3
  16. package/dist/chunk-SIQ3P4OR.js +1764 -0
  17. package/dist/{chunk-Z2K2EAPL.js → chunk-VDOOGGBA.js} +5 -6
  18. package/dist/{chunk-3FV6HBXS.js → chunk-WF7CONXF.js} +23 -23
  19. package/dist/chunk-YYX7OPZQ.js +25 -0
  20. package/dist/components/index.d.ts +69 -92
  21. package/dist/components/index.js +20 -3216
  22. package/dist/components/navigation/index.js +25 -7
  23. package/dist/execution/index.d.ts +9 -9
  24. package/dist/execution/index.js +1 -2
  25. package/dist/features/auth/index.js +23 -2
  26. package/dist/features/clients/index.js +20 -31
  27. package/dist/features/crm/index.js +20 -35
  28. package/dist/features/dashboard/index.d.ts +68 -91
  29. package/dist/features/dashboard/index.js +20 -33
  30. package/dist/features/delivery/index.js +20 -35
  31. package/dist/features/knowledge/index.js +25 -11
  32. package/dist/features/lead-gen/index.d.ts +9 -9
  33. package/dist/features/lead-gen/index.js +20 -36
  34. package/dist/features/monitoring/index.js +20 -35
  35. package/dist/features/monitoring/requests/index.js +20 -30
  36. package/dist/features/operations/index.d.ts +197 -188
  37. package/dist/features/operations/index.js +18 -42
  38. package/dist/features/seo/index.js +3 -4
  39. package/dist/features/settings/index.js +20 -32
  40. package/dist/graph/index.js +1 -1
  41. package/dist/hooks/delivery/index.js +30 -2
  42. package/dist/hooks/index.d.ts +105 -112
  43. package/dist/hooks/index.js +20 -26
  44. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +55 -62
  45. package/dist/hooks/published.d.ts +105 -112
  46. package/dist/hooks/published.js +20 -25
  47. package/dist/index.css +532 -532
  48. package/dist/index.d.ts +10261 -6793
  49. package/dist/index.js +22 -31
  50. package/dist/knowledge/index.d.ts +51 -59
  51. package/dist/knowledge/index.js +40 -211
  52. package/dist/{knowledge-search-index-VMAW7FLR.js → knowledge-search-index-ORIJCEZX.js} +3 -3
  53. package/dist/layout/index.js +4 -10
  54. package/dist/organization/index.js +27 -2
  55. package/dist/provider/index.d.ts +71 -52
  56. package/dist/provider/index.js +20 -20
  57. package/dist/provider/published.d.ts +39 -47
  58. package/dist/provider/published.js +20 -15
  59. package/dist/test-utils/index.d.ts +2 -0
  60. package/dist/test-utils/index.js +16 -4
  61. package/dist/test-utils/setup.js +38 -0
  62. package/dist/theme/index.js +2 -3
  63. package/dist/theme/presets/index.d.ts +28 -3
  64. package/dist/theme/presets/index.js +1 -1
  65. package/dist/typeform/index.js +1 -2049
  66. package/dist/types/index.d.ts +88 -95
  67. package/dist/utils/index.d.ts +46 -69
  68. package/dist/utils/index.js +1 -1
  69. package/dist/zustand/index.d.ts +21 -8
  70. package/dist/zustand/index.js +32 -1
  71. package/package.json +5 -5
  72. package/dist/chunk-2ZZ72TAB.js +0 -2281
  73. package/dist/chunk-32I2RCGC.js +0 -85
  74. package/dist/chunk-3MEXPLWT.js +0 -265
  75. package/dist/chunk-3ZMAGTWF.js +0 -18
  76. package/dist/chunk-44I4LOH6.js +0 -1593
  77. package/dist/chunk-4DYOXEH6.js +0 -951
  78. package/dist/chunk-7M2VOCYN.js +0 -1
  79. package/dist/chunk-A4VDJJCV.js +0 -1864
  80. package/dist/chunk-BZZCNLT6.js +0 -12
  81. package/dist/chunk-CLDCYJQT.js +0 -1
  82. package/dist/chunk-E565XMTQ.js +0 -17
  83. package/dist/chunk-EPTHX4VZ.js +0 -749
  84. package/dist/chunk-GWGQI6V4.js +0 -447
  85. package/dist/chunk-HUJCU55S.js +0 -159
  86. package/dist/chunk-IBWMR4TI.js +0 -469
  87. package/dist/chunk-IIMU5YAJ.js +0 -53
  88. package/dist/chunk-IOXOPMYS.js +0 -145
  89. package/dist/chunk-J2UD7BOH.js +0 -347
  90. package/dist/chunk-JA5ECJJB.js +0 -387
  91. package/dist/chunk-JFL3GRD4.js +0 -39
  92. package/dist/chunk-KW7ZNQD7.js +0 -126
  93. package/dist/chunk-LGKLC5MG.js +0 -44
  94. package/dist/chunk-N55DVMAG.js +0 -14
  95. package/dist/chunk-O56ESZCQ.js +0 -1874
  96. package/dist/chunk-OIBHQH5Q.js +0 -96
  97. package/dist/chunk-PDHTXPSF.js +0 -12
  98. package/dist/chunk-QDFJSUG3.js +0 -13
  99. package/dist/chunk-R2XR4FCV.js +0 -48
  100. package/dist/chunk-R66W5UDG.js +0 -26
  101. package/dist/chunk-RYTEQBAO.js +0 -37
  102. package/dist/chunk-SZHARWKU.js +0 -15
  103. package/dist/chunk-T3J6U77J.js +0 -12056
  104. package/dist/chunk-TBVLQRXT.js +0 -68
  105. package/dist/chunk-TGVAIWIL.js +0 -1778
  106. package/dist/chunk-TKAYX2SP.js +0 -204
  107. package/dist/chunk-TUMSNGTX.js +0 -35
  108. package/dist/chunk-VGU4ZFYZ.js +0 -4752
  109. package/dist/chunk-VNAZTCHA.js +0 -65
  110. package/dist/chunk-VNFR57DF.js +0 -87
  111. package/dist/chunk-WKW6B5ID.js +0 -29
  112. package/dist/chunk-XCYKC6OZ.js +0 -1
  113. package/dist/chunk-XZGSCABI.js +0 -383
  114. package/dist/chunk-ZMK5Z6KE.js +0 -5198
  115. /package/dist/{chunk-2RJMVWFJ.js → chunk-GEFWMU26.js} +0 -0
  116. /package/dist/{chunk-22UVE3RA.js → chunk-HENXLGVD.js} +0 -0
@@ -1,65 +0,0 @@
1
- import { useElevasisServices } from './chunk-KJ3QUBNU.js';
2
- import { useQuery } from '@tanstack/react-query';
3
-
4
- // src/hooks/observability/queryKeys.ts
5
- var observabilityKeys = {
6
- all: ["observability"],
7
- // Error analysis
8
- errorAnalysis: (organizationId, timeRange) => [...observabilityKeys.all, "error-analysis", organizationId, timeRange],
9
- // Error details list
10
- errorDetails: (organizationId, filters) => [...observabilityKeys.all, "error-details", organizationId, filters],
11
- // Single execution error detail
12
- errorDetail: (organizationId, executionId) => [...observabilityKeys.all, "error-detail", organizationId, executionId],
13
- // Error trends time-series
14
- errorTrends: (organizationId, startDate, endDate, granularity) => [...observabilityKeys.all, "error-trends", organizationId, startDate, endDate, granularity],
15
- // Error distribution breakdown
16
- errorDistribution: (organizationId, startDate, endDate, groupBy) => [...observabilityKeys.all, "error-distribution", organizationId, startDate, endDate, groupBy],
17
- // Top failing resources
18
- topFailingResources: (organizationId, startDate, endDate, limit) => [...observabilityKeys.all, "top-failing-resources", organizationId, startDate, endDate, limit],
19
- // Cost trends time-series
20
- costTrends: (organizationId, timeRange, granularity) => [...observabilityKeys.all, "cost-trends", organizationId, timeRange, granularity],
21
- // Cost by model breakdown
22
- costByModel: (organizationId, timeRange) => [...observabilityKeys.all, "cost-by-model", organizationId, timeRange],
23
- // Cost breakdown per resource/model
24
- costBreakdown: (organizationId, timeRange) => [...observabilityKeys.all, "cost-breakdown", organizationId, timeRange],
25
- // Composite dashboard metrics
26
- dashboardMetrics: (organizationId, timeRange) => [...observabilityKeys.all, "dashboard-metrics", organizationId, timeRange],
27
- // Business impact / automation ROI
28
- businessImpact: (organizationId, timeRange) => [...observabilityKeys.all, "business-impact", organizationId, timeRange],
29
- // Resources health batch
30
- resourcesHealth: (organizationId, resources, startDate, endDate, granularity) => [...observabilityKeys.all, "resources-health", organizationId, resources, startDate, endDate, granularity],
31
- // System-scoped health from direct/descendant resource descriptors
32
- systemHealth: (organizationId, systemPath, timeRange, includeDescendants, descendantMode, resourceSet, startDate, endDate, directResources, descendantResources) => [
33
- ...observabilityKeys.all,
34
- "system-health",
35
- organizationId,
36
- systemPath,
37
- timeRange,
38
- includeDescendants,
39
- descendantMode,
40
- resourceSet,
41
- startDate,
42
- endDate,
43
- directResources,
44
- descendantResources
45
- ],
46
- // Unresolved errors dashboard teaser
47
- unresolvedErrors: (organizationId, startDate, endDate) => [...observabilityKeys.all, "unresolved-errors", organizationId, startDate, endDate],
48
- // Recent executions grouped by resource (dashboard widget)
49
- recentExecutionsByResource: (organizationId, timeRange, limit) => [...observabilityKeys.all, "recent-executions-by-resource", organizationId, timeRange, limit]
50
- };
51
- function useErrorTrends({ startDate, endDate, granularity }) {
52
- const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
53
- return useQuery({
54
- queryKey: observabilityKeys.errorTrends(workOSOrganizationId, startDate, endDate, granularity),
55
- queryFn: async () => {
56
- const params = new URLSearchParams({ startDate, endDate, granularity });
57
- return apiRequest(`/observability/error-analytics/trends?${params.toString()}`);
58
- },
59
- enabled: isReady,
60
- refetchInterval: 6e4,
61
- staleTime: 3e4
62
- });
63
- }
64
-
65
- export { observabilityKeys, useErrorTrends };
@@ -1,87 +0,0 @@
1
- import { CustomModal } from './chunk-R66W5UDG.js';
2
- import { cloneElement } from 'react';
3
- import { Center, Space, Text, Button, Title, TextInput } from '@mantine/core';
4
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
-
6
- var ConfirmationModal = ({
7
- opened,
8
- onClose,
9
- loading,
10
- icon,
11
- confirmationHandler,
12
- style,
13
- title,
14
- text,
15
- buttonText,
16
- buttonColor,
17
- centerText
18
- }) => {
19
- const styledIcon = cloneElement(icon, {
20
- size: 55,
21
- strokeWidth: 1.5
22
- });
23
- return /* @__PURE__ */ jsxs(CustomModal, { opened, onClose, loading, style, children: [
24
- /* @__PURE__ */ jsx(Center, { children: styledIcon }),
25
- /* @__PURE__ */ jsx(Space, { h: 16 }),
26
- /* @__PURE__ */ jsx(Center, { style: { textAlign: "center" }, children: /* @__PURE__ */ jsx(Text, { size: "lg", c: "var(--color-text)", children: title }) }),
27
- /* @__PURE__ */ jsx(Space, { h: 16 }),
28
- text && /* @__PURE__ */ jsxs(Fragment, { children: [
29
- /* @__PURE__ */ jsx(Text, { size: "sm", c: "var(--color-text-dimmed)", style: { textAlign: centerText ? "center" : "left" }, children: text }),
30
- /* @__PURE__ */ jsx(Space, { h: 16 })
31
- ] }),
32
- /* @__PURE__ */ jsx(Button, { color: buttonColor || "blue", fullWidth: true, onClick: confirmationHandler, loading, children: buttonText || "Confirm" })
33
- ] });
34
- };
35
- var ConfirmationInputModal = ({
36
- opened,
37
- onClose,
38
- loading,
39
- icon,
40
- confirmationHandler,
41
- style,
42
- title,
43
- text,
44
- buttonText,
45
- buttonColor,
46
- inputValue,
47
- onInputChange,
48
- expectedValue,
49
- placeholder
50
- }) => {
51
- const styledIcon = cloneElement(icon, {
52
- size: 55,
53
- strokeWidth: 1.5
54
- });
55
- return /* @__PURE__ */ jsxs(CustomModal, { opened, onClose, loading, style, children: [
56
- /* @__PURE__ */ jsx(Center, { children: styledIcon }),
57
- /* @__PURE__ */ jsx(Space, { h: 16 }),
58
- /* @__PURE__ */ jsx(Center, { children: /* @__PURE__ */ jsx(Title, { order: 3, children: title }) }),
59
- /* @__PURE__ */ jsx(Space, { h: 16 }),
60
- text && /* @__PURE__ */ jsxs(Fragment, { children: [
61
- /* @__PURE__ */ jsx(Text, { size: "sm", c: "var(--color-text-dimmed)", children: text }),
62
- /* @__PURE__ */ jsx(Space, { h: 8 })
63
- ] }),
64
- /* @__PURE__ */ jsx(
65
- TextInput,
66
- {
67
- placeholder: placeholder || "Enter confirmation text",
68
- value: inputValue,
69
- onChange: (event) => onInputChange(event.currentTarget.value)
70
- }
71
- ),
72
- /* @__PURE__ */ jsx(Space, { h: 16 }),
73
- /* @__PURE__ */ jsx(
74
- Button,
75
- {
76
- color: buttonColor || "blue",
77
- fullWidth: true,
78
- onClick: confirmationHandler,
79
- loading,
80
- disabled: inputValue !== expectedValue,
81
- children: buttonText || "Confirm"
82
- }
83
- )
84
- ] });
85
- };
86
-
87
- export { ConfirmationInputModal, ConfirmationModal };
@@ -1,29 +0,0 @@
1
- import { FeatureUnavailableState } from './chunk-EPTHX4VZ.js';
2
- import { useElevasisSystems } from './chunk-IBWMR4TI.js';
3
- import { SubshellContainer, SubshellSidebar, SubshellRightSideContainer } from './chunk-TKAYX2SP.js';
4
- import { useRouterContext } from './chunk-Q7DJKLEN.js';
5
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
6
-
7
- var defaultSystemSidebarWidth = 250;
8
- function SystemShell({ children }) {
9
- const { shellRuntime } = useElevasisSystems();
10
- const { currentPath } = useRouterContext();
11
- const routeMatch = shellRuntime.resolveRoute(currentPath);
12
- if (routeMatch.status === "hidden") {
13
- return /* @__PURE__ */ jsx(FeatureUnavailableState, { path: currentPath });
14
- }
15
- if (routeMatch.status !== "matched" || !routeMatch.system?.sidebar) {
16
- return /* @__PURE__ */ jsx(Fragment, { children });
17
- }
18
- const SidebarComponent = routeMatch.system.sidebar;
19
- const sidebarWidth = typeof routeMatch.system.sidebarWidth === "function" ? routeMatch.system.sidebarWidth({ currentPath }) : routeMatch.system.sidebarWidth ?? defaultSystemSidebarWidth;
20
- if (sidebarWidth === 0) {
21
- return /* @__PURE__ */ jsx(Fragment, { children });
22
- }
23
- return /* @__PURE__ */ jsxs(SubshellContainer, { children: [
24
- /* @__PURE__ */ jsx(SubshellSidebar, { width: sidebarWidth, children: /* @__PURE__ */ jsx(SidebarComponent, {}) }),
25
- /* @__PURE__ */ jsx(SubshellRightSideContainer, { children })
26
- ] });
27
- }
28
-
29
- export { SystemShell };
@@ -1 +0,0 @@
1
-
@@ -1,383 +0,0 @@
1
- import { getErrorInfo, formatErrorMessage, getErrorTitle } from './chunk-2RJMVWFJ.js';
2
- import { useElevasisServices } from './chunk-KJ3QUBNU.js';
3
- import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
4
- import { notifications } from '@mantine/notifications';
5
-
6
- var showInfoNotification = (message) => {
7
- notifications.show({
8
- title: "Info",
9
- message,
10
- autoClose: 5e3,
11
- color: "blue",
12
- position: "top-right"
13
- });
14
- };
15
- var showSuccessNotification = (message) => {
16
- notifications.show({
17
- title: "Action Successful",
18
- message,
19
- autoClose: 5e3,
20
- color: "green",
21
- position: "top-right"
22
- });
23
- };
24
- var showErrorNotification = (error) => {
25
- if (error instanceof Error) {
26
- error = error.message;
27
- }
28
- notifications.show({
29
- title: "Action Failed",
30
- message: error,
31
- autoClose: 5e3,
32
- color: "red",
33
- position: "top-right"
34
- });
35
- };
36
- var showWarningNotification = (message) => {
37
- notifications.show({
38
- title: "Warning",
39
- message,
40
- autoClose: 5e3,
41
- color: "orange",
42
- position: "top-right"
43
- });
44
- };
45
- var showApiErrorNotification = (error) => {
46
- const { message, code, requestId, fields, retryAfter } = getErrorInfo(error);
47
- notifications.show({
48
- title: getErrorTitle(code),
49
- message: formatErrorMessage(message, requestId, fields, retryAfter),
50
- autoClose: retryAfter ? retryAfter * 1e3 : 5e3,
51
- color: "red",
52
- position: "top-right"
53
- });
54
- };
55
- var milestoneKeys = {
56
- all: ["project-milestones"],
57
- lists: () => [...milestoneKeys.all, "list"],
58
- list: (orgId, filters) => [...milestoneKeys.all, "list", orgId, filters],
59
- details: () => [...milestoneKeys.all, "detail"],
60
- detail: (id) => [...milestoneKeys.all, "detail", id]
61
- };
62
- function useMilestones(filters = {}) {
63
- const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
64
- return useQuery({
65
- queryKey: milestoneKeys.list(workOSOrganizationId, filters),
66
- queryFn: async () => {
67
- const res = await apiRequest(`/projects/${filters.projectId}/milestones`);
68
- return res.milestones;
69
- },
70
- enabled: isReady && !!filters.projectId
71
- });
72
- }
73
- function useCreateMilestone() {
74
- const { apiRequest } = useElevasisServices();
75
- const queryClient = useQueryClient();
76
- return useMutation({
77
- mutationFn: async (params) => {
78
- const { project_id, ...body } = params;
79
- if (!project_id) throw new Error("project_id is required to create a milestone");
80
- const res = await apiRequest(`/projects/${project_id}/milestones`, {
81
- method: "POST",
82
- body: JSON.stringify(body)
83
- });
84
- return res.milestone;
85
- },
86
- onSuccess: (data) => {
87
- queryClient.invalidateQueries({ queryKey: milestoneKeys.all });
88
- queryClient.invalidateQueries({ queryKey: projectKeys.all });
89
- queryClient.invalidateQueries({ queryKey: projectKeys.detail(data.project_id) });
90
- },
91
- onError: (error) => {
92
- showApiErrorNotification(error);
93
- }
94
- });
95
- }
96
- function useUpdateMilestone() {
97
- const { apiRequest } = useElevasisServices();
98
- const queryClient = useQueryClient();
99
- return useMutation({
100
- mutationFn: async (params) => {
101
- const res = await apiRequest(`/milestones/${params.id}`, {
102
- method: "PATCH",
103
- body: JSON.stringify(params.updates)
104
- });
105
- return res.milestone;
106
- },
107
- onSuccess: (data) => {
108
- queryClient.invalidateQueries({ queryKey: milestoneKeys.all });
109
- queryClient.invalidateQueries({ queryKey: projectKeys.all });
110
- queryClient.invalidateQueries({ queryKey: projectKeys.detail(data.project_id) });
111
- },
112
- onError: (error) => {
113
- showApiErrorNotification(error);
114
- }
115
- });
116
- }
117
- function useDeleteMilestone() {
118
- const { apiRequest } = useElevasisServices();
119
- const queryClient = useQueryClient();
120
- return useMutation({
121
- mutationFn: async (params) => {
122
- await apiRequest(`/milestones/${params.id}`, {
123
- method: "DELETE"
124
- });
125
- },
126
- onSuccess: (_, params) => {
127
- queryClient.invalidateQueries({ queryKey: milestoneKeys.all });
128
- queryClient.invalidateQueries({ queryKey: projectKeys.all });
129
- queryClient.invalidateQueries({ queryKey: projectKeys.detail(params.projectId) });
130
- },
131
- onError: (error) => {
132
- showApiErrorNotification(error);
133
- }
134
- });
135
- }
136
- var taskKeys = {
137
- all: ["project-tasks"],
138
- lists: () => [...taskKeys.all, "list"],
139
- list: (orgId, filters) => [...taskKeys.all, "list", orgId, filters],
140
- details: () => [...taskKeys.all, "detail"],
141
- detail: (id) => [...taskKeys.all, "detail", id]
142
- };
143
- function useTasks(filters = {}) {
144
- const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
145
- return useQuery({
146
- queryKey: taskKeys.list(workOSOrganizationId, filters),
147
- queryFn: async () => {
148
- const params = new URLSearchParams();
149
- if (filters.status) params.set("status", filters.status);
150
- if (filters.milestoneId) params.set("milestone_id", filters.milestoneId);
151
- const qs = params.toString();
152
- const base = `/projects/${filters.projectId}/tasks`;
153
- const path = qs ? `${base}?${qs}` : base;
154
- const res = await apiRequest(path);
155
- return res.tasks;
156
- },
157
- enabled: isReady && !!filters.projectId
158
- });
159
- }
160
- function useCreateTask() {
161
- const { apiRequest } = useElevasisServices();
162
- const queryClient = useQueryClient();
163
- return useMutation({
164
- mutationFn: async (params) => {
165
- const res = await apiRequest("/project-tasks", {
166
- method: "POST",
167
- body: JSON.stringify(params)
168
- });
169
- return res.task;
170
- },
171
- onSuccess: (data) => {
172
- queryClient.invalidateQueries({ queryKey: taskKeys.all });
173
- queryClient.invalidateQueries({ queryKey: projectKeys.all });
174
- queryClient.invalidateQueries({ queryKey: projectKeys.detail(data.project_id) });
175
- },
176
- onError: (error) => {
177
- showApiErrorNotification(error);
178
- }
179
- });
180
- }
181
- function useUpdateTask() {
182
- const { apiRequest } = useElevasisServices();
183
- const queryClient = useQueryClient();
184
- return useMutation({
185
- mutationFn: async (params) => {
186
- const res = await apiRequest(`/project-tasks/${params.id}`, {
187
- method: "PATCH",
188
- body: JSON.stringify(params.updates)
189
- });
190
- return res.task;
191
- },
192
- onSuccess: (data) => {
193
- queryClient.invalidateQueries({ queryKey: taskKeys.all });
194
- queryClient.invalidateQueries({ queryKey: projectKeys.all });
195
- queryClient.invalidateQueries({ queryKey: projectKeys.detail(data.project_id) });
196
- },
197
- onError: (error) => {
198
- showApiErrorNotification(error);
199
- }
200
- });
201
- }
202
- function useDeleteTask() {
203
- const { apiRequest } = useElevasisServices();
204
- const queryClient = useQueryClient();
205
- return useMutation({
206
- mutationFn: async (params) => {
207
- await apiRequest(`/project-tasks/${params.id}`, {
208
- method: "DELETE"
209
- });
210
- },
211
- onSuccess: (_, params) => {
212
- queryClient.invalidateQueries({ queryKey: taskKeys.all });
213
- queryClient.invalidateQueries({ queryKey: projectKeys.all });
214
- queryClient.invalidateQueries({ queryKey: projectKeys.detail(params.projectId) });
215
- },
216
- onError: (error) => {
217
- showApiErrorNotification(error);
218
- }
219
- });
220
- }
221
- var noteKeys = {
222
- all: ["project-notes"],
223
- lists: () => [...noteKeys.all, "list"],
224
- list: (orgId, filters) => [...noteKeys.all, "list", orgId, filters],
225
- details: () => [...noteKeys.all, "detail"],
226
- detail: (id) => [...noteKeys.all, "detail", id]
227
- };
228
- function useProjectNotes(filters = {}) {
229
- const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
230
- return useQuery({
231
- queryKey: noteKeys.list(workOSOrganizationId, filters),
232
- queryFn: async () => {
233
- const res = await apiRequest(`/projects/${filters.projectId}/notes`);
234
- return res.notes;
235
- },
236
- enabled: isReady && !!filters.projectId
237
- });
238
- }
239
- function useCreateNote() {
240
- const { apiRequest } = useElevasisServices();
241
- const queryClient = useQueryClient();
242
- return useMutation({
243
- mutationFn: async (params) => {
244
- const res = await apiRequest("/project-notes", {
245
- method: "POST",
246
- body: JSON.stringify(params)
247
- });
248
- return res.note;
249
- },
250
- onSuccess: (data) => {
251
- queryClient.invalidateQueries({ queryKey: noteKeys.all });
252
- queryClient.invalidateQueries({ queryKey: projectKeys.all });
253
- queryClient.invalidateQueries({ queryKey: projectKeys.detail(data.project_id) });
254
- },
255
- onError: (error) => {
256
- showApiErrorNotification(error);
257
- }
258
- });
259
- }
260
-
261
- // src/hooks/delivery/useProjects.ts
262
- var projectKeys = {
263
- all: ["projects"],
264
- lists: () => [...projectKeys.all, "list"],
265
- list: (orgId, filters) => [...projectKeys.all, "list", orgId, filters],
266
- details: () => [...projectKeys.all, "detail"],
267
- detail: (id) => [...projectKeys.all, "detail", id],
268
- milestones: (id) => [...projectKeys.all, id, "milestones"],
269
- tasks: (id) => [...projectKeys.all, id, "tasks"]
270
- };
271
- function useProjects(filters = {}) {
272
- const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
273
- return useQuery({
274
- queryKey: projectKeys.list(workOSOrganizationId, filters),
275
- queryFn: async () => {
276
- const params = new URLSearchParams();
277
- if (filters.kind) params.set("kind", filters.kind);
278
- const qs = params.toString();
279
- const path = qs ? `/projects?${qs}` : "/projects";
280
- const res = await apiRequest(path);
281
- return res.projects;
282
- },
283
- enabled: isReady
284
- });
285
- }
286
- function useProject(id) {
287
- const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
288
- return useQuery({
289
- queryKey: [...projectKeys.detail(id), workOSOrganizationId],
290
- queryFn: async () => {
291
- try {
292
- const res = await apiRequest(`/projects/${id}`);
293
- return res.project;
294
- } catch (err) {
295
- if (err && typeof err === "object" && "statusCode" in err && err.statusCode === 404) {
296
- return null;
297
- }
298
- throw err;
299
- }
300
- },
301
- enabled: isReady && !!id
302
- });
303
- }
304
- function useProjectMilestones(projectId) {
305
- const { apiRequest, isReady } = useElevasisServices();
306
- return useQuery({
307
- queryKey: projectKeys.milestones(projectId),
308
- queryFn: async () => {
309
- const res = await apiRequest(`/projects/${projectId}/milestones`);
310
- return res.milestones;
311
- },
312
- enabled: isReady && !!projectId
313
- });
314
- }
315
- function useProjectTasks(projectId) {
316
- const { apiRequest, isReady } = useElevasisServices();
317
- return useQuery({
318
- queryKey: projectKeys.tasks(projectId),
319
- queryFn: async () => {
320
- const res = await apiRequest(`/projects/${projectId}/tasks`);
321
- return res.tasks;
322
- },
323
- enabled: isReady && !!projectId
324
- });
325
- }
326
- function useCreateProject() {
327
- const { apiRequest } = useElevasisServices();
328
- const queryClient = useQueryClient();
329
- return useMutation({
330
- mutationFn: async (params) => {
331
- const res = await apiRequest("/projects", {
332
- method: "POST",
333
- body: JSON.stringify(params)
334
- });
335
- return res.project;
336
- },
337
- onSuccess: () => {
338
- queryClient.invalidateQueries({ queryKey: projectKeys.all });
339
- },
340
- onError: (error) => {
341
- showApiErrorNotification(error);
342
- }
343
- });
344
- }
345
- function useUpdateProject() {
346
- const { apiRequest } = useElevasisServices();
347
- const queryClient = useQueryClient();
348
- return useMutation({
349
- mutationFn: async (params) => {
350
- const res = await apiRequest(`/projects/${params.id}`, {
351
- method: "PATCH",
352
- body: JSON.stringify(params.updates)
353
- });
354
- return res.project;
355
- },
356
- onSuccess: (data) => {
357
- queryClient.invalidateQueries({ queryKey: projectKeys.all });
358
- queryClient.invalidateQueries({ queryKey: projectKeys.detail(data.id) });
359
- },
360
- onError: (error) => {
361
- showApiErrorNotification(error);
362
- }
363
- });
364
- }
365
- function useDeleteProject() {
366
- const { apiRequest } = useElevasisServices();
367
- const queryClient = useQueryClient();
368
- return useMutation({
369
- mutationFn: async (id) => {
370
- await apiRequest(`/projects/${id}`, {
371
- method: "DELETE"
372
- });
373
- },
374
- onSuccess: () => {
375
- queryClient.invalidateQueries({ queryKey: projectKeys.all });
376
- },
377
- onError: (error) => {
378
- showApiErrorNotification(error);
379
- }
380
- });
381
- }
382
-
383
- export { milestoneKeys, noteKeys, projectKeys, showApiErrorNotification, showErrorNotification, showInfoNotification, showSuccessNotification, showWarningNotification, taskKeys, useCreateMilestone, useCreateNote, useCreateProject, useCreateTask, useDeleteMilestone, useDeleteProject, useDeleteTask, useMilestones, useProject, useProjectMilestones, useProjectNotes, useProjectTasks, useProjects, useTasks, useUpdateMilestone, useUpdateProject, useUpdateTask };