@elevasis/ui 2.72.0 → 2.74.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 (100) hide show
  1. package/dist/api/index.js +3 -3
  2. package/dist/app/index.d.ts +172 -20
  3. package/dist/app/index.js +9 -10
  4. package/dist/auth/index.js +5 -6
  5. package/dist/charts/index.js +5 -6
  6. package/dist/chunk-2GIJBHZT.js +60 -0
  7. package/dist/{chunk-2454MK7P.js → chunk-2MRRDF32.js} +115 -8
  8. package/dist/chunk-3LOKYZJC.js +231 -0
  9. package/dist/chunk-3QHX4ZKV.js +224 -0
  10. package/dist/chunk-43LC6XAX.js +69 -0
  11. package/dist/chunk-4M2BSHVT.js +116 -0
  12. package/dist/{chunk-SV4M2BUI.js → chunk-4MXNHJTA.js} +111 -46
  13. package/dist/{chunk-LEQGGX2U.js → chunk-5A6KCFS5.js} +36 -43
  14. package/dist/{chunk-KIDZXZM5.js → chunk-6JN2TLV2.js} +1480 -4200
  15. package/dist/{chunk-UZ5JO5TK.js → chunk-7ARBBELS.js} +1 -1
  16. package/dist/{chunk-DJWIIPKW.js → chunk-7RJ7P6S6.js} +6 -3
  17. package/dist/chunk-ARAFQBNI.js +515 -0
  18. package/dist/{chunk-DKVGO6RJ.js → chunk-BA3AZJUR.js} +1 -1
  19. package/dist/chunk-BRTGCFBH.js +305 -0
  20. package/dist/{chunk-7ESZKTQG.js → chunk-CQPULKKL.js} +5 -3
  21. package/dist/chunk-CRA7WQZH.js +49 -0
  22. package/dist/{chunk-XZIOCB5D.js → chunk-DCQKTDIG.js} +2 -52
  23. package/dist/{chunk-A3JHFZDP.js → chunk-E6YGA5WH.js} +1 -1
  24. package/dist/chunk-FA7LMNQO.js +439 -0
  25. package/dist/chunk-FZSG6M6W.js +45 -0
  26. package/dist/chunk-GDOR57D7.js +165 -0
  27. package/dist/{chunk-RRS2QR3W.js → chunk-GO4XJ5D4.js} +1 -1
  28. package/dist/chunk-GPQQGQGT.js +645 -0
  29. package/dist/chunk-HYQOGRWG.js +54 -0
  30. package/dist/{chunk-LCHL5SM2.js → chunk-LN4UW6S4.js} +1 -1
  31. package/dist/chunk-N6K2Q5BM.js +393 -0
  32. package/dist/{chunk-Z2W5VNN3.js → chunk-O32UQ26A.js} +3 -2
  33. package/dist/{chunk-M7WWRZ5Z.js → chunk-QFGNRKIE.js} +1 -78
  34. package/dist/{chunk-Q3O3WY7Q.js → chunk-R5UGIFYU.js} +74 -18
  35. package/dist/{chunk-753MKWFV.js → chunk-RFNJ2PTO.js} +1 -1
  36. package/dist/chunk-VM2OWOXL.js +24 -0
  37. package/dist/{chunk-ZBXCEWKF.js → chunk-W2QRBQQA.js} +5 -3
  38. package/dist/chunk-WDBNW44Z.js +49 -0
  39. package/dist/{chunk-IXBRUIYI.js → chunk-WZU3MCKI.js} +1 -1
  40. package/dist/chunk-YQQ5GRUR.js +21 -0
  41. package/dist/{chunk-IMZTRDY2.js → chunk-ZFA56VSR.js} +2 -2
  42. package/dist/{chunk-AFBFSXP3.js → chunk-ZWI62BQ6.js} +7 -4
  43. package/dist/chunk-ZYNVCWDZ.js +286 -0
  44. package/dist/components/index.d.ts +490 -22
  45. package/dist/components/index.js +335 -35
  46. package/dist/components/navigation/index.js +6 -7
  47. package/dist/features/auth/index.d.ts +154 -2
  48. package/dist/features/auth/index.js +18 -9
  49. package/dist/features/clients/index.js +7 -7
  50. package/dist/features/content/index.d.ts +718 -34
  51. package/dist/features/content/index.js +1345 -51
  52. package/dist/features/crm/index.d.ts +172 -20
  53. package/dist/features/crm/index.js +10 -8
  54. package/dist/features/dashboard/index.d.ts +19 -10
  55. package/dist/features/dashboard/index.js +9 -8
  56. package/dist/features/delivery/index.d.ts +134 -0
  57. package/dist/features/delivery/index.js +23 -7
  58. package/dist/features/knowledge/index.js +5 -6
  59. package/dist/features/lead-gen/index.d.ts +47 -35
  60. package/dist/features/lead-gen/index.js +12 -8
  61. package/dist/features/monitoring/index.js +11 -9
  62. package/dist/features/monitoring/requests/index.js +8 -7
  63. package/dist/features/operations/index.d.ts +38 -20
  64. package/dist/features/operations/index.js +15 -11
  65. package/dist/features/public-agent-chat/index.js +3 -1
  66. package/dist/features/settings/index.d.ts +134 -0
  67. package/dist/features/settings/index.js +9 -8
  68. package/dist/hooks/access/index.js +5 -6
  69. package/dist/hooks/delivery/index.d.ts +134 -0
  70. package/dist/hooks/delivery/index.js +3 -2
  71. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +20 -11
  72. package/dist/hooks/published.d.ts +1421 -29
  73. package/dist/hooks/published.js +22 -6
  74. package/dist/initialization/index.d.ts +134 -0
  75. package/dist/knowledge/index.d.ts +38 -20
  76. package/dist/knowledge/index.js +167 -11
  77. package/dist/{knowledge-search-index-RZLIVWPJ.js → knowledge-search-index-6GQK55IQ.js} +1 -1
  78. package/dist/layout/index.js +8 -9
  79. package/dist/profile/index.d.ts +134 -0
  80. package/dist/provider/index.d.ts +191 -21
  81. package/dist/provider/index.js +5 -6
  82. package/dist/provider/published.d.ts +219 -21
  83. package/dist/provider/published.js +5 -6
  84. package/dist/test-utils/index.d.ts +16 -5
  85. package/dist/test-utils/index.js +17 -18
  86. package/dist/types/index.d.ts +184 -14
  87. package/dist/utils/index.d.ts +102 -13
  88. package/dist/utils/index.js +1 -1
  89. package/package.json +7 -6
  90. package/dist/chunk-6M6OLGQY.js +0 -36
  91. package/dist/chunk-MKH2KOAO.js +0 -39
  92. package/dist/hooks/index.css +0 -659
  93. package/dist/hooks/index.d.ts +0 -12853
  94. package/dist/hooks/index.js +0 -27
  95. package/dist/supabase/index.d.ts +0 -6969
  96. package/dist/supabase/index.js +0 -3
  97. package/dist/typeform/index.d.ts +0 -462
  98. package/dist/typeform/index.js +0 -2051
  99. package/dist/typeform/schemas.d.ts +0 -67
  100. package/dist/typeform/schemas.js +0 -2
@@ -0,0 +1,24 @@
1
+ import { UuidSchema } from './chunk-TVTSASST.js';
2
+ import { z } from 'zod';
3
+
4
+ var NotificationCategorySchema = z.enum(["info", "queue", "alert", "error", "system"]);
5
+ var GetNotificationsQuerySchema = z.object({
6
+ limit: z.coerce.number().int().min(1).max(100).default(50),
7
+ offset: z.coerce.number().int().min(0).default(0)
8
+ });
9
+ var MarkAsReadParamsSchema = z.object({
10
+ id: UuidSchema
11
+ });
12
+ z.object({
13
+ userId: UuidSchema,
14
+ organizationId: UuidSchema,
15
+ category: NotificationCategorySchema,
16
+ title: z.string().trim().min(1).max(200),
17
+ message: z.string().trim().min(1).max(1e3),
18
+ actionUrl: z.string().url().optional()
19
+ }).strict();
20
+ z.object({
21
+ ids: z.array(UuidSchema).min(1).max(500)
22
+ }).strict();
23
+
24
+ export { GetNotificationsQuerySchema, MarkAsReadParamsSchema };
@@ -1,13 +1,15 @@
1
+ import { useScheduledTasks } from './chunk-N6K2Q5BM.js';
1
2
  import { ZodFormRenderer } from './chunk-3MEXPLWT.js';
2
3
  import { ResourceHealthChart } from './chunk-LGKLC5MG.js';
4
+ import { useTimeRangeDates } from './chunk-YQQ5GRUR.js';
3
5
  import { Graph_module_css_default, useDirectedChainHighlighting, useNodeSelection, useFitViewTrigger } from './chunk-HENXLGVD.js';
4
- import { AppShellCenteredContainer, AppShellLoader } from './chunk-A3JHFZDP.js';
5
- import { useCyberColors, GlowDot, JsonViewer, useExecuteResource, EmptyState, useDashboardMetrics, useResources, useTimeRangeDates, useUnresolvedErrors, useRecentExecutionsByResource, PageTitleCaption, HeroStatsRow, useCommandQueue, useScheduledTasks, TabCountBadge, useResourcesHealth } from './chunk-KIDZXZM5.js';
6
+ import { AppShellCenteredContainer, AppShellLoader } from './chunk-E6YGA5WH.js';
7
+ import { useCyberColors, GlowDot, JsonViewer, useExecuteResource, EmptyState, useDashboardMetrics, useResources, useUnresolvedErrors, useRecentExecutionsByResource, PageTitleCaption, HeroStatsRow, useCommandQueue, TabCountBadge, useResourcesHealth } from './chunk-6JN2TLV2.js';
6
8
  import { glassBase } from './chunk-R6NMRXNO.js';
7
9
  import { CardHeader } from './chunk-62GVNH5U.js';
8
10
  import { useInitialization } from './chunk-P45GQ3ZW.js';
9
11
  import { STATUS_COLORS, getStatusIcon, formatDuration, getStatusColors, AGENT_CONSTANTS, shouldAnimateEdge, TIMELINE_CONSTANTS, calculateBarPosition, CONTAINER_CONSTANTS, useExecutionPath, useUnifiedWorkflowLayout, WORKFLOW_CONSTANTS, useReactFlowAgent } from './chunk-BLXJEIQS.js';
10
- import { formatTimeAgo, formatRelativeTime } from './chunk-Q3O3WY7Q.js';
12
+ import { formatTimeAgo, formatRelativeTime } from './chunk-R5UGIFYU.js';
11
13
  import { getTimeRangeDates } from './chunk-Y6I3IC45.js';
12
14
  import { ResourceStatusColors } from './chunk-6SSQGWK7.js';
13
15
  import { memo, useMemo, useEffect, useState, useCallback, Fragment } from 'react';
@@ -0,0 +1,49 @@
1
+ import { useState, useMemo, useEffect, useCallback } from 'react';
2
+
3
+ // src/hooks/table/useTableSelection.ts
4
+ function useTableSelection(items, allItems) {
5
+ const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
6
+ const pageIds = useMemo(() => new Set(items.map((i) => i.id)), [items]);
7
+ useEffect(() => {
8
+ setSelectedIds((prev) => {
9
+ const validIds = allItems ? new Set(allItems.map((i) => i.id)) : pageIds;
10
+ const next = new Set([...prev].filter((id) => validIds.has(id)));
11
+ return next.size === prev.size ? prev : next;
12
+ });
13
+ }, [allItems, pageIds]);
14
+ const toggle = useCallback((id) => {
15
+ setSelectedIds((prev) => {
16
+ const next = new Set(prev);
17
+ if (next.has(id)) next.delete(id);
18
+ else next.add(id);
19
+ return next;
20
+ });
21
+ }, []);
22
+ const togglePage = useCallback(() => {
23
+ setSelectedIds((prev) => {
24
+ const allPageSelected = items.every((i) => prev.has(i.id));
25
+ const next = new Set(prev);
26
+ if (allPageSelected) {
27
+ for (const item of items) next.delete(item.id);
28
+ } else {
29
+ for (const item of items) next.add(item.id);
30
+ }
31
+ return next;
32
+ });
33
+ }, [items]);
34
+ const clear = useCallback(() => setSelectedIds(/* @__PURE__ */ new Set()), []);
35
+ const isPageAllSelected = items.length > 0 && items.every((i) => selectedIds.has(i.id));
36
+ const isPagePartiallySelected = !isPageAllSelected && items.some((i) => selectedIds.has(i.id));
37
+ return {
38
+ selectedIds,
39
+ toggle,
40
+ togglePage,
41
+ clear,
42
+ isPageAllSelected,
43
+ isPagePartiallySelected,
44
+ selectedCount: selectedIds.size,
45
+ isSelected: (id) => selectedIds.has(id)
46
+ };
47
+ }
48
+
49
+ export { useTableSelection };
@@ -1,4 +1,4 @@
1
- import { useCyberColors, useResourcesHealth, EmptyState, CyberLegendItem, CyberAreaChart } from './chunk-KIDZXZM5.js';
1
+ import { useCyberColors, useResourcesHealth, EmptyState, CyberLegendItem, CyberAreaChart } from './chunk-6JN2TLV2.js';
2
2
  import { CardHeader } from './chunk-62GVNH5U.js';
3
3
  import { getTimeRangeDates, formatBucketTime } from './chunk-Y6I3IC45.js';
4
4
  import { Paper, Center, Loader, Group } from '@mantine/core';
@@ -0,0 +1,21 @@
1
+ import { useMemo } from 'react';
2
+
3
+ // src/hooks/useTimeRangeDates.ts
4
+ var RANGE_MS = {
5
+ "1h": 60 * 60 * 1e3,
6
+ "24h": 24 * 60 * 60 * 1e3,
7
+ "7d": 7 * 24 * 60 * 60 * 1e3,
8
+ "30d": 30 * 24 * 60 * 60 * 1e3
9
+ };
10
+ function useTimeRangeDates(timeRange) {
11
+ return useMemo(() => {
12
+ const now = /* @__PURE__ */ new Date();
13
+ const start = new Date(now.getTime() - RANGE_MS[timeRange]);
14
+ return {
15
+ startDate: start.toISOString(),
16
+ endDate: now.toISOString()
17
+ };
18
+ }, [timeRange]);
19
+ }
20
+
21
+ export { useTimeRangeDates };
@@ -1,5 +1,5 @@
1
- import { getLeadGenStageCatalog } from './chunk-KIDZXZM5.js';
2
- import { SYSTEM_INTERFACE_PROFILES, formatOntologyId, registerBuiltInReadinessProfile, registerReadinessInterfaceMarker, requireContractReadiness, computeInterfaceReadiness, addReadinessIssue, formatInterfaceIdentity, resourceBindingIds, requireCatalogReadiness, requireScopedBinding } from './chunk-Q3O3WY7Q.js';
1
+ import { getLeadGenStageCatalog } from './chunk-6JN2TLV2.js';
2
+ import { SYSTEM_INTERFACE_PROFILES, formatOntologyId, registerBuiltInReadinessProfile, registerReadinessInterfaceMarker, requireContractReadiness, computeInterfaceReadiness, addReadinessIssue, formatInterfaceIdentity, resourceBindingIds, requireCatalogReadiness, requireScopedBinding } from './chunk-R5UGIFYU.js';
3
3
 
4
4
  // ../core/src/business/acquisition/ontology-validation.ts
5
5
  var LEAD_GEN_API_INTERFACE = SYSTEM_INTERFACE_PROFILES[0];
@@ -1,12 +1,15 @@
1
- import { CRM_API_INTERFACE } from './chunk-IMZTRDY2.js';
1
+ import { useDealDetail, useExecuteAction } from './chunk-FZSG6M6W.js';
2
+ import { CRM_API_INTERFACE } from './chunk-ZFA56VSR.js';
3
+ import { useTableSort, sortData, useCompany, useContact, deriveActions } from './chunk-ZYNVCWDZ.js';
4
+ import { useTableSelection } from './chunk-WDBNW44Z.js';
2
5
  import { PageContainer } from './chunk-BZZCNLT6.js';
3
6
  import { TableSelectionToolbar, SortableHeader } from './chunk-TUMSNGTX.js';
4
7
  import { FilterBar } from './chunk-PDHTXPSF.js';
5
- import { CrmSidebarMiddle, useDealsSummary, useOptionalElevasisSystems, getCrmPipelineCatalog, CenteredErrorState, StatCard, PageTitleCaption, useDeleteDeal, usePaginationState, useDeals, useTableSort, sortData, useTableSelection, SubshellContentContainer, EmptyState, CustomModal, useDealDetail, useCrmActions, ActivityTimeline, useCompany, ContextViewer, JsonViewer, dealKeys, useContact, deriveActions, useExecuteAction } from './chunk-KIDZXZM5.js';
6
- import { showApiErrorNotification, showSuccessNotification } from './chunk-XZIOCB5D.js';
8
+ import { CrmSidebarMiddle, useDealsSummary, useOptionalElevasisSystems, getCrmPipelineCatalog, CenteredErrorState, StatCard, PageTitleCaption, useDeleteDeal, usePaginationState, useDeals, SubshellContentContainer, EmptyState, CustomModal, useCrmActions, ActivityTimeline, ContextViewer, JsonViewer, dealKeys } from './chunk-6JN2TLV2.js';
9
+ import { showApiErrorNotification, showSuccessNotification } from './chunk-HYQOGRWG.js';
7
10
  import { SubshellSidebarSection } from './chunk-MISHPEJX.js';
8
11
  import { CardHeader } from './chunk-62GVNH5U.js';
9
- import { computeInterfaceReadiness, getSystem, PAGE_SIZE_DEFAULT, formatTimeAgo } from './chunk-Q3O3WY7Q.js';
12
+ import { computeInterfaceReadiness, getSystem, PAGE_SIZE_DEFAULT, formatTimeAgo } from './chunk-R5UGIFYU.js';
10
13
  import { useElevasisServices } from './chunk-BI5VDO2K.js';
11
14
  import { Stack, Paper, Center, Loader, Group, Box, Text, Alert, Table, SimpleGrid, Button, Select, TextInput, Tabs, Checkbox, Badge, Tooltip, Pagination, Title, Code, Card, SegmentedControl, Switch, NumberInput, ColorSwatch, Popover, ActionIcon, Anchor, CopyButton, Divider, Textarea } from '@mantine/core';
12
15
  import { IconAddressBook, IconColumns, IconHistory, IconAlertCircle, IconCurrencyDollar, IconChartBar, IconBriefcase, IconTrophy, IconSearch, IconTargetArrow, IconAlertTriangle, IconMessages, IconArrowLeft, IconFileText, IconInbox, IconUser, IconBolt, IconBuilding, IconSettings, IconRestore, IconInfoCircle, IconMailForward, IconPlus, IconArrowRight, IconNote, IconCheck, IconCopy } from '@tabler/icons-react';
@@ -0,0 +1,286 @@
1
+ import { acquisitionListKeys } from './chunk-6JN2TLV2.js';
2
+ import { showApiErrorNotification, showSuccessNotification } from './chunk-HYQOGRWG.js';
3
+ import { APIClientError } from './chunk-R5UGIFYU.js';
4
+ import { useElevasisServices } from './chunk-BI5VDO2K.js';
5
+ import { useQuery, useQueryClient, useMutation } from '@tanstack/react-query';
6
+ import { z } from 'zod';
7
+ import { useState, useCallback, useMemo } from 'react';
8
+
9
+ z.object({
10
+ replyBody: z.string().trim().min(1).max(1e4)
11
+ }).strict();
12
+ function deriveActions(deal, actions = []) {
13
+ return actions.filter((a) => a.isAvailableFor(deal)).map(({ key, label, payloadSchema }) => ({ key, label, payloadSchema }));
14
+ }
15
+ function useTableSort(defaultColumn, defaultDirection = "desc") {
16
+ const [sort, setSort] = useState({ column: defaultColumn, direction: defaultDirection });
17
+ const toggleSort = useCallback((column) => {
18
+ setSort((prev) => {
19
+ if (prev.column === column) {
20
+ return { column, direction: prev.direction === "asc" ? "desc" : "asc" };
21
+ }
22
+ return { column, direction: "desc" };
23
+ });
24
+ }, []);
25
+ return { sort, toggleSort };
26
+ }
27
+ function sortData(data, sort, accessors) {
28
+ const accessor = accessors[sort.column];
29
+ if (!accessor) return data;
30
+ return [...data].sort((a, b) => {
31
+ const aVal = accessor(a);
32
+ const bVal = accessor(b);
33
+ if (aVal == null && bVal == null) return 0;
34
+ if (aVal == null) return 1;
35
+ if (bVal == null) return -1;
36
+ let comparison = 0;
37
+ if (typeof aVal === "string" && typeof bVal === "string") {
38
+ comparison = aVal.localeCompare(bVal);
39
+ } else if (typeof aVal === "number" && typeof bVal === "number") {
40
+ comparison = aVal - bVal;
41
+ } else {
42
+ comparison = String(aVal).localeCompare(String(bVal));
43
+ }
44
+ return sort.direction === "asc" ? comparison : -comparison;
45
+ });
46
+ }
47
+ function useSortedData(data, defaultColumn, accessors, defaultDirection = "desc") {
48
+ const { sort, toggleSort } = useTableSort(defaultColumn, defaultDirection);
49
+ const sorted = useMemo(() => sortData(data, sort, accessors), [data, sort, accessors]);
50
+ return { sorted, sort, toggleSort };
51
+ }
52
+ var contactKeys = {
53
+ all: ["acquisition-contacts"],
54
+ list: (organizationId, filters) => [...contactKeys.all, "list", organizationId, filters],
55
+ detail: (organizationId, contactId) => [...contactKeys.all, "detail", organizationId, contactId]
56
+ };
57
+ function buildQueryString(params) {
58
+ const searchParams = new URLSearchParams();
59
+ for (const [key, value] of Object.entries(params)) {
60
+ if (value === void 0) continue;
61
+ searchParams.set(key, String(value));
62
+ }
63
+ const queryString = searchParams.toString();
64
+ return queryString ? `?${queryString}` : "";
65
+ }
66
+ function useContacts(filters = {}) {
67
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
68
+ return useQuery({
69
+ queryKey: contactKeys.list(workOSOrganizationId, filters),
70
+ queryFn: async () => {
71
+ const queryString = buildQueryString({
72
+ listId: filters.listId,
73
+ search: filters.search,
74
+ openingLineIsNull: filters.openingLineIsNull,
75
+ batchId: filters.batchId,
76
+ contactStatus: filters.contactStatus,
77
+ limit: filters.limit,
78
+ offset: filters.offset
79
+ });
80
+ return apiRequest(`/acquisition/contacts${queryString}`);
81
+ },
82
+ enabled: isReady && !!workOSOrganizationId,
83
+ retry: (_failureCount, error) => !(error instanceof APIClientError && error.statusCode === 401)
84
+ });
85
+ }
86
+ function useContact(contactId) {
87
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
88
+ return useQuery({
89
+ queryKey: contactKeys.detail(workOSOrganizationId, contactId),
90
+ queryFn: async () => {
91
+ if (!contactId) return null;
92
+ return apiRequest(`/acquisition/contacts/${contactId}`);
93
+ },
94
+ enabled: isReady && !!workOSOrganizationId && !!contactId
95
+ });
96
+ }
97
+ function useCreateContact() {
98
+ const { apiRequest } = useElevasisServices();
99
+ const queryClient = useQueryClient();
100
+ return useMutation({
101
+ mutationFn: (body) => apiRequest("/acquisition/contacts", {
102
+ method: "POST",
103
+ body: JSON.stringify(body)
104
+ }),
105
+ onSuccess: () => {
106
+ queryClient.invalidateQueries({ queryKey: contactKeys.all });
107
+ queryClient.invalidateQueries({ queryKey: ["acquisition-companies"] });
108
+ queryClient.invalidateQueries({ queryKey: acquisitionListKeys.all });
109
+ showSuccessNotification("Contact created");
110
+ },
111
+ onError: (error) => {
112
+ showApiErrorNotification(error);
113
+ }
114
+ });
115
+ }
116
+ function useUpdateContact(contactId) {
117
+ const { apiRequest } = useElevasisServices();
118
+ const queryClient = useQueryClient();
119
+ return useMutation({
120
+ mutationFn: (body) => apiRequest(`/acquisition/contacts/${contactId}`, {
121
+ method: "PATCH",
122
+ body: JSON.stringify(body)
123
+ }),
124
+ onSuccess: () => {
125
+ queryClient.invalidateQueries({ queryKey: contactKeys.all });
126
+ queryClient.invalidateQueries({ queryKey: ["acquisition-companies"] });
127
+ queryClient.invalidateQueries({ queryKey: acquisitionListKeys.all });
128
+ showSuccessNotification("Contact updated");
129
+ },
130
+ onError: (error) => {
131
+ showApiErrorNotification(error);
132
+ }
133
+ });
134
+ }
135
+ function useDeleteContacts() {
136
+ const { apiRequest } = useElevasisServices();
137
+ const queryClient = useQueryClient();
138
+ return useMutation({
139
+ mutationFn: async (contactIds) => {
140
+ const uniqueIds = [...new Set(contactIds)].filter(Boolean);
141
+ if (uniqueIds.length === 0) return;
142
+ await Promise.all(
143
+ uniqueIds.map(
144
+ (contactId) => apiRequest(`/acquisition/contacts/${contactId}`, {
145
+ method: "DELETE"
146
+ })
147
+ )
148
+ );
149
+ },
150
+ onSuccess: () => {
151
+ queryClient.invalidateQueries({ queryKey: contactKeys.all });
152
+ queryClient.invalidateQueries({ queryKey: ["acquisition-companies"] });
153
+ queryClient.invalidateQueries({ queryKey: acquisitionListKeys.all });
154
+ showSuccessNotification("Contacts deleted");
155
+ },
156
+ onError: (error) => {
157
+ showApiErrorNotification(error);
158
+ }
159
+ });
160
+ }
161
+
162
+ // src/hooks/acquisition/useCompanies.ts
163
+ var companyKeys = {
164
+ all: ["acquisition-companies"],
165
+ list: (organizationId, filters) => [...companyKeys.all, "list", organizationId, filters],
166
+ facets: (organizationId) => [...companyKeys.all, "facets", organizationId],
167
+ detail: (organizationId, companyId) => [...companyKeys.all, "detail", organizationId, companyId]
168
+ };
169
+ function buildQueryString2(params) {
170
+ const searchParams = new URLSearchParams();
171
+ for (const [key, value] of Object.entries(params)) {
172
+ if (value === void 0) continue;
173
+ searchParams.set(key, String(value));
174
+ }
175
+ const queryString = searchParams.toString();
176
+ return queryString ? `?${queryString}` : "";
177
+ }
178
+ function useCompanies(filters = {}) {
179
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
180
+ return useQuery({
181
+ queryKey: companyKeys.list(workOSOrganizationId, filters),
182
+ queryFn: async () => {
183
+ const queryString = buildQueryString2({
184
+ listId: filters.listId,
185
+ search: filters.search,
186
+ domain: filters.domain,
187
+ website: filters.website,
188
+ segment: filters.segment,
189
+ category: filters.category,
190
+ batchId: filters.batchId,
191
+ status: filters.status,
192
+ includeAll: filters.includeAll,
193
+ limit: filters.limit,
194
+ offset: filters.offset
195
+ });
196
+ return apiRequest(`/acquisition/companies${queryString}`);
197
+ },
198
+ enabled: isReady && !!workOSOrganizationId,
199
+ retry: (_failureCount, error) => !(error instanceof APIClientError && error.statusCode === 401)
200
+ });
201
+ }
202
+ function useCompanyFacets() {
203
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
204
+ return useQuery({
205
+ queryKey: companyKeys.facets(workOSOrganizationId),
206
+ queryFn: () => apiRequest("/acquisition/companies/facets"),
207
+ enabled: isReady && !!workOSOrganizationId
208
+ });
209
+ }
210
+ function useCompany(companyId) {
211
+ const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
212
+ return useQuery({
213
+ queryKey: companyKeys.detail(workOSOrganizationId, companyId),
214
+ queryFn: async () => {
215
+ if (!companyId) return null;
216
+ return apiRequest(`/acquisition/companies/${companyId}`);
217
+ },
218
+ enabled: isReady && !!workOSOrganizationId && !!companyId
219
+ });
220
+ }
221
+ function useCreateCompany() {
222
+ const { apiRequest } = useElevasisServices();
223
+ const queryClient = useQueryClient();
224
+ return useMutation({
225
+ mutationFn: (body) => apiRequest("/acquisition/companies", {
226
+ method: "POST",
227
+ body: JSON.stringify(body)
228
+ }),
229
+ onSuccess: () => {
230
+ queryClient.invalidateQueries({ queryKey: companyKeys.all });
231
+ queryClient.invalidateQueries({ queryKey: ["acquisition-contacts"] });
232
+ queryClient.invalidateQueries({ queryKey: acquisitionListKeys.all });
233
+ showSuccessNotification("Company created");
234
+ },
235
+ onError: (error) => {
236
+ showApiErrorNotification(error);
237
+ }
238
+ });
239
+ }
240
+ function useUpdateCompany(companyId) {
241
+ const { apiRequest } = useElevasisServices();
242
+ const queryClient = useQueryClient();
243
+ return useMutation({
244
+ mutationFn: (body) => apiRequest(`/acquisition/companies/${companyId}`, {
245
+ method: "PATCH",
246
+ body: JSON.stringify(body)
247
+ }),
248
+ onSuccess: () => {
249
+ queryClient.invalidateQueries({ queryKey: companyKeys.all });
250
+ queryClient.invalidateQueries({ queryKey: ["acquisition-contacts"] });
251
+ queryClient.invalidateQueries({ queryKey: acquisitionListKeys.all });
252
+ showSuccessNotification("Company updated");
253
+ },
254
+ onError: (error) => {
255
+ showApiErrorNotification(error);
256
+ }
257
+ });
258
+ }
259
+ function useDeleteCompanies() {
260
+ const { apiRequest } = useElevasisServices();
261
+ const queryClient = useQueryClient();
262
+ return useMutation({
263
+ mutationFn: async (companyIds) => {
264
+ const uniqueIds = [...new Set(companyIds)].filter(Boolean);
265
+ if (uniqueIds.length === 0) return;
266
+ await Promise.all(
267
+ uniqueIds.map(
268
+ (companyId) => apiRequest(`/acquisition/companies/${companyId}`, {
269
+ method: "DELETE"
270
+ })
271
+ )
272
+ );
273
+ },
274
+ onSuccess: () => {
275
+ queryClient.invalidateQueries({ queryKey: companyKeys.all });
276
+ queryClient.invalidateQueries({ queryKey: ["acquisition-contacts"] });
277
+ queryClient.invalidateQueries({ queryKey: acquisitionListKeys.all });
278
+ showSuccessNotification("Companies deleted");
279
+ },
280
+ onError: (error) => {
281
+ showApiErrorNotification(error);
282
+ }
283
+ });
284
+ }
285
+
286
+ export { companyKeys, contactKeys, deriveActions, sortData, useCompanies, useCompany, useCompanyFacets, useContact, useContacts, useCreateCompany, useCreateContact, useDeleteCompanies, useDeleteContacts, useSortedData, useTableSort, useUpdateCompany, useUpdateContact };