@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.
- package/dist/api/index.d.ts +9 -2
- package/dist/api/index.js +3 -3
- package/dist/app/index.css +452 -0
- package/dist/app/index.d.ts +1255 -8
- package/dist/app/index.js +151 -13
- package/dist/charts/index.js +3 -6
- package/dist/chunk-26HFM4MH.js +41449 -0
- package/dist/{chunk-52K5RFDH.js → chunk-4U3XAWCN.js} +1328 -2492
- package/dist/{chunk-ND5TDV2J.js → chunk-57OZ3AEG.js} +1 -1
- package/dist/{chunk-E4WQGJNS.js → chunk-7FPLLSHN.js} +14 -1
- package/dist/{chunk-RQA2EVN3.js → chunk-AKW7KISS.js} +39 -3
- package/dist/chunk-AUDNF2Q7.js +2050 -0
- package/dist/{chunk-TYRUKGGD.js → chunk-GX6XBRRF.js} +1 -2
- package/dist/{chunk-V6SZ4ECN.js → chunk-LUYVRATI.js} +257 -6
- package/dist/{chunk-X4WBGKJQ.js → chunk-R3VCBZDC.js} +50 -3
- package/dist/chunk-SIQ3P4OR.js +1764 -0
- package/dist/{chunk-Z2K2EAPL.js → chunk-VDOOGGBA.js} +5 -6
- package/dist/{chunk-3FV6HBXS.js → chunk-WF7CONXF.js} +23 -23
- package/dist/chunk-YYX7OPZQ.js +25 -0
- package/dist/components/index.d.ts +69 -92
- package/dist/components/index.js +20 -3216
- package/dist/components/navigation/index.js +25 -7
- package/dist/execution/index.d.ts +9 -9
- package/dist/execution/index.js +1 -2
- package/dist/features/auth/index.js +23 -2
- package/dist/features/clients/index.js +20 -31
- package/dist/features/crm/index.js +20 -35
- package/dist/features/dashboard/index.d.ts +68 -91
- package/dist/features/dashboard/index.js +20 -33
- package/dist/features/delivery/index.js +20 -35
- package/dist/features/knowledge/index.js +25 -11
- package/dist/features/lead-gen/index.d.ts +9 -9
- package/dist/features/lead-gen/index.js +20 -36
- package/dist/features/monitoring/index.js +20 -35
- package/dist/features/monitoring/requests/index.js +20 -30
- package/dist/features/operations/index.d.ts +197 -188
- package/dist/features/operations/index.js +18 -42
- package/dist/features/seo/index.js +3 -4
- package/dist/features/settings/index.js +20 -32
- package/dist/graph/index.js +1 -1
- package/dist/hooks/delivery/index.js +30 -2
- package/dist/hooks/index.d.ts +105 -112
- package/dist/hooks/index.js +20 -26
- package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +55 -62
- package/dist/hooks/published.d.ts +105 -112
- package/dist/hooks/published.js +20 -25
- package/dist/index.css +532 -532
- package/dist/index.d.ts +10261 -6793
- package/dist/index.js +22 -31
- package/dist/knowledge/index.d.ts +51 -59
- package/dist/knowledge/index.js +40 -211
- package/dist/{knowledge-search-index-VMAW7FLR.js → knowledge-search-index-ORIJCEZX.js} +3 -3
- package/dist/layout/index.js +4 -10
- package/dist/organization/index.js +27 -2
- package/dist/provider/index.d.ts +71 -52
- package/dist/provider/index.js +20 -20
- package/dist/provider/published.d.ts +39 -47
- package/dist/provider/published.js +20 -15
- package/dist/test-utils/index.d.ts +2 -0
- package/dist/test-utils/index.js +16 -4
- package/dist/test-utils/setup.js +38 -0
- package/dist/theme/index.js +2 -3
- package/dist/theme/presets/index.d.ts +28 -3
- package/dist/theme/presets/index.js +1 -1
- package/dist/typeform/index.js +1 -2049
- package/dist/types/index.d.ts +88 -95
- package/dist/utils/index.d.ts +46 -69
- package/dist/utils/index.js +1 -1
- package/dist/zustand/index.d.ts +21 -8
- package/dist/zustand/index.js +32 -1
- package/package.json +5 -5
- package/dist/chunk-2ZZ72TAB.js +0 -2281
- package/dist/chunk-32I2RCGC.js +0 -85
- package/dist/chunk-3MEXPLWT.js +0 -265
- package/dist/chunk-3ZMAGTWF.js +0 -18
- package/dist/chunk-44I4LOH6.js +0 -1593
- package/dist/chunk-4DYOXEH6.js +0 -951
- package/dist/chunk-7M2VOCYN.js +0 -1
- package/dist/chunk-A4VDJJCV.js +0 -1864
- package/dist/chunk-BZZCNLT6.js +0 -12
- package/dist/chunk-CLDCYJQT.js +0 -1
- package/dist/chunk-E565XMTQ.js +0 -17
- package/dist/chunk-EPTHX4VZ.js +0 -749
- package/dist/chunk-GWGQI6V4.js +0 -447
- package/dist/chunk-HUJCU55S.js +0 -159
- package/dist/chunk-IBWMR4TI.js +0 -469
- package/dist/chunk-IIMU5YAJ.js +0 -53
- package/dist/chunk-IOXOPMYS.js +0 -145
- package/dist/chunk-J2UD7BOH.js +0 -347
- package/dist/chunk-JA5ECJJB.js +0 -387
- package/dist/chunk-JFL3GRD4.js +0 -39
- package/dist/chunk-KW7ZNQD7.js +0 -126
- package/dist/chunk-LGKLC5MG.js +0 -44
- package/dist/chunk-N55DVMAG.js +0 -14
- package/dist/chunk-O56ESZCQ.js +0 -1874
- package/dist/chunk-OIBHQH5Q.js +0 -96
- package/dist/chunk-PDHTXPSF.js +0 -12
- package/dist/chunk-QDFJSUG3.js +0 -13
- package/dist/chunk-R2XR4FCV.js +0 -48
- package/dist/chunk-R66W5UDG.js +0 -26
- package/dist/chunk-RYTEQBAO.js +0 -37
- package/dist/chunk-SZHARWKU.js +0 -15
- package/dist/chunk-T3J6U77J.js +0 -12056
- package/dist/chunk-TBVLQRXT.js +0 -68
- package/dist/chunk-TGVAIWIL.js +0 -1778
- package/dist/chunk-TKAYX2SP.js +0 -204
- package/dist/chunk-TUMSNGTX.js +0 -35
- package/dist/chunk-VGU4ZFYZ.js +0 -4752
- package/dist/chunk-VNAZTCHA.js +0 -65
- package/dist/chunk-VNFR57DF.js +0 -87
- package/dist/chunk-WKW6B5ID.js +0 -29
- package/dist/chunk-XCYKC6OZ.js +0 -1
- package/dist/chunk-XZGSCABI.js +0 -383
- package/dist/chunk-ZMK5Z6KE.js +0 -5198
- /package/dist/{chunk-2RJMVWFJ.js → chunk-GEFWMU26.js} +0 -0
- /package/dist/{chunk-22UVE3RA.js → chunk-HENXLGVD.js} +0 -0
package/dist/chunk-VGU4ZFYZ.js
DELETED
|
@@ -1,4752 +0,0 @@
|
|
|
1
|
-
import { SalesSidebar, LeadGenSidebarMiddle } from './chunk-J2UD7BOH.js';
|
|
2
|
-
import { sanitizeInput } from './chunk-3MEXPLWT.js';
|
|
3
|
-
import { SubshellSidebarSection } from './chunk-IIMU5YAJ.js';
|
|
4
|
-
import { PageContainer } from './chunk-BZZCNLT6.js';
|
|
5
|
-
import { TableSelectionToolbar, SortableHeader } from './chunk-TUMSNGTX.js';
|
|
6
|
-
import { FilterBar } from './chunk-PDHTXPSF.js';
|
|
7
|
-
import { CustomModal } from './chunk-R66W5UDG.js';
|
|
8
|
-
import { acquisitionListKeys, useListsTelemetry, useLists, useCreateList, useTableSort, sortData, usePaginationState, useTableSelection, useWorkflowExecution, useList, useListProgress, useListExecutions, useDeleteList, useCompanyFacets, useCompanies, useDeleteCompanies, useContacts, useDeleteContacts, useCredentials, useVerifyCredential, useInFlightExecutions, useListRecords, useExecutionSSE, useListMembers, useListMember, useTransitionListMember, useDeriveActions, useArtifacts } from './chunk-ZMK5Z6KE.js';
|
|
9
|
-
import { showApiErrorNotification, showSuccessNotification } from './chunk-XZGSCABI.js';
|
|
10
|
-
import { PageTitleCaption, CenteredErrorState, StatCard, CardHeader, EmptyState, JsonViewer } from './chunk-EPTHX4VZ.js';
|
|
11
|
-
import { useListActions } from './chunk-GWGQI6V4.js';
|
|
12
|
-
import { SubshellContentContainer } from './chunk-TKAYX2SP.js';
|
|
13
|
-
import { PROSPECTING_STEPS, LEAD_GEN_STAGE_CATALOG, LEAD_GEN_PIPELINE_DEFINITIONS, findPipeline } from './chunk-52K5RFDH.js';
|
|
14
|
-
import { isStepStartedContext, isStepCompletedContext, isStepFailedContext } from './chunk-KRWALB24.js';
|
|
15
|
-
import { useElevasisServices } from './chunk-KJ3QUBNU.js';
|
|
16
|
-
import { Stack, Group, Title, Text, Alert, Button, Collapse, Paper, Anchor, Center, Loader, SimpleGrid, Card, Table, Badge, TextInput, Select, Checkbox, Pagination, Textarea, ActionIcon, Tooltip, Tabs, ThemeIcon, Box, Pill, SegmentedControl, UnstyledButton, Drawer, JsonInput, Switch, NumberInput, MultiSelect, TagsInput, ScrollArea, Progress } from '@mantine/core';
|
|
17
|
-
import { IconTarget, IconAlertCircle, IconPlayerPlay, IconArrowRight, IconSparkles, IconListDetails, IconPlus, IconSearch, IconList, IconExternalLink, IconAlertTriangle, IconLayoutDashboard, IconBolt, IconCopy, IconBuilding, IconUsers, IconTrash, IconBuildingFactory2, IconArrowLeft, IconChevronDown, IconChevronRight, IconRefresh, IconAddressBook, IconSettings, IconCircleCheck, IconCircleDot, IconTerminal2, IconProgressCheck, IconMail, IconUser, IconDatabase } from '@tabler/icons-react';
|
|
18
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
|
-
import { useState, useRef, useMemo, useEffect, Fragment as Fragment$1, useCallback } from 'react';
|
|
20
|
-
import { useForm } from '@mantine/form';
|
|
21
|
-
import { zod4Resolver } from 'mantine-form-zod-resolver';
|
|
22
|
-
import { Link, useNavigate, useSearch } from '@tanstack/react-router';
|
|
23
|
-
import { useQueryClient, useMutation } from '@tanstack/react-query';
|
|
24
|
-
|
|
25
|
-
var LeadGenSidebarTop = () => {
|
|
26
|
-
return /* @__PURE__ */ jsx(SubshellSidebarSection, { icon: IconTarget, label: "Lead Gen" });
|
|
27
|
-
};
|
|
28
|
-
var LeadGenSidebar = ({ children } = {}) => {
|
|
29
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: 0, style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
|
|
30
|
-
/* @__PURE__ */ jsx(LeadGenSidebarTop, {}),
|
|
31
|
-
children ?? /* @__PURE__ */ jsx(LeadGenSidebarMiddle, {})
|
|
32
|
-
] });
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// ../core/src/business/acquisition/build-templates.ts
|
|
36
|
-
var BUILD_TEMPLATE_CATALOG = [
|
|
37
|
-
{
|
|
38
|
-
id: "local-services",
|
|
39
|
-
label: "Local Services",
|
|
40
|
-
description: "Source, analyze, qualify, and personalize local service businesses for outreach.",
|
|
41
|
-
steps: Object.values(PROSPECTING_STEPS.localServices)
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: "dtc-subscription-apollo-clickup",
|
|
45
|
-
label: "DTC Subscription (Apollo + ClickUp)",
|
|
46
|
-
description: "Import DTC brand leads from Apollo, crawl their websites, score fit, enrich contacts, and export via ClickUp.",
|
|
47
|
-
steps: Object.values(PROSPECTING_STEPS.dtcApolloClickup)
|
|
48
|
-
}
|
|
49
|
-
];
|
|
50
|
-
var DEFAULT_PROSPECTING_BUILD_TEMPLATE_ID = "local-services";
|
|
51
|
-
var PROSPECTING_BUILD_TEMPLATE_OPTIONS = BUILD_TEMPLATE_CATALOG.map(({ id, label, description }) => ({
|
|
52
|
-
id,
|
|
53
|
-
label,
|
|
54
|
-
description
|
|
55
|
-
}));
|
|
56
|
-
function createBuildPlanSnapshotFromTemplateId(templateId) {
|
|
57
|
-
const template = BUILD_TEMPLATE_CATALOG.find((item) => item.id === templateId);
|
|
58
|
-
if (!template) return null;
|
|
59
|
-
return {
|
|
60
|
-
templateId: template.id,
|
|
61
|
-
templateLabel: template.label,
|
|
62
|
-
steps: template.steps.map((step) => {
|
|
63
|
-
const snapshotStep = {
|
|
64
|
-
id: step.id,
|
|
65
|
-
label: step.label,
|
|
66
|
-
primaryEntity: step.primaryEntity,
|
|
67
|
-
outputs: [...step.outputs],
|
|
68
|
-
stageKey: step.stageKey,
|
|
69
|
-
recordsStageKey: step.recordsStageKey ?? step.stageKey,
|
|
70
|
-
recordSourceStageKey: step.recordSourceStageKey ?? step.recordsStageKey ?? step.stageKey,
|
|
71
|
-
dependencyMode: step.dependencyMode,
|
|
72
|
-
actionKey: step.actionKey,
|
|
73
|
-
defaultBatchSize: step.defaultBatchSize,
|
|
74
|
-
maxBatchSize: step.maxBatchSize
|
|
75
|
-
};
|
|
76
|
-
if (step.description) snapshotStep.description = step.description;
|
|
77
|
-
if (step.recordEntity) snapshotStep.recordEntity = step.recordEntity;
|
|
78
|
-
if (step.dependsOn?.length) snapshotStep.dependsOn = [...step.dependsOn];
|
|
79
|
-
if (step.credentialRequirements?.length) {
|
|
80
|
-
snapshotStep.credentialRequirements = step.credentialRequirements.map((requirement) => ({
|
|
81
|
-
...requirement
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
|
-
if (step.recordColumns) {
|
|
85
|
-
snapshotStep.recordColumns = {
|
|
86
|
-
...step.recordColumns.company ? {
|
|
87
|
-
company: step.recordColumns.company.map((column) => ({ ...column }))
|
|
88
|
-
} : {},
|
|
89
|
-
...step.recordColumns.contact ? {
|
|
90
|
-
contact: step.recordColumns.contact.map((column) => ({ ...column }))
|
|
91
|
-
} : {}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
return snapshotStep;
|
|
95
|
-
})
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
function TabSection({ icon, title, description, rightSection, children }) {
|
|
99
|
-
const wrappedIcon = icon ? /* @__PURE__ */ jsx(ThemeIcon, { size: "md", variant: "light", children: icon }) : null;
|
|
100
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: "sm", p: "md", children: [
|
|
101
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "md", align: "flex-start", wrap: "nowrap", children: [
|
|
102
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 2, style: { minWidth: 0 }, children: [
|
|
103
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", children: [
|
|
104
|
-
wrappedIcon,
|
|
105
|
-
/* @__PURE__ */ jsx(Title, { order: 3, style: { overflowWrap: "anywhere" }, children: title })
|
|
106
|
-
] }),
|
|
107
|
-
description ? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", style: { overflowWrap: "anywhere" }, children: description }) : null
|
|
108
|
-
] }),
|
|
109
|
-
rightSection
|
|
110
|
-
] }),
|
|
111
|
-
children
|
|
112
|
-
] });
|
|
113
|
-
}
|
|
114
|
-
function renderField(field, form, disabled, jsonState, setJsonState) {
|
|
115
|
-
const inputProps = form.getInputProps(field.path);
|
|
116
|
-
const label = field.label;
|
|
117
|
-
const description = field.description;
|
|
118
|
-
const placeholder = field.placeholder;
|
|
119
|
-
switch (field.component) {
|
|
120
|
-
case "segmented": {
|
|
121
|
-
const options = field.options ?? [];
|
|
122
|
-
return /* @__PURE__ */ jsx(
|
|
123
|
-
SegmentedControl,
|
|
124
|
-
{
|
|
125
|
-
fullWidth: true,
|
|
126
|
-
disabled,
|
|
127
|
-
data: options,
|
|
128
|
-
value: inputProps.value ?? options[0]?.value ?? "",
|
|
129
|
-
onChange: (val) => {
|
|
130
|
-
form.setFieldValue(field.path, val);
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
field.path
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
case "tags":
|
|
137
|
-
return /* @__PURE__ */ jsx(
|
|
138
|
-
TagsInput,
|
|
139
|
-
{
|
|
140
|
-
label,
|
|
141
|
-
description,
|
|
142
|
-
placeholder,
|
|
143
|
-
disabled,
|
|
144
|
-
value: inputProps.value ?? [],
|
|
145
|
-
onChange: (val) => form.setFieldValue(field.path, val),
|
|
146
|
-
error: inputProps.error,
|
|
147
|
-
clearable: true
|
|
148
|
-
},
|
|
149
|
-
field.path
|
|
150
|
-
);
|
|
151
|
-
case "multiselect":
|
|
152
|
-
return /* @__PURE__ */ jsx(
|
|
153
|
-
MultiSelect,
|
|
154
|
-
{
|
|
155
|
-
label,
|
|
156
|
-
description,
|
|
157
|
-
placeholder,
|
|
158
|
-
disabled,
|
|
159
|
-
data: field.options ?? [],
|
|
160
|
-
value: inputProps.value ?? [],
|
|
161
|
-
onChange: (val) => form.setFieldValue(field.path, val),
|
|
162
|
-
error: inputProps.error,
|
|
163
|
-
clearable: true
|
|
164
|
-
},
|
|
165
|
-
field.path
|
|
166
|
-
);
|
|
167
|
-
case "select":
|
|
168
|
-
return /* @__PURE__ */ jsx(
|
|
169
|
-
Select,
|
|
170
|
-
{
|
|
171
|
-
label,
|
|
172
|
-
description,
|
|
173
|
-
placeholder,
|
|
174
|
-
disabled,
|
|
175
|
-
data: field.options ?? [],
|
|
176
|
-
...inputProps
|
|
177
|
-
},
|
|
178
|
-
field.path
|
|
179
|
-
);
|
|
180
|
-
case "textinput":
|
|
181
|
-
return /* @__PURE__ */ jsx(
|
|
182
|
-
TextInput,
|
|
183
|
-
{
|
|
184
|
-
label,
|
|
185
|
-
description,
|
|
186
|
-
placeholder,
|
|
187
|
-
disabled,
|
|
188
|
-
...inputProps
|
|
189
|
-
},
|
|
190
|
-
field.path
|
|
191
|
-
);
|
|
192
|
-
case "textarea":
|
|
193
|
-
return /* @__PURE__ */ jsx(
|
|
194
|
-
Textarea,
|
|
195
|
-
{
|
|
196
|
-
label,
|
|
197
|
-
description,
|
|
198
|
-
placeholder,
|
|
199
|
-
disabled,
|
|
200
|
-
autosize: true,
|
|
201
|
-
minRows: 3,
|
|
202
|
-
...inputProps
|
|
203
|
-
},
|
|
204
|
-
field.path
|
|
205
|
-
);
|
|
206
|
-
case "numberinput":
|
|
207
|
-
return /* @__PURE__ */ jsx(
|
|
208
|
-
NumberInput,
|
|
209
|
-
{
|
|
210
|
-
label,
|
|
211
|
-
description,
|
|
212
|
-
placeholder,
|
|
213
|
-
disabled,
|
|
214
|
-
min: field.min,
|
|
215
|
-
max: field.max,
|
|
216
|
-
step: field.step,
|
|
217
|
-
allowDecimal: false,
|
|
218
|
-
value: inputProps.value ?? 0,
|
|
219
|
-
onChange: (val) => form.setFieldValue(field.path, typeof val === "number" ? val : 0),
|
|
220
|
-
error: inputProps.error
|
|
221
|
-
},
|
|
222
|
-
field.path
|
|
223
|
-
);
|
|
224
|
-
case "switch":
|
|
225
|
-
return /* @__PURE__ */ jsx(
|
|
226
|
-
Switch,
|
|
227
|
-
{
|
|
228
|
-
label,
|
|
229
|
-
description,
|
|
230
|
-
disabled,
|
|
231
|
-
checked: inputProps.value ?? false,
|
|
232
|
-
onChange: (e) => form.setFieldValue(field.path, e.currentTarget.checked),
|
|
233
|
-
error: inputProps.error
|
|
234
|
-
},
|
|
235
|
-
field.path
|
|
236
|
-
);
|
|
237
|
-
case "json": {
|
|
238
|
-
const path = field.path;
|
|
239
|
-
const state = jsonState[path];
|
|
240
|
-
const rawValue = state?.raw ?? (() => {
|
|
241
|
-
const current = inputProps.value;
|
|
242
|
-
if (current === void 0 || current === null) return "";
|
|
243
|
-
if (typeof current === "string") return current;
|
|
244
|
-
try {
|
|
245
|
-
return JSON.stringify(current, null, 2);
|
|
246
|
-
} catch {
|
|
247
|
-
return "";
|
|
248
|
-
}
|
|
249
|
-
})();
|
|
250
|
-
return /* @__PURE__ */ jsx(
|
|
251
|
-
JsonInput,
|
|
252
|
-
{
|
|
253
|
-
label,
|
|
254
|
-
description,
|
|
255
|
-
placeholder,
|
|
256
|
-
disabled,
|
|
257
|
-
value: rawValue,
|
|
258
|
-
onChange: (next) => {
|
|
259
|
-
if (!next.trim()) {
|
|
260
|
-
setJsonState(path, { raw: next, invalid: false });
|
|
261
|
-
form.setFieldValue(path, void 0);
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
try {
|
|
265
|
-
const parsed = JSON.parse(next);
|
|
266
|
-
setJsonState(path, { raw: next, invalid: false });
|
|
267
|
-
form.setFieldValue(path, parsed);
|
|
268
|
-
} catch {
|
|
269
|
-
setJsonState(path, { raw: next, invalid: true });
|
|
270
|
-
form.setFieldError(path, "Invalid JSON");
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
error: state?.invalid ? "Invalid JSON" : inputProps.error,
|
|
274
|
-
autosize: true,
|
|
275
|
-
minRows: 3,
|
|
276
|
-
formatOnBlur: true
|
|
277
|
-
},
|
|
278
|
-
path
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
default:
|
|
282
|
-
return null;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
function renderSection(section, values, form, disabled, jsonState, setJsonState) {
|
|
286
|
-
if (section.when && !section.when(values)) return null;
|
|
287
|
-
const visibleFields = section.fields.filter((f) => !f.when || f.when(values));
|
|
288
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
289
|
-
section.title && /* @__PURE__ */ jsxs(Box, { children: [
|
|
290
|
-
/* @__PURE__ */ jsx(Title, { order: 5, children: section.title }),
|
|
291
|
-
section.description && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: section.description })
|
|
292
|
-
] }),
|
|
293
|
-
visibleFields.map((field) => renderField(field, form, disabled, jsonState, setJsonState))
|
|
294
|
-
] }, section.id);
|
|
295
|
-
}
|
|
296
|
-
function StepConfigForm({
|
|
297
|
-
schema,
|
|
298
|
-
layout,
|
|
299
|
-
value,
|
|
300
|
-
onChange,
|
|
301
|
-
onAction,
|
|
302
|
-
actions,
|
|
303
|
-
disabled = false,
|
|
304
|
-
slot = "all"
|
|
305
|
-
}) {
|
|
306
|
-
const initialValues = sanitizeInput(schema, value);
|
|
307
|
-
const [validationError, setValidationError] = useState(null);
|
|
308
|
-
const [advancedOpen, setAdvancedOpen] = useState(false);
|
|
309
|
-
const [jsonState, setJsonStateMap] = useState({});
|
|
310
|
-
const validationErrorRef = useRef(null);
|
|
311
|
-
const setJsonState = (path, next) => {
|
|
312
|
-
setJsonStateMap((prev) => ({ ...prev, [path]: next }));
|
|
313
|
-
};
|
|
314
|
-
const form = useForm({
|
|
315
|
-
initialValues,
|
|
316
|
-
validate: zod4Resolver(schema),
|
|
317
|
-
// onValuesChange fires synchronously after each field update — no setTimeout needed.
|
|
318
|
-
onValuesChange: (values2) => {
|
|
319
|
-
if (validationErrorRef.current) {
|
|
320
|
-
validationErrorRef.current = null;
|
|
321
|
-
setValidationError(null);
|
|
322
|
-
}
|
|
323
|
-
onChange(values2);
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
const handleActionClick = (action) => {
|
|
327
|
-
const parsed = schema.safeParse(form.values);
|
|
328
|
-
if (!parsed.success) {
|
|
329
|
-
const firstIssue = parsed.error.issues[0];
|
|
330
|
-
const fieldErrors = {};
|
|
331
|
-
for (const issue of parsed.error.issues) {
|
|
332
|
-
const path = issue.path.join(".");
|
|
333
|
-
if (path && !fieldErrors[path]) {
|
|
334
|
-
fieldErrors[path] = issue.message;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
form.setErrors(fieldErrors);
|
|
338
|
-
const msg = firstIssue?.message ?? "Validation failed";
|
|
339
|
-
validationErrorRef.current = msg;
|
|
340
|
-
setValidationError(msg);
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
validationErrorRef.current = null;
|
|
344
|
-
setValidationError(null);
|
|
345
|
-
void onAction?.(action, parsed.data);
|
|
346
|
-
};
|
|
347
|
-
const values = form.values;
|
|
348
|
-
if (slot === "advanced") {
|
|
349
|
-
return /* @__PURE__ */ jsx(Stack, { gap: "md", children: layout.advanced ? renderSection(layout.advanced, values, form, disabled, jsonState, setJsonState) : /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "No advanced settings for this step." }) });
|
|
350
|
-
}
|
|
351
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
352
|
-
slot === "all" && validationError && /* @__PURE__ */ jsx(
|
|
353
|
-
Alert,
|
|
354
|
-
{
|
|
355
|
-
color: "red",
|
|
356
|
-
onClose: () => {
|
|
357
|
-
validationErrorRef.current = null;
|
|
358
|
-
setValidationError(null);
|
|
359
|
-
},
|
|
360
|
-
withCloseButton: true,
|
|
361
|
-
children: validationError
|
|
362
|
-
}
|
|
363
|
-
),
|
|
364
|
-
layout.sections.map((section) => renderSection(section, values, form, disabled, jsonState, setJsonState)),
|
|
365
|
-
slot === "all" && layout.advanced && /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
|
|
366
|
-
/* @__PURE__ */ jsx(
|
|
367
|
-
Button,
|
|
368
|
-
{
|
|
369
|
-
variant: "subtle",
|
|
370
|
-
size: "xs",
|
|
371
|
-
onClick: () => setAdvancedOpen((o) => !o),
|
|
372
|
-
style: { alignSelf: "flex-start" },
|
|
373
|
-
children: advancedOpen ? "Hide advanced" : "Show advanced"
|
|
374
|
-
}
|
|
375
|
-
),
|
|
376
|
-
/* @__PURE__ */ jsx(Collapse, { in: advancedOpen, children: renderSection(layout.advanced, values, form, disabled, jsonState, setJsonState) })
|
|
377
|
-
] }),
|
|
378
|
-
slot === "all" && actions && actions.length > 0 && /* @__PURE__ */ jsx(Group, { gap: "sm", children: actions.map((action) => /* @__PURE__ */ jsx(
|
|
379
|
-
Button,
|
|
380
|
-
{
|
|
381
|
-
variant: action.variant ?? "filled",
|
|
382
|
-
loading: action.loading,
|
|
383
|
-
disabled: disabled || action.disabled,
|
|
384
|
-
onClick: () => handleActionClick(action),
|
|
385
|
-
children: action.label
|
|
386
|
-
},
|
|
387
|
-
action.id
|
|
388
|
-
)) })
|
|
389
|
-
] });
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
// src/features/lead-gen/manifest.ts
|
|
393
|
-
var leadGenManifest = {
|
|
394
|
-
key: "lead-gen",
|
|
395
|
-
systemId: "sales.lead-gen",
|
|
396
|
-
capabilityIds: ["leadgen.lists.manage"],
|
|
397
|
-
icon: IconTarget,
|
|
398
|
-
sidebar: SalesSidebar
|
|
399
|
-
};
|
|
400
|
-
var LEAD_GEN_ROUTE_LINKS = [
|
|
401
|
-
{ label: "Overview", to: "/lead-gen" },
|
|
402
|
-
{ label: "Lists", to: "/lead-gen/lists" },
|
|
403
|
-
{ label: "Companies", to: "/lead-gen/companies" },
|
|
404
|
-
{ label: "Contacts", to: "/lead-gen/contacts" }
|
|
405
|
-
];
|
|
406
|
-
function LeadGenRouteShell({
|
|
407
|
-
title,
|
|
408
|
-
caption,
|
|
409
|
-
body,
|
|
410
|
-
links = LEAD_GEN_ROUTE_LINKS
|
|
411
|
-
}) {
|
|
412
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
413
|
-
/* @__PURE__ */ jsx(PageTitleCaption, { title, caption }),
|
|
414
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, p: "lg", children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
415
|
-
body,
|
|
416
|
-
/* @__PURE__ */ jsx(Text, { children: links.map((link, index) => /* @__PURE__ */ jsxs("span", { children: [
|
|
417
|
-
index > 0 ? " | " : null,
|
|
418
|
-
/* @__PURE__ */ jsx(Anchor, { component: Link, to: link.to, children: link.label })
|
|
419
|
-
] }, link.to)) })
|
|
420
|
-
] }) })
|
|
421
|
-
] }) }) });
|
|
422
|
-
}
|
|
423
|
-
function formatDate(dateValue) {
|
|
424
|
-
const date = typeof dateValue === "string" ? new Date(dateValue) : dateValue;
|
|
425
|
-
return date.toLocaleDateString("en-US", {
|
|
426
|
-
month: "short",
|
|
427
|
-
day: "numeric",
|
|
428
|
-
year: "numeric"
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
function getStatusColor(status) {
|
|
432
|
-
return status === "active" ? "green" : status === "invalid" ? "red" : "gray";
|
|
433
|
-
}
|
|
434
|
-
function getStateKeyColor(stateKey) {
|
|
435
|
-
switch (stateKey) {
|
|
436
|
-
case "draft":
|
|
437
|
-
return "gray";
|
|
438
|
-
case "enriching":
|
|
439
|
-
return "blue";
|
|
440
|
-
case "launched":
|
|
441
|
-
return "green";
|
|
442
|
-
case "closing":
|
|
443
|
-
return "yellow";
|
|
444
|
-
case "archived":
|
|
445
|
-
return "dimmed";
|
|
446
|
-
default:
|
|
447
|
-
return "gray";
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
function getEnrichmentColor(status) {
|
|
451
|
-
switch (status) {
|
|
452
|
-
case "complete":
|
|
453
|
-
return "green";
|
|
454
|
-
case "pending":
|
|
455
|
-
return "yellow";
|
|
456
|
-
case "failed":
|
|
457
|
-
return "red";
|
|
458
|
-
default:
|
|
459
|
-
return "gray";
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
function getEnrichmentStatus(enrichmentData) {
|
|
463
|
-
if (!enrichmentData || typeof enrichmentData !== "object") return "pending";
|
|
464
|
-
const website = enrichmentData.website;
|
|
465
|
-
const linkedin = enrichmentData.linkedin;
|
|
466
|
-
if (website === "complete" && linkedin === "complete") return "complete";
|
|
467
|
-
if (website === "failed" || linkedin === "failed") return "failed";
|
|
468
|
-
return "pending";
|
|
469
|
-
}
|
|
470
|
-
function useDeleteLists() {
|
|
471
|
-
const { apiRequest, workOSOrganizationId } = useElevasisServices();
|
|
472
|
-
const queryClient = useQueryClient();
|
|
473
|
-
return useMutation({
|
|
474
|
-
mutationFn: async (listIds) => {
|
|
475
|
-
const uniqueIds = [...new Set(listIds)].filter(Boolean);
|
|
476
|
-
if (uniqueIds.length === 0) return;
|
|
477
|
-
await Promise.all(
|
|
478
|
-
uniqueIds.map(
|
|
479
|
-
(listId) => apiRequest(`/acquisition/lists/${listId}`, {
|
|
480
|
-
method: "DELETE"
|
|
481
|
-
})
|
|
482
|
-
)
|
|
483
|
-
);
|
|
484
|
-
},
|
|
485
|
-
onSuccess: () => {
|
|
486
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.list(workOSOrganizationId) });
|
|
487
|
-
queryClient.invalidateQueries({ queryKey: acquisitionListKeys.telemetry(workOSOrganizationId) });
|
|
488
|
-
showSuccessNotification("Lists deleted");
|
|
489
|
-
},
|
|
490
|
-
onError: (error) => {
|
|
491
|
-
showApiErrorNotification(error);
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
function computeBacklog(current, completed) {
|
|
496
|
-
return Math.max(current - completed, 0);
|
|
497
|
-
}
|
|
498
|
-
function getOverviewStatus(list) {
|
|
499
|
-
if ((list.activeWorkflows?.length ?? 0) > 0) {
|
|
500
|
-
return { label: "Active Work", color: "green" };
|
|
501
|
-
}
|
|
502
|
-
if (list.stageCounts.personalized > 0 && list.stageCounts.personalized === list.stageCounts.uploaded) {
|
|
503
|
-
return { label: "Complete", color: "blue" };
|
|
504
|
-
}
|
|
505
|
-
return { label: "Idle", color: "gray" };
|
|
506
|
-
}
|
|
507
|
-
function getNextFocus(list) {
|
|
508
|
-
if ((list.activeWorkflows?.length ?? 0) > 0) {
|
|
509
|
-
return { label: "Workflow running", count: list.activeWorkflows?.length ?? 0 };
|
|
510
|
-
}
|
|
511
|
-
if (list.totalCompanies === 0 && list.totalContacts === 0) {
|
|
512
|
-
return { label: "Populate list", count: null };
|
|
513
|
-
}
|
|
514
|
-
const extractGap = computeBacklog(list.stageCounts.populated, list.stageCounts.extracted);
|
|
515
|
-
if (extractGap > 0) {
|
|
516
|
-
return { label: "Extract website data", count: extractGap };
|
|
517
|
-
}
|
|
518
|
-
const qualifyGap = computeBacklog(list.stageCounts.extracted, list.stageCounts.qualified);
|
|
519
|
-
if (qualifyGap > 0) {
|
|
520
|
-
return { label: "Qualify companies", count: qualifyGap };
|
|
521
|
-
}
|
|
522
|
-
const discoverGap = computeBacklog(list.stageCounts.qualified, list.stageCounts.discovered);
|
|
523
|
-
if (discoverGap > 0) {
|
|
524
|
-
return { label: "Discover contacts", count: discoverGap };
|
|
525
|
-
}
|
|
526
|
-
const verifyGap = computeBacklog(list.stageCounts.discovered, list.stageCounts.verified);
|
|
527
|
-
if (verifyGap > 0) {
|
|
528
|
-
return { label: "Verify emails", count: verifyGap };
|
|
529
|
-
}
|
|
530
|
-
const personalizeGap = computeBacklog(list.stageCounts.verified, list.stageCounts.personalized);
|
|
531
|
-
if (personalizeGap > 0) {
|
|
532
|
-
return { label: "Personalize outreach", count: personalizeGap };
|
|
533
|
-
}
|
|
534
|
-
const uploadGap = computeBacklog(list.stageCounts.personalized, list.stageCounts.uploaded);
|
|
535
|
-
if (uploadGap > 0) {
|
|
536
|
-
return { label: "Upload contacts", count: uploadGap };
|
|
537
|
-
}
|
|
538
|
-
return { label: "Complete", count: null };
|
|
539
|
-
}
|
|
540
|
-
function formatCountLabel(value, noun) {
|
|
541
|
-
return `${value} ${noun}${value === 1 ? "" : "s"}`;
|
|
542
|
-
}
|
|
543
|
-
function getPrimaryAction({
|
|
544
|
-
uploadBacklog,
|
|
545
|
-
personalizationBacklog,
|
|
546
|
-
verificationBacklog,
|
|
547
|
-
deliverabilityRiskCount,
|
|
548
|
-
activeListCount,
|
|
549
|
-
totalLists
|
|
550
|
-
}) {
|
|
551
|
-
if (uploadBacklog > 0) {
|
|
552
|
-
return {
|
|
553
|
-
title: `Upload ${formatCountLabel(uploadBacklog, "personalized contact")}`,
|
|
554
|
-
detail: "No verification blockers are left on the contacts already ready for outreach.",
|
|
555
|
-
buttonLabel: "Review lists",
|
|
556
|
-
buttonTo: "/lead-gen/lists",
|
|
557
|
-
tone: "blue"
|
|
558
|
-
};
|
|
559
|
-
}
|
|
560
|
-
if (personalizationBacklog > 0) {
|
|
561
|
-
return {
|
|
562
|
-
title: `Personalize ${formatCountLabel(personalizationBacklog, "verified contact")}`,
|
|
563
|
-
detail: "Verification is done. The next bottleneck is drafting outreach copy.",
|
|
564
|
-
buttonLabel: "Open lists",
|
|
565
|
-
buttonTo: "/lead-gen/lists",
|
|
566
|
-
tone: "blue"
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
if (verificationBacklog > 0) {
|
|
570
|
-
return {
|
|
571
|
-
title: `Verify ${formatCountLabel(verificationBacklog, "discovered contact")}`,
|
|
572
|
-
detail: "Email validation is the main blocker before personalization can continue.",
|
|
573
|
-
buttonLabel: "Open lists",
|
|
574
|
-
buttonTo: "/lead-gen/lists",
|
|
575
|
-
tone: "orange"
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
if (deliverabilityRiskCount > 0) {
|
|
579
|
-
return {
|
|
580
|
-
title: `Resolve ${formatCountLabel(deliverabilityRiskCount, "deliverability risk")}`,
|
|
581
|
-
detail: "Risky, invalid, or bounced records are the main campaign health issue right now.",
|
|
582
|
-
buttonLabel: "Review lists",
|
|
583
|
-
buttonTo: "/lead-gen/lists",
|
|
584
|
-
tone: "orange"
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
if (activeListCount > 0) {
|
|
588
|
-
return {
|
|
589
|
-
title: `Monitor ${formatCountLabel(activeListCount, "active list")}`,
|
|
590
|
-
detail: "Workflows are running and there are no immediate contact-stage backlogs to clear.",
|
|
591
|
-
buttonLabel: "Open lists",
|
|
592
|
-
buttonTo: "/lead-gen/lists",
|
|
593
|
-
tone: "green"
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
if (totalLists > 0) {
|
|
597
|
-
return {
|
|
598
|
-
title: "No blockers right now",
|
|
599
|
-
detail: "Lists are idle and the current pipeline does not show an urgent follow-up step.",
|
|
600
|
-
buttonLabel: "Review lists",
|
|
601
|
-
buttonTo: "/lead-gen/lists",
|
|
602
|
-
tone: "gray"
|
|
603
|
-
};
|
|
604
|
-
}
|
|
605
|
-
return {
|
|
606
|
-
title: "Create your first list",
|
|
607
|
-
detail: "Lead gen telemetry will appear here once a list starts moving through the pipeline.",
|
|
608
|
-
buttonLabel: "Open lists",
|
|
609
|
-
buttonTo: "/lead-gen/lists",
|
|
610
|
-
tone: "gray"
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
function LeadGenOverviewPage() {
|
|
614
|
-
const navigate = useNavigate();
|
|
615
|
-
const telemetryQuery = useListsTelemetry();
|
|
616
|
-
const listsQuery = useLists();
|
|
617
|
-
const data = telemetryQuery.data;
|
|
618
|
-
const listMetaById = new Map((listsQuery.data ?? []).map((list) => [list.id, list]));
|
|
619
|
-
const stageTotals = data?.reduce(
|
|
620
|
-
(acc, list) => ({
|
|
621
|
-
populated: acc.populated + list.stageCounts.populated,
|
|
622
|
-
extracted: acc.extracted + list.stageCounts.extracted,
|
|
623
|
-
qualified: acc.qualified + list.stageCounts.qualified,
|
|
624
|
-
discovered: acc.discovered + list.stageCounts.discovered,
|
|
625
|
-
verified: acc.verified + list.stageCounts.verified,
|
|
626
|
-
personalized: acc.personalized + list.stageCounts.personalized,
|
|
627
|
-
uploaded: acc.uploaded + list.stageCounts.uploaded
|
|
628
|
-
}),
|
|
629
|
-
{ populated: 0, extracted: 0, qualified: 0, discovered: 0, verified: 0, personalized: 0, uploaded: 0 }
|
|
630
|
-
) ?? { discovered: 0, verified: 0, personalized: 0, uploaded: 0 };
|
|
631
|
-
const deliverabilityTotals = data?.reduce(
|
|
632
|
-
(acc, list) => ({
|
|
633
|
-
valid: acc.valid + list.deliverability.valid,
|
|
634
|
-
risky: acc.risky + list.deliverability.risky,
|
|
635
|
-
invalid: acc.invalid + list.deliverability.invalid,
|
|
636
|
-
unknown: acc.unknown + list.deliverability.unknown,
|
|
637
|
-
bounced: acc.bounced + list.deliverability.bounced
|
|
638
|
-
}),
|
|
639
|
-
{ valid: 0, risky: 0, invalid: 0, unknown: 0, bounced: 0 }
|
|
640
|
-
) ?? { risky: 0, invalid: 0, bounced: 0 };
|
|
641
|
-
const activeListCount = data?.filter((list) => (list.activeWorkflows?.length ?? 0) > 0).length ?? 0;
|
|
642
|
-
const verificationBacklog = computeBacklog(stageTotals.discovered, stageTotals.verified);
|
|
643
|
-
const personalizationBacklog = computeBacklog(stageTotals.verified, stageTotals.personalized);
|
|
644
|
-
const uploadBacklog = computeBacklog(stageTotals.personalized, stageTotals.uploaded);
|
|
645
|
-
const deliverabilityRiskCount = deliverabilityTotals.risky + deliverabilityTotals.invalid + deliverabilityTotals.bounced;
|
|
646
|
-
const totalLists = data?.length ?? 0;
|
|
647
|
-
const summaryLine = [
|
|
648
|
-
`${totalLists} total ${totalLists === 1 ? "list" : "lists"}`,
|
|
649
|
-
`${formatCountLabel(uploadBacklog, "contact")} ready for upload`,
|
|
650
|
-
deliverabilityRiskCount === 0 ? "no risks" : `${formatCountLabel(deliverabilityRiskCount, "risk")}`
|
|
651
|
-
].join(" | ");
|
|
652
|
-
const primaryAction = getPrimaryAction({
|
|
653
|
-
uploadBacklog,
|
|
654
|
-
personalizationBacklog,
|
|
655
|
-
verificationBacklog,
|
|
656
|
-
deliverabilityRiskCount,
|
|
657
|
-
activeListCount,
|
|
658
|
-
totalLists
|
|
659
|
-
});
|
|
660
|
-
const overviewRows = data?.map((list) => {
|
|
661
|
-
const listMeta = listMetaById.get(list.listId);
|
|
662
|
-
const nextFocus = getNextFocus(list);
|
|
663
|
-
return {
|
|
664
|
-
...list,
|
|
665
|
-
name: listMeta?.name ?? `List ${list.listId.slice(0, 8)}`,
|
|
666
|
-
nextFocus,
|
|
667
|
-
status: getOverviewStatus(list)
|
|
668
|
-
};
|
|
669
|
-
}).sort((a, b) => {
|
|
670
|
-
const aActive = a.status.label === "Active Work" ? 1 : 0;
|
|
671
|
-
const bActive = b.status.label === "Active Work" ? 1 : 0;
|
|
672
|
-
if (aActive !== bActive) return bActive - aActive;
|
|
673
|
-
const aBacklog = computeBacklog(a.stageCounts.discovered, a.stageCounts.verified) + computeBacklog(a.stageCounts.verified, a.stageCounts.personalized) + computeBacklog(a.stageCounts.personalized, a.stageCounts.uploaded);
|
|
674
|
-
const bBacklog = computeBacklog(b.stageCounts.discovered, b.stageCounts.verified) + computeBacklog(b.stageCounts.verified, b.stageCounts.personalized) + computeBacklog(b.stageCounts.personalized, b.stageCounts.uploaded);
|
|
675
|
-
if (aBacklog !== bBacklog) return bBacklog - aBacklog;
|
|
676
|
-
return b.totalContacts - a.totalContacts;
|
|
677
|
-
}) ?? [];
|
|
678
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
679
|
-
/* @__PURE__ */ jsx(PageTitleCaption, { title: "Lead Gen Overview", caption: summaryLine }),
|
|
680
|
-
telemetryQuery.isLoading ? /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) }) : telemetryQuery.isError ? /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(CenteredErrorState, { error: telemetryQuery.error, title: "Failed to load list telemetry" }) }) : !data?.length ? /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { h: 300, children: /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), color: "gray", variant: "light", children: "No lists yet." }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
681
|
-
/* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 1, sm: 3 }, children: [
|
|
682
|
-
/* @__PURE__ */ jsx(StatCard, { variant: "hero", icon: IconPlayerPlay, value: totalLists, label: "Total Lists" }),
|
|
683
|
-
/* @__PURE__ */ jsx(StatCard, { variant: "hero", icon: IconArrowRight, value: uploadBacklog, label: "Ready Contacts" }),
|
|
684
|
-
/* @__PURE__ */ jsx(StatCard, { variant: "hero", icon: IconAlertCircle, value: deliverabilityRiskCount, label: "At Risk" })
|
|
685
|
-
] }),
|
|
686
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, p: "md", children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
687
|
-
/* @__PURE__ */ jsx(CardHeader, { icon: /* @__PURE__ */ jsx(IconSparkles, { size: 18 }), title: "Next Action", subtitle: primaryAction.title }),
|
|
688
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", maw: 620, children: primaryAction.detail }),
|
|
689
|
-
/* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 1, md: 2 }, children: [
|
|
690
|
-
/* @__PURE__ */ jsxs(Card, { withBorder: true, p: "sm", children: [
|
|
691
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", tt: "uppercase", fw: 600, children: "Verification" }),
|
|
692
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "flex-end", mt: 6, children: [
|
|
693
|
-
/* @__PURE__ */ jsx(Title, { order: 4, children: verificationBacklog }),
|
|
694
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "waiting" })
|
|
695
|
-
] })
|
|
696
|
-
] }),
|
|
697
|
-
/* @__PURE__ */ jsxs(Card, { withBorder: true, p: "sm", children: [
|
|
698
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", tt: "uppercase", fw: 600, children: "Personalization" }),
|
|
699
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "flex-end", mt: 6, children: [
|
|
700
|
-
/* @__PURE__ */ jsx(Title, { order: 4, children: personalizationBacklog }),
|
|
701
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "ready" })
|
|
702
|
-
] })
|
|
703
|
-
] })
|
|
704
|
-
] })
|
|
705
|
-
] }) }),
|
|
706
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, p: "md", children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
707
|
-
/* @__PURE__ */ jsx(
|
|
708
|
-
CardHeader,
|
|
709
|
-
{
|
|
710
|
-
icon: /* @__PURE__ */ jsx(IconListDetails, { size: 18 }),
|
|
711
|
-
title: "List Snapshot",
|
|
712
|
-
subtitle: "Ranked to surface active work first, then the largest unresolved backlogs."
|
|
713
|
-
}
|
|
714
|
-
),
|
|
715
|
-
/* @__PURE__ */ jsxs(Table, { children: [
|
|
716
|
-
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
717
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "List" }),
|
|
718
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Companies" }),
|
|
719
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Contacts" }),
|
|
720
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Next Focus" }),
|
|
721
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Status" })
|
|
722
|
-
] }) }),
|
|
723
|
-
/* @__PURE__ */ jsx(Table.Tbody, { children: overviewRows.map((list) => /* @__PURE__ */ jsxs(
|
|
724
|
-
Table.Tr,
|
|
725
|
-
{
|
|
726
|
-
style: { cursor: "pointer" },
|
|
727
|
-
onClick: () => navigate({ to: "/lead-gen/lists/$listId", params: { listId: list.listId } }),
|
|
728
|
-
children: [
|
|
729
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
730
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, children: list.name }),
|
|
731
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: list.listId })
|
|
732
|
-
] }) }),
|
|
733
|
-
/* @__PURE__ */ jsx(Table.Td, { children: list.totalCompanies }),
|
|
734
|
-
/* @__PURE__ */ jsx(Table.Td, { children: list.totalContacts }),
|
|
735
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
736
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, children: list.nextFocus.label }),
|
|
737
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: list.nextFocus.count == null ? "No outstanding count" : `${list.nextFocus.count} item${list.nextFocus.count === 1 ? "" : "s"} queued` })
|
|
738
|
-
] }) }),
|
|
739
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: list.status.color, children: list.status.label }) })
|
|
740
|
-
]
|
|
741
|
-
},
|
|
742
|
-
list.listId
|
|
743
|
-
)) })
|
|
744
|
-
] })
|
|
745
|
-
] }) })
|
|
746
|
-
] })
|
|
747
|
-
] }) }) });
|
|
748
|
-
}
|
|
749
|
-
var PAGE_SIZE_DEFAULT = 20;
|
|
750
|
-
var BUILD_TEMPLATE_SELECT_OPTIONS = PROSPECTING_BUILD_TEMPLATE_OPTIONS.map((template) => ({
|
|
751
|
-
value: template.id,
|
|
752
|
-
label: template.label
|
|
753
|
-
}));
|
|
754
|
-
var STATUS_FILTER_OPTIONS = [
|
|
755
|
-
{ value: "", label: "All statuses" },
|
|
756
|
-
{ value: "draft", label: "Draft" },
|
|
757
|
-
{ value: "enriching", label: "Enriching" },
|
|
758
|
-
{ value: "launched", label: "Launched" },
|
|
759
|
-
{ value: "closing", label: "Closing" },
|
|
760
|
-
{ value: "archived", label: "Archived" }
|
|
761
|
-
];
|
|
762
|
-
function LeadGenListsPage() {
|
|
763
|
-
const navigate = useNavigate();
|
|
764
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
765
|
-
const [statusFilter, setStatusFilter] = useState("");
|
|
766
|
-
const [showCreateList, setShowCreateList] = useState(false);
|
|
767
|
-
const [newListName, setNewListName] = useState("");
|
|
768
|
-
const [newListDescription, setNewListDescription] = useState("");
|
|
769
|
-
const [newBuildTemplateId, setNewBuildTemplateId] = useState(DEFAULT_PROSPECTING_BUILD_TEMPLATE_ID);
|
|
770
|
-
const [showBatchDelete, setShowBatchDelete] = useState(false);
|
|
771
|
-
const { data: lists, isLoading: listsLoading } = useLists();
|
|
772
|
-
const { data: telemetry, isLoading: telemetryLoading } = useListsTelemetry();
|
|
773
|
-
const createListMutation = useCreateList();
|
|
774
|
-
const deleteListsMutation = useDeleteLists();
|
|
775
|
-
const { sort, toggleSort } = useTableSort("created");
|
|
776
|
-
const contactCountByListId = useMemo(
|
|
777
|
-
() => new Map((telemetry ?? []).map((item) => [item.listId, item.totalContacts])),
|
|
778
|
-
[telemetry]
|
|
779
|
-
);
|
|
780
|
-
const sortAccessors = useMemo(
|
|
781
|
-
() => ({
|
|
782
|
-
name: (list) => list.name,
|
|
783
|
-
description: (list) => list.description || "",
|
|
784
|
-
contacts: (list) => contactCountByListId.get(list.id) ?? 0,
|
|
785
|
-
batches: (list) => list.batchIds.length,
|
|
786
|
-
created: (list) => list.createdAt,
|
|
787
|
-
status: (list) => list.status
|
|
788
|
-
}),
|
|
789
|
-
[contactCountByListId]
|
|
790
|
-
);
|
|
791
|
-
const filteredLists = useMemo(() => {
|
|
792
|
-
if (!lists) return [];
|
|
793
|
-
let result = lists;
|
|
794
|
-
if (searchQuery.trim()) {
|
|
795
|
-
const query = searchQuery.toLowerCase();
|
|
796
|
-
result = result.filter((list) => list.name.toLowerCase().includes(query));
|
|
797
|
-
}
|
|
798
|
-
if (statusFilter) {
|
|
799
|
-
result = result.filter((list) => list.status === statusFilter);
|
|
800
|
-
}
|
|
801
|
-
return result;
|
|
802
|
-
}, [lists, searchQuery, statusFilter]);
|
|
803
|
-
const sortedLists = useMemo(() => sortData(filteredLists, sort, sortAccessors), [filteredLists, sort, sortAccessors]);
|
|
804
|
-
const pagination = usePaginationState(PAGE_SIZE_DEFAULT, [searchQuery, statusFilter], sortedLists.length);
|
|
805
|
-
const paginatedLists = useMemo(
|
|
806
|
-
() => sortedLists.slice(pagination.offset, pagination.offset + PAGE_SIZE_DEFAULT),
|
|
807
|
-
[sortedLists, pagination.offset]
|
|
808
|
-
);
|
|
809
|
-
const selection = useTableSelection(paginatedLists, sortedLists);
|
|
810
|
-
const selectedBuildTemplate = PROSPECTING_BUILD_TEMPLATE_OPTIONS.find((template) => template.id === newBuildTemplateId);
|
|
811
|
-
function resetCreateListModal() {
|
|
812
|
-
setNewListName("");
|
|
813
|
-
setNewListDescription("");
|
|
814
|
-
setNewBuildTemplateId(DEFAULT_PROSPECTING_BUILD_TEMPLATE_ID);
|
|
815
|
-
setShowCreateList(false);
|
|
816
|
-
}
|
|
817
|
-
function handleCreateList() {
|
|
818
|
-
const trimmedName = newListName.trim();
|
|
819
|
-
if (!trimmedName) return;
|
|
820
|
-
const body = {
|
|
821
|
-
name: trimmedName,
|
|
822
|
-
description: newListDescription.trim() || null,
|
|
823
|
-
buildTemplateId: newBuildTemplateId
|
|
824
|
-
};
|
|
825
|
-
createListMutation.mutate(body, {
|
|
826
|
-
onSuccess: (list) => {
|
|
827
|
-
resetCreateListModal();
|
|
828
|
-
navigate({ to: "/lead-gen/lists/$listId", params: { listId: list.id } });
|
|
829
|
-
}
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsxs(PageContainer, { children: [
|
|
833
|
-
/* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(
|
|
834
|
-
PageTitleCaption,
|
|
835
|
-
{
|
|
836
|
-
title: "Lists",
|
|
837
|
-
caption: "Lead lists and contact organization",
|
|
838
|
-
rightSection: /* @__PURE__ */ jsx(
|
|
839
|
-
Button,
|
|
840
|
-
{
|
|
841
|
-
leftSection: /* @__PURE__ */ jsx(IconPlus, { size: 16 }),
|
|
842
|
-
onClick: () => setShowCreateList(true),
|
|
843
|
-
variant: "light",
|
|
844
|
-
size: "xs",
|
|
845
|
-
children: "New List"
|
|
846
|
-
}
|
|
847
|
-
)
|
|
848
|
-
}
|
|
849
|
-
) }),
|
|
850
|
-
/* @__PURE__ */ jsx(Paper, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
851
|
-
/* @__PURE__ */ jsxs(
|
|
852
|
-
FilterBar,
|
|
853
|
-
{
|
|
854
|
-
actions: /* @__PURE__ */ jsx(
|
|
855
|
-
TableSelectionToolbar,
|
|
856
|
-
{
|
|
857
|
-
selectedCount: selection.selectedCount,
|
|
858
|
-
onDelete: () => setShowBatchDelete(true),
|
|
859
|
-
isDeleting: deleteListsMutation.isPending
|
|
860
|
-
}
|
|
861
|
-
),
|
|
862
|
-
children: [
|
|
863
|
-
/* @__PURE__ */ jsx(
|
|
864
|
-
TextInput,
|
|
865
|
-
{
|
|
866
|
-
placeholder: "Search by name...",
|
|
867
|
-
leftSection: /* @__PURE__ */ jsx(IconSearch, { size: 16 }),
|
|
868
|
-
value: searchQuery,
|
|
869
|
-
onChange: (e) => setSearchQuery(e.currentTarget.value)
|
|
870
|
-
}
|
|
871
|
-
),
|
|
872
|
-
/* @__PURE__ */ jsx(
|
|
873
|
-
Select,
|
|
874
|
-
{
|
|
875
|
-
placeholder: "All statuses",
|
|
876
|
-
data: STATUS_FILTER_OPTIONS,
|
|
877
|
-
value: statusFilter,
|
|
878
|
-
onChange: (value) => setStatusFilter(value ?? ""),
|
|
879
|
-
clearable: true,
|
|
880
|
-
size: "sm",
|
|
881
|
-
w: 160
|
|
882
|
-
}
|
|
883
|
-
)
|
|
884
|
-
]
|
|
885
|
-
}
|
|
886
|
-
),
|
|
887
|
-
listsLoading || telemetryLoading ? /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) : !filteredLists.length ? /* @__PURE__ */ jsx(
|
|
888
|
-
EmptyState,
|
|
889
|
-
{
|
|
890
|
-
icon: IconList,
|
|
891
|
-
title: searchQuery.trim() || statusFilter ? "No lists match your filters" : "No lists yet",
|
|
892
|
-
description: searchQuery.trim() || statusFilter ? void 0 : "Create one to get started.",
|
|
893
|
-
action: searchQuery.trim() || statusFilter ? void 0 : {
|
|
894
|
-
label: "Create List",
|
|
895
|
-
onClick: () => setShowCreateList(true),
|
|
896
|
-
icon: /* @__PURE__ */ jsx(IconPlus, { size: 16 })
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
) : /* @__PURE__ */ jsxs(Table, { children: [
|
|
900
|
-
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
901
|
-
/* @__PURE__ */ jsx(Table.Th, { w: 40, children: /* @__PURE__ */ jsx(
|
|
902
|
-
Checkbox,
|
|
903
|
-
{
|
|
904
|
-
checked: selection.isPageAllSelected,
|
|
905
|
-
indeterminate: selection.isPagePartiallySelected,
|
|
906
|
-
onChange: selection.togglePage
|
|
907
|
-
}
|
|
908
|
-
) }),
|
|
909
|
-
/* @__PURE__ */ jsx(SortableHeader, { column: "name", sort, onToggle: toggleSort, children: "Name" }),
|
|
910
|
-
/* @__PURE__ */ jsx(SortableHeader, { column: "description", sort, onToggle: toggleSort, children: "Description" }),
|
|
911
|
-
/* @__PURE__ */ jsx(SortableHeader, { column: "status", sort, onToggle: toggleSort, children: "Status" }),
|
|
912
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Pipeline" }),
|
|
913
|
-
/* @__PURE__ */ jsx(SortableHeader, { column: "contacts", sort, onToggle: toggleSort, children: "Contacts" }),
|
|
914
|
-
/* @__PURE__ */ jsx(SortableHeader, { column: "batches", sort, onToggle: toggleSort, children: "Batches" }),
|
|
915
|
-
/* @__PURE__ */ jsx(SortableHeader, { column: "created", sort, onToggle: toggleSort, children: "Created" }),
|
|
916
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "List" })
|
|
917
|
-
] }) }),
|
|
918
|
-
/* @__PURE__ */ jsx(Table.Tbody, { children: paginatedLists.map((list) => {
|
|
919
|
-
const pipelineLabel = list.metadata.buildPlanSnapshot?.templateLabel;
|
|
920
|
-
return /* @__PURE__ */ jsxs(
|
|
921
|
-
Table.Tr,
|
|
922
|
-
{
|
|
923
|
-
style: { cursor: "pointer" },
|
|
924
|
-
onClick: () => navigate({ to: "/lead-gen/lists/$listId", params: { listId: list.id } }),
|
|
925
|
-
children: [
|
|
926
|
-
/* @__PURE__ */ jsx(Table.Td, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
|
|
927
|
-
Checkbox,
|
|
928
|
-
{
|
|
929
|
-
checked: selection.isSelected(list.id),
|
|
930
|
-
onChange: () => selection.toggle(list.id)
|
|
931
|
-
}
|
|
932
|
-
) }),
|
|
933
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Group, { gap: 6, wrap: "nowrap", children: [
|
|
934
|
-
/* @__PURE__ */ jsx(Text, { fw: 500, children: list.name }),
|
|
935
|
-
list.instantlyCampaignId ? /* @__PURE__ */ jsx(
|
|
936
|
-
Anchor,
|
|
937
|
-
{
|
|
938
|
-
href: `https://app.instantly.ai/app/campaign/${list.instantlyCampaignId}/analytics`,
|
|
939
|
-
target: "_blank",
|
|
940
|
-
rel: "noreferrer",
|
|
941
|
-
onClick: (e) => e.stopPropagation(),
|
|
942
|
-
c: "dimmed",
|
|
943
|
-
lh: 1,
|
|
944
|
-
children: /* @__PURE__ */ jsx(IconExternalLink, { size: 16 })
|
|
945
|
-
}
|
|
946
|
-
) : null
|
|
947
|
-
] }) }),
|
|
948
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: list.description || "-" }) }),
|
|
949
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { size: "sm", color: getStateKeyColor(list.status), variant: "light", children: list.status }) }),
|
|
950
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: pipelineLabel || "\u2014" }) }),
|
|
951
|
-
/* @__PURE__ */ jsx(Table.Td, { children: contactCountByListId.get(list.id) ?? 0 }),
|
|
952
|
-
/* @__PURE__ */ jsx(Table.Td, { children: list.batchIds.length }),
|
|
953
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: formatDate(list.createdAt) }) }),
|
|
954
|
-
/* @__PURE__ */ jsx(Table.Td, { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(
|
|
955
|
-
Button,
|
|
956
|
-
{
|
|
957
|
-
size: "xs",
|
|
958
|
-
variant: "subtle",
|
|
959
|
-
leftSection: /* @__PURE__ */ jsx(IconList, { size: 14 }),
|
|
960
|
-
onClick: () => navigate({ to: "/lead-gen/lists/$listId", params: { listId: list.id } }),
|
|
961
|
-
children: "Open"
|
|
962
|
-
}
|
|
963
|
-
) })
|
|
964
|
-
]
|
|
965
|
-
},
|
|
966
|
-
list.id
|
|
967
|
-
);
|
|
968
|
-
}) })
|
|
969
|
-
] }),
|
|
970
|
-
sortedLists.length > PAGE_SIZE_DEFAULT && /* @__PURE__ */ jsx(Group, { justify: "center", children: /* @__PURE__ */ jsx(
|
|
971
|
-
Pagination,
|
|
972
|
-
{
|
|
973
|
-
value: pagination.page,
|
|
974
|
-
onChange: pagination.setPage,
|
|
975
|
-
total: pagination.totalPages(sortedLists.length),
|
|
976
|
-
size: "sm"
|
|
977
|
-
}
|
|
978
|
-
) })
|
|
979
|
-
] }) }),
|
|
980
|
-
/* @__PURE__ */ jsx(
|
|
981
|
-
CustomModal,
|
|
982
|
-
{
|
|
983
|
-
opened: showCreateList,
|
|
984
|
-
onClose: () => !createListMutation.isPending && resetCreateListModal(),
|
|
985
|
-
size: "md",
|
|
986
|
-
loading: createListMutation.isPending,
|
|
987
|
-
children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
988
|
-
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
989
|
-
/* @__PURE__ */ jsx(IconSparkles, { size: 24 }),
|
|
990
|
-
/* @__PURE__ */ jsx(Title, { order: 4, children: "Create List" })
|
|
991
|
-
] }),
|
|
992
|
-
/* @__PURE__ */ jsx(
|
|
993
|
-
TextInput,
|
|
994
|
-
{
|
|
995
|
-
label: "List Name",
|
|
996
|
-
placeholder: "e.g. Orange County Vets Q2",
|
|
997
|
-
value: newListName,
|
|
998
|
-
onChange: (event) => setNewListName(event.currentTarget.value),
|
|
999
|
-
disabled: createListMutation.isPending,
|
|
1000
|
-
required: true
|
|
1001
|
-
}
|
|
1002
|
-
),
|
|
1003
|
-
/* @__PURE__ */ jsx(
|
|
1004
|
-
Textarea,
|
|
1005
|
-
{
|
|
1006
|
-
label: "Description",
|
|
1007
|
-
placeholder: "Optional context for this list",
|
|
1008
|
-
value: newListDescription,
|
|
1009
|
-
onChange: (event) => setNewListDescription(event.currentTarget.value),
|
|
1010
|
-
disabled: createListMutation.isPending,
|
|
1011
|
-
minRows: 3
|
|
1012
|
-
}
|
|
1013
|
-
),
|
|
1014
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
|
|
1015
|
-
/* @__PURE__ */ jsx(
|
|
1016
|
-
Select,
|
|
1017
|
-
{
|
|
1018
|
-
label: "Build Pipeline",
|
|
1019
|
-
description: "Choose the sequence this list should follow.",
|
|
1020
|
-
data: BUILD_TEMPLATE_SELECT_OPTIONS,
|
|
1021
|
-
value: newBuildTemplateId,
|
|
1022
|
-
onChange: (value) => setNewBuildTemplateId(value ?? DEFAULT_PROSPECTING_BUILD_TEMPLATE_ID),
|
|
1023
|
-
disabled: createListMutation.isPending,
|
|
1024
|
-
required: true
|
|
1025
|
-
}
|
|
1026
|
-
),
|
|
1027
|
-
selectedBuildTemplate?.description ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: selectedBuildTemplate.description }) : null
|
|
1028
|
-
] }),
|
|
1029
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "The list will open in draft mode after creation so you can review configuration and run build steps from the list workspace." }),
|
|
1030
|
-
/* @__PURE__ */ jsxs(Group, { justify: "flex-end", children: [
|
|
1031
|
-
/* @__PURE__ */ jsx(Button, { variant: "light", onClick: resetCreateListModal, disabled: createListMutation.isPending, children: "Cancel" }),
|
|
1032
|
-
/* @__PURE__ */ jsx(Button, { onClick: handleCreateList, loading: createListMutation.isPending, disabled: !newListName.trim(), children: "Create List" })
|
|
1033
|
-
] })
|
|
1034
|
-
] })
|
|
1035
|
-
}
|
|
1036
|
-
),
|
|
1037
|
-
/* @__PURE__ */ jsx(
|
|
1038
|
-
CustomModal,
|
|
1039
|
-
{
|
|
1040
|
-
opened: showBatchDelete,
|
|
1041
|
-
onClose: () => !deleteListsMutation.isPending && setShowBatchDelete(false),
|
|
1042
|
-
size: "sm",
|
|
1043
|
-
loading: deleteListsMutation.isPending,
|
|
1044
|
-
children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
1045
|
-
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
1046
|
-
/* @__PURE__ */ jsx(IconAlertTriangle, { size: 24, color: "var(--color-error)" }),
|
|
1047
|
-
/* @__PURE__ */ jsxs(Title, { order: 4, children: [
|
|
1048
|
-
"Delete ",
|
|
1049
|
-
selection.selectedCount,
|
|
1050
|
-
" Lists"
|
|
1051
|
-
] })
|
|
1052
|
-
] }),
|
|
1053
|
-
/* @__PURE__ */ jsxs(Text, { size: "sm", children: [
|
|
1054
|
-
"Are you sure you want to delete",
|
|
1055
|
-
" ",
|
|
1056
|
-
/* @__PURE__ */ jsx(Text, { span: true, fw: 600, children: selection.selectedCount }),
|
|
1057
|
-
" ",
|
|
1058
|
-
"selected lists?"
|
|
1059
|
-
] }),
|
|
1060
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "This action cannot be undone." }),
|
|
1061
|
-
/* @__PURE__ */ jsxs(Group, { justify: "flex-end", mt: "md", children: [
|
|
1062
|
-
/* @__PURE__ */ jsx(
|
|
1063
|
-
Button,
|
|
1064
|
-
{
|
|
1065
|
-
variant: "light",
|
|
1066
|
-
onClick: () => setShowBatchDelete(false),
|
|
1067
|
-
disabled: deleteListsMutation.isPending,
|
|
1068
|
-
children: "Cancel"
|
|
1069
|
-
}
|
|
1070
|
-
),
|
|
1071
|
-
/* @__PURE__ */ jsx(
|
|
1072
|
-
Button,
|
|
1073
|
-
{
|
|
1074
|
-
color: "red",
|
|
1075
|
-
loading: deleteListsMutation.isPending,
|
|
1076
|
-
onClick: () => {
|
|
1077
|
-
deleteListsMutation.mutate([...selection.selectedIds], {
|
|
1078
|
-
onSuccess: () => {
|
|
1079
|
-
setShowBatchDelete(false);
|
|
1080
|
-
selection.clear();
|
|
1081
|
-
}
|
|
1082
|
-
});
|
|
1083
|
-
},
|
|
1084
|
-
children: "Delete"
|
|
1085
|
-
}
|
|
1086
|
-
)
|
|
1087
|
-
] })
|
|
1088
|
-
] })
|
|
1089
|
-
}
|
|
1090
|
-
)
|
|
1091
|
-
] }) });
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
// src/lib/lead-gen/legacy-pipeline.ts
|
|
1095
|
-
function resolveLegacyListMemberPipelineLabel(member) {
|
|
1096
|
-
const defs = LEAD_GEN_PIPELINE_DEFINITIONS["acq.list-member"];
|
|
1097
|
-
if (!defs) return null;
|
|
1098
|
-
const pipeline = findPipeline(defs, member.pipelineKey);
|
|
1099
|
-
if (!pipeline) return null;
|
|
1100
|
-
const stage = pipeline.stages.find((s) => s.stageKey === member.stageKey);
|
|
1101
|
-
if (!stage) return null;
|
|
1102
|
-
const state = stage.states.find((s) => s.stateKey === member.stateKey);
|
|
1103
|
-
return {
|
|
1104
|
-
stageLabel: stage.label,
|
|
1105
|
-
stateLabel: state?.label ?? member.stateKey
|
|
1106
|
-
};
|
|
1107
|
-
}
|
|
1108
|
-
function formatDateTime(value) {
|
|
1109
|
-
if (!value) return "Not yet";
|
|
1110
|
-
return new Date(value).toLocaleString("en-US", {
|
|
1111
|
-
month: "short",
|
|
1112
|
-
day: "numeric",
|
|
1113
|
-
year: "numeric",
|
|
1114
|
-
hour: "numeric",
|
|
1115
|
-
minute: "2-digit"
|
|
1116
|
-
});
|
|
1117
|
-
}
|
|
1118
|
-
function getMemberStateColor(stateKey) {
|
|
1119
|
-
const stage = LEAD_GEN_STAGE_CATALOG[stateKey];
|
|
1120
|
-
if (stage?.entity === "contact") return "green";
|
|
1121
|
-
if (stage?.entity === "company") return "blue";
|
|
1122
|
-
return "gray";
|
|
1123
|
-
}
|
|
1124
|
-
function ArtifactsPanel({ listMemberId }) {
|
|
1125
|
-
const { data, isLoading, error } = useArtifacts({ ownerKind: "list_member", ownerId: listMemberId });
|
|
1126
|
-
const artifacts = data?.artifacts ?? [];
|
|
1127
|
-
if (isLoading) {
|
|
1128
|
-
return /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) });
|
|
1129
|
-
}
|
|
1130
|
-
if (error) {
|
|
1131
|
-
return /* @__PURE__ */ jsx(CenteredErrorState, { error, title: "Failed to load artifacts" });
|
|
1132
|
-
}
|
|
1133
|
-
if (!artifacts.length) {
|
|
1134
|
-
return /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconDatabase, { size: 16 }), color: "gray", variant: "light", children: "No artifacts recorded for this member yet." });
|
|
1135
|
-
}
|
|
1136
|
-
return /* @__PURE__ */ jsx(Stack, { gap: "sm", children: artifacts.map((artifact) => /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
|
|
1137
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
|
|
1138
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
1139
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: "blue", children: artifact.kind }),
|
|
1140
|
-
/* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
1141
|
-
"v",
|
|
1142
|
-
artifact.version
|
|
1143
|
-
] })
|
|
1144
|
-
] }),
|
|
1145
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatDateTime(artifact.createdAt) })
|
|
1146
|
-
] }),
|
|
1147
|
-
/* @__PURE__ */ jsx(JsonViewer, { data: artifact.content, maxHeight: 240 })
|
|
1148
|
-
] }) }, artifact.id)) });
|
|
1149
|
-
}
|
|
1150
|
-
function ListMemberDrawerContent({ member, listId }) {
|
|
1151
|
-
const transitionMember = useTransitionListMember();
|
|
1152
|
-
const statefulItem = useMemo(
|
|
1153
|
-
() => ({
|
|
1154
|
-
id: member.id,
|
|
1155
|
-
pipeline_key: member.pipelineKey,
|
|
1156
|
-
stage_key: member.stageKey,
|
|
1157
|
-
state_key: member.stateKey,
|
|
1158
|
-
activity_log: member.activityLog
|
|
1159
|
-
}),
|
|
1160
|
-
[member]
|
|
1161
|
-
);
|
|
1162
|
-
const derivedActions = useDeriveActions(statefulItem);
|
|
1163
|
-
const resolved = resolveLegacyListMemberPipelineLabel(member);
|
|
1164
|
-
const contactName = [member.contact?.firstName, member.contact?.lastName].filter(Boolean).join(" ").trim() || member.contact?.email || "\u2014";
|
|
1165
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: "md", p: "md", children: [
|
|
1166
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
|
|
1167
|
-
/* @__PURE__ */ jsx(Group, { gap: "xs", align: "center", children: resolved ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1168
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: "blue", children: resolved.stageLabel }),
|
|
1169
|
-
/* @__PURE__ */ jsx(IconChevronRight, { size: 14, style: { color: "var(--color-text-dimmed)" } }),
|
|
1170
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "filled", color: getMemberStateColor(member.stateKey), children: resolved.stateLabel })
|
|
1171
|
-
] }) : /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "filled", color: getMemberStateColor(member.stateKey), children: member.stateKey }) }),
|
|
1172
|
-
/* @__PURE__ */ jsx(Title, { order: 4, children: contactName }),
|
|
1173
|
-
member.contact?.email && /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
1174
|
-
/* @__PURE__ */ jsx(IconMail, { size: 14, style: { color: "var(--color-text-dimmed)" } }),
|
|
1175
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: member.contact.email })
|
|
1176
|
-
] }),
|
|
1177
|
-
member.contact?.title && /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
1178
|
-
/* @__PURE__ */ jsx(IconUser, { size: 14, style: { color: "var(--color-text-dimmed)" } }),
|
|
1179
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: member.contact.title })
|
|
1180
|
-
] })
|
|
1181
|
-
] }),
|
|
1182
|
-
derivedActions.length > 0 && /* @__PURE__ */ jsx(Group, { gap: "xs", children: derivedActions.map((action) => /* @__PURE__ */ jsx(
|
|
1183
|
-
Button,
|
|
1184
|
-
{
|
|
1185
|
-
variant: "light",
|
|
1186
|
-
size: "xs",
|
|
1187
|
-
loading: transitionMember.isPending,
|
|
1188
|
-
onClick: () => {
|
|
1189
|
-
transitionMember.mutate({
|
|
1190
|
-
memberId: member.id,
|
|
1191
|
-
listId,
|
|
1192
|
-
pipelineKey: member.pipelineKey,
|
|
1193
|
-
// Lead-gen action dispatch targets are resolved server-side via the action key.
|
|
1194
|
-
// Stage/state keys are no longer embedded in the client-side Action shape.
|
|
1195
|
-
stageKey: action.key,
|
|
1196
|
-
stateKey: null
|
|
1197
|
-
});
|
|
1198
|
-
},
|
|
1199
|
-
children: action.label
|
|
1200
|
-
},
|
|
1201
|
-
action.key
|
|
1202
|
-
)) }),
|
|
1203
|
-
/* @__PURE__ */ jsx(ArtifactsPanel, { listMemberId: member.id })
|
|
1204
|
-
] });
|
|
1205
|
-
}
|
|
1206
|
-
function CompanyMemberDrawerContent({ companyId: _companyId }) {
|
|
1207
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: "md", p: "md", children: [
|
|
1208
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
|
|
1209
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: "gray", children: "company member" }),
|
|
1210
|
-
/* @__PURE__ */ jsx(Title, { order: 4, children: "Company" })
|
|
1211
|
-
] }),
|
|
1212
|
-
/* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), color: "blue", variant: "light", children: "Company-level pipeline transitions are not yet available in this view." })
|
|
1213
|
-
] });
|
|
1214
|
-
}
|
|
1215
|
-
function ContactMemberDrawerShell({ contactId, listId }) {
|
|
1216
|
-
const { data: membersData, isLoading, error } = useListMembers({ listId });
|
|
1217
|
-
const listMember = useMemo(() => {
|
|
1218
|
-
if (!membersData?.members) return null;
|
|
1219
|
-
return membersData.members.find((m) => m.contactId === contactId) ?? null;
|
|
1220
|
-
}, [membersData, contactId]);
|
|
1221
|
-
const directQuery = useListMember(listMember === null && !isLoading ? contactId : "");
|
|
1222
|
-
const resolvedMember = listMember ?? directQuery.data ?? null;
|
|
1223
|
-
if (isLoading) {
|
|
1224
|
-
return /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) });
|
|
1225
|
-
}
|
|
1226
|
-
if (error) {
|
|
1227
|
-
return /* @__PURE__ */ jsx(CenteredErrorState, { error, title: "Failed to load member detail" });
|
|
1228
|
-
}
|
|
1229
|
-
if (!resolvedMember) {
|
|
1230
|
-
return /* @__PURE__ */ jsx(Stack, { gap: "md", p: "md", children: /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), color: "gray", variant: "light", children: "Member detail not found. The member may have been removed from this list." }) });
|
|
1231
|
-
}
|
|
1232
|
-
return /* @__PURE__ */ jsx(ListMemberDrawerContent, { member: resolvedMember, listId });
|
|
1233
|
-
}
|
|
1234
|
-
function ListMemberDrawer({ memberId, memberKind, listId, onClose }) {
|
|
1235
|
-
const opened = !!memberId && !!memberKind;
|
|
1236
|
-
return /* @__PURE__ */ jsxs(
|
|
1237
|
-
Drawer,
|
|
1238
|
-
{
|
|
1239
|
-
opened,
|
|
1240
|
-
onClose,
|
|
1241
|
-
position: "right",
|
|
1242
|
-
size: "lg",
|
|
1243
|
-
title: "Member Detail",
|
|
1244
|
-
styles: {
|
|
1245
|
-
body: { padding: 0 }
|
|
1246
|
-
},
|
|
1247
|
-
children: [
|
|
1248
|
-
opened && memberId && memberKind === "contact" && /* @__PURE__ */ jsx(ContactMemberDrawerShell, { contactId: memberId, listId }),
|
|
1249
|
-
opened && memberId && memberKind === "company" && /* @__PURE__ */ jsx(CompanyMemberDrawerContent, { companyId: memberId })
|
|
1250
|
-
]
|
|
1251
|
-
}
|
|
1252
|
-
);
|
|
1253
|
-
}
|
|
1254
|
-
function formatEventTime(timestamp) {
|
|
1255
|
-
return new Date(timestamp).toLocaleTimeString("en-US", {
|
|
1256
|
-
hour12: false,
|
|
1257
|
-
hour: "2-digit",
|
|
1258
|
-
minute: "2-digit",
|
|
1259
|
-
second: "2-digit"
|
|
1260
|
-
});
|
|
1261
|
-
}
|
|
1262
|
-
function formatId(executionId) {
|
|
1263
|
-
return executionId.length > 10 ? `${executionId.slice(0, 8)}...` : executionId;
|
|
1264
|
-
}
|
|
1265
|
-
function getLogLevelColor(level) {
|
|
1266
|
-
switch (level) {
|
|
1267
|
-
case "error":
|
|
1268
|
-
return "red";
|
|
1269
|
-
case "warn":
|
|
1270
|
-
return "yellow";
|
|
1271
|
-
case "debug":
|
|
1272
|
-
return "gray";
|
|
1273
|
-
default:
|
|
1274
|
-
return "blue";
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
function getStepStatusColor(status) {
|
|
1278
|
-
switch (status) {
|
|
1279
|
-
case "failed":
|
|
1280
|
-
return "red";
|
|
1281
|
-
case "done":
|
|
1282
|
-
return "green";
|
|
1283
|
-
default:
|
|
1284
|
-
return "blue";
|
|
1285
|
-
}
|
|
1286
|
-
}
|
|
1287
|
-
function getStepStatusLabel(status) {
|
|
1288
|
-
switch (status) {
|
|
1289
|
-
case "failed":
|
|
1290
|
-
return "Failed";
|
|
1291
|
-
case "done":
|
|
1292
|
-
return "Done";
|
|
1293
|
-
default:
|
|
1294
|
-
return "Running";
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
function getEventColor(event) {
|
|
1298
|
-
switch (event.type) {
|
|
1299
|
-
case "new-execution":
|
|
1300
|
-
return "blue";
|
|
1301
|
-
case "execution-complete":
|
|
1302
|
-
return event.data.success ? "green" : "red";
|
|
1303
|
-
case "log":
|
|
1304
|
-
return getLogLevelColor(event.data.log.level);
|
|
1305
|
-
default:
|
|
1306
|
-
return "gray";
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
function getEventLabel(event) {
|
|
1310
|
-
switch (event.type) {
|
|
1311
|
-
case "new-execution":
|
|
1312
|
-
return "Execution started";
|
|
1313
|
-
case "execution-complete":
|
|
1314
|
-
return event.data.success ? "Execution completed" : "Execution failed";
|
|
1315
|
-
case "log":
|
|
1316
|
-
return event.data.log.message;
|
|
1317
|
-
default:
|
|
1318
|
-
return "Stream connected";
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
function hasExecutionId(event) {
|
|
1322
|
-
return event.type !== "connected" && typeof event.executionId === "string" && event.executionId.length > 0;
|
|
1323
|
-
}
|
|
1324
|
-
function toTimelineEvents(events) {
|
|
1325
|
-
return events.filter(hasExecutionId).map((event) => ({
|
|
1326
|
-
executionId: event.executionId,
|
|
1327
|
-
timestamp: event.timestamp,
|
|
1328
|
-
label: getEventLabel(event),
|
|
1329
|
-
color: getEventColor(event),
|
|
1330
|
-
detail: event.type === "execution-complete" ? event.data.error : void 0
|
|
1331
|
-
})).sort((a, b) => b.timestamp - a.timestamp).slice(0, 5);
|
|
1332
|
-
}
|
|
1333
|
-
function collectStepStatuses(events, streamingLogs) {
|
|
1334
|
-
const statuses = /* @__PURE__ */ new Map();
|
|
1335
|
-
const applyLog = (executionId, log) => {
|
|
1336
|
-
const context = log.context;
|
|
1337
|
-
if (!context || context.type !== "workflow") return;
|
|
1338
|
-
if (!("stepId" in context)) return;
|
|
1339
|
-
let status = null;
|
|
1340
|
-
if (isStepStartedContext(context)) status = "running";
|
|
1341
|
-
if (isStepCompletedContext(context)) status = "done";
|
|
1342
|
-
if (isStepFailedContext(context)) status = "failed";
|
|
1343
|
-
if (!status) return;
|
|
1344
|
-
statuses.set(executionId, {
|
|
1345
|
-
executionId,
|
|
1346
|
-
stepId: context.stepId,
|
|
1347
|
-
status,
|
|
1348
|
-
timestamp: log.timestamp,
|
|
1349
|
-
message: log.message
|
|
1350
|
-
});
|
|
1351
|
-
};
|
|
1352
|
-
events.forEach((event) => {
|
|
1353
|
-
if (event.type === "log") applyLog(event.executionId, event.data.log);
|
|
1354
|
-
});
|
|
1355
|
-
streamingLogs.forEach((logs, executionId) => {
|
|
1356
|
-
logs.forEach((log) => applyLog(executionId, log));
|
|
1357
|
-
});
|
|
1358
|
-
return Array.from(statuses.values()).sort((a, b) => b.timestamp - a.timestamp);
|
|
1359
|
-
}
|
|
1360
|
-
function getExecutionId(execution) {
|
|
1361
|
-
return "executionId" in execution ? execution.executionId : execution.id;
|
|
1362
|
-
}
|
|
1363
|
-
function getInFlightExecutions(data) {
|
|
1364
|
-
if (Array.isArray(data)) return data;
|
|
1365
|
-
if (data && typeof data === "object" && "executions" in data) {
|
|
1366
|
-
const executions = data.executions;
|
|
1367
|
-
return Array.isArray(executions) ? executions : [];
|
|
1368
|
-
}
|
|
1369
|
-
return [];
|
|
1370
|
-
}
|
|
1371
|
-
function getStageProgress(progress, stageKey) {
|
|
1372
|
-
return progress?.byCompanyStage[stageKey] ?? progress?.byContactStage[stageKey];
|
|
1373
|
-
}
|
|
1374
|
-
function getStageLabel(stageKey) {
|
|
1375
|
-
return LEAD_GEN_STAGE_CATALOG[stageKey]?.label ?? stageKey;
|
|
1376
|
-
}
|
|
1377
|
-
function getDoneCount(stageProgress) {
|
|
1378
|
-
return stageProgress?.attempted ?? 0;
|
|
1379
|
-
}
|
|
1380
|
-
function LeadGenLiveStatusPanel({
|
|
1381
|
-
listId,
|
|
1382
|
-
resourceId,
|
|
1383
|
-
stageKey,
|
|
1384
|
-
stepLabel,
|
|
1385
|
-
enabled = true,
|
|
1386
|
-
onRunningChange
|
|
1387
|
-
}) {
|
|
1388
|
-
const sse = useExecutionSSE(resourceId, {
|
|
1389
|
-
enabled: enabled && Boolean(resourceId),
|
|
1390
|
-
listId
|
|
1391
|
-
});
|
|
1392
|
-
const inFlightQuery = useInFlightExecutions(resourceId, {
|
|
1393
|
-
enabled: enabled && Boolean(resourceId),
|
|
1394
|
-
limit: 5,
|
|
1395
|
-
refetchInterval: enabled && Boolean(resourceId) ? 2e3 : false
|
|
1396
|
-
});
|
|
1397
|
-
const inFlightExecutions = useMemo(() => getInFlightExecutions(inFlightQuery.data), [inFlightQuery.data]);
|
|
1398
|
-
const activeExecutionIds = useMemo(() => {
|
|
1399
|
-
const ids = new Set(sse.liveExecutions);
|
|
1400
|
-
inFlightExecutions.forEach((execution) => {
|
|
1401
|
-
const executionId = getExecutionId(execution);
|
|
1402
|
-
if (executionId) ids.add(executionId);
|
|
1403
|
-
});
|
|
1404
|
-
return Array.from(ids);
|
|
1405
|
-
}, [inFlightExecutions, sse.liveExecutions]);
|
|
1406
|
-
const running = enabled && activeExecutionIds.length > 0;
|
|
1407
|
-
const [showCompletedActivity, setShowCompletedActivity] = useState(false);
|
|
1408
|
-
const progressQuery = useListProgress(listId, {
|
|
1409
|
-
enabled: enabled && Boolean(listId),
|
|
1410
|
-
refetchInterval: running ? 2e3 : false
|
|
1411
|
-
});
|
|
1412
|
-
useEffect(() => {
|
|
1413
|
-
onRunningChange?.(running);
|
|
1414
|
-
}, [onRunningChange, running]);
|
|
1415
|
-
const stepStatuses = useMemo(
|
|
1416
|
-
() => collectStepStatuses(sse.events, sse.streamingLogs),
|
|
1417
|
-
[sse.events, sse.streamingLogs]
|
|
1418
|
-
);
|
|
1419
|
-
const latestStepStatus = stepStatuses[0];
|
|
1420
|
-
const lastEvents = useMemo(() => toTimelineEvents(sse.events), [sse.events]);
|
|
1421
|
-
const stageProgress = getStageProgress(progressQuery.data, stageKey);
|
|
1422
|
-
const doneCount = getDoneCount(stageProgress);
|
|
1423
|
-
const totalCount = stageProgress?.total ?? 0;
|
|
1424
|
-
const failed = Boolean(sse.error) || sse.events.some((event) => event.type === "execution-complete" && !event.data.success);
|
|
1425
|
-
const latestEvent = sse.latestEvent;
|
|
1426
|
-
useEffect(() => {
|
|
1427
|
-
if (running || failed || sse.error) {
|
|
1428
|
-
setShowCompletedActivity(true);
|
|
1429
|
-
return;
|
|
1430
|
-
}
|
|
1431
|
-
if (latestEvent?.type !== "execution-complete") return;
|
|
1432
|
-
setShowCompletedActivity(true);
|
|
1433
|
-
const timeoutId = window.setTimeout(() => setShowCompletedActivity(false), 1e4);
|
|
1434
|
-
return () => window.clearTimeout(timeoutId);
|
|
1435
|
-
}, [failed, latestEvent, running, sse.error]);
|
|
1436
|
-
const hasActivity = activeExecutionIds.length > 0 || sse.streamingLogs.size > 0 || showCompletedActivity || Boolean(sse.error);
|
|
1437
|
-
if (!enabled || !hasActivity && !sse.error && !failed) {
|
|
1438
|
-
return null;
|
|
1439
|
-
}
|
|
1440
|
-
return /* @__PURE__ */ jsx(Paper, { withBorder: true, p: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
|
|
1441
|
-
/* @__PURE__ */ jsx(
|
|
1442
|
-
CardHeader,
|
|
1443
|
-
{
|
|
1444
|
-
icon: /* @__PURE__ */ jsx(IconTerminal2, { size: 16 }),
|
|
1445
|
-
title: stepLabel ? `${stepLabel} status` : "Live status",
|
|
1446
|
-
rightSection: /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
|
|
1447
|
-
/* @__PURE__ */ jsx(
|
|
1448
|
-
Badge,
|
|
1449
|
-
{
|
|
1450
|
-
size: "xs",
|
|
1451
|
-
variant: "light",
|
|
1452
|
-
color: sse.connected ? "green" : running ? "yellow" : "gray",
|
|
1453
|
-
leftSection: sse.connected ? /* @__PURE__ */ jsx(IconCircleCheck, { size: 9 }) : /* @__PURE__ */ jsx(IconCircleDot, { size: 9 }),
|
|
1454
|
-
children: sse.connected ? "Connected" : running ? "Reconnecting" : "Idle"
|
|
1455
|
-
}
|
|
1456
|
-
),
|
|
1457
|
-
running ? /* @__PURE__ */ jsxs(Badge, { size: "xs", variant: "filled", color: "blue", leftSection: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 9 }), children: [
|
|
1458
|
-
activeExecutionIds.length,
|
|
1459
|
-
" running"
|
|
1460
|
-
] }) : null
|
|
1461
|
-
] })
|
|
1462
|
-
}
|
|
1463
|
-
),
|
|
1464
|
-
sse.error ? /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 14 }), color: "red", variant: "light", p: "xs", children: /* @__PURE__ */ jsx(Text, { size: "xs", children: sse.error }) }) : null,
|
|
1465
|
-
activeExecutionIds.length > 0 ? /* @__PURE__ */ jsx(Group, { gap: 6, children: activeExecutionIds.map((executionId) => /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "blue", ff: "monospace", children: formatId(executionId) }, executionId)) }) : null,
|
|
1466
|
-
/* @__PURE__ */ jsxs(Box, { p: "xs", bg: "var(--surface-primary-subtle)", style: { borderRadius: "var(--mantine-radius-sm)" }, children: [
|
|
1467
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "xs", wrap: "nowrap", children: [
|
|
1468
|
-
/* @__PURE__ */ jsxs(Group, { gap: 6, wrap: "nowrap", style: { minWidth: 0 }, children: [
|
|
1469
|
-
/* @__PURE__ */ jsx(IconProgressCheck, { size: 14 }),
|
|
1470
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", fw: 600, truncate: "end", children: getStageLabel(stageKey) })
|
|
1471
|
-
] }),
|
|
1472
|
-
/* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", ff: "monospace", children: [
|
|
1473
|
-
doneCount,
|
|
1474
|
-
"/",
|
|
1475
|
-
totalCount,
|
|
1476
|
-
" done"
|
|
1477
|
-
] })
|
|
1478
|
-
] }),
|
|
1479
|
-
/* @__PURE__ */ jsx(
|
|
1480
|
-
Progress,
|
|
1481
|
-
{
|
|
1482
|
-
mt: 6,
|
|
1483
|
-
size: "xs",
|
|
1484
|
-
value: totalCount > 0 ? doneCount / totalCount * 100 : 0,
|
|
1485
|
-
color: stageProgress && stageProgress.error > 0 ? "red" : "blue"
|
|
1486
|
-
}
|
|
1487
|
-
)
|
|
1488
|
-
] }),
|
|
1489
|
-
latestStepStatus ? /* @__PURE__ */ jsxs(Group, { gap: 6, wrap: "nowrap", children: [
|
|
1490
|
-
/* @__PURE__ */ jsx(Badge, { size: "xs", color: getStepStatusColor(latestStepStatus.status), variant: "light", children: getStepStatusLabel(latestStepStatus.status) }),
|
|
1491
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", fw: 500, truncate: "end", children: latestStepStatus.stepId }),
|
|
1492
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", truncate: "end", style: { flex: 1 }, children: latestStepStatus.message })
|
|
1493
|
-
] }) : running ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Waiting for workflow step events." }) : null,
|
|
1494
|
-
lastEvents.length > 0 ? /* @__PURE__ */ jsx(Stack, { gap: 4, children: lastEvents.map((event) => /* @__PURE__ */ jsxs(Group, { gap: 6, wrap: "nowrap", children: [
|
|
1495
|
-
/* @__PURE__ */ jsx(Badge, { size: "xs", variant: "dot", color: event.color, miw: 68, children: formatEventTime(event.timestamp) }),
|
|
1496
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", ff: "monospace", miw: 62, children: formatId(event.executionId) }),
|
|
1497
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", truncate: "end", style: { flex: 1 }, children: event.detail ?? event.label })
|
|
1498
|
-
] }, `${event.executionId}-${event.timestamp}-${event.label}`)) }) : null
|
|
1499
|
-
] }) });
|
|
1500
|
-
}
|
|
1501
|
-
var panelStyle = {
|
|
1502
|
-
flex: 1,
|
|
1503
|
-
minHeight: 0,
|
|
1504
|
-
overflowY: "auto",
|
|
1505
|
-
paddingTop: "var(--mantine-spacing-sm)"
|
|
1506
|
-
};
|
|
1507
|
-
function StepDetailRightColumn({
|
|
1508
|
-
configuration,
|
|
1509
|
-
records,
|
|
1510
|
-
advanced,
|
|
1511
|
-
runs,
|
|
1512
|
-
action,
|
|
1513
|
-
activeTab,
|
|
1514
|
-
onTabChange
|
|
1515
|
-
}) {
|
|
1516
|
-
return /* @__PURE__ */ jsxs(
|
|
1517
|
-
Stack,
|
|
1518
|
-
{
|
|
1519
|
-
gap: "sm",
|
|
1520
|
-
style: {
|
|
1521
|
-
flex: 1,
|
|
1522
|
-
minHeight: 0
|
|
1523
|
-
},
|
|
1524
|
-
children: [
|
|
1525
|
-
/* @__PURE__ */ jsxs(
|
|
1526
|
-
Tabs,
|
|
1527
|
-
{
|
|
1528
|
-
value: activeTab,
|
|
1529
|
-
onChange: (value) => {
|
|
1530
|
-
if (value === "configuration" || value === "records" || value === "advanced" || value === "runs") {
|
|
1531
|
-
onTabChange(value);
|
|
1532
|
-
}
|
|
1533
|
-
},
|
|
1534
|
-
style: {
|
|
1535
|
-
flex: 1,
|
|
1536
|
-
minHeight: 0,
|
|
1537
|
-
display: "flex",
|
|
1538
|
-
flexDirection: "column"
|
|
1539
|
-
},
|
|
1540
|
-
children: [
|
|
1541
|
-
/* @__PURE__ */ jsxs(Tabs.List, { children: [
|
|
1542
|
-
/* @__PURE__ */ jsx(Tabs.Tab, { value: "configuration", children: "Configuration" }),
|
|
1543
|
-
/* @__PURE__ */ jsx(Tabs.Tab, { value: "records", children: "Records" }),
|
|
1544
|
-
/* @__PURE__ */ jsx(Tabs.Tab, { value: "advanced", children: "Advanced" }),
|
|
1545
|
-
/* @__PURE__ */ jsx(Tabs.Tab, { value: "runs", children: "Runs" })
|
|
1546
|
-
] }),
|
|
1547
|
-
/* @__PURE__ */ jsx(Tabs.Panel, { value: "configuration", style: panelStyle, children: configuration }),
|
|
1548
|
-
/* @__PURE__ */ jsx(Tabs.Panel, { value: "records", style: panelStyle, children: records ?? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "No records view configured for this step." }) }),
|
|
1549
|
-
/* @__PURE__ */ jsx(Tabs.Panel, { value: "advanced", style: panelStyle, children: advanced ?? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "No advanced settings for this step." }) }),
|
|
1550
|
-
/* @__PURE__ */ jsx(Tabs.Panel, { value: "runs", style: panelStyle, children: runs })
|
|
1551
|
-
]
|
|
1552
|
-
}
|
|
1553
|
-
),
|
|
1554
|
-
/* @__PURE__ */ jsx(Stack, { gap: "xs", style: { flexShrink: 0 }, children: action })
|
|
1555
|
-
]
|
|
1556
|
-
}
|
|
1557
|
-
);
|
|
1558
|
-
}
|
|
1559
|
-
function ListBuilderIndexPage() {
|
|
1560
|
-
const navigate = useNavigate();
|
|
1561
|
-
const [query, setQuery] = useState("");
|
|
1562
|
-
const listsQuery = useLists();
|
|
1563
|
-
const lists = listsQuery.data ?? [];
|
|
1564
|
-
const filteredLists = useMemo(() => {
|
|
1565
|
-
const normalized = query.trim().toLowerCase();
|
|
1566
|
-
if (!normalized) return lists;
|
|
1567
|
-
return lists.filter((list) => list.name.toLowerCase().includes(normalized));
|
|
1568
|
-
}, [lists, query]);
|
|
1569
|
-
const openList = (listId) => {
|
|
1570
|
-
navigate({ to: "/lead-gen/list-builder/$listId", params: { listId } });
|
|
1571
|
-
};
|
|
1572
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
1573
|
-
/* @__PURE__ */ jsx(PageTitleCaption, { title: "List Builder", caption: "Choose a list to run lead-gen workflows and monitor progress." }),
|
|
1574
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, p: "md", children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
1575
|
-
/* @__PURE__ */ jsx(
|
|
1576
|
-
TextInput,
|
|
1577
|
-
{
|
|
1578
|
-
placeholder: "Search lists...",
|
|
1579
|
-
leftSection: /* @__PURE__ */ jsx(IconSearch, { size: 16 }),
|
|
1580
|
-
value: query,
|
|
1581
|
-
onChange: (event) => setQuery(event.currentTarget.value)
|
|
1582
|
-
}
|
|
1583
|
-
),
|
|
1584
|
-
listsQuery.isLoading ? /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) : !filteredLists.length ? /* @__PURE__ */ jsx(
|
|
1585
|
-
EmptyState,
|
|
1586
|
-
{
|
|
1587
|
-
icon: IconLayoutDashboard,
|
|
1588
|
-
title: query.trim() ? "No lists match your search" : "No lists available",
|
|
1589
|
-
description: query.trim() ? void 0 : "Create a list first, then open it in the builder."
|
|
1590
|
-
}
|
|
1591
|
-
) : /* @__PURE__ */ jsxs(Table, { highlightOnHover: true, children: [
|
|
1592
|
-
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
1593
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Name" }),
|
|
1594
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Status" }),
|
|
1595
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Batches" }),
|
|
1596
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Created" })
|
|
1597
|
-
] }) }),
|
|
1598
|
-
/* @__PURE__ */ jsx(Table.Tbody, { children: filteredLists.map((list) => /* @__PURE__ */ jsxs(
|
|
1599
|
-
Table.Tr,
|
|
1600
|
-
{
|
|
1601
|
-
role: "button",
|
|
1602
|
-
tabIndex: 0,
|
|
1603
|
-
onClick: () => openList(list.id),
|
|
1604
|
-
onKeyDown: (event) => {
|
|
1605
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
1606
|
-
event.preventDefault();
|
|
1607
|
-
openList(list.id);
|
|
1608
|
-
}
|
|
1609
|
-
},
|
|
1610
|
-
style: { cursor: "pointer" },
|
|
1611
|
-
children: [
|
|
1612
|
-
/* @__PURE__ */ jsxs(Table.Td, { children: [
|
|
1613
|
-
/* @__PURE__ */ jsx(Text, { fw: 500, children: list.name }),
|
|
1614
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: list.description ?? list.id })
|
|
1615
|
-
] }),
|
|
1616
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: getStateKeyColor(list.status), children: list.status }) }),
|
|
1617
|
-
/* @__PURE__ */ jsx(Table.Td, { children: list.batchIds.length }),
|
|
1618
|
-
/* @__PURE__ */ jsx(Table.Td, { children: formatDate(list.createdAt) })
|
|
1619
|
-
]
|
|
1620
|
-
},
|
|
1621
|
-
list.id
|
|
1622
|
-
)) })
|
|
1623
|
-
] })
|
|
1624
|
-
] }) })
|
|
1625
|
-
] }) }) });
|
|
1626
|
-
}
|
|
1627
|
-
|
|
1628
|
-
// src/lib/lead-gen/stage-colors.ts
|
|
1629
|
-
var FALLBACK_STAGE_COLORS = {
|
|
1630
|
-
accent: "var(--color-text-dimmed)",
|
|
1631
|
-
background: "color-mix(in srgb, var(--color-text-dimmed) 10%, transparent)",
|
|
1632
|
-
border: "color-mix(in srgb, var(--color-border) 85%, var(--color-text-dimmed))",
|
|
1633
|
-
text: "var(--color-text)"
|
|
1634
|
-
};
|
|
1635
|
-
var STAGE_COLOR_SETS = {
|
|
1636
|
-
scraped: {
|
|
1637
|
-
accent: "var(--color-text-subtle)",
|
|
1638
|
-
background: "color-mix(in srgb, var(--color-text-subtle) 12%, transparent)",
|
|
1639
|
-
border: "color-mix(in srgb, var(--color-border) 80%, var(--color-text-subtle))",
|
|
1640
|
-
text: "var(--color-text)"
|
|
1641
|
-
},
|
|
1642
|
-
populated: {
|
|
1643
|
-
accent: "var(--color-primary)",
|
|
1644
|
-
background: "color-mix(in srgb, var(--color-primary) 12%, transparent)",
|
|
1645
|
-
border: "color-mix(in srgb, var(--color-border) 70%, var(--color-primary))",
|
|
1646
|
-
text: "var(--color-text)"
|
|
1647
|
-
},
|
|
1648
|
-
crawled: {
|
|
1649
|
-
accent: "color-mix(in srgb, var(--color-primary) 70%, var(--color-text-subtle))",
|
|
1650
|
-
background: "color-mix(in srgb, var(--color-primary) 9%, transparent)",
|
|
1651
|
-
border: "color-mix(in srgb, var(--color-border) 72%, var(--color-primary))",
|
|
1652
|
-
text: "var(--color-text)"
|
|
1653
|
-
},
|
|
1654
|
-
extracted: {
|
|
1655
|
-
accent: "color-mix(in srgb, var(--color-primary) 78%, var(--color-success))",
|
|
1656
|
-
background: "color-mix(in srgb, var(--color-primary) 10%, transparent)",
|
|
1657
|
-
border: "color-mix(in srgb, var(--color-border) 65%, var(--color-primary))",
|
|
1658
|
-
text: "var(--color-text)"
|
|
1659
|
-
},
|
|
1660
|
-
enriched: {
|
|
1661
|
-
accent: "color-mix(in srgb, var(--color-success) 70%, var(--color-primary))",
|
|
1662
|
-
background: "color-mix(in srgb, var(--color-success) 12%, transparent)",
|
|
1663
|
-
border: "color-mix(in srgb, var(--color-border) 68%, var(--color-success))",
|
|
1664
|
-
text: "var(--color-text)"
|
|
1665
|
-
},
|
|
1666
|
-
"decision-makers-enriched": {
|
|
1667
|
-
accent: "color-mix(in srgb, var(--color-primary) 66%, var(--color-warning))",
|
|
1668
|
-
background: "color-mix(in srgb, var(--color-primary) 12%, transparent)",
|
|
1669
|
-
border: "color-mix(in srgb, var(--color-border) 66%, var(--color-primary))",
|
|
1670
|
-
text: "var(--color-text)"
|
|
1671
|
-
},
|
|
1672
|
-
discovered: {
|
|
1673
|
-
accent: "color-mix(in srgb, var(--color-primary) 70%, var(--color-warning))",
|
|
1674
|
-
background: "color-mix(in srgb, var(--color-warning) 10%, transparent)",
|
|
1675
|
-
border: "color-mix(in srgb, var(--color-border) 68%, var(--color-warning))",
|
|
1676
|
-
text: "var(--color-text)"
|
|
1677
|
-
},
|
|
1678
|
-
verified: {
|
|
1679
|
-
accent: "var(--color-success)",
|
|
1680
|
-
background: "color-mix(in srgb, var(--color-success) 12%, transparent)",
|
|
1681
|
-
border: "color-mix(in srgb, var(--color-border) 64%, var(--color-success))",
|
|
1682
|
-
text: "var(--color-text)"
|
|
1683
|
-
},
|
|
1684
|
-
qualified: {
|
|
1685
|
-
accent: "color-mix(in srgb, var(--color-success) 82%, var(--color-text))",
|
|
1686
|
-
background: "color-mix(in srgb, var(--color-success) 14%, transparent)",
|
|
1687
|
-
border: "color-mix(in srgb, var(--color-border) 62%, var(--color-success))",
|
|
1688
|
-
text: "var(--color-text)"
|
|
1689
|
-
},
|
|
1690
|
-
personalized: {
|
|
1691
|
-
accent: "color-mix(in srgb, var(--color-primary) 58%, var(--color-success))",
|
|
1692
|
-
background: "color-mix(in srgb, var(--color-primary) 11%, transparent)",
|
|
1693
|
-
border: "color-mix(in srgb, var(--color-border) 66%, var(--color-primary))",
|
|
1694
|
-
text: "var(--color-text)"
|
|
1695
|
-
},
|
|
1696
|
-
uploaded: {
|
|
1697
|
-
accent: "color-mix(in srgb, var(--color-warning) 72%, var(--color-primary))",
|
|
1698
|
-
background: "color-mix(in srgb, var(--color-warning) 12%, transparent)",
|
|
1699
|
-
border: "color-mix(in srgb, var(--color-border) 64%, var(--color-warning))",
|
|
1700
|
-
text: "var(--color-text)"
|
|
1701
|
-
},
|
|
1702
|
-
interested: {
|
|
1703
|
-
accent: "color-mix(in srgb, var(--color-success) 72%, var(--color-warning))",
|
|
1704
|
-
background: "color-mix(in srgb, var(--color-success) 15%, transparent)",
|
|
1705
|
-
border: "color-mix(in srgb, var(--color-border) 58%, var(--color-success))",
|
|
1706
|
-
text: "var(--color-text)"
|
|
1707
|
-
}
|
|
1708
|
-
};
|
|
1709
|
-
function getLeadGenStageColor(stageKey) {
|
|
1710
|
-
if (!LEAD_GEN_STAGE_CATALOG[stageKey]) return FALLBACK_STAGE_COLORS;
|
|
1711
|
-
return STAGE_COLOR_SETS[stageKey] ?? FALLBACK_STAGE_COLORS;
|
|
1712
|
-
}
|
|
1713
|
-
function getLeadGenStageColorVar(stageKey, tone = "accent") {
|
|
1714
|
-
return getLeadGenStageColor(stageKey)[tone];
|
|
1715
|
-
}
|
|
1716
|
-
var FALLBACK_STAGE_ORDER = 1e4;
|
|
1717
|
-
function unique(values) {
|
|
1718
|
-
return Array.from(new Set(values.filter(Boolean)));
|
|
1719
|
-
}
|
|
1720
|
-
function configuredStages(pipelineConfig) {
|
|
1721
|
-
return (pipelineConfig?.stages ?? []).filter((stage) => stage.enabled !== false).slice().sort((a, b) => {
|
|
1722
|
-
const aOrder = a.order ?? LEAD_GEN_STAGE_CATALOG[a.key]?.order ?? FALLBACK_STAGE_ORDER;
|
|
1723
|
-
const bOrder = b.order ?? LEAD_GEN_STAGE_CATALOG[b.key]?.order ?? FALLBACK_STAGE_ORDER;
|
|
1724
|
-
return aOrder - bOrder || a.key.localeCompare(b.key);
|
|
1725
|
-
});
|
|
1726
|
-
}
|
|
1727
|
-
function workflowStageKeys(actions) {
|
|
1728
|
-
return unique((actions ?? []).flatMap((action) => [...action.stagesAffected]));
|
|
1729
|
-
}
|
|
1730
|
-
function sourceFor(stageKey, observedKeys, configKeys, workflowKeys) {
|
|
1731
|
-
if (observedKeys.has(stageKey)) return "activity";
|
|
1732
|
-
if (configKeys.has(stageKey)) return "config";
|
|
1733
|
-
if (workflowKeys.has(stageKey)) return "workflow";
|
|
1734
|
-
return "activity";
|
|
1735
|
-
}
|
|
1736
|
-
function sortStageNodes(nodes) {
|
|
1737
|
-
return nodes.slice().sort((a, b) => a.order - b.order || a.key.localeCompare(b.key));
|
|
1738
|
-
}
|
|
1739
|
-
function buildLaneStages({
|
|
1740
|
-
entity,
|
|
1741
|
-
progress,
|
|
1742
|
-
pipelineConfig,
|
|
1743
|
-
actions
|
|
1744
|
-
}) {
|
|
1745
|
-
const stageMap = entity === "company" ? progress.byCompanyStage : progress.byContactStage;
|
|
1746
|
-
const observedKeys = new Set(Object.keys(stageMap));
|
|
1747
|
-
const configStages = configuredStages(pipelineConfig);
|
|
1748
|
-
const configStageByKey = new Map(configStages.map((stage) => [stage.key, stage]));
|
|
1749
|
-
const configKeys = new Set(configStages.map((stage) => stage.key));
|
|
1750
|
-
const workflowKeys = new Set(workflowStageKeys(actions));
|
|
1751
|
-
const stageKeys = unique([...observedKeys, ...configKeys, ...workflowKeys]);
|
|
1752
|
-
return sortStageNodes(
|
|
1753
|
-
stageKeys.flatMap((key) => {
|
|
1754
|
-
const catalogEntry = LEAD_GEN_STAGE_CATALOG[key];
|
|
1755
|
-
const inferredEntity = catalogEntry?.entity ?? (observedKeys.has(key) ? entity : null);
|
|
1756
|
-
if (inferredEntity !== entity) return [];
|
|
1757
|
-
return [
|
|
1758
|
-
{
|
|
1759
|
-
key,
|
|
1760
|
-
label: configStageByKey.get(key)?.label ?? catalogEntry?.label ?? key,
|
|
1761
|
-
order: configStageByKey.get(key)?.order ?? catalogEntry?.order ?? FALLBACK_STAGE_ORDER,
|
|
1762
|
-
entity,
|
|
1763
|
-
source: sourceFor(key, observedKeys, configKeys, workflowKeys)
|
|
1764
|
-
}
|
|
1765
|
-
];
|
|
1766
|
-
})
|
|
1767
|
-
);
|
|
1768
|
-
}
|
|
1769
|
-
function getStageProgress2(progress, stageKey, entity) {
|
|
1770
|
-
const stageProgress = entity === "company" ? progress.byCompanyStage[stageKey] : progress.byContactStage[stageKey];
|
|
1771
|
-
const total = stageProgress?.total ?? (entity === "company" ? progress.totalCompanies : progress.totalMembers);
|
|
1772
|
-
return {
|
|
1773
|
-
total,
|
|
1774
|
-
attempted: stageProgress?.attempted ?? 0,
|
|
1775
|
-
success: stageProgress?.success ?? 0,
|
|
1776
|
-
noResult: stageProgress?.noResult ?? 0,
|
|
1777
|
-
skipped: stageProgress?.skipped ?? 0,
|
|
1778
|
-
error: stageProgress?.error ?? 0,
|
|
1779
|
-
other: stageProgress?.other ?? 0,
|
|
1780
|
-
notAttempted: stageProgress?.notAttempted ?? total
|
|
1781
|
-
};
|
|
1782
|
-
}
|
|
1783
|
-
function percent(value, total) {
|
|
1784
|
-
if (total <= 0) return 0;
|
|
1785
|
-
return Math.max(0, Math.min(100, value / total * 100));
|
|
1786
|
-
}
|
|
1787
|
-
function SourceBadge({ source }) {
|
|
1788
|
-
const label = source === "activity" ? "recorded" : source;
|
|
1789
|
-
const color = source === "activity" ? "green" : source === "config" ? "blue" : "gray";
|
|
1790
|
-
return /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color, children: label });
|
|
1791
|
-
}
|
|
1792
|
-
function ProgressRail({ counts, stageKey }) {
|
|
1793
|
-
const accent = getLeadGenStageColorVar(stageKey);
|
|
1794
|
-
const segments = [
|
|
1795
|
-
{ key: "success", value: counts.success, color: accent },
|
|
1796
|
-
{ key: "noResult", value: counts.noResult, color: "var(--color-text-subtle)" },
|
|
1797
|
-
{ key: "skipped", value: counts.skipped, color: "var(--color-warning)" },
|
|
1798
|
-
{ key: "error", value: counts.error, color: "var(--color-error)" },
|
|
1799
|
-
{ key: "other", value: counts.other, color: "var(--color-primary)" }
|
|
1800
|
-
].filter((segment) => segment.value > 0);
|
|
1801
|
-
return /* @__PURE__ */ jsx(
|
|
1802
|
-
Box,
|
|
1803
|
-
{
|
|
1804
|
-
h: 6,
|
|
1805
|
-
bg: "var(--color-surface-hover)",
|
|
1806
|
-
style: {
|
|
1807
|
-
borderRadius: 999,
|
|
1808
|
-
display: "flex",
|
|
1809
|
-
overflow: "hidden",
|
|
1810
|
-
opacity: counts.total > 0 ? 1 : 0.55
|
|
1811
|
-
},
|
|
1812
|
-
children: segments.length > 0 ? segments.map((segment) => /* @__PURE__ */ jsx(Box, { h: "100%", w: `${percent(segment.value, counts.total)}%`, bg: segment.color }, segment.key)) : /* @__PURE__ */ jsx(Box, { h: "100%", w: counts.total > 0 ? `${percent(counts.attempted, counts.total)}%` : "0%", bg: accent })
|
|
1813
|
-
}
|
|
1814
|
-
);
|
|
1815
|
-
}
|
|
1816
|
-
function TimelineLane({
|
|
1817
|
-
title,
|
|
1818
|
-
entity,
|
|
1819
|
-
total,
|
|
1820
|
-
stages,
|
|
1821
|
-
progress,
|
|
1822
|
-
emptyText
|
|
1823
|
-
}) {
|
|
1824
|
-
const Icon = entity === "company" ? IconBuilding : IconUsers;
|
|
1825
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
1826
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", gap: "xs", children: [
|
|
1827
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
1828
|
-
/* @__PURE__ */ jsx(
|
|
1829
|
-
Box,
|
|
1830
|
-
{
|
|
1831
|
-
w: 28,
|
|
1832
|
-
h: 28,
|
|
1833
|
-
style: {
|
|
1834
|
-
alignItems: "center",
|
|
1835
|
-
background: "color-mix(in srgb, var(--color-primary) 14%, transparent)",
|
|
1836
|
-
border: "1px solid color-mix(in srgb, var(--color-border) 75%, var(--color-primary))",
|
|
1837
|
-
borderRadius: 999,
|
|
1838
|
-
color: "var(--color-primary)",
|
|
1839
|
-
display: "flex",
|
|
1840
|
-
justifyContent: "center"
|
|
1841
|
-
},
|
|
1842
|
-
children: /* @__PURE__ */ jsx(Icon, { size: 15 })
|
|
1843
|
-
}
|
|
1844
|
-
),
|
|
1845
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 0, children: [
|
|
1846
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", fw: 700, children: title }),
|
|
1847
|
-
/* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
1848
|
-
total,
|
|
1849
|
-
" ",
|
|
1850
|
-
entity === "company" ? "companies" : "contacts"
|
|
1851
|
-
] })
|
|
1852
|
-
] })
|
|
1853
|
-
] }),
|
|
1854
|
-
/* @__PURE__ */ jsxs(Badge, { size: "sm", variant: "outline", color: entity === "company" ? "blue" : "teal", children: [
|
|
1855
|
-
stages.length,
|
|
1856
|
-
" stages"
|
|
1857
|
-
] })
|
|
1858
|
-
] }),
|
|
1859
|
-
stages.length === 0 ? /* @__PURE__ */ jsx(
|
|
1860
|
-
Box,
|
|
1861
|
-
{
|
|
1862
|
-
p: "sm",
|
|
1863
|
-
style: {
|
|
1864
|
-
border: "1px dashed var(--color-border)",
|
|
1865
|
-
borderRadius: "var(--mantine-radius-md)"
|
|
1866
|
-
},
|
|
1867
|
-
children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: emptyText })
|
|
1868
|
-
}
|
|
1869
|
-
) : /* @__PURE__ */ jsx(ScrollArea, { type: "hover", offsetScrollbars: true, children: /* @__PURE__ */ jsx(
|
|
1870
|
-
Box,
|
|
1871
|
-
{
|
|
1872
|
-
style: {
|
|
1873
|
-
minWidth: Math.max(560, stages.length * 178),
|
|
1874
|
-
padding: "8px 2px 2px"
|
|
1875
|
-
},
|
|
1876
|
-
children: /* @__PURE__ */ jsx(
|
|
1877
|
-
Box,
|
|
1878
|
-
{
|
|
1879
|
-
style: {
|
|
1880
|
-
alignItems: "start",
|
|
1881
|
-
display: "grid",
|
|
1882
|
-
gap: 0,
|
|
1883
|
-
gridTemplateColumns: `repeat(${stages.length}, minmax(150px, 1fr))`,
|
|
1884
|
-
position: "relative"
|
|
1885
|
-
},
|
|
1886
|
-
children: stages.map((stage, index) => {
|
|
1887
|
-
const counts = getStageProgress2(progress, stage.key, entity);
|
|
1888
|
-
const accent = getLeadGenStageColorVar(stage.key);
|
|
1889
|
-
const completion = Math.round(percent(counts.success, counts.total));
|
|
1890
|
-
const attempted = Math.round(percent(counts.attempted, counts.total));
|
|
1891
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: 8, px: "xs", style: { position: "relative", zIndex: 1 }, children: [
|
|
1892
|
-
/* @__PURE__ */ jsxs(Group, { gap: 8, wrap: "nowrap", children: [
|
|
1893
|
-
/* @__PURE__ */ jsx(
|
|
1894
|
-
Box,
|
|
1895
|
-
{
|
|
1896
|
-
w: 44,
|
|
1897
|
-
h: 44,
|
|
1898
|
-
style: {
|
|
1899
|
-
alignItems: "center",
|
|
1900
|
-
background: getLeadGenStageColorVar(stage.key, "background"),
|
|
1901
|
-
border: `1px solid ${getLeadGenStageColorVar(stage.key, "border")}`,
|
|
1902
|
-
borderRadius: 999,
|
|
1903
|
-
boxShadow: `0 0 0 4px ${getLeadGenStageColorVar(stage.key, "background")}`,
|
|
1904
|
-
color: accent,
|
|
1905
|
-
display: "flex",
|
|
1906
|
-
flexShrink: 0,
|
|
1907
|
-
fontSize: 13,
|
|
1908
|
-
fontWeight: 800,
|
|
1909
|
-
justifyContent: "center"
|
|
1910
|
-
},
|
|
1911
|
-
children: index + 1
|
|
1912
|
-
}
|
|
1913
|
-
),
|
|
1914
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 1, style: { minWidth: 0 }, children: [
|
|
1915
|
-
/* @__PURE__ */ jsxs(Group, { gap: 6, wrap: "nowrap", children: [
|
|
1916
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", fw: 700, lineClamp: 1, children: stage.label }),
|
|
1917
|
-
/* @__PURE__ */ jsx(SourceBadge, { source: stage.source })
|
|
1918
|
-
] }),
|
|
1919
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", lineClamp: 1, children: counts.total > 0 ? `${counts.attempted} / ${counts.total} attempted` : `Ready for ${entity === "company" ? "company" : "contact"} rows` })
|
|
1920
|
-
] })
|
|
1921
|
-
] }),
|
|
1922
|
-
/* @__PURE__ */ jsx(ProgressRail, { counts, stageKey: stage.key }),
|
|
1923
|
-
/* @__PURE__ */ jsxs(Group, { gap: 10, wrap: "nowrap", children: [
|
|
1924
|
-
/* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
1925
|
-
counts.success,
|
|
1926
|
-
" success"
|
|
1927
|
-
] }),
|
|
1928
|
-
/* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
1929
|
-
attempted,
|
|
1930
|
-
"% attempted"
|
|
1931
|
-
] }),
|
|
1932
|
-
counts.error > 0 ? /* @__PURE__ */ jsxs(Text, { size: "xs", c: "red", children: [
|
|
1933
|
-
counts.error,
|
|
1934
|
-
" errors"
|
|
1935
|
-
] }) : null
|
|
1936
|
-
] }),
|
|
1937
|
-
/* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
1938
|
-
completion,
|
|
1939
|
-
"% complete"
|
|
1940
|
-
] })
|
|
1941
|
-
] }, stage.key);
|
|
1942
|
-
})
|
|
1943
|
-
}
|
|
1944
|
-
)
|
|
1945
|
-
}
|
|
1946
|
-
) })
|
|
1947
|
-
] });
|
|
1948
|
-
}
|
|
1949
|
-
function PipelineFunnel({ progress, pipelineConfig, actions }) {
|
|
1950
|
-
const companyStages = buildLaneStages({ entity: "company", progress, pipelineConfig, actions });
|
|
1951
|
-
const contactStages = buildLaneStages({ entity: "contact", progress, pipelineConfig, actions });
|
|
1952
|
-
return /* @__PURE__ */ jsx(Paper, { withBorder: true, p: "md", children: /* @__PURE__ */ jsxs(Stack, { gap: "lg", children: [
|
|
1953
|
-
/* @__PURE__ */ jsx(CardHeader, { icon: /* @__PURE__ */ jsx(IconListDetails, { size: 16 }), title: "Pipeline" }),
|
|
1954
|
-
/* @__PURE__ */ jsx(
|
|
1955
|
-
TimelineLane,
|
|
1956
|
-
{
|
|
1957
|
-
title: "Company pipeline",
|
|
1958
|
-
entity: "company",
|
|
1959
|
-
total: progress.totalCompanies,
|
|
1960
|
-
stages: companyStages,
|
|
1961
|
-
progress,
|
|
1962
|
-
emptyText: "No company stages are configured, runnable, or recorded yet."
|
|
1963
|
-
}
|
|
1964
|
-
),
|
|
1965
|
-
/* @__PURE__ */ jsx(
|
|
1966
|
-
TimelineLane,
|
|
1967
|
-
{
|
|
1968
|
-
title: "Contact pipeline",
|
|
1969
|
-
entity: "contact",
|
|
1970
|
-
total: progress.totalMembers,
|
|
1971
|
-
stages: contactStages,
|
|
1972
|
-
progress,
|
|
1973
|
-
emptyText: "No contact stages are configured, runnable, or recorded yet."
|
|
1974
|
-
}
|
|
1975
|
-
)
|
|
1976
|
-
] }) });
|
|
1977
|
-
}
|
|
1978
|
-
function asRecord(value) {
|
|
1979
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1980
|
-
}
|
|
1981
|
-
function selectedCount(selection) {
|
|
1982
|
-
return selection.selectedCompanyIds.length + selection.selectedContactIds.length;
|
|
1983
|
-
}
|
|
1984
|
-
function buildInput(input, selection) {
|
|
1985
|
-
const base = input && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
1986
|
-
return {
|
|
1987
|
-
...base,
|
|
1988
|
-
selectedCompanyIds: selection.selectedCompanyIds,
|
|
1989
|
-
selectedContactIds: selection.selectedContactIds
|
|
1990
|
-
};
|
|
1991
|
-
}
|
|
1992
|
-
function RunWorkflowModal({
|
|
1993
|
-
opened,
|
|
1994
|
-
onClose,
|
|
1995
|
-
list,
|
|
1996
|
-
actions,
|
|
1997
|
-
selection,
|
|
1998
|
-
initialResourceId,
|
|
1999
|
-
title = "Run Workflow",
|
|
2000
|
-
description = "Start a workflow immediately for this list.",
|
|
2001
|
-
lockResourceSelection = false,
|
|
2002
|
-
onResourceChange,
|
|
2003
|
-
onSubmitted
|
|
2004
|
-
}) {
|
|
2005
|
-
const [selectedResourceId, setSelectedResourceId] = useState(
|
|
2006
|
-
initialResourceId ?? actions[0]?.resourceId ?? null
|
|
2007
|
-
);
|
|
2008
|
-
const selectedAction = useMemo(
|
|
2009
|
-
() => actions.find((action) => action.resourceId === selectedResourceId) ?? actions[0],
|
|
2010
|
-
[actions, selectedResourceId]
|
|
2011
|
-
);
|
|
2012
|
-
const execution = useWorkflowExecution({
|
|
2013
|
-
workflowId: selectedAction?.resourceId ?? "",
|
|
2014
|
-
listId: list.id
|
|
2015
|
-
});
|
|
2016
|
-
useEffect(() => {
|
|
2017
|
-
if (!opened) return;
|
|
2018
|
-
const nextResourceId = initialResourceId ?? actions[0]?.resourceId ?? null;
|
|
2019
|
-
setSelectedResourceId(nextResourceId);
|
|
2020
|
-
onResourceChange?.(nextResourceId);
|
|
2021
|
-
}, [actions, initialResourceId, onResourceChange, opened]);
|
|
2022
|
-
const actionOptions = actions.map((action) => ({
|
|
2023
|
-
value: action.resourceId,
|
|
2024
|
-
label: action.label
|
|
2025
|
-
}));
|
|
2026
|
-
const handleResourceChange = (value) => {
|
|
2027
|
-
setSelectedResourceId(value);
|
|
2028
|
-
onResourceChange?.(value);
|
|
2029
|
-
execution.reset();
|
|
2030
|
-
};
|
|
2031
|
-
const submitInput = async (input) => {
|
|
2032
|
-
if (!selectedAction) return;
|
|
2033
|
-
try {
|
|
2034
|
-
const result = await execution.execute({
|
|
2035
|
-
input: buildInput(input, selection)
|
|
2036
|
-
});
|
|
2037
|
-
onSubmitted?.(selectedAction.resourceId, result.executionId);
|
|
2038
|
-
onClose();
|
|
2039
|
-
} catch (error) {
|
|
2040
|
-
showApiErrorNotification(error);
|
|
2041
|
-
}
|
|
2042
|
-
};
|
|
2043
|
-
const count = selectedCount(selection);
|
|
2044
|
-
return /* @__PURE__ */ jsx(
|
|
2045
|
-
CustomModal,
|
|
2046
|
-
{
|
|
2047
|
-
opened,
|
|
2048
|
-
onClose: () => !execution.isPending && onClose(),
|
|
2049
|
-
size: "lg",
|
|
2050
|
-
loading: execution.isPending,
|
|
2051
|
-
children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
2052
|
-
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
2053
|
-
/* @__PURE__ */ jsx(IconBolt, { size: 22 }),
|
|
2054
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
2055
|
-
/* @__PURE__ */ jsx(Text, { fw: 600, children: title }),
|
|
2056
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: description })
|
|
2057
|
-
] })
|
|
2058
|
-
] }),
|
|
2059
|
-
!actions.length ? /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), color: "gray", variant: "light", children: "No list builder workflows are registered." }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2060
|
-
/* @__PURE__ */ jsx(
|
|
2061
|
-
Select,
|
|
2062
|
-
{
|
|
2063
|
-
label: "Workflow",
|
|
2064
|
-
data: actionOptions,
|
|
2065
|
-
value: selectedAction?.resourceId ?? null,
|
|
2066
|
-
onChange: handleResourceChange,
|
|
2067
|
-
disabled: execution.isPending || lockResourceSelection,
|
|
2068
|
-
searchable: true
|
|
2069
|
-
}
|
|
2070
|
-
),
|
|
2071
|
-
selectedAction ? /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
|
|
2072
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
2073
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", children: selectedAction.category }),
|
|
2074
|
-
selectedAction.stagesAffected.map((stage) => /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "outline", color: "gray", children: stage }, stage))
|
|
2075
|
-
] }),
|
|
2076
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: selectedAction.description })
|
|
2077
|
-
] }) : null,
|
|
2078
|
-
count > 0 ? /* @__PURE__ */ jsxs(Alert, { color: "blue", variant: "light", children: [
|
|
2079
|
-
"This run includes ",
|
|
2080
|
-
selection.selectedCompanyIds.length,
|
|
2081
|
-
" selected companies and",
|
|
2082
|
-
" ",
|
|
2083
|
-
selection.selectedContactIds.length,
|
|
2084
|
-
" selected contacts."
|
|
2085
|
-
] }) : null,
|
|
2086
|
-
selectedAction ? /* @__PURE__ */ jsx(
|
|
2087
|
-
RunWorkflowConfigForm,
|
|
2088
|
-
{
|
|
2089
|
-
action: selectedAction,
|
|
2090
|
-
list,
|
|
2091
|
-
onSubmit: submitInput,
|
|
2092
|
-
isSubmitting: execution.isPending
|
|
2093
|
-
},
|
|
2094
|
-
selectedAction.resourceId
|
|
2095
|
-
) : null
|
|
2096
|
-
] })
|
|
2097
|
-
] })
|
|
2098
|
-
}
|
|
2099
|
-
);
|
|
2100
|
-
}
|
|
2101
|
-
function RunWorkflowConfigForm({ action, list, onSubmit, isSubmitting }) {
|
|
2102
|
-
const schema = action.schema;
|
|
2103
|
-
const layout = action.layout;
|
|
2104
|
-
const [config, setConfig] = useState(() => asRecord(action.defaultInput?.(list)));
|
|
2105
|
-
const handleChange = (next) => {
|
|
2106
|
-
setConfig(next);
|
|
2107
|
-
};
|
|
2108
|
-
const handleSubmit = async () => {
|
|
2109
|
-
await onSubmit(config);
|
|
2110
|
-
};
|
|
2111
|
-
return /* @__PURE__ */ jsx(Stack, { gap: "md", children: /* @__PURE__ */ jsx(
|
|
2112
|
-
StepConfigForm,
|
|
2113
|
-
{
|
|
2114
|
-
schema,
|
|
2115
|
-
layout,
|
|
2116
|
-
value: config,
|
|
2117
|
-
onChange: (v) => handleChange(asRecord(v)),
|
|
2118
|
-
actions: [{ id: "run", label: `Run ${action.label}`, loading: isSubmitting }],
|
|
2119
|
-
onAction: async () => {
|
|
2120
|
-
await handleSubmit();
|
|
2121
|
-
},
|
|
2122
|
-
disabled: isSubmitting
|
|
2123
|
-
}
|
|
2124
|
-
) });
|
|
2125
|
-
}
|
|
2126
|
-
function formatDateTime2(value) {
|
|
2127
|
-
if (!value) return "Not yet";
|
|
2128
|
-
return new Date(value).toLocaleString("en-US", {
|
|
2129
|
-
month: "short",
|
|
2130
|
-
day: "numeric",
|
|
2131
|
-
year: "numeric",
|
|
2132
|
-
hour: "numeric",
|
|
2133
|
-
minute: "2-digit"
|
|
2134
|
-
});
|
|
2135
|
-
}
|
|
2136
|
-
function formatDuration(durationMs) {
|
|
2137
|
-
if (durationMs == null) return "n/a";
|
|
2138
|
-
if (durationMs < 1e3) return `${durationMs} ms`;
|
|
2139
|
-
const seconds = durationMs / 1e3;
|
|
2140
|
-
if (seconds < 60) return `${seconds.toFixed(1)} s`;
|
|
2141
|
-
return `${Math.floor(seconds / 60)}m ${Math.round(seconds % 60)}s`;
|
|
2142
|
-
}
|
|
2143
|
-
function getStatusColor2(status) {
|
|
2144
|
-
switch (status) {
|
|
2145
|
-
case "completed":
|
|
2146
|
-
case "success":
|
|
2147
|
-
case "succeeded":
|
|
2148
|
-
return "green";
|
|
2149
|
-
case "running":
|
|
2150
|
-
case "pending":
|
|
2151
|
-
case "queued":
|
|
2152
|
-
return "blue";
|
|
2153
|
-
case "failed":
|
|
2154
|
-
case "error":
|
|
2155
|
-
case "cancelled":
|
|
2156
|
-
return "red";
|
|
2157
|
-
default:
|
|
2158
|
-
return "gray";
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
function hasObjectContent(value) {
|
|
2162
|
-
return typeof value === "object" && value !== null && Object.keys(value).length > 0;
|
|
2163
|
-
}
|
|
2164
|
-
function getRunDetails(run) {
|
|
2165
|
-
const payload = hasObjectContent(run.payload) ? run.payload : void 0;
|
|
2166
|
-
const input = run.input ?? run.inputs ?? payload?.input ?? payload?.inputs;
|
|
2167
|
-
const config = run.configSnapshot ?? run.config_snapshot ?? run.config ?? payload?.config_snapshot ?? payload?.configSnapshot ?? payload?.config;
|
|
2168
|
-
return { input, config };
|
|
2169
|
-
}
|
|
2170
|
-
function getSummaryKeys(value) {
|
|
2171
|
-
if (!hasObjectContent(value)) return [];
|
|
2172
|
-
return Object.keys(value).slice(0, 6);
|
|
2173
|
-
}
|
|
2174
|
-
function WorkflowRunsPanel({
|
|
2175
|
-
listId,
|
|
2176
|
-
title = "Workflow Runs",
|
|
2177
|
-
resourceFilter,
|
|
2178
|
-
onClearResourceFilter
|
|
2179
|
-
}) {
|
|
2180
|
-
const navigate = useNavigate();
|
|
2181
|
-
const executionsQuery = useListExecutions(listId, resourceFilter ? { resourceId: resourceFilter } : {});
|
|
2182
|
-
const [expandedExecutionId, setExpandedExecutionId] = useState(null);
|
|
2183
|
-
const executions = useMemo(() => executionsQuery.data ?? [], [executionsQuery.data]);
|
|
2184
|
-
const openWorkflow = (resourceId) => {
|
|
2185
|
-
void navigate({ to: "/operations/resources/workflow/$workflowId", params: { workflowId: resourceId } });
|
|
2186
|
-
};
|
|
2187
|
-
return /* @__PURE__ */ jsxs(
|
|
2188
|
-
TabSection,
|
|
2189
|
-
{
|
|
2190
|
-
icon: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 16 }),
|
|
2191
|
-
title,
|
|
2192
|
-
description: "Execution history recorded for this lead-gen list.",
|
|
2193
|
-
rightSection: /* @__PURE__ */ jsx(Tooltip, { label: "Refresh runs", children: /* @__PURE__ */ jsx(
|
|
2194
|
-
ActionIcon,
|
|
2195
|
-
{
|
|
2196
|
-
variant: "subtle",
|
|
2197
|
-
size: "sm",
|
|
2198
|
-
"aria-label": "Refresh workflow runs",
|
|
2199
|
-
loading: executionsQuery.isFetching,
|
|
2200
|
-
onClick: () => void executionsQuery.refetch(),
|
|
2201
|
-
children: /* @__PURE__ */ jsx(IconRefresh, { size: 14 })
|
|
2202
|
-
}
|
|
2203
|
-
) }),
|
|
2204
|
-
children: [
|
|
2205
|
-
resourceFilter ? /* @__PURE__ */ jsxs(Group, { gap: "xs", mb: "xs", children: [
|
|
2206
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Filtered by workflow:" }),
|
|
2207
|
-
/* @__PURE__ */ jsx(Pill, { withRemoveButton: true, onRemove: onClearResourceFilter, children: resourceFilter })
|
|
2208
|
-
] }) : null,
|
|
2209
|
-
executionsQuery.isLoading ? /* @__PURE__ */ jsx(Center, { p: "lg", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) }) : !executions.length ? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: resourceFilter ? `No workflow runs recorded for ${resourceFilter}.` : "No workflow runs recorded for this list." }) : /* @__PURE__ */ jsx(Table.ScrollContainer, { minWidth: 720, children: /* @__PURE__ */ jsxs(Table, { highlightOnHover: true, children: [
|
|
2210
|
-
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
2211
|
-
/* @__PURE__ */ jsx(Table.Th, {}),
|
|
2212
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Workflow" }),
|
|
2213
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Status" }),
|
|
2214
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Started" }),
|
|
2215
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Completed" }),
|
|
2216
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Duration" })
|
|
2217
|
-
] }) }),
|
|
2218
|
-
/* @__PURE__ */ jsx(Table.Tbody, { children: executions.map((execution) => {
|
|
2219
|
-
const details = getRunDetails(execution);
|
|
2220
|
-
const hasDetails = details.input !== void 0 || details.config !== void 0;
|
|
2221
|
-
const expanded = expandedExecutionId === execution.executionId;
|
|
2222
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2223
|
-
/* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
2224
|
-
/* @__PURE__ */ jsx(Table.Td, { w: 32, children: /* @__PURE__ */ jsx(
|
|
2225
|
-
ThemeIcon,
|
|
2226
|
-
{
|
|
2227
|
-
variant: "light",
|
|
2228
|
-
color: "blue",
|
|
2229
|
-
size: "md",
|
|
2230
|
-
role: hasDetails ? "button" : void 0,
|
|
2231
|
-
tabIndex: hasDetails ? 0 : void 0,
|
|
2232
|
-
"aria-label": hasDetails ? expanded ? "Collapse run details" : "Expand run details" : void 0,
|
|
2233
|
-
onClick: hasDetails ? () => setExpandedExecutionId(expanded ? null : execution.executionId) : void 0,
|
|
2234
|
-
onKeyDown: hasDetails ? (event) => {
|
|
2235
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
2236
|
-
event.preventDefault();
|
|
2237
|
-
setExpandedExecutionId(expanded ? null : execution.executionId);
|
|
2238
|
-
}
|
|
2239
|
-
} : void 0,
|
|
2240
|
-
style: {
|
|
2241
|
-
cursor: hasDetails ? "pointer" : "default",
|
|
2242
|
-
opacity: hasDetails ? 1 : 0.7
|
|
2243
|
-
},
|
|
2244
|
-
children: expanded ? /* @__PURE__ */ jsx(IconChevronDown, { size: 14 }) : /* @__PURE__ */ jsx(IconChevronRight, { size: 14 })
|
|
2245
|
-
}
|
|
2246
|
-
) }),
|
|
2247
|
-
/* @__PURE__ */ jsxs(Table.Td, { children: [
|
|
2248
|
-
execution.resourceId ? /* @__PURE__ */ jsx(
|
|
2249
|
-
Text,
|
|
2250
|
-
{
|
|
2251
|
-
fw: 500,
|
|
2252
|
-
role: "button",
|
|
2253
|
-
tabIndex: 0,
|
|
2254
|
-
c: "blue",
|
|
2255
|
-
onClick: () => openWorkflow(execution.resourceId),
|
|
2256
|
-
onKeyDown: (event) => {
|
|
2257
|
-
if (event.key === "Enter" || event.key === " ") {
|
|
2258
|
-
event.preventDefault();
|
|
2259
|
-
openWorkflow(execution.resourceId);
|
|
2260
|
-
}
|
|
2261
|
-
},
|
|
2262
|
-
style: { cursor: "pointer" },
|
|
2263
|
-
children: execution.resourceId
|
|
2264
|
-
}
|
|
2265
|
-
) : /* @__PURE__ */ jsx(Text, { fw: 500, children: "Unknown workflow" }),
|
|
2266
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", ff: "monospace", children: execution.executionId })
|
|
2267
|
-
] }),
|
|
2268
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: getStatusColor2(execution.status), children: execution.status }) }),
|
|
2269
|
-
/* @__PURE__ */ jsx(Table.Td, { children: formatDateTime2(execution.createdAt) }),
|
|
2270
|
-
/* @__PURE__ */ jsx(Table.Td, { children: formatDateTime2(execution.completedAt) }),
|
|
2271
|
-
/* @__PURE__ */ jsx(Table.Td, { children: formatDuration(execution.durationMs) })
|
|
2272
|
-
] }),
|
|
2273
|
-
/* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan: 6, p: 0, children: /* @__PURE__ */ jsx(Collapse, { in: expanded, children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", p: "sm", children: [
|
|
2274
|
-
details.input !== void 0 ? /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
|
|
2275
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
2276
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, children: "Input" }),
|
|
2277
|
-
getSummaryKeys(details.input).map((key) => /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "gray", children: key }, key))
|
|
2278
|
-
] }),
|
|
2279
|
-
/* @__PURE__ */ jsx(JsonViewer, { data: details.input, maxHeight: 220, fontSize: "0.75rem" })
|
|
2280
|
-
] }) : null,
|
|
2281
|
-
details.config !== void 0 ? /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
|
|
2282
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
2283
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, children: "Config" }),
|
|
2284
|
-
getSummaryKeys(details.config).map((key) => /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "gray", children: key }, key))
|
|
2285
|
-
] }),
|
|
2286
|
-
/* @__PURE__ */ jsx(JsonViewer, { data: details.config, maxHeight: 220, fontSize: "0.75rem" })
|
|
2287
|
-
] }) : null
|
|
2288
|
-
] }) }) }) })
|
|
2289
|
-
] }, execution.executionId);
|
|
2290
|
-
}) })
|
|
2291
|
-
] }) })
|
|
2292
|
-
]
|
|
2293
|
-
}
|
|
2294
|
-
);
|
|
2295
|
-
}
|
|
2296
|
-
var EMPTY_SELECTION = {
|
|
2297
|
-
selectedCompanyIds: [],
|
|
2298
|
-
selectedContactIds: []
|
|
2299
|
-
};
|
|
2300
|
-
function formatDateTime3(value) {
|
|
2301
|
-
if (!value) return "Not yet";
|
|
2302
|
-
return new Date(value).toLocaleString("en-US", {
|
|
2303
|
-
month: "short",
|
|
2304
|
-
day: "numeric",
|
|
2305
|
-
year: "numeric",
|
|
2306
|
-
hour: "numeric",
|
|
2307
|
-
minute: "2-digit"
|
|
2308
|
-
});
|
|
2309
|
-
}
|
|
2310
|
-
function getStatusColor3(status) {
|
|
2311
|
-
switch (status) {
|
|
2312
|
-
case "completed":
|
|
2313
|
-
case "success":
|
|
2314
|
-
case "launched":
|
|
2315
|
-
return "green";
|
|
2316
|
-
case "running":
|
|
2317
|
-
case "pending":
|
|
2318
|
-
case "enriching":
|
|
2319
|
-
return "blue";
|
|
2320
|
-
case "failed":
|
|
2321
|
-
case "error":
|
|
2322
|
-
case "archived":
|
|
2323
|
-
return "red";
|
|
2324
|
-
case "closing":
|
|
2325
|
-
return "yellow";
|
|
2326
|
-
default:
|
|
2327
|
-
return "gray";
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
2330
|
-
function ListBuilderPage({ listId }) {
|
|
2331
|
-
const navigate = useNavigate();
|
|
2332
|
-
const actions = useListActions();
|
|
2333
|
-
const [runModalOpen, setRunModalOpen] = useState(false);
|
|
2334
|
-
const [initialRunResourceId, setInitialRunResourceId] = useState(null);
|
|
2335
|
-
const listQuery = useList(listId);
|
|
2336
|
-
const progressQuery = useListProgress(listId);
|
|
2337
|
-
const executionsQuery = useListExecutions(listId);
|
|
2338
|
-
const isLoading = listQuery.isLoading || progressQuery.isLoading || executionsQuery.isLoading;
|
|
2339
|
-
const error = listQuery.error ?? progressQuery.error ?? executionsQuery.error;
|
|
2340
|
-
const executions = useMemo(() => executionsQuery.data ?? [], [executionsQuery.data]);
|
|
2341
|
-
const openRunModal = (resourceId) => {
|
|
2342
|
-
const nextResourceId = actions[0]?.resourceId ?? null;
|
|
2343
|
-
setInitialRunResourceId(nextResourceId);
|
|
2344
|
-
setRunModalOpen(true);
|
|
2345
|
-
};
|
|
2346
|
-
const closeRunModal = () => {
|
|
2347
|
-
setRunModalOpen(false);
|
|
2348
|
-
setInitialRunResourceId(null);
|
|
2349
|
-
};
|
|
2350
|
-
const copyListCommand = (id) => {
|
|
2351
|
-
void navigator.clipboard.writeText(`/acquisition --lead-gen list ${id}`);
|
|
2352
|
-
showSuccessNotification("Copied list command to clipboard");
|
|
2353
|
-
};
|
|
2354
|
-
const backButton = /* @__PURE__ */ jsx(
|
|
2355
|
-
Button,
|
|
2356
|
-
{
|
|
2357
|
-
variant: "light",
|
|
2358
|
-
size: "xs",
|
|
2359
|
-
leftSection: /* @__PURE__ */ jsx(IconArrowLeft, { size: 16 }),
|
|
2360
|
-
onClick: () => navigate({ to: "/lead-gen/lists" }),
|
|
2361
|
-
children: "Lists"
|
|
2362
|
-
}
|
|
2363
|
-
);
|
|
2364
|
-
if (isLoading) {
|
|
2365
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
2366
|
-
/* @__PURE__ */ jsx(PageTitleCaption, { title: "List Builder", caption: "Lead-gen workspace", rightSection: backButton }),
|
|
2367
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) })
|
|
2368
|
-
] }) }) });
|
|
2369
|
-
}
|
|
2370
|
-
if (error) {
|
|
2371
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
2372
|
-
/* @__PURE__ */ jsx(PageTitleCaption, { title: "List Builder", caption: "Lead-gen workspace", rightSection: backButton }),
|
|
2373
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(CenteredErrorState, { error, title: "Failed to load list builder" }) })
|
|
2374
|
-
] }) }) });
|
|
2375
|
-
}
|
|
2376
|
-
if (!listQuery.data || !progressQuery.data) {
|
|
2377
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
2378
|
-
/* @__PURE__ */ jsx(PageTitleCaption, { title: "List Not Found", caption: "The requested lead-gen list is unavailable." }),
|
|
2379
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { h: 240, children: /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), color: "gray", variant: "light", children: "The requested list could not be found." }) }) })
|
|
2380
|
-
] }) }) });
|
|
2381
|
-
}
|
|
2382
|
-
const list = listQuery.data;
|
|
2383
|
-
const progress = progressQuery.data;
|
|
2384
|
-
return /* @__PURE__ */ jsxs(SubshellContentContainer, { children: [
|
|
2385
|
-
/* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
2386
|
-
/* @__PURE__ */ jsx(
|
|
2387
|
-
PageTitleCaption,
|
|
2388
|
-
{
|
|
2389
|
-
title: list.name,
|
|
2390
|
-
caption: list.description ?? "Lead-gen list builder",
|
|
2391
|
-
rightSection: /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
2392
|
-
/* @__PURE__ */ jsx(Button, { size: "xs", leftSection: /* @__PURE__ */ jsx(IconBolt, { size: 16 }), onClick: () => openRunModal(), children: "Run Workflow" }),
|
|
2393
|
-
backButton
|
|
2394
|
-
] })
|
|
2395
|
-
}
|
|
2396
|
-
),
|
|
2397
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "xs", children: [
|
|
2398
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
2399
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "filled", color: getStatusColor3(list.status), children: list.status }),
|
|
2400
|
-
/* @__PURE__ */ jsxs(Text, { size: "sm", c: "dimmed", children: [
|
|
2401
|
-
"Created ",
|
|
2402
|
-
formatDateTime3(list.createdAt)
|
|
2403
|
-
] })
|
|
2404
|
-
] }),
|
|
2405
|
-
/* @__PURE__ */ jsx(Group, { gap: "xs", children: /* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", onClick: () => copyListCommand(list.id), style: { cursor: "pointer" }, children: [
|
|
2406
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", ff: "monospace", children: list.id }),
|
|
2407
|
-
/* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", size: "sm", "aria-label": "Copy list command", children: /* @__PURE__ */ jsx(IconCopy, { size: 14 }) })
|
|
2408
|
-
] }) })
|
|
2409
|
-
] }),
|
|
2410
|
-
/* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 1, sm: 2, lg: 4 }, children: [
|
|
2411
|
-
/* @__PURE__ */ jsx(StatCard, { label: "Companies", value: progress.totalCompanies, icon: IconBuilding }),
|
|
2412
|
-
/* @__PURE__ */ jsx(StatCard, { label: "Contacts", value: progress.totalMembers, icon: IconUsers }),
|
|
2413
|
-
/* @__PURE__ */ jsx(StatCard, { label: "Workflows", value: actions.length, icon: IconBolt }),
|
|
2414
|
-
/* @__PURE__ */ jsx(StatCard, { label: "Runs", value: executions.length, icon: IconPlayerPlay })
|
|
2415
|
-
] }),
|
|
2416
|
-
/* @__PURE__ */ jsx(PipelineFunnel, { progress, pipelineConfig: list.pipelineConfig, actions }),
|
|
2417
|
-
/* @__PURE__ */ jsx(WorkflowRunsPanel, { listId })
|
|
2418
|
-
] }) }),
|
|
2419
|
-
/* @__PURE__ */ jsx(
|
|
2420
|
-
RunWorkflowModal,
|
|
2421
|
-
{
|
|
2422
|
-
opened: runModalOpen,
|
|
2423
|
-
onClose: closeRunModal,
|
|
2424
|
-
list,
|
|
2425
|
-
actions,
|
|
2426
|
-
selection: EMPTY_SELECTION,
|
|
2427
|
-
initialResourceId: initialRunResourceId,
|
|
2428
|
-
onSubmitted: (_resourceId, executionId) => {
|
|
2429
|
-
showSuccessNotification(`Workflow run started: ${executionId}`);
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
)
|
|
2433
|
-
] });
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2436
|
-
// src/lib/lead-gen/processing-state.ts
|
|
2437
|
-
function isRecord(value) {
|
|
2438
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2439
|
-
}
|
|
2440
|
-
function parseProcessingStageStatus(value) {
|
|
2441
|
-
if (value === true || value === "success") return "success";
|
|
2442
|
-
if (value === "no_result" || value === "noResult") return "noResult";
|
|
2443
|
-
if (value === "skipped") return "skipped";
|
|
2444
|
-
if (value === "error") return "error";
|
|
2445
|
-
if (isRecord(value)) return parseProcessingStageStatus(value.status);
|
|
2446
|
-
if (typeof value === "string") return "other";
|
|
2447
|
-
return null;
|
|
2448
|
-
}
|
|
2449
|
-
function parseProcessingState(value) {
|
|
2450
|
-
const parsed = {};
|
|
2451
|
-
const stageStatuses = {};
|
|
2452
|
-
const knownStageStatuses = {};
|
|
2453
|
-
const unknownFields = {};
|
|
2454
|
-
if (!isRecord(value)) {
|
|
2455
|
-
Object.defineProperties(parsed, {
|
|
2456
|
-
stageStatuses: { value: stageStatuses },
|
|
2457
|
-
knownStageStatuses: { value: knownStageStatuses },
|
|
2458
|
-
unknownFields: { value: unknownFields }
|
|
2459
|
-
});
|
|
2460
|
-
return parsed;
|
|
2461
|
-
}
|
|
2462
|
-
for (const [key, rawStatus] of Object.entries(value)) {
|
|
2463
|
-
const parsedStatus = parseProcessingStageStatus(rawStatus);
|
|
2464
|
-
const isKnownStage = Boolean(LEAD_GEN_STAGE_CATALOG[key]);
|
|
2465
|
-
if (!parsedStatus) {
|
|
2466
|
-
unknownFields[key] = rawStatus;
|
|
2467
|
-
continue;
|
|
2468
|
-
}
|
|
2469
|
-
stageStatuses[key] = parsedStatus;
|
|
2470
|
-
parsed[key] = parsedStatus;
|
|
2471
|
-
if (isKnownStage) {
|
|
2472
|
-
knownStageStatuses[key] = parsedStatus;
|
|
2473
|
-
} else {
|
|
2474
|
-
unknownFields[key] = rawStatus;
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
Object.defineProperties(parsed, {
|
|
2478
|
-
stageStatuses: { value: stageStatuses },
|
|
2479
|
-
knownStageStatuses: { value: knownStageStatuses },
|
|
2480
|
-
unknownFields: { value: unknownFields }
|
|
2481
|
-
});
|
|
2482
|
-
return parsed;
|
|
2483
|
-
}
|
|
2484
|
-
function readLeadGenProcessingState(row) {
|
|
2485
|
-
if (!isRecord(row)) return null;
|
|
2486
|
-
return row.processingState ?? row.processing_state ?? row.pipelineStatus ?? null;
|
|
2487
|
-
}
|
|
2488
|
-
function readLeadGenStateKey(row) {
|
|
2489
|
-
if (!isRecord(row)) return null;
|
|
2490
|
-
const stateKey = row.stateKey ?? row.state_key;
|
|
2491
|
-
return typeof stateKey === "string" && stateKey.length > 0 ? stateKey : null;
|
|
2492
|
-
}
|
|
2493
|
-
function getDisplayLeadGenStageStateFor(row, entity) {
|
|
2494
|
-
const parsed = parseProcessingState(readLeadGenProcessingState(row));
|
|
2495
|
-
const latest = Object.values(LEAD_GEN_STAGE_CATALOG).filter((stage) => stage.entity === entity && parsed.knownStageStatuses[stage.key]).sort((a, b) => b.order - a.order)[0];
|
|
2496
|
-
if (latest) {
|
|
2497
|
-
return {
|
|
2498
|
-
stageKey: latest.key,
|
|
2499
|
-
stageStatus: parsed.knownStageStatuses[latest.key]
|
|
2500
|
-
};
|
|
2501
|
-
}
|
|
2502
|
-
const unknownStageKey = Object.keys(parsed.stageStatuses).find((stageKey) => !LEAD_GEN_STAGE_CATALOG[stageKey]);
|
|
2503
|
-
if (unknownStageKey) {
|
|
2504
|
-
return {
|
|
2505
|
-
stageKey: unknownStageKey,
|
|
2506
|
-
stageStatus: parsed.stageStatuses[unknownStageKey]
|
|
2507
|
-
};
|
|
2508
|
-
}
|
|
2509
|
-
const stateKey = readLeadGenStateKey(row);
|
|
2510
|
-
return stateKey && LEAD_GEN_STAGE_CATALOG[stateKey] ? { stageKey: stateKey, stageStatus: null } : { stageKey: null, stageStatus: null };
|
|
2511
|
-
}
|
|
2512
|
-
|
|
2513
|
-
// src/features/lead-gen/build-state.ts
|
|
2514
|
-
var ORPHAN_STAGE_ORDER = 9999;
|
|
2515
|
-
function asRecord2(value) {
|
|
2516
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2517
|
-
}
|
|
2518
|
-
function defineMvpBuildStep(step, emptyBlockedText) {
|
|
2519
|
-
const description = "description" in step && typeof step.description === "string" ? step.description : `Run ${step.label.toLowerCase()} for this list.`;
|
|
2520
|
-
return {
|
|
2521
|
-
...step,
|
|
2522
|
-
description,
|
|
2523
|
-
emptyBlockedText
|
|
2524
|
-
};
|
|
2525
|
-
}
|
|
2526
|
-
var MVP_BUILD_STEPS = [
|
|
2527
|
-
defineMvpBuildStep(
|
|
2528
|
-
PROSPECTING_STEPS.localServices.sourceCompanies,
|
|
2529
|
-
"No company source has been configured or populated yet."
|
|
2530
|
-
),
|
|
2531
|
-
defineMvpBuildStep(
|
|
2532
|
-
PROSPECTING_STEPS.localServices.analyzeWebsites,
|
|
2533
|
-
"Source companies before website analysis can run."
|
|
2534
|
-
),
|
|
2535
|
-
defineMvpBuildStep(
|
|
2536
|
-
PROSPECTING_STEPS.localServices.qualifyCompanies,
|
|
2537
|
-
"Analyze websites before qualification can run."
|
|
2538
|
-
),
|
|
2539
|
-
defineMvpBuildStep(
|
|
2540
|
-
PROSPECTING_STEPS.localServices.findContacts,
|
|
2541
|
-
"Qualify companies before contact discovery can run."
|
|
2542
|
-
),
|
|
2543
|
-
defineMvpBuildStep(PROSPECTING_STEPS.localServices.verifyEmails, "Find contacts before email verification can run."),
|
|
2544
|
-
defineMvpBuildStep(PROSPECTING_STEPS.localServices.personalize, "Verify emails before personalization can run."),
|
|
2545
|
-
defineMvpBuildStep(
|
|
2546
|
-
PROSPECTING_STEPS.localServices.review,
|
|
2547
|
-
"Personalize contacts before records are ready for review."
|
|
2548
|
-
)
|
|
2549
|
-
];
|
|
2550
|
-
function sortStageKeys(keys) {
|
|
2551
|
-
return keys.slice().sort((a, b) => {
|
|
2552
|
-
const oa = LEAD_GEN_STAGE_CATALOG[a]?.order ?? ORPHAN_STAGE_ORDER;
|
|
2553
|
-
const ob = LEAD_GEN_STAGE_CATALOG[b]?.order ?? ORPHAN_STAGE_ORDER;
|
|
2554
|
-
return oa - ob || a.localeCompare(b);
|
|
2555
|
-
});
|
|
2556
|
-
}
|
|
2557
|
-
function getStageProgress3(progress, step) {
|
|
2558
|
-
return step.primaryEntity === "company" ? progress.byCompanyStage[step.stageKey] : progress.byContactStage[step.stageKey];
|
|
2559
|
-
}
|
|
2560
|
-
function getEntityTotal(progress, entity) {
|
|
2561
|
-
return entity === "company" ? progress.totalCompanies : progress.totalMembers;
|
|
2562
|
-
}
|
|
2563
|
-
function findActionForStep(actions, step) {
|
|
2564
|
-
return actions.find((action) => action.actionKey === step.actionKey) ?? actions.find((action) => action.stagesAffected?.includes(step.stageKey));
|
|
2565
|
-
}
|
|
2566
|
-
function normalizeBuildPlanStep(step) {
|
|
2567
|
-
const fallback = MVP_BUILD_STEPS.find((item) => item.id === step.id || item.stageKey === step.stageKey);
|
|
2568
|
-
return {
|
|
2569
|
-
id: step.id,
|
|
2570
|
-
label: step.label,
|
|
2571
|
-
description: step.description ?? fallback?.description ?? `Run ${step.label.toLowerCase()} for this list.`,
|
|
2572
|
-
primaryEntity: step.primaryEntity,
|
|
2573
|
-
outputs: step.outputs,
|
|
2574
|
-
stageKey: step.stageKey,
|
|
2575
|
-
recordEntity: step.recordEntity,
|
|
2576
|
-
recordsStageKey: step.recordsStageKey,
|
|
2577
|
-
recordSourceStageKey: step.recordSourceStageKey,
|
|
2578
|
-
dependsOn: step.dependsOn,
|
|
2579
|
-
dependencyMode: step.dependencyMode,
|
|
2580
|
-
actionKey: step.actionKey,
|
|
2581
|
-
defaultBatchSize: step.defaultBatchSize,
|
|
2582
|
-
maxBatchSize: step.maxBatchSize,
|
|
2583
|
-
recordColumns: step.recordColumns,
|
|
2584
|
-
credentialRequirements: step.credentialRequirements,
|
|
2585
|
-
emptyBlockedText: fallback?.emptyBlockedText ?? "Complete prerequisite build steps before this action can run."
|
|
2586
|
-
};
|
|
2587
|
-
}
|
|
2588
|
-
function isCurrentBuildPlanStep(step) {
|
|
2589
|
-
if (!step || typeof step !== "object") return false;
|
|
2590
|
-
const candidate = step;
|
|
2591
|
-
return (candidate.primaryEntity === "company" || candidate.primaryEntity === "contact") && Array.isArray(candidate.outputs) && candidate.outputs.length > 0 && candidate.dependencyMode === "per-record-eligibility";
|
|
2592
|
-
}
|
|
2593
|
-
function resolveBuildPlanSteps(list) {
|
|
2594
|
-
const snapshot = list.metadata.buildPlanSnapshot;
|
|
2595
|
-
const snapshotSteps = snapshot?.steps;
|
|
2596
|
-
if (snapshotSteps?.length && snapshotSteps.every(isCurrentBuildPlanStep)) {
|
|
2597
|
-
return snapshotSteps.map(normalizeBuildPlanStep);
|
|
2598
|
-
}
|
|
2599
|
-
if (snapshot?.templateId) {
|
|
2600
|
-
const templateSnapshot = createBuildPlanSnapshotFromTemplateId(snapshot.templateId);
|
|
2601
|
-
if (templateSnapshot?.steps.length) return templateSnapshot.steps.map(normalizeBuildPlanStep);
|
|
2602
|
-
}
|
|
2603
|
-
return MVP_BUILD_STEPS;
|
|
2604
|
-
}
|
|
2605
|
-
function getPrerequisiteSteps(step, byStepId) {
|
|
2606
|
-
return (step.dependsOn ?? []).flatMap((dependencyId) => {
|
|
2607
|
-
const dependency = byStepId.get(dependencyId);
|
|
2608
|
-
return dependency ? [dependency] : [];
|
|
2609
|
-
});
|
|
2610
|
-
}
|
|
2611
|
-
function getStepActionKind(step, ready, failed, action) {
|
|
2612
|
-
if (!action) return "none";
|
|
2613
|
-
if (failed > 0) return "retry_failed";
|
|
2614
|
-
if (ready > 0) return "run_next_batch";
|
|
2615
|
-
const isSeedStep = (step.dependsOn?.length ?? 0) === 0 && step.outputs.includes(step.primaryEntity);
|
|
2616
|
-
if (isSeedStep) return "run_next_batch";
|
|
2617
|
-
return "none";
|
|
2618
|
-
}
|
|
2619
|
-
function getStepActionLabel(kind) {
|
|
2620
|
-
switch (kind) {
|
|
2621
|
-
case "retry_failed":
|
|
2622
|
-
return "Retry failed";
|
|
2623
|
-
case "run_next_batch":
|
|
2624
|
-
return "Run next batch";
|
|
2625
|
-
case "advanced":
|
|
2626
|
-
return "Advanced";
|
|
2627
|
-
case "none":
|
|
2628
|
-
default:
|
|
2629
|
-
return "No action";
|
|
2630
|
-
}
|
|
2631
|
-
}
|
|
2632
|
-
function createCompleteStageCounts(total) {
|
|
2633
|
-
return {
|
|
2634
|
-
total,
|
|
2635
|
-
attempted: total,
|
|
2636
|
-
success: total,
|
|
2637
|
-
noResult: 0,
|
|
2638
|
-
skipped: 0,
|
|
2639
|
-
error: 0,
|
|
2640
|
-
other: 0,
|
|
2641
|
-
notAttempted: 0
|
|
2642
|
-
};
|
|
2643
|
-
}
|
|
2644
|
-
function isStageComplete(entry) {
|
|
2645
|
-
if (!entry || entry.total <= 0) return false;
|
|
2646
|
-
return entry.error === 0 && entry.attempted >= entry.total && entry.success + entry.noResult + entry.skipped + entry.other >= entry.total;
|
|
2647
|
-
}
|
|
2648
|
-
function getExecutionInput(run) {
|
|
2649
|
-
return asRecord2(run.input);
|
|
2650
|
-
}
|
|
2651
|
-
function isCompletedRun(run) {
|
|
2652
|
-
return run.status === "completed" || run.status === "success" || run.status === "succeeded";
|
|
2653
|
-
}
|
|
2654
|
-
function getApprovedCompanyIds(run) {
|
|
2655
|
-
const input = getExecutionInput(run);
|
|
2656
|
-
const raw = input.approvedCompanyIds;
|
|
2657
|
-
return Array.isArray(raw) ? raw.filter((value) => typeof value === "string") : [];
|
|
2658
|
-
}
|
|
2659
|
-
function hasApprovedExportRun(executions) {
|
|
2660
|
-
return executions.some((run) => {
|
|
2661
|
-
if (!isCompletedRun(run) || run.resourceId !== "lgn-06-export-list-workflow") return false;
|
|
2662
|
-
const input = getExecutionInput(run);
|
|
2663
|
-
return input.approved === true || getApprovedCompanyIds(run).length > 0;
|
|
2664
|
-
});
|
|
2665
|
-
}
|
|
2666
|
-
function hasCompletedSourcingRun(step, action, executions) {
|
|
2667
|
-
return executions.some((run) => isCompletedRun(run) && run.resourceId === (action?.resourceId ?? step.actionKey));
|
|
2668
|
-
}
|
|
2669
|
-
function deriveBusinessProgress(list, progress, actions = [], executions = []) {
|
|
2670
|
-
const byCompanyStage = { ...progress.byCompanyStage };
|
|
2671
|
-
const byContactStage = { ...progress.byContactStage };
|
|
2672
|
-
const steps = resolveBuildPlanSteps(list);
|
|
2673
|
-
for (const step of steps) {
|
|
2674
|
-
const stageProgress = step.primaryEntity === "company" ? byCompanyStage[step.stageKey] : byContactStage[step.stageKey];
|
|
2675
|
-
if (stageProgress || (step.dependsOn?.length ?? 0) > 0 || !step.outputs.includes("company")) continue;
|
|
2676
|
-
if (progress.totalCompanies <= 0) continue;
|
|
2677
|
-
const action = findActionForStep(actions, step);
|
|
2678
|
-
if (hasCompletedSourcingRun(step, action, executions) || step.stageKey === "populated") {
|
|
2679
|
-
byCompanyStage[step.stageKey] = createCompleteStageCounts(progress.totalCompanies);
|
|
2680
|
-
}
|
|
2681
|
-
}
|
|
2682
|
-
if (!isStageComplete(byCompanyStage.uploaded) && hasApprovedExportRun(executions)) {
|
|
2683
|
-
const exportedCount = Math.max(
|
|
2684
|
-
...executions.filter((run) => isCompletedRun(run) && run.resourceId === "lgn-06-export-list-workflow").map((run) => getApprovedCompanyIds(run).length),
|
|
2685
|
-
0
|
|
2686
|
-
);
|
|
2687
|
-
const total = exportedCount > 0 ? exportedCount : progress.totalCompanies;
|
|
2688
|
-
if (total > 0) byCompanyStage.uploaded = createCompleteStageCounts(total);
|
|
2689
|
-
}
|
|
2690
|
-
return {
|
|
2691
|
-
...progress,
|
|
2692
|
-
byCompanyStage,
|
|
2693
|
-
byContactStage
|
|
2694
|
-
};
|
|
2695
|
-
}
|
|
2696
|
-
function getStepRecommendedAction(step, action, kind) {
|
|
2697
|
-
if (!action || kind === "none") return void 0;
|
|
2698
|
-
return {
|
|
2699
|
-
kind,
|
|
2700
|
-
label: getStepActionLabel(kind),
|
|
2701
|
-
actionKey: action.actionKey ?? step.actionKey,
|
|
2702
|
-
defaultSize: step.defaultBatchSize,
|
|
2703
|
-
maxSize: step.maxBatchSize
|
|
2704
|
-
};
|
|
2705
|
-
}
|
|
2706
|
-
function deriveBuildStepStates(list, progress, actions) {
|
|
2707
|
-
const byStepId = /* @__PURE__ */ new Map();
|
|
2708
|
-
for (const step of resolveBuildPlanSteps(list)) {
|
|
2709
|
-
const stageProgress = getStageProgress3(progress, step);
|
|
2710
|
-
const entityTotal = getEntityTotal(progress, step.primaryEntity);
|
|
2711
|
-
const prerequisites = getPrerequisiteSteps(step, byStepId);
|
|
2712
|
-
const hasDependencies = (step.dependsOn?.length ?? 0) > 0;
|
|
2713
|
-
const prerequisiteEligibleTotal = prerequisites.reduce((sum, prerequisite) => sum + prerequisite.complete, 0);
|
|
2714
|
-
const eligibleTotal = hasDependencies ? entityTotal > 0 ? Math.min(entityTotal, prerequisiteEligibleTotal) : prerequisiteEligibleTotal : entityTotal > 0 ? entityTotal : 0;
|
|
2715
|
-
const total = Math.max(stageProgress?.total ?? 0, entityTotal, eligibleTotal);
|
|
2716
|
-
const complete = stageProgress ? stageProgress.success + stageProgress.noResult + stageProgress.skipped + stageProgress.other : 0;
|
|
2717
|
-
const failed = stageProgress?.error ?? 0;
|
|
2718
|
-
const ready = Math.max(0, eligibleTotal - complete - failed);
|
|
2719
|
-
const blocked = hasDependencies ? Math.max(total - eligibleTotal - complete - failed, 0) : 0;
|
|
2720
|
-
const status = failed > 0 ? "failed" : ready > 0 ? "ready" : blocked > 0 || total === 0 ? "blocked" : "complete";
|
|
2721
|
-
const action = findActionForStep(actions, step);
|
|
2722
|
-
const nextActionKind = getStepActionKind(step, ready, failed, action);
|
|
2723
|
-
const state = {
|
|
2724
|
-
...step,
|
|
2725
|
-
status,
|
|
2726
|
-
ready,
|
|
2727
|
-
complete,
|
|
2728
|
-
failed,
|
|
2729
|
-
blocked,
|
|
2730
|
-
nextActionKind,
|
|
2731
|
-
recommendedAction: getStepRecommendedAction(step, action, nextActionKind),
|
|
2732
|
-
action
|
|
2733
|
-
};
|
|
2734
|
-
byStepId.set(step.id, state);
|
|
2735
|
-
}
|
|
2736
|
-
return Array.from(byStepId.values());
|
|
2737
|
-
}
|
|
2738
|
-
function getRecommendedBuildStep(steps) {
|
|
2739
|
-
return steps.find((step) => step.nextActionKind === "retry_failed") ?? steps.find((step) => step.nextActionKind === "run_next_batch") ?? null;
|
|
2740
|
-
}
|
|
2741
|
-
function resolveBuildState(list, progress, actions) {
|
|
2742
|
-
const steps = deriveBuildStepStates(list, progress, actions);
|
|
2743
|
-
const recommendedStep = getRecommendedBuildStep(steps);
|
|
2744
|
-
return {
|
|
2745
|
-
steps,
|
|
2746
|
-
recommendedStep,
|
|
2747
|
-
recommendedAction: recommendedStep?.recommendedAction ?? null
|
|
2748
|
-
};
|
|
2749
|
-
}
|
|
2750
|
-
function formatDateTime4(value) {
|
|
2751
|
-
if (!value) return "Not yet";
|
|
2752
|
-
return new Date(value).toLocaleString("en-US", {
|
|
2753
|
-
month: "short",
|
|
2754
|
-
day: "numeric",
|
|
2755
|
-
year: "numeric",
|
|
2756
|
-
hour: "numeric",
|
|
2757
|
-
minute: "2-digit"
|
|
2758
|
-
});
|
|
2759
|
-
}
|
|
2760
|
-
function contactDisplayName(firstName, lastName) {
|
|
2761
|
-
const full = [firstName, lastName].filter(Boolean).join(" ").trim();
|
|
2762
|
-
return full || "\u2014";
|
|
2763
|
-
}
|
|
2764
|
-
function getStatusColor4(status) {
|
|
2765
|
-
switch (status) {
|
|
2766
|
-
case "draft":
|
|
2767
|
-
return "gray";
|
|
2768
|
-
case "enriching":
|
|
2769
|
-
return "blue";
|
|
2770
|
-
case "launched":
|
|
2771
|
-
return "green";
|
|
2772
|
-
case "closing":
|
|
2773
|
-
return "yellow";
|
|
2774
|
-
case "archived":
|
|
2775
|
-
return "red";
|
|
2776
|
-
default:
|
|
2777
|
-
return "gray";
|
|
2778
|
-
}
|
|
2779
|
-
}
|
|
2780
|
-
function getMemberStateColor2(stateKey) {
|
|
2781
|
-
const stage = LEAD_GEN_STAGE_CATALOG[stateKey];
|
|
2782
|
-
if (stage?.entity === "contact") return "green";
|
|
2783
|
-
if (stage?.entity === "company") return "blue";
|
|
2784
|
-
return "gray";
|
|
2785
|
-
}
|
|
2786
|
-
function displayMemberStageFor(row, kind) {
|
|
2787
|
-
const stage = getDisplayLeadGenStageStateFor(row, kind);
|
|
2788
|
-
if (!stage.stageKey) return null;
|
|
2789
|
-
const catalogStage = LEAD_GEN_STAGE_CATALOG[stage.stageKey];
|
|
2790
|
-
return {
|
|
2791
|
-
key: stage.stageKey,
|
|
2792
|
-
label: catalogStage?.label ?? stage.stageKey
|
|
2793
|
-
};
|
|
2794
|
-
}
|
|
2795
|
-
function asRecord3(value) {
|
|
2796
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2797
|
-
}
|
|
2798
|
-
function valueAtPath(source, path) {
|
|
2799
|
-
return path.split(".").reduce((current, segment) => {
|
|
2800
|
-
if (!current || typeof current !== "object") return void 0;
|
|
2801
|
-
return current[segment];
|
|
2802
|
-
}, source);
|
|
2803
|
-
}
|
|
2804
|
-
function compactText(value) {
|
|
2805
|
-
if (value === null || value === void 0 || value === "") return "-";
|
|
2806
|
-
if (Array.isArray(value)) {
|
|
2807
|
-
if (!value.length) return "-";
|
|
2808
|
-
return value.map((item) => {
|
|
2809
|
-
if (item && typeof item === "object") {
|
|
2810
|
-
const labelled = item;
|
|
2811
|
-
return String(labelled.name ?? labelled.label ?? labelled.title ?? labelled.id ?? JSON.stringify(item));
|
|
2812
|
-
}
|
|
2813
|
-
return String(item);
|
|
2814
|
-
}).join(", ");
|
|
2815
|
-
}
|
|
2816
|
-
if (typeof value === "object") return JSON.stringify(value);
|
|
2817
|
-
return String(value);
|
|
2818
|
-
}
|
|
2819
|
-
function getRecordDisplayName(row) {
|
|
2820
|
-
if (row.entity === "company") return row.company?.name ?? "Company";
|
|
2821
|
-
const contact = row.contact;
|
|
2822
|
-
const full = [contact?.firstName, contact?.lastName].filter(Boolean).join(" ").trim();
|
|
2823
|
-
return full || contact?.email || "Contact";
|
|
2824
|
-
}
|
|
2825
|
-
function getRecordColumnSource(row) {
|
|
2826
|
-
if (row.entity === "company") {
|
|
2827
|
-
return {
|
|
2828
|
-
...row,
|
|
2829
|
-
company: row.company ? {
|
|
2830
|
-
...row.company,
|
|
2831
|
-
enrichmentData: row.enrichmentData,
|
|
2832
|
-
processingState: row.processingState
|
|
2833
|
-
} : null
|
|
2834
|
-
};
|
|
2835
|
-
}
|
|
2836
|
-
return {
|
|
2837
|
-
...row,
|
|
2838
|
-
contact: row.contact ? {
|
|
2839
|
-
...row.contact,
|
|
2840
|
-
name: getRecordDisplayName(row),
|
|
2841
|
-
enrichmentData: row.enrichmentData,
|
|
2842
|
-
processingState: row.processingState
|
|
2843
|
-
} : null
|
|
2844
|
-
};
|
|
2845
|
-
}
|
|
2846
|
-
function getStageEntry(row, stageKey) {
|
|
2847
|
-
const entry = valueAtPath(row.processingState, stageKey);
|
|
2848
|
-
return asRecord3(entry);
|
|
2849
|
-
}
|
|
2850
|
-
function getRecordStageStatus(row, stageKey) {
|
|
2851
|
-
const status = getStageEntry(row, stageKey).status;
|
|
2852
|
-
return typeof status === "string" ? status : "pending";
|
|
2853
|
-
}
|
|
2854
|
-
function getStageFailureReason(row, stageKey) {
|
|
2855
|
-
const data = asRecord3(getStageEntry(row, stageKey).data);
|
|
2856
|
-
const error = data.error ?? data.reason ?? data.failureReason ?? data.disqualifiedReason;
|
|
2857
|
-
return compactText(error);
|
|
2858
|
-
}
|
|
2859
|
-
function getRecordStatusColor(status) {
|
|
2860
|
-
switch (status) {
|
|
2861
|
-
case "success":
|
|
2862
|
-
return "green";
|
|
2863
|
-
case "error":
|
|
2864
|
-
case "failed":
|
|
2865
|
-
return "red";
|
|
2866
|
-
case "skipped":
|
|
2867
|
-
case "no_result":
|
|
2868
|
-
return "yellow";
|
|
2869
|
-
case "pending":
|
|
2870
|
-
return "gray";
|
|
2871
|
-
default:
|
|
2872
|
-
return "blue";
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
2875
|
-
function renderRecordValue(value, column) {
|
|
2876
|
-
if (value === null || value === void 0 || value === "") {
|
|
2877
|
-
return /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "-" });
|
|
2878
|
-
}
|
|
2879
|
-
switch (column.renderType) {
|
|
2880
|
-
case "badge":
|
|
2881
|
-
return /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: column.badgeColor ?? getRecordStatusColor(String(value)), children: compactText(value) });
|
|
2882
|
-
case "datetime":
|
|
2883
|
-
return compactText(typeof value === "string" ? formatDateTime4(value) : value);
|
|
2884
|
-
case "count":
|
|
2885
|
-
return Array.isArray(value) ? value.length : compactText(value);
|
|
2886
|
-
case "json":
|
|
2887
|
-
return /* @__PURE__ */ jsx(Text, { size: "xs", lineClamp: 2, children: compactText(value) });
|
|
2888
|
-
case "text":
|
|
2889
|
-
default:
|
|
2890
|
-
return /* @__PURE__ */ jsx(Text, { size: "sm", lineClamp: 2, children: compactText(value) });
|
|
2891
|
-
}
|
|
2892
|
-
}
|
|
2893
|
-
function getRunStatusColor(status) {
|
|
2894
|
-
switch (status) {
|
|
2895
|
-
case "completed":
|
|
2896
|
-
case "success":
|
|
2897
|
-
case "succeeded":
|
|
2898
|
-
return "green";
|
|
2899
|
-
case "running":
|
|
2900
|
-
case "pending":
|
|
2901
|
-
case "queued":
|
|
2902
|
-
return "blue";
|
|
2903
|
-
case "failed":
|
|
2904
|
-
case "error":
|
|
2905
|
-
case "cancelled":
|
|
2906
|
-
return "red";
|
|
2907
|
-
default:
|
|
2908
|
-
return "gray";
|
|
2909
|
-
}
|
|
2910
|
-
}
|
|
2911
|
-
function getRunInput(run) {
|
|
2912
|
-
const payload = asRecord3(run.payload);
|
|
2913
|
-
return run.input ?? run.inputs ?? payload.input ?? payload.inputs;
|
|
2914
|
-
}
|
|
2915
|
-
function hasRunInput(run) {
|
|
2916
|
-
const input = getRunInput(run);
|
|
2917
|
-
return input !== void 0 && input !== null;
|
|
2918
|
-
}
|
|
2919
|
-
function sanitizeStepInput(value, _actionKey) {
|
|
2920
|
-
return value;
|
|
2921
|
-
}
|
|
2922
|
-
function getDefaultStepInput(list, action) {
|
|
2923
|
-
return asRecord3(action?.defaultInput?.(list));
|
|
2924
|
-
}
|
|
2925
|
-
function getInitialStepInput(list, action) {
|
|
2926
|
-
return getDefaultStepInput(list, action);
|
|
2927
|
-
}
|
|
2928
|
-
function mergeStepRunInput(list, action, inputAtSubmit) {
|
|
2929
|
-
return {
|
|
2930
|
-
...getDefaultStepInput(list, action),
|
|
2931
|
-
...inputAtSubmit
|
|
2932
|
-
};
|
|
2933
|
-
}
|
|
2934
|
-
var EMPTY_SELECTION2 = {
|
|
2935
|
-
selectedCompanyIds: [],
|
|
2936
|
-
selectedContactIds: []
|
|
2937
|
-
};
|
|
2938
|
-
function getStageStatus(entry) {
|
|
2939
|
-
if (!entry || (entry.total ?? 0) === 0) return "not-started";
|
|
2940
|
-
if ((entry.error ?? 0) > 0) return "errors";
|
|
2941
|
-
if ((entry.attempted ?? 0) >= (entry.total ?? 0) && (entry.success ?? 0) > 0) return "complete";
|
|
2942
|
-
return "in-progress";
|
|
2943
|
-
}
|
|
2944
|
-
function getStageColors(status) {
|
|
2945
|
-
switch (status) {
|
|
2946
|
-
case "complete":
|
|
2947
|
-
return {
|
|
2948
|
-
bg: "var(--color-success)",
|
|
2949
|
-
fg: "white",
|
|
2950
|
-
border: "var(--color-success)",
|
|
2951
|
-
ring: "color-mix(in srgb, var(--color-success) 22%, transparent)"
|
|
2952
|
-
};
|
|
2953
|
-
case "errors":
|
|
2954
|
-
return {
|
|
2955
|
-
bg: "var(--color-error)",
|
|
2956
|
-
fg: "white",
|
|
2957
|
-
border: "var(--color-error)",
|
|
2958
|
-
ring: "color-mix(in srgb, var(--color-error) 22%, transparent)"
|
|
2959
|
-
};
|
|
2960
|
-
case "in-progress":
|
|
2961
|
-
return {
|
|
2962
|
-
bg: "var(--color-primary)",
|
|
2963
|
-
fg: "white",
|
|
2964
|
-
border: "var(--color-primary)",
|
|
2965
|
-
ring: "color-mix(in srgb, var(--color-primary) 22%, transparent)"
|
|
2966
|
-
};
|
|
2967
|
-
case "not-started":
|
|
2968
|
-
default:
|
|
2969
|
-
return {
|
|
2970
|
-
bg: "color-mix(in srgb, var(--color-primary) 28%, var(--mantine-color-body))",
|
|
2971
|
-
fg: "color-mix(in srgb, var(--color-primary) 55%, var(--color-text-dimmed))",
|
|
2972
|
-
border: "color-mix(in srgb, var(--color-primary) 45%, var(--color-border))",
|
|
2973
|
-
ring: "color-mix(in srgb, var(--color-primary) 10%, transparent)"
|
|
2974
|
-
};
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2977
|
-
var STAGE_NODE_WIDTH = 110;
|
|
2978
|
-
var STAGE_CIRCLE_SIZE = 36;
|
|
2979
|
-
function StageNode({
|
|
2980
|
-
index,
|
|
2981
|
-
stageKey,
|
|
2982
|
-
fallbackLabel,
|
|
2983
|
-
entry
|
|
2984
|
-
}) {
|
|
2985
|
-
const label = LEAD_GEN_STAGE_CATALOG[stageKey]?.label ?? fallbackLabel ?? stageKey;
|
|
2986
|
-
const status = getStageStatus(entry);
|
|
2987
|
-
const colors = getStageColors(status);
|
|
2988
|
-
const total = entry?.total ?? 0;
|
|
2989
|
-
const attempted = entry?.attempted ?? 0;
|
|
2990
|
-
const success = entry?.success ?? 0;
|
|
2991
|
-
const done = entry ? entry.success + entry.noResult + entry.skipped + entry.other : 0;
|
|
2992
|
-
const summary = entry ? status === "complete" ? `${done}/${total} done` : status === "errors" ? `${entry.error} failed` : `${attempted}/${total} started` : "Not started";
|
|
2993
|
-
const tooltipLines = entry ? [
|
|
2994
|
-
`${attempted} / ${total} attempted`,
|
|
2995
|
-
`${success} success`,
|
|
2996
|
-
(entry.noResult ?? 0) > 0 ? `${entry.noResult} no result` : null,
|
|
2997
|
-
(entry.skipped ?? 0) > 0 ? `${entry.skipped} skipped` : null,
|
|
2998
|
-
(entry.error ?? 0) > 0 ? `${entry.error} errors` : null,
|
|
2999
|
-
(entry.notAttempted ?? 0) > 0 ? `${entry.notAttempted} not attempted` : null
|
|
3000
|
-
].filter(Boolean) : ["Not started"];
|
|
3001
|
-
return /* @__PURE__ */ jsxs(
|
|
3002
|
-
Stack,
|
|
3003
|
-
{
|
|
3004
|
-
gap: 6,
|
|
3005
|
-
align: "center",
|
|
3006
|
-
style: {
|
|
3007
|
-
width: STAGE_NODE_WIDTH,
|
|
3008
|
-
flex: "0 0 auto",
|
|
3009
|
-
padding: "0 4px",
|
|
3010
|
-
position: "relative",
|
|
3011
|
-
zIndex: 1
|
|
3012
|
-
},
|
|
3013
|
-
children: [
|
|
3014
|
-
/* @__PURE__ */ jsx(Tooltip, { label: tooltipLines.join(" \xB7 "), position: "top", withArrow: true, multiline: true, maw: 260, children: /* @__PURE__ */ jsx(
|
|
3015
|
-
Box,
|
|
3016
|
-
{
|
|
3017
|
-
style: {
|
|
3018
|
-
width: STAGE_CIRCLE_SIZE,
|
|
3019
|
-
height: STAGE_CIRCLE_SIZE,
|
|
3020
|
-
borderRadius: "50%",
|
|
3021
|
-
backgroundColor: colors.bg,
|
|
3022
|
-
border: `1.5px solid ${colors.border}`,
|
|
3023
|
-
display: "flex",
|
|
3024
|
-
alignItems: "center",
|
|
3025
|
-
justifyContent: "center",
|
|
3026
|
-
boxShadow: `0 0 0 4px ${colors.ring}`,
|
|
3027
|
-
transition: "all var(--duration-normal) var(--easing)"
|
|
3028
|
-
},
|
|
3029
|
-
children: /* @__PURE__ */ jsx(Box, { style: { color: colors.fg, lineHeight: 1, display: "flex", alignItems: "center" }, children: status === "complete" ? "OK" : index + 1 })
|
|
3030
|
-
}
|
|
3031
|
-
) }),
|
|
3032
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 2, align: "center", style: { minWidth: 0, maxWidth: "100%" }, children: [
|
|
3033
|
-
/* @__PURE__ */ jsx(
|
|
3034
|
-
Text,
|
|
3035
|
-
{
|
|
3036
|
-
size: "xs",
|
|
3037
|
-
fw: status === "not-started" ? 500 : 600,
|
|
3038
|
-
ta: "center",
|
|
3039
|
-
lineClamp: 1,
|
|
3040
|
-
style: {
|
|
3041
|
-
maxWidth: "100%",
|
|
3042
|
-
color: status === "not-started" ? "var(--color-text-dimmed)" : "var(--color-text)",
|
|
3043
|
-
letterSpacing: 0.2
|
|
3044
|
-
},
|
|
3045
|
-
children: label
|
|
3046
|
-
}
|
|
3047
|
-
),
|
|
3048
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", style: { color: "var(--color-text-subtle)", fontVariantNumeric: "tabular-nums" }, children: summary })
|
|
3049
|
-
] })
|
|
3050
|
-
]
|
|
3051
|
-
}
|
|
3052
|
-
);
|
|
3053
|
-
}
|
|
3054
|
-
function PipelineStepper({
|
|
3055
|
-
plannedSteps,
|
|
3056
|
-
byStage,
|
|
3057
|
-
emptyText
|
|
3058
|
-
}) {
|
|
3059
|
-
const stageKeys = plannedSteps.length > 0 ? plannedSteps.map((s) => s.stageKey) : sortStageKeys(Object.keys(byStage));
|
|
3060
|
-
const labelByKey = new Map(plannedSteps.map((s) => [s.stageKey, s.label]));
|
|
3061
|
-
if (stageKeys.length === 0) {
|
|
3062
|
-
return /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: emptyText });
|
|
3063
|
-
}
|
|
3064
|
-
return /* @__PURE__ */ jsx(Box, { style: { overflowX: "auto", padding: "4px 0" }, children: /* @__PURE__ */ jsxs(
|
|
3065
|
-
Box,
|
|
3066
|
-
{
|
|
3067
|
-
style: {
|
|
3068
|
-
position: "relative",
|
|
3069
|
-
display: "flex",
|
|
3070
|
-
justifyContent: "space-between",
|
|
3071
|
-
alignItems: "flex-start",
|
|
3072
|
-
minWidth: stageKeys.length * STAGE_NODE_WIDTH
|
|
3073
|
-
},
|
|
3074
|
-
children: [
|
|
3075
|
-
/* @__PURE__ */ jsx(
|
|
3076
|
-
Box,
|
|
3077
|
-
{
|
|
3078
|
-
style: {
|
|
3079
|
-
position: "absolute",
|
|
3080
|
-
top: STAGE_CIRCLE_SIZE / 2 - 1,
|
|
3081
|
-
left: STAGE_NODE_WIDTH / 2,
|
|
3082
|
-
right: STAGE_NODE_WIDTH / 2,
|
|
3083
|
-
height: 2,
|
|
3084
|
-
backgroundColor: "var(--color-border)"
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3087
|
-
),
|
|
3088
|
-
stageKeys.map((key, index) => /* @__PURE__ */ jsx(StageNode, { index, stageKey: key, fallbackLabel: labelByKey.get(key), entry: byStage[key] }, key))
|
|
3089
|
-
]
|
|
3090
|
-
}
|
|
3091
|
-
) });
|
|
3092
|
-
}
|
|
3093
|
-
function PipelineStagesCard({ list, progress }) {
|
|
3094
|
-
const plannedSteps = resolveBuildPlanSteps(list);
|
|
3095
|
-
const templateLabel = list.metadata.buildPlanSnapshot?.templateLabel;
|
|
3096
|
-
const combinedByStage = { ...progress.byCompanyStage, ...progress.byContactStage };
|
|
3097
|
-
const hasAnyContent = plannedSteps.length > 0 || Object.keys(combinedByStage).length > 0;
|
|
3098
|
-
return /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
3099
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", children: [
|
|
3100
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
3101
|
-
/* @__PURE__ */ jsx(Title, { order: 5, children: "List Build Progress" }),
|
|
3102
|
-
templateLabel && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
3103
|
-
"Template: ",
|
|
3104
|
-
templateLabel
|
|
3105
|
-
] })
|
|
3106
|
-
] }),
|
|
3107
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
3108
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "filled", color: getStatusColor4(list.status), children: list.status }),
|
|
3109
|
-
list.launchedAt && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
3110
|
-
"Launched ",
|
|
3111
|
-
formatDateTime4(list.launchedAt)
|
|
3112
|
-
] }),
|
|
3113
|
-
list.completedAt && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
3114
|
-
"Completed ",
|
|
3115
|
-
formatDateTime4(list.completedAt)
|
|
3116
|
-
] })
|
|
3117
|
-
] })
|
|
3118
|
-
] }),
|
|
3119
|
-
!hasAnyContent ? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No pipeline stages configured yet \u2014 plan a build template to populate this list." }) : /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
|
|
3120
|
-
/* @__PURE__ */ jsxs(Text, { size: "sm", fw: 600, children: [
|
|
3121
|
-
"Pipeline (",
|
|
3122
|
-
progress.totalCompanies,
|
|
3123
|
-
" companies \xB7 ",
|
|
3124
|
-
progress.totalMembers,
|
|
3125
|
-
" contacts)"
|
|
3126
|
-
] }),
|
|
3127
|
-
/* @__PURE__ */ jsx(
|
|
3128
|
-
PipelineStepper,
|
|
3129
|
-
{
|
|
3130
|
-
plannedSteps,
|
|
3131
|
-
byStage: combinedByStage,
|
|
3132
|
-
emptyText: "No pipeline activity recorded yet."
|
|
3133
|
-
}
|
|
3134
|
-
)
|
|
3135
|
-
] })
|
|
3136
|
-
] }) });
|
|
3137
|
-
}
|
|
3138
|
-
function ListConfigCard({ list }) {
|
|
3139
|
-
const icp = list.icp ?? {};
|
|
3140
|
-
const scraping = list.scrapingConfig ?? {};
|
|
3141
|
-
const hasIcp = Object.values(icp).some((v) => v !== void 0 && v !== null && v !== "");
|
|
3142
|
-
const hasScraping = Object.values(scraping).some((v) => v !== void 0 && v !== null && v !== "");
|
|
3143
|
-
if (!hasIcp && !hasScraping) {
|
|
3144
|
-
return /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
|
|
3145
|
-
/* @__PURE__ */ jsx(Title, { order: 5, children: "List Config" }),
|
|
3146
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No ICP rubric or scraping criteria recorded for this list." })
|
|
3147
|
-
] }) });
|
|
3148
|
-
}
|
|
3149
|
-
return /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
3150
|
-
/* @__PURE__ */ jsx(Title, { order: 5, children: "List Config" }),
|
|
3151
|
-
(hasIcp || hasScraping) && /* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 1, md: 2 }, spacing: "md", children: [
|
|
3152
|
-
hasIcp && /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
|
|
3153
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, children: "ICP Rubric" }),
|
|
3154
|
-
icp.qualificationRubricKey && /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
3155
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Rubric Key" }),
|
|
3156
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", children: icp.qualificationRubricKey })
|
|
3157
|
-
] }),
|
|
3158
|
-
icp.targetDescription && /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
3159
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Target" }),
|
|
3160
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", children: icp.targetDescription })
|
|
3161
|
-
] }),
|
|
3162
|
-
(icp.minReviewCount !== void 0 || icp.minRating !== void 0) && /* @__PURE__ */ jsxs(Group, { gap: "md", children: [
|
|
3163
|
-
icp.minReviewCount !== void 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
3164
|
-
"Min reviews:",
|
|
3165
|
-
" ",
|
|
3166
|
-
/* @__PURE__ */ jsx(Text, { span: true, size: "xs", c: "bright", children: icp.minReviewCount })
|
|
3167
|
-
] }),
|
|
3168
|
-
icp.minRating !== void 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
3169
|
-
"Min rating:",
|
|
3170
|
-
" ",
|
|
3171
|
-
/* @__PURE__ */ jsx(Text, { span: true, size: "xs", c: "bright", children: icp.minRating })
|
|
3172
|
-
] })
|
|
3173
|
-
] }),
|
|
3174
|
-
icp.excludeFranchises !== void 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
3175
|
-
"Exclude franchises:",
|
|
3176
|
-
" ",
|
|
3177
|
-
/* @__PURE__ */ jsx(Text, { span: true, size: "xs", c: "bright", children: String(icp.excludeFranchises) })
|
|
3178
|
-
] }),
|
|
3179
|
-
icp.customRules && /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
3180
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Custom rules" }),
|
|
3181
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", children: icp.customRules })
|
|
3182
|
-
] })
|
|
3183
|
-
] }),
|
|
3184
|
-
hasScraping && /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
|
|
3185
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, children: "Scraping Criteria" }),
|
|
3186
|
-
scraping.vertical && /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
3187
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Vertical" }),
|
|
3188
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", children: scraping.vertical })
|
|
3189
|
-
] }),
|
|
3190
|
-
scraping.geography && /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
3191
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Geography" }),
|
|
3192
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", children: scraping.geography })
|
|
3193
|
-
] }),
|
|
3194
|
-
scraping.size && /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
3195
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Size" }),
|
|
3196
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", children: scraping.size })
|
|
3197
|
-
] }),
|
|
3198
|
-
scraping.apifyInput && Object.keys(scraping.apifyInput).length > 0 && /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
3199
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Apify input" }),
|
|
3200
|
-
/* @__PURE__ */ jsx(JsonViewer, { data: scraping.apifyInput, maxHeight: 160, fontSize: "0.75rem" })
|
|
3201
|
-
] })
|
|
3202
|
-
] })
|
|
3203
|
-
] })
|
|
3204
|
-
] }) });
|
|
3205
|
-
}
|
|
3206
|
-
function OverviewTab({ list, progress }) {
|
|
3207
|
-
const hasMetadata = list.metadata && Object.keys(list.metadata).length > 0;
|
|
3208
|
-
return /* @__PURE__ */ jsxs(
|
|
3209
|
-
TabSection,
|
|
3210
|
-
{
|
|
3211
|
-
icon: /* @__PURE__ */ jsx(IconBuilding, { size: 16 }),
|
|
3212
|
-
title: "Overview",
|
|
3213
|
-
description: "Build status and source details for this list.",
|
|
3214
|
-
children: [
|
|
3215
|
-
/* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 1, sm: 2 }, children: [
|
|
3216
|
-
/* @__PURE__ */ jsx(StatCard, { label: "Companies", value: progress.totalCompanies, icon: IconBuilding }),
|
|
3217
|
-
/* @__PURE__ */ jsx(StatCard, { label: "Members", value: progress.totalMembers, icon: IconUsers })
|
|
3218
|
-
] }),
|
|
3219
|
-
/* @__PURE__ */ jsx(PipelineStagesCard, { list, progress }),
|
|
3220
|
-
/* @__PURE__ */ jsx(ListConfigCard, { list }),
|
|
3221
|
-
hasMetadata && /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
|
|
3222
|
-
/* @__PURE__ */ jsx(Title, { order: 5, children: "Metadata" }),
|
|
3223
|
-
/* @__PURE__ */ jsx(JsonViewer, { data: list.metadata, maxHeight: 320 })
|
|
3224
|
-
] }) })
|
|
3225
|
-
]
|
|
3226
|
-
}
|
|
3227
|
-
);
|
|
3228
|
-
}
|
|
3229
|
-
function getBuildToneStyle(tone) {
|
|
3230
|
-
switch (tone) {
|
|
3231
|
-
case "complete":
|
|
3232
|
-
return {
|
|
3233
|
-
backgroundColor: "color-mix(in srgb, var(--color-success) 16%, transparent)",
|
|
3234
|
-
borderColor: "color-mix(in srgb, var(--color-success) 34%, var(--color-border))",
|
|
3235
|
-
color: "var(--color-success)"
|
|
3236
|
-
};
|
|
3237
|
-
case "failed":
|
|
3238
|
-
return {
|
|
3239
|
-
backgroundColor: "color-mix(in srgb, var(--color-error) 14%, transparent)",
|
|
3240
|
-
borderColor: "color-mix(in srgb, var(--color-error) 38%, var(--color-border))",
|
|
3241
|
-
color: "var(--color-error)"
|
|
3242
|
-
};
|
|
3243
|
-
case "ready":
|
|
3244
|
-
return {
|
|
3245
|
-
backgroundColor: "color-mix(in srgb, var(--color-primary) 14%, transparent)",
|
|
3246
|
-
borderColor: "var(--border-primary-muted)",
|
|
3247
|
-
color: "var(--color-primary)"
|
|
3248
|
-
};
|
|
3249
|
-
case "blocked":
|
|
3250
|
-
case "neutral":
|
|
3251
|
-
default:
|
|
3252
|
-
return {
|
|
3253
|
-
backgroundColor: "color-mix(in srgb, var(--color-surface-hover) 70%, transparent)",
|
|
3254
|
-
borderColor: "var(--color-border)",
|
|
3255
|
-
color: "var(--color-text-dimmed)"
|
|
3256
|
-
};
|
|
3257
|
-
}
|
|
3258
|
-
}
|
|
3259
|
-
function StatusPill({ label, tone }) {
|
|
3260
|
-
return /* @__PURE__ */ jsx(
|
|
3261
|
-
Box,
|
|
3262
|
-
{
|
|
3263
|
-
component: "span",
|
|
3264
|
-
px: 8,
|
|
3265
|
-
py: 3,
|
|
3266
|
-
style: {
|
|
3267
|
-
...getBuildToneStyle(tone),
|
|
3268
|
-
borderRadius: 999,
|
|
3269
|
-
borderStyle: "solid",
|
|
3270
|
-
borderWidth: 1,
|
|
3271
|
-
display: "inline-flex",
|
|
3272
|
-
fontSize: 11,
|
|
3273
|
-
fontWeight: 700,
|
|
3274
|
-
lineHeight: 1,
|
|
3275
|
-
whiteSpace: "nowrap"
|
|
3276
|
-
},
|
|
3277
|
-
children: label
|
|
3278
|
-
}
|
|
3279
|
-
);
|
|
3280
|
-
}
|
|
3281
|
-
function StepCounterLine({ step }) {
|
|
3282
|
-
const items = [
|
|
3283
|
-
step.ready > 0 ? { label: "ready", value: step.ready, color: "var(--color-primary)" } : null,
|
|
3284
|
-
step.complete > 0 ? { label: "done", value: step.complete, color: "var(--color-success)" } : null,
|
|
3285
|
-
step.failed > 0 ? { label: "failed", value: step.failed, color: "var(--color-error)" } : null,
|
|
3286
|
-
step.blocked > 0 ? { label: "waiting", value: step.blocked, color: "var(--color-text-dimmed)" } : null
|
|
3287
|
-
].filter((item) => item !== null);
|
|
3288
|
-
if (!items.length) {
|
|
3289
|
-
return /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "No records yet" });
|
|
3290
|
-
}
|
|
3291
|
-
return /* @__PURE__ */ jsx(Group, { gap: "md", wrap: "nowrap", children: items.map((item) => /* @__PURE__ */ jsxs(Text, { size: "xs", fw: 700, style: { color: item.color }, children: [
|
|
3292
|
-
item.value,
|
|
3293
|
-
" ",
|
|
3294
|
-
item.label
|
|
3295
|
-
] }, item.label)) });
|
|
3296
|
-
}
|
|
3297
|
-
function BuildStepProgressBar({ step }) {
|
|
3298
|
-
const segments = [
|
|
3299
|
-
{ key: "complete", value: step.complete, color: "var(--color-success)" },
|
|
3300
|
-
{ key: "ready", value: step.ready, color: "var(--color-primary)" },
|
|
3301
|
-
{ key: "failed", value: step.failed, color: "var(--color-error)" },
|
|
3302
|
-
{ key: "blocked", value: step.blocked, color: "var(--color-border)" }
|
|
3303
|
-
].filter((segment) => segment.value > 0);
|
|
3304
|
-
const total = segments.reduce((sum, segment) => sum + segment.value, 0);
|
|
3305
|
-
return /* @__PURE__ */ jsx(
|
|
3306
|
-
Box,
|
|
3307
|
-
{
|
|
3308
|
-
h: 8,
|
|
3309
|
-
"aria-label": `${step.label} progress: ${step.complete} complete, ${step.ready} ready, ${step.failed} failed, ${step.blocked} blocked`,
|
|
3310
|
-
style: {
|
|
3311
|
-
backgroundColor: "color-mix(in srgb, var(--color-border) 65%, transparent)",
|
|
3312
|
-
borderRadius: 999,
|
|
3313
|
-
display: "flex",
|
|
3314
|
-
overflow: "hidden"
|
|
3315
|
-
},
|
|
3316
|
-
children: segments.map((segment) => /* @__PURE__ */ jsx(Box, { h: "100%", w: `${total > 0 ? segment.value / total * 100 : 0}%`, bg: segment.color }, segment.key))
|
|
3317
|
-
}
|
|
3318
|
-
);
|
|
3319
|
-
}
|
|
3320
|
-
function getDisplayStep(steps, recommendedStep) {
|
|
3321
|
-
return recommendedStep ?? steps.find((step) => step.status !== "complete") ?? steps[steps.length - 1] ?? null;
|
|
3322
|
-
}
|
|
3323
|
-
function getBuildTabDescription(steps, currentStep) {
|
|
3324
|
-
if (!steps.length) return "No build steps are available for this list.";
|
|
3325
|
-
if (steps.every((step) => step.status === "complete")) return "List build complete.";
|
|
3326
|
-
if (!currentStep) return "No build steps need attention right now.";
|
|
3327
|
-
if (currentStep.status === "ready") return `${currentStep.label} is ready to run.`;
|
|
3328
|
-
if (currentStep.status === "failed") return `${currentStep.label} needs attention.`;
|
|
3329
|
-
return `${currentStep.label} is waiting on earlier work.`;
|
|
3330
|
-
}
|
|
3331
|
-
var RECORDS_PAGE_SIZE = 25;
|
|
3332
|
-
var EXPORT_WORKFLOW_ID = "lgn-06-export-list-workflow";
|
|
3333
|
-
function setValueAtInputPath(source, path, value) {
|
|
3334
|
-
const segments = path.split(".").filter(Boolean);
|
|
3335
|
-
if (!segments.length) return source;
|
|
3336
|
-
const next = { ...source };
|
|
3337
|
-
let cursor = next;
|
|
3338
|
-
segments.forEach((segment, index) => {
|
|
3339
|
-
if (index === segments.length - 1) {
|
|
3340
|
-
cursor[segment] = value;
|
|
3341
|
-
return;
|
|
3342
|
-
}
|
|
3343
|
-
const current = cursor[segment];
|
|
3344
|
-
const child = current && typeof current === "object" && !Array.isArray(current) ? { ...current } : {};
|
|
3345
|
-
cursor[segment] = child;
|
|
3346
|
-
cursor = child;
|
|
3347
|
-
});
|
|
3348
|
-
return next;
|
|
3349
|
-
}
|
|
3350
|
-
function credentialMatchesRequirement(credential, requirement) {
|
|
3351
|
-
const provider = requirement.provider.toLowerCase();
|
|
3352
|
-
const credentialProvider = credential.provider?.toLowerCase() ?? "";
|
|
3353
|
-
const credentialType = credential.type.toLowerCase();
|
|
3354
|
-
const credentialName = credential.name.toLowerCase();
|
|
3355
|
-
if (credentialProvider === provider || credentialType === provider || credentialName.startsWith(`${provider}-`) || credentialName.includes(`-${provider}`) || credentialName.includes(`${provider}-`)) {
|
|
3356
|
-
return true;
|
|
3357
|
-
}
|
|
3358
|
-
return credentialType === requirement.credentialType;
|
|
3359
|
-
}
|
|
3360
|
-
function getMatchingCredentials(credentials, requirement) {
|
|
3361
|
-
return credentials.filter((credential) => credentialMatchesRequirement(credential, requirement));
|
|
3362
|
-
}
|
|
3363
|
-
function getSelectedCredential(credentials, selections, requirement) {
|
|
3364
|
-
const selectedId = selections[requirement.key];
|
|
3365
|
-
return credentials.find((credential) => credential.id === selectedId) ?? null;
|
|
3366
|
-
}
|
|
3367
|
-
function getClickUpRequirement(step) {
|
|
3368
|
-
return step.credentialRequirements?.find((requirement) => requirement.provider === "clickup") ?? null;
|
|
3369
|
-
}
|
|
3370
|
-
function filterCredentialRequirementFields(layout, requirements) {
|
|
3371
|
-
if (!layout || requirements.length === 0) return layout;
|
|
3372
|
-
const credentialInputPaths = new Set(requirements.map((requirement) => requirement.inputPath).filter(Boolean));
|
|
3373
|
-
if (!credentialInputPaths.size) return layout;
|
|
3374
|
-
const filterSection = (section) => {
|
|
3375
|
-
const fields = section.fields.filter((field) => !credentialInputPaths.has(field.path));
|
|
3376
|
-
return fields.length > 0 ? { ...section, fields } : null;
|
|
3377
|
-
};
|
|
3378
|
-
return {
|
|
3379
|
-
...layout,
|
|
3380
|
-
sections: layout.sections.map(filterSection).filter((section) => section !== null),
|
|
3381
|
-
advanced: layout.advanced ? filterSection(layout.advanced) ?? void 0 : void 0
|
|
3382
|
-
};
|
|
3383
|
-
}
|
|
3384
|
-
function hasMainConfigFields(layout) {
|
|
3385
|
-
return Boolean(layout?.sections.some((section) => section.fields.length > 0));
|
|
3386
|
-
}
|
|
3387
|
-
function hasAdvancedConfigFields(layout) {
|
|
3388
|
-
return Boolean(layout?.advanced?.fields.length);
|
|
3389
|
-
}
|
|
3390
|
-
function formatCredentialVerificationDetails(details) {
|
|
3391
|
-
if (!details) return null;
|
|
3392
|
-
const entries = Object.entries(details).filter(([, value]) => value !== null && value !== void 0 && value !== "").slice(0, 4);
|
|
3393
|
-
if (!entries.length) return null;
|
|
3394
|
-
return entries.map(([key, value]) => `${key}: ${compactText(value)}`).join(" | ");
|
|
3395
|
-
}
|
|
3396
|
-
function CredentialRequirementsPanel({
|
|
3397
|
-
requirements,
|
|
3398
|
-
credentials,
|
|
3399
|
-
credentialsLoading,
|
|
3400
|
-
selections,
|
|
3401
|
-
verificationByCredentialId,
|
|
3402
|
-
verifyingCredentialId,
|
|
3403
|
-
onSelect,
|
|
3404
|
-
onVerify
|
|
3405
|
-
}) {
|
|
3406
|
-
if (!requirements.length) return null;
|
|
3407
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
|
|
3408
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 700, tt: "uppercase", children: "Credentials" }),
|
|
3409
|
-
requirements.map((requirement) => {
|
|
3410
|
-
const matchingCredentials = getMatchingCredentials(credentials, requirement);
|
|
3411
|
-
const selectedCredential = getSelectedCredential(credentials, selections, requirement);
|
|
3412
|
-
const verification = selectedCredential ? verificationByCredentialId[selectedCredential.id] : null;
|
|
3413
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
|
|
3414
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", align: "flex-end", wrap: "nowrap", children: [
|
|
3415
|
-
/* @__PURE__ */ jsx(
|
|
3416
|
-
Select,
|
|
3417
|
-
{
|
|
3418
|
-
label: requirement.label,
|
|
3419
|
-
description: `${requirement.provider} credential for ${requirement.inputPath}`,
|
|
3420
|
-
placeholder: credentialsLoading ? "Loading credentials..." : "Select credential",
|
|
3421
|
-
data: matchingCredentials.map((credential) => ({
|
|
3422
|
-
value: credential.id,
|
|
3423
|
-
label: `${credential.name} (${credential.provider ?? credential.type})`
|
|
3424
|
-
})),
|
|
3425
|
-
value: selectedCredential?.id ?? null,
|
|
3426
|
-
onChange: (credentialId) => {
|
|
3427
|
-
onSelect(requirement, credentials.find((credential) => credential.id === credentialId) ?? null);
|
|
3428
|
-
},
|
|
3429
|
-
required: requirement.required,
|
|
3430
|
-
disabled: credentialsLoading || matchingCredentials.length === 0,
|
|
3431
|
-
style: { flex: 1 }
|
|
3432
|
-
}
|
|
3433
|
-
),
|
|
3434
|
-
/* @__PURE__ */ jsx(
|
|
3435
|
-
Button,
|
|
3436
|
-
{
|
|
3437
|
-
size: "xs",
|
|
3438
|
-
variant: "light",
|
|
3439
|
-
disabled: !selectedCredential,
|
|
3440
|
-
loading: selectedCredential ? verifyingCredentialId === selectedCredential.id : false,
|
|
3441
|
-
onClick: () => selectedCredential && onVerify(selectedCredential),
|
|
3442
|
-
children: "Test credential"
|
|
3443
|
-
}
|
|
3444
|
-
)
|
|
3445
|
-
] }),
|
|
3446
|
-
matchingCredentials.length === 0 ? /* @__PURE__ */ jsx(
|
|
3447
|
-
Alert,
|
|
3448
|
-
{
|
|
3449
|
-
color: requirement.required ? "yellow" : "gray",
|
|
3450
|
-
variant: "light",
|
|
3451
|
-
icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }),
|
|
3452
|
-
children: /* @__PURE__ */ jsxs(Text, { size: "sm", children: [
|
|
3453
|
-
"No matching ",
|
|
3454
|
-
requirement.provider,
|
|
3455
|
-
" credentials found. Add one in",
|
|
3456
|
-
" ",
|
|
3457
|
-
/* @__PURE__ */ jsx(Text, { component: "a", href: "/settings/credentials", size: "sm", fw: 600, children: "Settings -> Credentials" }),
|
|
3458
|
-
"."
|
|
3459
|
-
] })
|
|
3460
|
-
}
|
|
3461
|
-
) : null,
|
|
3462
|
-
verification ? /* @__PURE__ */ jsx(
|
|
3463
|
-
Alert,
|
|
3464
|
-
{
|
|
3465
|
-
color: verification.status === "success" ? "green" : "red",
|
|
3466
|
-
variant: "light",
|
|
3467
|
-
icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }),
|
|
3468
|
-
children: /* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
3469
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", children: verification.message }),
|
|
3470
|
-
verification.checkedAt ? /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
3471
|
-
"Checked ",
|
|
3472
|
-
formatDateTime4(verification.checkedAt)
|
|
3473
|
-
] }) : null,
|
|
3474
|
-
formatCredentialVerificationDetails(verification.details) ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatCredentialVerificationDetails(verification.details) }) : null
|
|
3475
|
-
] })
|
|
3476
|
-
}
|
|
3477
|
-
) : null
|
|
3478
|
-
] }, requirement.key);
|
|
3479
|
-
})
|
|
3480
|
-
] });
|
|
3481
|
-
}
|
|
3482
|
-
function BuildStepRunningWatcher({
|
|
3483
|
-
resourceId,
|
|
3484
|
-
onRunningChange
|
|
3485
|
-
}) {
|
|
3486
|
-
const inFlightQuery = useInFlightExecutions(resourceId, {
|
|
3487
|
-
enabled: Boolean(resourceId),
|
|
3488
|
-
limit: 5,
|
|
3489
|
-
refetchInterval: 2e3
|
|
3490
|
-
});
|
|
3491
|
-
const isRunning = (inFlightQuery.data?.executions.length ?? 0) > 0;
|
|
3492
|
-
useEffect(() => {
|
|
3493
|
-
onRunningChange(resourceId, isRunning);
|
|
3494
|
-
return () => onRunningChange(resourceId, false);
|
|
3495
|
-
}, [isRunning, onRunningChange, resourceId]);
|
|
3496
|
-
return null;
|
|
3497
|
-
}
|
|
3498
|
-
function StepRecordsPanel({
|
|
3499
|
-
list,
|
|
3500
|
-
step,
|
|
3501
|
-
credentialSelections,
|
|
3502
|
-
credentials,
|
|
3503
|
-
clickupListId
|
|
3504
|
-
}) {
|
|
3505
|
-
const queryClient = useQueryClient();
|
|
3506
|
-
const [page, setPage] = useState(1);
|
|
3507
|
-
const [approvalByCompanyId, setApprovalByCompanyId] = useState({});
|
|
3508
|
-
const navigate = useNavigate();
|
|
3509
|
-
const recordsStageKey = step.recordSourceStageKey ?? step.recordsStageKey ?? step.stageKey;
|
|
3510
|
-
const recordsEntity = step.recordEntity ?? step.primaryEntity;
|
|
3511
|
-
const columns = step.recordColumns?.[recordsEntity] ?? [];
|
|
3512
|
-
const recordsQuery = useListRecords(list.id, {
|
|
3513
|
-
entity: recordsEntity,
|
|
3514
|
-
stage: recordsStageKey,
|
|
3515
|
-
limit: RECORDS_PAGE_SIZE,
|
|
3516
|
-
offset: (page - 1) * RECORDS_PAGE_SIZE
|
|
3517
|
-
});
|
|
3518
|
-
const exportWorkflowId = step.action?.resourceId ?? EXPORT_WORKFLOW_ID;
|
|
3519
|
-
const exportExecution = useWorkflowExecution({
|
|
3520
|
-
workflowId: exportWorkflowId,
|
|
3521
|
-
listId: list.id
|
|
3522
|
-
});
|
|
3523
|
-
useEffect(() => {
|
|
3524
|
-
setPage(1);
|
|
3525
|
-
setApprovalByCompanyId({});
|
|
3526
|
-
}, [step.id]);
|
|
3527
|
-
const rows = recordsQuery.data?.data ?? [];
|
|
3528
|
-
const total = recordsQuery.data?.total ?? 0;
|
|
3529
|
-
const totalPages = Math.max(1, Math.ceil(total / RECORDS_PAGE_SIZE));
|
|
3530
|
-
const isReviewExportStep = step.primaryEntity === "company" && (step.actionKey === "lead-gen.export.list" || exportWorkflowId === EXPORT_WORKFLOW_ID);
|
|
3531
|
-
const approvedCompanyIds = Object.entries(approvalByCompanyId).filter(([, status]) => status === "approved").map(([companyId]) => companyId);
|
|
3532
|
-
const rejectedCompanyIds = Object.entries(approvalByCompanyId).filter(([, status]) => status === "rejected").map(([companyId]) => companyId);
|
|
3533
|
-
const clickupRequirement = getClickUpRequirement(step);
|
|
3534
|
-
const clickupCredential = clickupRequirement ? getSelectedCredential(credentials, credentialSelections, clickupRequirement) : null;
|
|
3535
|
-
const isClickUpExportPath = isReviewExportStep && Boolean(clickupRequirement);
|
|
3536
|
-
const normalizedClickupListId = clickupListId.trim();
|
|
3537
|
-
const canExport = approvedCompanyIds.length > 0 && (!isClickUpExportPath || Boolean(clickupCredential) && normalizedClickupListId.length > 0);
|
|
3538
|
-
const exportDisabledReason = approvedCompanyIds.length === 0 ? "Approve at least one company before export." : isClickUpExportPath && !clickupCredential ? "Select a ClickUp credential in Configuration." : isClickUpExportPath && !normalizedClickupListId ? "Enter a ClickUp List ID in Configuration." : null;
|
|
3539
|
-
const setApproval = (companyId, status) => {
|
|
3540
|
-
setApprovalByCompanyId((current) => ({ ...current, [companyId]: status }));
|
|
3541
|
-
};
|
|
3542
|
-
const openRecordDetail = (row) => {
|
|
3543
|
-
if (row.entity === "company") {
|
|
3544
|
-
void navigate({ to: "/crm/companies/$companyId", params: { companyId: row.companyId } });
|
|
3545
|
-
return;
|
|
3546
|
-
}
|
|
3547
|
-
void navigate({ to: "/crm/contacts/$contactId", params: { contactId: row.contactId } });
|
|
3548
|
-
};
|
|
3549
|
-
const exportApproved = async () => {
|
|
3550
|
-
try {
|
|
3551
|
-
const result = await exportExecution.execute({
|
|
3552
|
-
input: {
|
|
3553
|
-
listId: list.id,
|
|
3554
|
-
mode: "export",
|
|
3555
|
-
approved: true,
|
|
3556
|
-
...isClickUpExportPath ? {
|
|
3557
|
-
destination: "clickup",
|
|
3558
|
-
clickupCredential: clickupCredential?.name,
|
|
3559
|
-
clickupListId: normalizedClickupListId
|
|
3560
|
-
} : {},
|
|
3561
|
-
approvedCompanyIds,
|
|
3562
|
-
rejectedCompanyIds
|
|
3563
|
-
}
|
|
3564
|
-
});
|
|
3565
|
-
showSuccessNotification(`Export workflow run started: ${result.executionId}`);
|
|
3566
|
-
await queryClient.invalidateQueries({ queryKey: acquisitionListKeys.all });
|
|
3567
|
-
} catch (error) {
|
|
3568
|
-
showApiErrorNotification(error);
|
|
3569
|
-
}
|
|
3570
|
-
};
|
|
3571
|
-
if (!columns.length) {
|
|
3572
|
-
return /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "No record columns are configured for this step." });
|
|
3573
|
-
}
|
|
3574
|
-
if (recordsQuery.isLoading) {
|
|
3575
|
-
return /* @__PURE__ */ jsx(Center, { p: "md", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) });
|
|
3576
|
-
}
|
|
3577
|
-
if (recordsQuery.error) {
|
|
3578
|
-
return /* @__PURE__ */ jsx(CenteredErrorState, { error: recordsQuery.error, title: "Failed to load records" });
|
|
3579
|
-
}
|
|
3580
|
-
if (!rows.length) {
|
|
3581
|
-
return /* @__PURE__ */ jsx(Stack, { gap: "xs", children: /* @__PURE__ */ jsxs(Text, { size: "sm", c: "dimmed", children: [
|
|
3582
|
-
"No records found for ",
|
|
3583
|
-
LEAD_GEN_STAGE_CATALOG[recordsStageKey]?.label ?? recordsStageKey,
|
|
3584
|
-
"."
|
|
3585
|
-
] }) });
|
|
3586
|
-
}
|
|
3587
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
3588
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "xs", children: [
|
|
3589
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 2, children: [
|
|
3590
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 700, tt: "uppercase", children: "Records" }),
|
|
3591
|
-
/* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
3592
|
-
total,
|
|
3593
|
-
" ",
|
|
3594
|
-
recordsEntity,
|
|
3595
|
-
" records from ",
|
|
3596
|
-
LEAD_GEN_STAGE_CATALOG[recordsStageKey]?.label ?? recordsStageKey
|
|
3597
|
-
] })
|
|
3598
|
-
] }),
|
|
3599
|
-
recordsQuery.isFetching ? /* @__PURE__ */ jsx(Loader, { size: "xs" }) : null
|
|
3600
|
-
] }),
|
|
3601
|
-
/* @__PURE__ */ jsx(Box, { style: { overflowX: "auto" }, children: /* @__PURE__ */ jsxs(Table, { highlightOnHover: true, children: [
|
|
3602
|
-
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
3603
|
-
columns.map((column) => /* @__PURE__ */ jsx(Table.Th, { style: column.width ? { width: column.width } : void 0, children: column.label }, column.key)),
|
|
3604
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Status" }),
|
|
3605
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Failure reason" }),
|
|
3606
|
-
isReviewExportStep ? /* @__PURE__ */ jsx(Table.Th, { children: "Approval" }) : null
|
|
3607
|
-
] }) }),
|
|
3608
|
-
/* @__PURE__ */ jsx(Table.Tbody, { children: rows.map((row) => {
|
|
3609
|
-
const columnSource = getRecordColumnSource(row);
|
|
3610
|
-
const status = getRecordStageStatus(row, recordsStageKey);
|
|
3611
|
-
const companyId = row.entity === "company" ? row.companyId : null;
|
|
3612
|
-
return /* @__PURE__ */ jsxs(Table.Tr, { onClick: () => openRecordDetail(row), style: { cursor: "pointer" }, children: [
|
|
3613
|
-
columns.map((column) => /* @__PURE__ */ jsx(Table.Td, { children: renderRecordValue(valueAtPath(columnSource, column.path), column) }, column.key)),
|
|
3614
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: getRecordStatusColor(status), children: status }) }),
|
|
3615
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", lineClamp: 2, children: getStageFailureReason(row, recordsStageKey) }) }),
|
|
3616
|
-
isReviewExportStep ? /* @__PURE__ */ jsx(Table.Td, { children: companyId ? /* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", "aria-label": `Approval for ${getRecordDisplayName(row)}`, children: [
|
|
3617
|
-
/* @__PURE__ */ jsx(
|
|
3618
|
-
Button,
|
|
3619
|
-
{
|
|
3620
|
-
size: "compact-xs",
|
|
3621
|
-
variant: approvalByCompanyId[companyId] === "approved" ? "filled" : "light",
|
|
3622
|
-
color: "green",
|
|
3623
|
-
onClick: (event) => {
|
|
3624
|
-
event.stopPropagation();
|
|
3625
|
-
setApproval(companyId, "approved");
|
|
3626
|
-
},
|
|
3627
|
-
children: "Approve"
|
|
3628
|
-
}
|
|
3629
|
-
),
|
|
3630
|
-
/* @__PURE__ */ jsx(
|
|
3631
|
-
Button,
|
|
3632
|
-
{
|
|
3633
|
-
size: "compact-xs",
|
|
3634
|
-
variant: approvalByCompanyId[companyId] === "rejected" ? "filled" : "light",
|
|
3635
|
-
color: "red",
|
|
3636
|
-
onClick: (event) => {
|
|
3637
|
-
event.stopPropagation();
|
|
3638
|
-
setApproval(companyId, "rejected");
|
|
3639
|
-
},
|
|
3640
|
-
children: "Reject"
|
|
3641
|
-
}
|
|
3642
|
-
)
|
|
3643
|
-
] }) : /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "-" }) }) : null
|
|
3644
|
-
] }, row.id);
|
|
3645
|
-
}) })
|
|
3646
|
-
] }) }),
|
|
3647
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "xs", children: [
|
|
3648
|
-
/* @__PURE__ */ jsx(Pagination, { size: "sm", total: totalPages, value: page, onChange: setPage, disabled: recordsQuery.isFetching }),
|
|
3649
|
-
isReviewExportStep ? /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
3650
|
-
/* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
3651
|
-
approvedCompanyIds.length,
|
|
3652
|
-
" approved, ",
|
|
3653
|
-
rejectedCompanyIds.length,
|
|
3654
|
-
" rejected"
|
|
3655
|
-
] }),
|
|
3656
|
-
exportDisabledReason ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: exportDisabledReason }) : null,
|
|
3657
|
-
/* @__PURE__ */ jsx(
|
|
3658
|
-
Button,
|
|
3659
|
-
{
|
|
3660
|
-
size: "xs",
|
|
3661
|
-
leftSection: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 14 }),
|
|
3662
|
-
loading: exportExecution.isPending,
|
|
3663
|
-
disabled: !canExport,
|
|
3664
|
-
onClick: () => void exportApproved(),
|
|
3665
|
-
children: isClickUpExportPath ? "Export to ClickUp" : "Export approved"
|
|
3666
|
-
}
|
|
3667
|
-
)
|
|
3668
|
-
] }) : null
|
|
3669
|
-
] })
|
|
3670
|
-
] });
|
|
3671
|
-
}
|
|
3672
|
-
function BuildTab({
|
|
3673
|
-
list,
|
|
3674
|
-
steps,
|
|
3675
|
-
recommendedStep,
|
|
3676
|
-
onRunStep,
|
|
3677
|
-
onRetryStep,
|
|
3678
|
-
onViewRunLog
|
|
3679
|
-
}) {
|
|
3680
|
-
const [selectedStepId, setSelectedStepId] = useState(null);
|
|
3681
|
-
const [stepInputFormState, setStepInputFormState] = useState({});
|
|
3682
|
-
const [stepInputError, setStepInputError] = useState(null);
|
|
3683
|
-
const [stepInputInitialized, setStepInputInitialized] = useState(false);
|
|
3684
|
-
const [activeRightColumnTab, setActiveRightColumnTab] = useState("configuration");
|
|
3685
|
-
const [credentialSelections, setCredentialSelections] = useState({});
|
|
3686
|
-
const [credentialVerificationById, setCredentialVerificationById] = useState({});
|
|
3687
|
-
const [clickupListId, setClickupListId] = useState("");
|
|
3688
|
-
const [runningResources, setRunningResources] = useState({});
|
|
3689
|
-
const [stepInputResetKey, setStepInputResetKey] = useState(0);
|
|
3690
|
-
const currentStep = getDisplayStep(steps, recommendedStep);
|
|
3691
|
-
const selectedStep = steps.find((step) => step.id === selectedStepId) ?? currentStep;
|
|
3692
|
-
const selectedStepIndex = selectedStep ? steps.findIndex((step) => step.id === selectedStep.id) : -1;
|
|
3693
|
-
const selectedActionKind = selectedStep?.nextActionKind ?? "none";
|
|
3694
|
-
const selectedCapabilityKey = selectedStep?.action?.actionKey ?? selectedStep?.actionKey;
|
|
3695
|
-
const selectedResourceId = selectedStep?.action?.resourceId ?? null;
|
|
3696
|
-
const stepSchema = selectedStep?.action?.schema;
|
|
3697
|
-
const stepLayout = selectedStep?.action?.layout;
|
|
3698
|
-
const credentialRequirements = selectedStep?.credentialRequirements ?? [];
|
|
3699
|
-
const visibleStepLayout = useMemo(
|
|
3700
|
-
() => filterCredentialRequirementFields(stepLayout, credentialRequirements),
|
|
3701
|
-
[stepLayout, credentialRequirements]
|
|
3702
|
-
);
|
|
3703
|
-
const showMainStepConfig = stepSchema && hasMainConfigFields(visibleStepLayout);
|
|
3704
|
-
const showAdvancedStepConfig = stepSchema && hasAdvancedConfigFields(visibleStepLayout);
|
|
3705
|
-
const recentRunsQuery = useListExecutions(list.id, { resourceId: selectedResourceId, limit: 5 });
|
|
3706
|
-
const recentRuns = useMemo(() => recentRunsQuery.data ?? [], [recentRunsQuery.data]);
|
|
3707
|
-
const credentialsQuery = useCredentials();
|
|
3708
|
-
const credentials = credentialsQuery.data ?? [];
|
|
3709
|
-
const verifyCredential = useVerifyCredential();
|
|
3710
|
-
const canRunSelectedAction = !!selectedStep?.action && (selectedActionKind === "retry_failed" || selectedActionKind === "run_next_batch");
|
|
3711
|
-
const selectedResourceIsRunning = selectedResourceId ? runningResources[selectedResourceId] ?? false : false;
|
|
3712
|
-
const selectedActionDisabled = !canRunSelectedAction || selectedResourceIsRunning;
|
|
3713
|
-
const selectedActionLabel = selectedResourceIsRunning ? "Running..." : selectedActionKind === "none" ? "No action" : getStepActionLabel(selectedActionKind);
|
|
3714
|
-
const selectedActionIcon = selectedActionKind === "retry_failed" ? /* @__PURE__ */ jsx(IconRefresh, { size: 14 }) : /* @__PURE__ */ jsx(IconPlayerPlay, { size: 14 });
|
|
3715
|
-
const handleResourceRunningChange = useCallback((resourceId, isRunning) => {
|
|
3716
|
-
setRunningResources((current) => {
|
|
3717
|
-
if (current[resourceId] === isRunning) return current;
|
|
3718
|
-
return { ...current, [resourceId]: isRunning };
|
|
3719
|
-
});
|
|
3720
|
-
}, []);
|
|
3721
|
-
const handleSelectedResourceRunningChange = useCallback(
|
|
3722
|
-
(isRunning) => {
|
|
3723
|
-
if (!selectedResourceId) return;
|
|
3724
|
-
handleResourceRunningChange(selectedResourceId, isRunning);
|
|
3725
|
-
},
|
|
3726
|
-
[handleResourceRunningChange, selectedResourceId]
|
|
3727
|
-
);
|
|
3728
|
-
useEffect(() => {
|
|
3729
|
-
setStepInputFormState(getInitialStepInput(list, selectedStep?.action));
|
|
3730
|
-
setStepInputError(null);
|
|
3731
|
-
setStepInputInitialized(false);
|
|
3732
|
-
setStepInputResetKey((k) => k + 1);
|
|
3733
|
-
}, [list, selectedStep?.action]);
|
|
3734
|
-
useEffect(() => {
|
|
3735
|
-
if (stepInputInitialized) return;
|
|
3736
|
-
if (recentRunsQuery.isLoading) return;
|
|
3737
|
-
if (recentRuns.length > 0) {
|
|
3738
|
-
const lastInput = getRunInput(recentRuns[0]);
|
|
3739
|
-
if (lastInput) {
|
|
3740
|
-
setStepInputFormState(sanitizeStepInput(asRecord3(lastInput)));
|
|
3741
|
-
setStepInputResetKey((k) => k + 1);
|
|
3742
|
-
}
|
|
3743
|
-
}
|
|
3744
|
-
setStepInputInitialized(true);
|
|
3745
|
-
}, [stepInputInitialized, recentRunsQuery.isLoading, recentRuns, selectedCapabilityKey]);
|
|
3746
|
-
const handleStepInputChange = (next) => {
|
|
3747
|
-
setStepInputFormState(next);
|
|
3748
|
-
if (stepInputError) setStepInputError(null);
|
|
3749
|
-
};
|
|
3750
|
-
const handleCredentialSelect = (requirement, credential) => {
|
|
3751
|
-
setCredentialSelections((current) => ({
|
|
3752
|
-
...current,
|
|
3753
|
-
[requirement.key]: credential?.id ?? null
|
|
3754
|
-
}));
|
|
3755
|
-
setStepInputFormState((current) => setValueAtInputPath(current, requirement.inputPath, credential?.name ?? ""));
|
|
3756
|
-
if (stepInputError) setStepInputError(null);
|
|
3757
|
-
};
|
|
3758
|
-
const handleVerifyCredential = (credential) => {
|
|
3759
|
-
verifyCredential.mutate(credential.id, {
|
|
3760
|
-
onSuccess: (result) => {
|
|
3761
|
-
setCredentialVerificationById((current) => ({
|
|
3762
|
-
...current,
|
|
3763
|
-
[credential.id]: {
|
|
3764
|
-
status: result.ok ? "success" : "error",
|
|
3765
|
-
checkedAt: result.checkedAt,
|
|
3766
|
-
message: result.message ?? (result.ok ? "Credential verified." : "Credential verification failed."),
|
|
3767
|
-
details: result.details
|
|
3768
|
-
}
|
|
3769
|
-
}));
|
|
3770
|
-
},
|
|
3771
|
-
onError: (error) => {
|
|
3772
|
-
setCredentialVerificationById((current) => ({
|
|
3773
|
-
...current,
|
|
3774
|
-
[credential.id]: {
|
|
3775
|
-
status: "error",
|
|
3776
|
-
message: error instanceof Error ? error.message : "Credential verification failed."
|
|
3777
|
-
}
|
|
3778
|
-
}));
|
|
3779
|
-
}
|
|
3780
|
-
});
|
|
3781
|
-
};
|
|
3782
|
-
const handleClickupListIdChange = (value) => {
|
|
3783
|
-
setClickupListId(value);
|
|
3784
|
-
setStepInputFormState((current) => setValueAtInputPath(current, "clickupListId", value));
|
|
3785
|
-
if (stepInputError) setStepInputError(null);
|
|
3786
|
-
};
|
|
3787
|
-
const handleSelectedAction = () => {
|
|
3788
|
-
if (!selectedStep || selectedActionDisabled) return;
|
|
3789
|
-
if (stepSchema) {
|
|
3790
|
-
const parsed = stepSchema.safeParse(stepInputFormState);
|
|
3791
|
-
if (!parsed.success) {
|
|
3792
|
-
const firstIssue = parsed.error.issues[0];
|
|
3793
|
-
setStepInputError(firstIssue?.message ?? "Validation failed");
|
|
3794
|
-
return;
|
|
3795
|
-
}
|
|
3796
|
-
}
|
|
3797
|
-
setStepInputError(null);
|
|
3798
|
-
const submittedInput = stepSchema ? stepInputFormState : {};
|
|
3799
|
-
if (selectedActionKind === "retry_failed") {
|
|
3800
|
-
onRetryStep(selectedStep, submittedInput);
|
|
3801
|
-
return;
|
|
3802
|
-
}
|
|
3803
|
-
onRunStep(selectedStep, submittedInput);
|
|
3804
|
-
};
|
|
3805
|
-
const loadRecentRunInput = (run) => {
|
|
3806
|
-
setStepInputFormState(sanitizeStepInput(asRecord3(getRunInput(run))));
|
|
3807
|
-
setStepInputResetKey((k) => k + 1);
|
|
3808
|
-
setActiveRightColumnTab("configuration");
|
|
3809
|
-
};
|
|
3810
|
-
const openRecentRunLog = (run) => {
|
|
3811
|
-
const resourceId = run.resourceId ?? selectedResourceId;
|
|
3812
|
-
if (!resourceId) return;
|
|
3813
|
-
onViewRunLog(resourceId, run.executionId);
|
|
3814
|
-
};
|
|
3815
|
-
return /* @__PURE__ */ jsx(TabSection, { icon: /* @__PURE__ */ jsx(IconBolt, { size: 16 }), title: "Build", description: getBuildTabDescription(steps, currentStep), children: /* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 1, md: 2 }, spacing: "md", children: [
|
|
3816
|
-
/* @__PURE__ */ jsx(Card, { withBorder: true, style: { height: "100%", display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ jsxs(Stack, { gap: "xs", style: { flex: 1, minHeight: 0 }, children: [
|
|
3817
|
-
steps.map(
|
|
3818
|
-
(step) => step.action?.resourceId ? /* @__PURE__ */ jsx(
|
|
3819
|
-
BuildStepRunningWatcher,
|
|
3820
|
-
{
|
|
3821
|
-
resourceId: step.action.resourceId,
|
|
3822
|
-
onRunningChange: handleResourceRunningChange
|
|
3823
|
-
},
|
|
3824
|
-
`running-${step.id}`
|
|
3825
|
-
) : null
|
|
3826
|
-
),
|
|
3827
|
-
steps.map((step, index) => {
|
|
3828
|
-
const isCurrent = currentStep?.id === step.id;
|
|
3829
|
-
const isSelected = selectedStep?.id === step.id;
|
|
3830
|
-
const stepResourceId = step.action?.resourceId ?? null;
|
|
3831
|
-
const isStepRunning = stepResourceId ? runningResources[stepResourceId] ?? false : false;
|
|
3832
|
-
const isWaiting = step.status === "blocked";
|
|
3833
|
-
const isPassiveWaiting = isWaiting && !isSelected && !isCurrent;
|
|
3834
|
-
const stepTone = isStepRunning ? "ready" : isSelected || isCurrent ? step.status : step.status === "complete" || isWaiting ? step.status : "neutral";
|
|
3835
|
-
return /* @__PURE__ */ jsx(
|
|
3836
|
-
UnstyledButton,
|
|
3837
|
-
{
|
|
3838
|
-
onClick: () => setSelectedStepId(step.id),
|
|
3839
|
-
style: {
|
|
3840
|
-
backgroundColor: isSelected ? "var(--surface-primary-strong)" : isStepRunning ? "color-mix(in srgb, var(--color-primary) 12%, transparent)" : isPassiveWaiting ? "color-mix(in srgb, var(--color-surface-hover) 38%, transparent)" : "transparent",
|
|
3841
|
-
border: isSelected ? "var(--active-border)" : isStepRunning ? "1px solid var(--border-primary-muted)" : "1px solid var(--color-border)",
|
|
3842
|
-
borderStyle: isPassiveWaiting && !isStepRunning ? "dashed" : "solid",
|
|
3843
|
-
borderRadius: 8,
|
|
3844
|
-
display: "block",
|
|
3845
|
-
opacity: isPassiveWaiting && !isStepRunning ? 0.72 : 1,
|
|
3846
|
-
padding: 12,
|
|
3847
|
-
textAlign: "left",
|
|
3848
|
-
width: "100%"
|
|
3849
|
-
},
|
|
3850
|
-
children: /* @__PURE__ */ jsxs(Group, { gap: "sm", align: "flex-start", wrap: "nowrap", children: [
|
|
3851
|
-
/* @__PURE__ */ jsx(
|
|
3852
|
-
Box,
|
|
3853
|
-
{
|
|
3854
|
-
w: 28,
|
|
3855
|
-
h: 28,
|
|
3856
|
-
style: {
|
|
3857
|
-
alignItems: "center",
|
|
3858
|
-
...getBuildToneStyle(stepTone),
|
|
3859
|
-
borderRadius: 999,
|
|
3860
|
-
borderStyle: "solid",
|
|
3861
|
-
borderWidth: 1,
|
|
3862
|
-
display: "flex",
|
|
3863
|
-
flexShrink: 0,
|
|
3864
|
-
fontWeight: 700,
|
|
3865
|
-
justifyContent: "center"
|
|
3866
|
-
},
|
|
3867
|
-
children: index + 1
|
|
3868
|
-
}
|
|
3869
|
-
),
|
|
3870
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 4, style: { minWidth: 0, flex: 1 }, children: [
|
|
3871
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "space-between", wrap: "nowrap", children: [
|
|
3872
|
-
/* @__PURE__ */ jsx(Text, { fw: 700, c: isPassiveWaiting && !isStepRunning ? "dimmed" : void 0, truncate: true, children: step.label }),
|
|
3873
|
-
isStepRunning ? /* @__PURE__ */ jsx(StatusPill, { label: "Running", tone: "ready" }) : null,
|
|
3874
|
-
!isStepRunning && isCurrent ? /* @__PURE__ */ jsx(StatusPill, { label: "Current", tone: step.status }) : null,
|
|
3875
|
-
!isStepRunning && !isCurrent && isWaiting ? /* @__PURE__ */ jsx(StatusPill, { label: "Waiting", tone: "blocked" }) : null
|
|
3876
|
-
] }),
|
|
3877
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", lineClamp: 2, children: step.description }),
|
|
3878
|
-
/* @__PURE__ */ jsx(StepCounterLine, { step })
|
|
3879
|
-
] })
|
|
3880
|
-
] })
|
|
3881
|
-
},
|
|
3882
|
-
step.id
|
|
3883
|
-
);
|
|
3884
|
-
})
|
|
3885
|
-
] }) }),
|
|
3886
|
-
selectedStep ? /* @__PURE__ */ jsx(Card, { withBorder: true, style: { height: "100%", display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ jsxs(Stack, { gap: "md", style: { flex: 1, minHeight: 0 }, children: [
|
|
3887
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 2, style: { minWidth: 0, flexShrink: 0 }, children: [
|
|
3888
|
-
/* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", fw: 700, tt: "uppercase", children: [
|
|
3889
|
-
"Step ",
|
|
3890
|
-
selectedStepIndex + 1,
|
|
3891
|
-
" details"
|
|
3892
|
-
] }),
|
|
3893
|
-
/* @__PURE__ */ jsx(Title, { order: 5, children: selectedStep.label })
|
|
3894
|
-
] }),
|
|
3895
|
-
/* @__PURE__ */ jsx(BuildStepProgressBar, { step: selectedStep }),
|
|
3896
|
-
/* @__PURE__ */ jsx(
|
|
3897
|
-
StepDetailRightColumn,
|
|
3898
|
-
{
|
|
3899
|
-
activeTab: activeRightColumnTab,
|
|
3900
|
-
onTabChange: setActiveRightColumnTab,
|
|
3901
|
-
configuration: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
3902
|
-
selectedResourceId && selectedStep.stageKey ? /* @__PURE__ */ jsx(
|
|
3903
|
-
LeadGenLiveStatusPanel,
|
|
3904
|
-
{
|
|
3905
|
-
listId: list.id,
|
|
3906
|
-
resourceId: selectedResourceId,
|
|
3907
|
-
stageKey: selectedStep.stageKey,
|
|
3908
|
-
stepLabel: selectedStep.label,
|
|
3909
|
-
enabled: true,
|
|
3910
|
-
onRunningChange: handleSelectedResourceRunningChange
|
|
3911
|
-
},
|
|
3912
|
-
selectedResourceId
|
|
3913
|
-
) : null,
|
|
3914
|
-
selectedStep.status === "blocked" ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: selectedStep.emptyBlockedText }) : null,
|
|
3915
|
-
selectedStep.outputs.includes(selectedStep.primaryEntity) && selectedStep.ready === 0 && selectedStep.complete === 0 && selectedStep.failed === 0 && selectedStep.blocked === 0 ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Run this step to populate members." }) : null,
|
|
3916
|
-
!selectedStep.outputs.includes(selectedStep.primaryEntity) && selectedStep.recommendedAction?.defaultSize !== void 0 && selectedStep.recommendedAction.maxSize !== void 0 ? /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
|
|
3917
|
-
"Batch size: ",
|
|
3918
|
-
selectedStep.recommendedAction.defaultSize,
|
|
3919
|
-
" default,",
|
|
3920
|
-
" ",
|
|
3921
|
-
selectedStep.recommendedAction.maxSize,
|
|
3922
|
-
" max."
|
|
3923
|
-
] }) : null,
|
|
3924
|
-
showMainStepConfig && visibleStepLayout ? /* @__PURE__ */ jsx(
|
|
3925
|
-
StepConfigForm,
|
|
3926
|
-
{
|
|
3927
|
-
slot: "main",
|
|
3928
|
-
schema: stepSchema,
|
|
3929
|
-
layout: visibleStepLayout,
|
|
3930
|
-
value: stepInputFormState,
|
|
3931
|
-
onChange: (v) => handleStepInputChange(asRecord3(v) ?? {}),
|
|
3932
|
-
disabled: !canRunSelectedAction
|
|
3933
|
-
},
|
|
3934
|
-
`${selectedResourceId ?? "none"}-main-${stepInputResetKey}`
|
|
3935
|
-
) : !credentialRequirements.length ? /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "No configuration for this step." }) : null,
|
|
3936
|
-
/* @__PURE__ */ jsx(
|
|
3937
|
-
CredentialRequirementsPanel,
|
|
3938
|
-
{
|
|
3939
|
-
requirements: credentialRequirements,
|
|
3940
|
-
credentials,
|
|
3941
|
-
credentialsLoading: credentialsQuery.isLoading,
|
|
3942
|
-
selections: credentialSelections,
|
|
3943
|
-
verificationByCredentialId: credentialVerificationById,
|
|
3944
|
-
verifyingCredentialId: verifyCredential.isPending ? verifyCredential.variables ?? null : null,
|
|
3945
|
-
onSelect: handleCredentialSelect,
|
|
3946
|
-
onVerify: handleVerifyCredential
|
|
3947
|
-
}
|
|
3948
|
-
),
|
|
3949
|
-
selectedStep.actionKey === "lead-gen.export.list" || getClickUpRequirement(selectedStep) ? /* @__PURE__ */ jsx(
|
|
3950
|
-
TextInput,
|
|
3951
|
-
{
|
|
3952
|
-
label: "ClickUp List ID",
|
|
3953
|
-
description: "Destination List ID for approved company tasks.",
|
|
3954
|
-
placeholder: "123456789",
|
|
3955
|
-
value: clickupListId,
|
|
3956
|
-
onChange: (event) => handleClickupListIdChange(event.currentTarget.value)
|
|
3957
|
-
}
|
|
3958
|
-
) : null
|
|
3959
|
-
] }),
|
|
3960
|
-
advanced: showAdvancedStepConfig && visibleStepLayout ? /* @__PURE__ */ jsx(
|
|
3961
|
-
StepConfigForm,
|
|
3962
|
-
{
|
|
3963
|
-
slot: "advanced",
|
|
3964
|
-
schema: stepSchema,
|
|
3965
|
-
layout: visibleStepLayout,
|
|
3966
|
-
value: stepInputFormState,
|
|
3967
|
-
onChange: (v) => handleStepInputChange(asRecord3(v) ?? {}),
|
|
3968
|
-
disabled: !canRunSelectedAction
|
|
3969
|
-
},
|
|
3970
|
-
`${selectedResourceId ?? "none"}-advanced-${stepInputResetKey}`
|
|
3971
|
-
) : void 0,
|
|
3972
|
-
records: /* @__PURE__ */ jsx(
|
|
3973
|
-
StepRecordsPanel,
|
|
3974
|
-
{
|
|
3975
|
-
list,
|
|
3976
|
-
step: selectedStep,
|
|
3977
|
-
credentialSelections,
|
|
3978
|
-
credentials,
|
|
3979
|
-
clickupListId
|
|
3980
|
-
},
|
|
3981
|
-
selectedStep.id
|
|
3982
|
-
),
|
|
3983
|
-
runs: selectedResourceId ? /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
|
|
3984
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "xs", children: [
|
|
3985
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", fw: 700, tt: "uppercase", children: "Recent runs" }),
|
|
3986
|
-
recentRunsQuery.isFetching ? /* @__PURE__ */ jsx(Loader, { size: "xs" }) : null
|
|
3987
|
-
] }),
|
|
3988
|
-
!recentRuns.length && !recentRunsQuery.isLoading ? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No runs yet for this step." }) : /* @__PURE__ */ jsx(Stack, { gap: 4, children: recentRuns.map((run) => {
|
|
3989
|
-
const canUseSettings = hasRunInput(run);
|
|
3990
|
-
return /* @__PURE__ */ jsx(
|
|
3991
|
-
Box,
|
|
3992
|
-
{
|
|
3993
|
-
style: {
|
|
3994
|
-
border: "1px solid var(--color-border)",
|
|
3995
|
-
borderRadius: 8,
|
|
3996
|
-
padding: "8px 10px",
|
|
3997
|
-
width: "100%"
|
|
3998
|
-
},
|
|
3999
|
-
children: /* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "xs", wrap: "nowrap", children: [
|
|
4000
|
-
/* @__PURE__ */ jsx(
|
|
4001
|
-
UnstyledButton,
|
|
4002
|
-
{
|
|
4003
|
-
onClick: () => openRecentRunLog(run),
|
|
4004
|
-
style: { flex: 1, minWidth: 0, textAlign: "left" },
|
|
4005
|
-
children: /* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "xs", wrap: "nowrap", children: [
|
|
4006
|
-
/* @__PURE__ */ jsxs(Stack, { gap: 2, style: { minWidth: 0 }, children: [
|
|
4007
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, truncate: true, children: formatDateTime4(run.createdAt) }),
|
|
4008
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", ff: "monospace", truncate: true, children: run.executionId })
|
|
4009
|
-
] }),
|
|
4010
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: getRunStatusColor(run.status), children: run.status })
|
|
4011
|
-
] })
|
|
4012
|
-
}
|
|
4013
|
-
),
|
|
4014
|
-
/* @__PURE__ */ jsx(Tooltip, { label: "Use this run's settings", children: /* @__PURE__ */ jsx(
|
|
4015
|
-
Button,
|
|
4016
|
-
{
|
|
4017
|
-
size: "xs",
|
|
4018
|
-
variant: "subtle",
|
|
4019
|
-
leftSection: /* @__PURE__ */ jsx(IconSettings, { size: 12 }),
|
|
4020
|
-
disabled: !canUseSettings,
|
|
4021
|
-
onClick: () => loadRecentRunInput(run),
|
|
4022
|
-
children: "Use settings"
|
|
4023
|
-
}
|
|
4024
|
-
) })
|
|
4025
|
-
] })
|
|
4026
|
-
},
|
|
4027
|
-
run.executionId
|
|
4028
|
-
);
|
|
4029
|
-
}) })
|
|
4030
|
-
] }) : /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "No runs available for this step." }),
|
|
4031
|
-
action: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4032
|
-
stepInputError ? /* @__PURE__ */ jsx(Alert, { color: "red", icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), variant: "light", children: stepInputError }) : null,
|
|
4033
|
-
/* @__PURE__ */ jsx(Group, { gap: "xs", justify: "flex-end", wrap: "nowrap", children: /* @__PURE__ */ jsx(
|
|
4034
|
-
Button,
|
|
4035
|
-
{
|
|
4036
|
-
leftSection: selectedActionIcon,
|
|
4037
|
-
disabled: selectedActionDisabled,
|
|
4038
|
-
onClick: handleSelectedAction,
|
|
4039
|
-
children: selectedActionLabel
|
|
4040
|
-
}
|
|
4041
|
-
) })
|
|
4042
|
-
] })
|
|
4043
|
-
}
|
|
4044
|
-
)
|
|
4045
|
-
] }) }) : null
|
|
4046
|
-
] }) });
|
|
4047
|
-
}
|
|
4048
|
-
function MembersTab({
|
|
4049
|
-
listId,
|
|
4050
|
-
progress,
|
|
4051
|
-
onMemberClick
|
|
4052
|
-
}) {
|
|
4053
|
-
const [memberTab, setMemberTab] = useState("contacts");
|
|
4054
|
-
const contactsQuery = useContacts({ listId, limit: 100, offset: 0 });
|
|
4055
|
-
const companiesQuery = useCompanies({ listId, limit: 100, offset: 0 });
|
|
4056
|
-
const contacts = contactsQuery.data?.data ?? [];
|
|
4057
|
-
const companies = companiesQuery.data?.data ?? [];
|
|
4058
|
-
return /* @__PURE__ */ jsxs(
|
|
4059
|
-
TabSection,
|
|
4060
|
-
{
|
|
4061
|
-
icon: /* @__PURE__ */ jsx(IconAddressBook, { size: 16 }),
|
|
4062
|
-
title: "Members",
|
|
4063
|
-
description: "Contacts and companies attached to this list.",
|
|
4064
|
-
rightSection: /* @__PURE__ */ jsx(
|
|
4065
|
-
SegmentedControl,
|
|
4066
|
-
{
|
|
4067
|
-
value: memberTab,
|
|
4068
|
-
onChange: (value) => setMemberTab(value),
|
|
4069
|
-
size: "xs",
|
|
4070
|
-
data: [
|
|
4071
|
-
{ label: `Members (${progress.totalMembers})`, value: "contacts" },
|
|
4072
|
-
{ label: `Companies (${progress.totalCompanies})`, value: "companies" }
|
|
4073
|
-
]
|
|
4074
|
-
}
|
|
4075
|
-
),
|
|
4076
|
-
children: [
|
|
4077
|
-
memberTab === "contacts" && /* @__PURE__ */ jsx(Fragment, { children: contactsQuery.isLoading ? /* @__PURE__ */ jsx(Center, { p: "md", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) }) : !contacts.length ? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No contacts attached to this list yet." }) : /* @__PURE__ */ jsxs(Table, { highlightOnHover: true, children: [
|
|
4078
|
-
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
4079
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Name" }),
|
|
4080
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Email" }),
|
|
4081
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Title" }),
|
|
4082
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Company" }),
|
|
4083
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Status" }),
|
|
4084
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "State" }),
|
|
4085
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Created" })
|
|
4086
|
-
] }) }),
|
|
4087
|
-
/* @__PURE__ */ jsx(Table.Tbody, { children: contacts.map((contact) => {
|
|
4088
|
-
const handleRowClick = () => onMemberClick?.(contact.id, "contact");
|
|
4089
|
-
const memberStage = displayMemberStageFor(contact, "contact");
|
|
4090
|
-
return /* @__PURE__ */ jsxs(Table.Tr, { onClick: handleRowClick, style: { cursor: "pointer" }, children: [
|
|
4091
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { fw: 500, children: contactDisplayName(contact.firstName, contact.lastName) }) }),
|
|
4092
|
-
/* @__PURE__ */ jsx(Table.Td, { children: contact.email }),
|
|
4093
|
-
/* @__PURE__ */ jsx(Table.Td, { children: contact.title ?? "\u2014" }),
|
|
4094
|
-
/* @__PURE__ */ jsx(Table.Td, { children: contact.company?.name ?? "\u2014" }),
|
|
4095
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: getStatusColor4(contact.status), children: contact.status }) }),
|
|
4096
|
-
/* @__PURE__ */ jsx(Table.Td, { children: memberStage ? /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "dot", color: getMemberStateColor2(memberStage.key), children: memberStage.label }) : /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "\u2014" }) }),
|
|
4097
|
-
/* @__PURE__ */ jsx(Table.Td, { children: formatDateTime4(contact.createdAt) })
|
|
4098
|
-
] }, contact.id);
|
|
4099
|
-
}) })
|
|
4100
|
-
] }) }),
|
|
4101
|
-
memberTab === "companies" && /* @__PURE__ */ jsx(Fragment, { children: companiesQuery.isLoading ? /* @__PURE__ */ jsx(Center, { p: "md", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) }) : !companies.length ? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No companies attached to this list yet." }) : /* @__PURE__ */ jsxs(Table, { highlightOnHover: true, children: [
|
|
4102
|
-
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
4103
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Name" }),
|
|
4104
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Domain" }),
|
|
4105
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Segment" }),
|
|
4106
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Contacts" }),
|
|
4107
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Status" }),
|
|
4108
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "State" }),
|
|
4109
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Created" })
|
|
4110
|
-
] }) }),
|
|
4111
|
-
/* @__PURE__ */ jsx(Table.Tbody, { children: companies.map((company) => {
|
|
4112
|
-
const handleRowClick = () => onMemberClick?.(company.id, "company");
|
|
4113
|
-
const memberStage = displayMemberStageFor(company, "company");
|
|
4114
|
-
return /* @__PURE__ */ jsxs(Table.Tr, { onClick: handleRowClick, style: { cursor: "pointer" }, children: [
|
|
4115
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { fw: 500, children: company.name }) }),
|
|
4116
|
-
/* @__PURE__ */ jsx(Table.Td, { children: company.domain ?? "\u2014" }),
|
|
4117
|
-
/* @__PURE__ */ jsx(Table.Td, { children: company.segment ?? "\u2014" }),
|
|
4118
|
-
/* @__PURE__ */ jsx(Table.Td, { children: company.contactCount }),
|
|
4119
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: getStatusColor4(company.status), children: company.status }) }),
|
|
4120
|
-
/* @__PURE__ */ jsx(Table.Td, { children: memberStage ? /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "dot", color: getMemberStateColor2(memberStage.key), children: memberStage.label }) : /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "\u2014" }) }),
|
|
4121
|
-
/* @__PURE__ */ jsx(Table.Td, { children: formatDateTime4(company.createdAt) })
|
|
4122
|
-
] }, company.id);
|
|
4123
|
-
}) })
|
|
4124
|
-
] }) })
|
|
4125
|
-
]
|
|
4126
|
-
}
|
|
4127
|
-
);
|
|
4128
|
-
}
|
|
4129
|
-
function ListDetailHeader({
|
|
4130
|
-
title,
|
|
4131
|
-
caption,
|
|
4132
|
-
rightSection
|
|
4133
|
-
}) {
|
|
4134
|
-
return /* @__PURE__ */ jsx(PageTitleCaption, { title, caption, rightSection });
|
|
4135
|
-
}
|
|
4136
|
-
function LeadGenListDetailPage({ listId }) {
|
|
4137
|
-
const navigate = useNavigate();
|
|
4138
|
-
const actions = useListActions();
|
|
4139
|
-
const rawSearch = useSearch({ strict: false });
|
|
4140
|
-
const memberId = rawSearch.member ?? null;
|
|
4141
|
-
const memberKind = rawSearch.memberKind ?? null;
|
|
4142
|
-
const handleMemberClick = (id, kind) => {
|
|
4143
|
-
const params = new URLSearchParams(window.location.search);
|
|
4144
|
-
params.set("member", id);
|
|
4145
|
-
params.set("memberKind", kind);
|
|
4146
|
-
window.history.pushState(null, "", `${window.location.pathname}?${params.toString()}`);
|
|
4147
|
-
};
|
|
4148
|
-
const handleDrawerClose = () => {
|
|
4149
|
-
const params = new URLSearchParams(window.location.search);
|
|
4150
|
-
params.delete("member");
|
|
4151
|
-
params.delete("memberKind");
|
|
4152
|
-
const qs = params.toString();
|
|
4153
|
-
window.history.pushState(null, "", qs ? `${window.location.pathname}?${qs}` : window.location.pathname);
|
|
4154
|
-
};
|
|
4155
|
-
const listQuery = useList(listId);
|
|
4156
|
-
const progressQuery = useListProgress(listId);
|
|
4157
|
-
const executionsQuery = useListExecutions(listId);
|
|
4158
|
-
const deleteListMutation = useDeleteList();
|
|
4159
|
-
const [deleteModalOpen, setDeleteModalOpen] = useState(false);
|
|
4160
|
-
const [runModalOpen, setRunModalOpen] = useState(false);
|
|
4161
|
-
const [activeTab, setActiveTab] = useState("overview");
|
|
4162
|
-
const [runsResourceFilter, setRunsResourceFilter] = useState(null);
|
|
4163
|
-
const [initialRunResourceId, setInitialRunResourceId] = useState(null);
|
|
4164
|
-
const [pendingStepRunInput, setPendingStepRunInput] = useState(null);
|
|
4165
|
-
const runModalActions = useMemo(() => {
|
|
4166
|
-
if (!pendingStepRunInput) return actions;
|
|
4167
|
-
return actions.map((action) => {
|
|
4168
|
-
if (action.resourceId !== pendingStepRunInput.resourceId) return action;
|
|
4169
|
-
return {
|
|
4170
|
-
...action,
|
|
4171
|
-
defaultInput: (nextList) => mergeStepRunInput(nextList, action, pendingStepRunInput.inputAtSubmit)
|
|
4172
|
-
};
|
|
4173
|
-
});
|
|
4174
|
-
}, [actions, pendingStepRunInput]);
|
|
4175
|
-
const isLoading = listQuery.isLoading || progressQuery.isLoading || executionsQuery.isLoading;
|
|
4176
|
-
const error = listQuery.error ?? progressQuery.error ?? executionsQuery.error;
|
|
4177
|
-
const backButton = /* @__PURE__ */ jsx(
|
|
4178
|
-
Button,
|
|
4179
|
-
{
|
|
4180
|
-
variant: "light",
|
|
4181
|
-
size: "xs",
|
|
4182
|
-
leftSection: /* @__PURE__ */ jsx(IconArrowLeft, { size: 16 }),
|
|
4183
|
-
onClick: () => navigate({ to: "/lead-gen/lists" }),
|
|
4184
|
-
children: "Lists"
|
|
4185
|
-
}
|
|
4186
|
-
);
|
|
4187
|
-
if (isLoading) {
|
|
4188
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
4189
|
-
/* @__PURE__ */ jsx(
|
|
4190
|
-
ListDetailHeader,
|
|
4191
|
-
{
|
|
4192
|
-
title: "List Detail",
|
|
4193
|
-
caption: "Configuration, progress, and execution history for a single lead-gen list",
|
|
4194
|
-
rightSection: backButton
|
|
4195
|
-
}
|
|
4196
|
-
),
|
|
4197
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) })
|
|
4198
|
-
] }) }) });
|
|
4199
|
-
}
|
|
4200
|
-
if (error) {
|
|
4201
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
4202
|
-
/* @__PURE__ */ jsx(
|
|
4203
|
-
ListDetailHeader,
|
|
4204
|
-
{
|
|
4205
|
-
title: "List Detail",
|
|
4206
|
-
caption: "Configuration, progress, and execution history for a single lead-gen list",
|
|
4207
|
-
rightSection: backButton
|
|
4208
|
-
}
|
|
4209
|
-
),
|
|
4210
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(CenteredErrorState, { error, title: "Failed to load list detail" }) })
|
|
4211
|
-
] }) }) });
|
|
4212
|
-
}
|
|
4213
|
-
if (!listQuery.data || !progressQuery.data) {
|
|
4214
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
4215
|
-
/* @__PURE__ */ jsx(
|
|
4216
|
-
ListDetailHeader,
|
|
4217
|
-
{
|
|
4218
|
-
title: "List Not Found",
|
|
4219
|
-
caption: "The requested lead-gen list is unavailable.",
|
|
4220
|
-
rightSection: backButton
|
|
4221
|
-
}
|
|
4222
|
-
),
|
|
4223
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { h: 240, children: /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), color: "gray", variant: "light", children: "The requested list could not be found." }) }) })
|
|
4224
|
-
] }) }) });
|
|
4225
|
-
}
|
|
4226
|
-
const list = listQuery.data;
|
|
4227
|
-
const progress = progressQuery.data;
|
|
4228
|
-
const executions = executionsQuery.data ?? [];
|
|
4229
|
-
const businessProgress = deriveBusinessProgress(list, progress, actions, executions);
|
|
4230
|
-
const currentBuildTemplateLabel = list.metadata.buildPlanSnapshot?.templateLabel ?? "Default lead generation";
|
|
4231
|
-
const buildResolution = resolveBuildState(list, businessProgress, actions);
|
|
4232
|
-
const buildSteps = buildResolution.steps;
|
|
4233
|
-
const recommendedBuildStep = buildResolution.recommendedStep;
|
|
4234
|
-
const openRunModal = (resourceId) => {
|
|
4235
|
-
const nextResourceId = resourceId ?? actions[0]?.resourceId ?? null;
|
|
4236
|
-
setInitialRunResourceId(nextResourceId);
|
|
4237
|
-
setRunModalOpen(true);
|
|
4238
|
-
};
|
|
4239
|
-
const closeRunModal = () => {
|
|
4240
|
-
setRunModalOpen(false);
|
|
4241
|
-
setInitialRunResourceId(null);
|
|
4242
|
-
setPendingStepRunInput(null);
|
|
4243
|
-
};
|
|
4244
|
-
const openStepRun = (step, inputAtSubmit) => {
|
|
4245
|
-
if (step.action?.schema) {
|
|
4246
|
-
setPendingStepRunInput({
|
|
4247
|
-
resourceId: step.action.resourceId,
|
|
4248
|
-
inputAtSubmit
|
|
4249
|
-
});
|
|
4250
|
-
} else {
|
|
4251
|
-
setPendingStepRunInput(null);
|
|
4252
|
-
}
|
|
4253
|
-
openRunModal(step.action?.resourceId ?? null);
|
|
4254
|
-
};
|
|
4255
|
-
const handleCopyListCommand = () => {
|
|
4256
|
-
void navigator.clipboard.writeText(`/acquisition --lead-gen list ${list.id}`);
|
|
4257
|
-
showSuccessNotification("Copied list command to clipboard");
|
|
4258
|
-
};
|
|
4259
|
-
const handleDeleteList = () => {
|
|
4260
|
-
deleteListMutation.mutate(list.id, {
|
|
4261
|
-
onSuccess: () => {
|
|
4262
|
-
setDeleteModalOpen(false);
|
|
4263
|
-
void navigate({ to: "/lead-gen/lists" });
|
|
4264
|
-
}
|
|
4265
|
-
});
|
|
4266
|
-
};
|
|
4267
|
-
return /* @__PURE__ */ jsxs(SubshellContentContainer, { children: [
|
|
4268
|
-
/* @__PURE__ */ jsx(PageContainer, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
4269
|
-
/* @__PURE__ */ jsx(
|
|
4270
|
-
ListDetailHeader,
|
|
4271
|
-
{
|
|
4272
|
-
title: list.name,
|
|
4273
|
-
caption: list.description ?? "Configuration, progress, and execution history for this list"
|
|
4274
|
-
}
|
|
4275
|
-
),
|
|
4276
|
-
/* @__PURE__ */ jsxs(Group, { justify: "space-between", gap: "xs", wrap: "nowrap", children: [
|
|
4277
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
4278
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "filled", color: getStatusColor4(list.status), children: list.status }),
|
|
4279
|
-
/* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: "violet", children: currentBuildTemplateLabel }),
|
|
4280
|
-
/* @__PURE__ */ jsxs(Text, { size: "sm", c: "dimmed", children: [
|
|
4281
|
-
"Created ",
|
|
4282
|
-
formatDateTime4(list.createdAt)
|
|
4283
|
-
] })
|
|
4284
|
-
] }),
|
|
4285
|
-
/* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
|
|
4286
|
-
/* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", onClick: handleCopyListCommand, style: { cursor: "pointer" }, children: [
|
|
4287
|
-
/* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", ff: "monospace", children: list.id }),
|
|
4288
|
-
/* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", size: "sm", "aria-label": "Copy list command", children: /* @__PURE__ */ jsx(IconCopy, { size: 14 }) })
|
|
4289
|
-
] }),
|
|
4290
|
-
/* @__PURE__ */ jsx(Tooltip, { label: "Delete list", children: /* @__PURE__ */ jsx(
|
|
4291
|
-
ActionIcon,
|
|
4292
|
-
{
|
|
4293
|
-
variant: "subtle",
|
|
4294
|
-
color: "red",
|
|
4295
|
-
size: "sm",
|
|
4296
|
-
"aria-label": "Delete list",
|
|
4297
|
-
loading: deleteListMutation.isPending,
|
|
4298
|
-
onClick: () => setDeleteModalOpen(true),
|
|
4299
|
-
children: /* @__PURE__ */ jsx(IconTrash, { size: 14 })
|
|
4300
|
-
}
|
|
4301
|
-
) }),
|
|
4302
|
-
backButton
|
|
4303
|
-
] })
|
|
4304
|
-
] }),
|
|
4305
|
-
/* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsxs(Tabs, { value: activeTab, onChange: setActiveTab, children: [
|
|
4306
|
-
/* @__PURE__ */ jsxs(Tabs.List, { children: [
|
|
4307
|
-
/* @__PURE__ */ jsx(Tabs.Tab, { value: "overview", leftSection: /* @__PURE__ */ jsx(IconBuilding, { size: 14 }), children: "Overview" }),
|
|
4308
|
-
/* @__PURE__ */ jsx(Tabs.Tab, { value: "members", leftSection: /* @__PURE__ */ jsx(IconUsers, { size: 14 }), children: "Members" }),
|
|
4309
|
-
/* @__PURE__ */ jsx(Tabs.Tab, { value: "build", leftSection: /* @__PURE__ */ jsx(IconBolt, { size: 14 }), children: "Build" }),
|
|
4310
|
-
/* @__PURE__ */ jsx(Tabs.Tab, { value: "runs", leftSection: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 14 }), children: "Runs" })
|
|
4311
|
-
] }),
|
|
4312
|
-
/* @__PURE__ */ jsx(Tabs.Panel, { value: "overview", pt: "sm", children: /* @__PURE__ */ jsx(OverviewTab, { list, progress: businessProgress }) }),
|
|
4313
|
-
/* @__PURE__ */ jsx(Tabs.Panel, { value: "members", pt: "sm", children: /* @__PURE__ */ jsx(MembersTab, { listId, progress: businessProgress, onMemberClick: handleMemberClick }) }),
|
|
4314
|
-
/* @__PURE__ */ jsx(Tabs.Panel, { value: "build", pt: "sm", children: /* @__PURE__ */ jsx(
|
|
4315
|
-
BuildTab,
|
|
4316
|
-
{
|
|
4317
|
-
list,
|
|
4318
|
-
steps: buildSteps,
|
|
4319
|
-
recommendedStep: recommendedBuildStep,
|
|
4320
|
-
onRunStep: openStepRun,
|
|
4321
|
-
onRetryStep: openStepRun,
|
|
4322
|
-
onViewRunLog: (resourceId, executionId) => {
|
|
4323
|
-
void navigate({
|
|
4324
|
-
to: "/operations/resources/workflow/$workflowId",
|
|
4325
|
-
params: { workflowId: resourceId },
|
|
4326
|
-
search: { exec: executionId }
|
|
4327
|
-
});
|
|
4328
|
-
}
|
|
4329
|
-
}
|
|
4330
|
-
) }),
|
|
4331
|
-
/* @__PURE__ */ jsx(Tabs.Panel, { value: "runs", pt: "sm", children: /* @__PURE__ */ jsx(
|
|
4332
|
-
WorkflowRunsPanel,
|
|
4333
|
-
{
|
|
4334
|
-
listId,
|
|
4335
|
-
title: "Runs",
|
|
4336
|
-
resourceFilter: runsResourceFilter,
|
|
4337
|
-
onClearResourceFilter: () => setRunsResourceFilter(null)
|
|
4338
|
-
}
|
|
4339
|
-
) })
|
|
4340
|
-
] }) })
|
|
4341
|
-
] }) }),
|
|
4342
|
-
/* @__PURE__ */ jsx(ListMemberDrawer, { memberId, memberKind, listId, onClose: handleDrawerClose }),
|
|
4343
|
-
/* @__PURE__ */ jsx(
|
|
4344
|
-
CustomModal,
|
|
4345
|
-
{
|
|
4346
|
-
opened: deleteModalOpen,
|
|
4347
|
-
onClose: () => !deleteListMutation.isPending && setDeleteModalOpen(false),
|
|
4348
|
-
size: "sm",
|
|
4349
|
-
loading: deleteListMutation.isPending,
|
|
4350
|
-
children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
4351
|
-
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
4352
|
-
/* @__PURE__ */ jsx(IconTrash, { size: 22, color: "var(--color-error)" }),
|
|
4353
|
-
/* @__PURE__ */ jsx(Title, { order: 4, children: "Delete list" })
|
|
4354
|
-
] }),
|
|
4355
|
-
/* @__PURE__ */ jsxs(Text, { size: "sm", children: [
|
|
4356
|
-
"Are you sure you want to delete",
|
|
4357
|
-
" ",
|
|
4358
|
-
/* @__PURE__ */ jsx(Text, { span: true, fw: 600, children: list.name }),
|
|
4359
|
-
"?"
|
|
4360
|
-
] }),
|
|
4361
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "This removes the list and its list membership links. Companies and contacts remain in the shared lead-gen database." }),
|
|
4362
|
-
/* @__PURE__ */ jsxs(Group, { justify: "flex-end", mt: "md", children: [
|
|
4363
|
-
/* @__PURE__ */ jsx(Button, { variant: "light", onClick: () => setDeleteModalOpen(false), disabled: deleteListMutation.isPending, children: "Cancel" }),
|
|
4364
|
-
/* @__PURE__ */ jsx(Button, { color: "red", loading: deleteListMutation.isPending, onClick: handleDeleteList, children: "Delete" })
|
|
4365
|
-
] })
|
|
4366
|
-
] })
|
|
4367
|
-
}
|
|
4368
|
-
),
|
|
4369
|
-
/* @__PURE__ */ jsx(
|
|
4370
|
-
RunWorkflowModal,
|
|
4371
|
-
{
|
|
4372
|
-
opened: runModalOpen,
|
|
4373
|
-
onClose: closeRunModal,
|
|
4374
|
-
list,
|
|
4375
|
-
actions: runModalActions,
|
|
4376
|
-
selection: EMPTY_SELECTION2,
|
|
4377
|
-
initialResourceId: initialRunResourceId,
|
|
4378
|
-
title: "Run build step",
|
|
4379
|
-
description: "Run the selected bounded build workflow for this list.",
|
|
4380
|
-
lockResourceSelection: true,
|
|
4381
|
-
onSubmitted: (_, executionId) => {
|
|
4382
|
-
showSuccessNotification(`Workflow run started: ${executionId}`);
|
|
4383
|
-
}
|
|
4384
|
-
}
|
|
4385
|
-
)
|
|
4386
|
-
] });
|
|
4387
|
-
}
|
|
4388
|
-
var PAGE_SIZE_DEFAULT2 = 20;
|
|
4389
|
-
function LeadGenCompaniesPage() {
|
|
4390
|
-
const [companySearch, setCompanySearch] = useState("");
|
|
4391
|
-
const [segmentFilter, setSegmentFilter] = useState(null);
|
|
4392
|
-
const [categoryFilter, setCategoryFilter] = useState(null);
|
|
4393
|
-
const [statusFilter, setStatusFilter] = useState(null);
|
|
4394
|
-
const [showBatchDelete, setShowBatchDelete] = useState(false);
|
|
4395
|
-
const navigate = useNavigate();
|
|
4396
|
-
const pagination = usePaginationState(PAGE_SIZE_DEFAULT2, [companySearch, segmentFilter, categoryFilter, statusFilter]);
|
|
4397
|
-
const { data: companyFacets } = useCompanyFacets();
|
|
4398
|
-
const {
|
|
4399
|
-
data: pagedCompanies,
|
|
4400
|
-
isLoading: pagedCompaniesLoading,
|
|
4401
|
-
error: pagedCompaniesError
|
|
4402
|
-
} = useCompanies({
|
|
4403
|
-
search: companySearch || void 0,
|
|
4404
|
-
segment: segmentFilter || void 0,
|
|
4405
|
-
category: categoryFilter || void 0,
|
|
4406
|
-
status: statusFilter || void 0,
|
|
4407
|
-
limit: PAGE_SIZE_DEFAULT2,
|
|
4408
|
-
offset: pagination.offset
|
|
4409
|
-
});
|
|
4410
|
-
const deleteCompaniesMutation = useDeleteCompanies();
|
|
4411
|
-
const companyRows = pagedCompanies?.data ?? [];
|
|
4412
|
-
const selection = useTableSelection(companyRows);
|
|
4413
|
-
useEffect(() => {
|
|
4414
|
-
if ((pagedCompanies?.total ?? 0) === 0) return;
|
|
4415
|
-
if (companyRows.length > 0 || pagination.page === 1) return;
|
|
4416
|
-
pagination.setPage(pagination.page - 1);
|
|
4417
|
-
}, [companyRows.length, pagedCompanies?.total, pagination.page, pagination.setPage]);
|
|
4418
|
-
function handleBatchDelete() {
|
|
4419
|
-
deleteCompaniesMutation.mutate([...selection.selectedIds], {
|
|
4420
|
-
onSuccess: () => {
|
|
4421
|
-
selection.clear();
|
|
4422
|
-
setShowBatchDelete(false);
|
|
4423
|
-
}
|
|
4424
|
-
});
|
|
4425
|
-
}
|
|
4426
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsxs(PageContainer, { children: [
|
|
4427
|
-
/* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(PageTitleCaption, { title: "Companies", caption: "Company records and enrichment tracking" }) }),
|
|
4428
|
-
/* @__PURE__ */ jsx(Paper, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
4429
|
-
/* @__PURE__ */ jsxs(
|
|
4430
|
-
FilterBar,
|
|
4431
|
-
{
|
|
4432
|
-
actions: /* @__PURE__ */ jsx(
|
|
4433
|
-
TableSelectionToolbar,
|
|
4434
|
-
{
|
|
4435
|
-
selectedCount: selection.selectedCount,
|
|
4436
|
-
onDelete: () => setShowBatchDelete(true),
|
|
4437
|
-
isDeleting: deleteCompaniesMutation.isPending
|
|
4438
|
-
}
|
|
4439
|
-
),
|
|
4440
|
-
children: [
|
|
4441
|
-
/* @__PURE__ */ jsx(
|
|
4442
|
-
Select,
|
|
4443
|
-
{
|
|
4444
|
-
placeholder: "All Segments",
|
|
4445
|
-
data: companyFacets?.segments ?? [],
|
|
4446
|
-
value: segmentFilter,
|
|
4447
|
-
onChange: (value) => setSegmentFilter(value),
|
|
4448
|
-
style: { minWidth: 180 },
|
|
4449
|
-
size: "sm",
|
|
4450
|
-
clearable: true
|
|
4451
|
-
}
|
|
4452
|
-
),
|
|
4453
|
-
/* @__PURE__ */ jsx(
|
|
4454
|
-
Select,
|
|
4455
|
-
{
|
|
4456
|
-
placeholder: "All Categories",
|
|
4457
|
-
data: companyFacets?.categories ?? [],
|
|
4458
|
-
value: categoryFilter,
|
|
4459
|
-
onChange: (value) => setCategoryFilter(value),
|
|
4460
|
-
style: { minWidth: 160 },
|
|
4461
|
-
size: "sm",
|
|
4462
|
-
clearable: true
|
|
4463
|
-
}
|
|
4464
|
-
),
|
|
4465
|
-
/* @__PURE__ */ jsx(
|
|
4466
|
-
Select,
|
|
4467
|
-
{
|
|
4468
|
-
placeholder: "All Statuses",
|
|
4469
|
-
data: (companyFacets?.statuses ?? []).map((status) => ({
|
|
4470
|
-
value: status,
|
|
4471
|
-
label: status[0].toUpperCase() + status.slice(1)
|
|
4472
|
-
})),
|
|
4473
|
-
value: statusFilter,
|
|
4474
|
-
onChange: (value) => setStatusFilter(value),
|
|
4475
|
-
style: { minWidth: 160 },
|
|
4476
|
-
size: "sm",
|
|
4477
|
-
clearable: true
|
|
4478
|
-
}
|
|
4479
|
-
),
|
|
4480
|
-
/* @__PURE__ */ jsx(
|
|
4481
|
-
TextInput,
|
|
4482
|
-
{
|
|
4483
|
-
placeholder: "Search by name or domain...",
|
|
4484
|
-
leftSection: /* @__PURE__ */ jsx(IconSearch, { size: 16 }),
|
|
4485
|
-
style: { minWidth: 250 },
|
|
4486
|
-
size: "sm",
|
|
4487
|
-
value: companySearch,
|
|
4488
|
-
onChange: (e) => setCompanySearch(e.target.value)
|
|
4489
|
-
}
|
|
4490
|
-
)
|
|
4491
|
-
]
|
|
4492
|
-
}
|
|
4493
|
-
),
|
|
4494
|
-
pagedCompaniesLoading ? /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) : pagedCompaniesError ? /* @__PURE__ */ jsx(CenteredErrorState, { error: pagedCompaniesError, title: "Failed to load companies" }) : !companyRows.length ? /* @__PURE__ */ jsx(EmptyState, { icon: IconBuildingFactory2, title: "No companies yet", description: "Add one to get started." }) : /* @__PURE__ */ jsxs(Table, { children: [
|
|
4495
|
-
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
4496
|
-
/* @__PURE__ */ jsx(Table.Th, { w: 40, children: /* @__PURE__ */ jsx(
|
|
4497
|
-
Checkbox,
|
|
4498
|
-
{
|
|
4499
|
-
checked: selection.isPageAllSelected,
|
|
4500
|
-
indeterminate: selection.isPagePartiallySelected,
|
|
4501
|
-
onChange: selection.togglePage
|
|
4502
|
-
}
|
|
4503
|
-
) }),
|
|
4504
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Company" }),
|
|
4505
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Domain" }),
|
|
4506
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Segment" }),
|
|
4507
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Category" }),
|
|
4508
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Employees" }),
|
|
4509
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Enrichment" }),
|
|
4510
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Contacts" })
|
|
4511
|
-
] }) }),
|
|
4512
|
-
/* @__PURE__ */ jsx(Table.Tbody, { children: companyRows.map((company) => {
|
|
4513
|
-
const enrichStatus = getEnrichmentStatus(company.enrichmentData);
|
|
4514
|
-
return /* @__PURE__ */ jsxs(
|
|
4515
|
-
Table.Tr,
|
|
4516
|
-
{
|
|
4517
|
-
style: { cursor: "pointer" },
|
|
4518
|
-
onClick: () => navigate({ to: "/crm/companies/$companyId", params: { companyId: company.id } }),
|
|
4519
|
-
children: [
|
|
4520
|
-
/* @__PURE__ */ jsx(
|
|
4521
|
-
Table.Td,
|
|
4522
|
-
{
|
|
4523
|
-
onClick: (e) => {
|
|
4524
|
-
e.stopPropagation();
|
|
4525
|
-
selection.toggle(company.id);
|
|
4526
|
-
},
|
|
4527
|
-
children: /* @__PURE__ */ jsx(
|
|
4528
|
-
Checkbox,
|
|
4529
|
-
{
|
|
4530
|
-
checked: selection.isSelected(company.id),
|
|
4531
|
-
onChange: () => selection.toggle(company.id),
|
|
4532
|
-
onClick: (e) => e.stopPropagation()
|
|
4533
|
-
}
|
|
4534
|
-
)
|
|
4535
|
-
}
|
|
4536
|
-
),
|
|
4537
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { fw: 500, children: company.name }) }),
|
|
4538
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: company.domain || "-" }) }),
|
|
4539
|
-
/* @__PURE__ */ jsx(Table.Td, { children: company.segment || "-" }),
|
|
4540
|
-
/* @__PURE__ */ jsx(Table.Td, { children: company.category || "-" }),
|
|
4541
|
-
/* @__PURE__ */ jsx(Table.Td, { children: company.numEmployees || "-" }),
|
|
4542
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { variant: "light", color: getEnrichmentColor(enrichStatus), size: "sm", children: enrichStatus }) }),
|
|
4543
|
-
/* @__PURE__ */ jsx(Table.Td, { children: company.contactCount })
|
|
4544
|
-
]
|
|
4545
|
-
},
|
|
4546
|
-
company.id
|
|
4547
|
-
);
|
|
4548
|
-
}) })
|
|
4549
|
-
] }),
|
|
4550
|
-
(pagedCompanies?.total ?? 0) > PAGE_SIZE_DEFAULT2 ? /* @__PURE__ */ jsx(Group, { justify: "center", children: /* @__PURE__ */ jsx(
|
|
4551
|
-
Pagination,
|
|
4552
|
-
{
|
|
4553
|
-
value: pagination.page,
|
|
4554
|
-
onChange: pagination.setPage,
|
|
4555
|
-
total: pagination.totalPages(pagedCompanies?.total ?? 0),
|
|
4556
|
-
size: "sm"
|
|
4557
|
-
}
|
|
4558
|
-
) }) : null
|
|
4559
|
-
] }) }),
|
|
4560
|
-
/* @__PURE__ */ jsx(CustomModal, { opened: showBatchDelete, onClose: () => setShowBatchDelete(false), size: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
4561
|
-
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
4562
|
-
/* @__PURE__ */ jsx(IconAlertTriangle, { size: 20, color: "var(--mantine-color-red-6)" }),
|
|
4563
|
-
/* @__PURE__ */ jsxs(Title, { order: 5, children: [
|
|
4564
|
-
"Delete ",
|
|
4565
|
-
selection.selectedCount,
|
|
4566
|
-
" companies?"
|
|
4567
|
-
] })
|
|
4568
|
-
] }),
|
|
4569
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "This will permanently delete the selected companies and cannot be undone." }),
|
|
4570
|
-
/* @__PURE__ */ jsxs(Group, { justify: "flex-end", gap: "sm", children: [
|
|
4571
|
-
/* @__PURE__ */ jsx(Button, { variant: "default", size: "sm", onClick: () => setShowBatchDelete(false), children: "Cancel" }),
|
|
4572
|
-
/* @__PURE__ */ jsx(Button, { color: "red", size: "sm", loading: deleteCompaniesMutation.isPending, onClick: handleBatchDelete, children: "Delete" })
|
|
4573
|
-
] })
|
|
4574
|
-
] }) })
|
|
4575
|
-
] }) });
|
|
4576
|
-
}
|
|
4577
|
-
var PAGE_SIZE_DEFAULT3 = 20;
|
|
4578
|
-
function LeadGenContactsPage() {
|
|
4579
|
-
const [contactSearch, setContactSearch] = useState("");
|
|
4580
|
-
const [statusFilter, setStatusFilter] = useState(null);
|
|
4581
|
-
const [listFilter, setListFilter] = useState(null);
|
|
4582
|
-
const [showBatchDelete, setShowBatchDelete] = useState(false);
|
|
4583
|
-
const navigate = useNavigate();
|
|
4584
|
-
const pagination = usePaginationState(PAGE_SIZE_DEFAULT3, [contactSearch, statusFilter, listFilter]);
|
|
4585
|
-
const { data: lists } = useLists();
|
|
4586
|
-
const {
|
|
4587
|
-
data: contacts,
|
|
4588
|
-
isLoading: contactsLoading,
|
|
4589
|
-
error: contactsError
|
|
4590
|
-
} = useContacts({
|
|
4591
|
-
search: contactSearch || void 0,
|
|
4592
|
-
contactStatus: statusFilter || void 0,
|
|
4593
|
-
listId: listFilter || void 0,
|
|
4594
|
-
limit: PAGE_SIZE_DEFAULT3,
|
|
4595
|
-
offset: pagination.offset
|
|
4596
|
-
});
|
|
4597
|
-
const deleteContactsMutation = useDeleteContacts();
|
|
4598
|
-
const contactRows = contacts?.data ?? [];
|
|
4599
|
-
const selection = useTableSelection(contactRows);
|
|
4600
|
-
useEffect(() => {
|
|
4601
|
-
if ((contacts?.total ?? 0) === 0) return;
|
|
4602
|
-
if (contactRows.length > 0 || pagination.page === 1) return;
|
|
4603
|
-
pagination.setPage(pagination.page - 1);
|
|
4604
|
-
}, [contactRows.length, contacts?.total, pagination.page, pagination.setPage]);
|
|
4605
|
-
function handleBatchDelete() {
|
|
4606
|
-
deleteContactsMutation.mutate([...selection.selectedIds], {
|
|
4607
|
-
onSuccess: () => {
|
|
4608
|
-
selection.clear();
|
|
4609
|
-
setShowBatchDelete(false);
|
|
4610
|
-
}
|
|
4611
|
-
});
|
|
4612
|
-
}
|
|
4613
|
-
return /* @__PURE__ */ jsx(SubshellContentContainer, { children: /* @__PURE__ */ jsxs(PageContainer, { children: [
|
|
4614
|
-
/* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(PageTitleCaption, { title: "Contacts", caption: "Contact records and outreach tracking" }) }),
|
|
4615
|
-
/* @__PURE__ */ jsx(Paper, { children: /* @__PURE__ */ jsxs(Stack, { children: [
|
|
4616
|
-
/* @__PURE__ */ jsxs(
|
|
4617
|
-
FilterBar,
|
|
4618
|
-
{
|
|
4619
|
-
actions: /* @__PURE__ */ jsx(
|
|
4620
|
-
TableSelectionToolbar,
|
|
4621
|
-
{
|
|
4622
|
-
selectedCount: selection.selectedCount,
|
|
4623
|
-
onDelete: () => setShowBatchDelete(true),
|
|
4624
|
-
isDeleting: deleteContactsMutation.isPending
|
|
4625
|
-
}
|
|
4626
|
-
),
|
|
4627
|
-
children: [
|
|
4628
|
-
/* @__PURE__ */ jsx(
|
|
4629
|
-
Select,
|
|
4630
|
-
{
|
|
4631
|
-
placeholder: "All Statuses",
|
|
4632
|
-
data: [
|
|
4633
|
-
{ value: "active", label: "Active" },
|
|
4634
|
-
{ value: "invalid", label: "Invalid" }
|
|
4635
|
-
],
|
|
4636
|
-
value: statusFilter,
|
|
4637
|
-
onChange: (value) => setStatusFilter(value),
|
|
4638
|
-
style: { minWidth: 160 },
|
|
4639
|
-
size: "sm",
|
|
4640
|
-
clearable: true
|
|
4641
|
-
}
|
|
4642
|
-
),
|
|
4643
|
-
/* @__PURE__ */ jsx(
|
|
4644
|
-
Select,
|
|
4645
|
-
{
|
|
4646
|
-
placeholder: "All Lists",
|
|
4647
|
-
data: (lists ?? []).map((list) => ({ value: list.id, label: list.name })),
|
|
4648
|
-
value: listFilter,
|
|
4649
|
-
onChange: (value) => setListFilter(value),
|
|
4650
|
-
style: { minWidth: 200 },
|
|
4651
|
-
size: "sm",
|
|
4652
|
-
clearable: true
|
|
4653
|
-
}
|
|
4654
|
-
),
|
|
4655
|
-
/* @__PURE__ */ jsx(
|
|
4656
|
-
TextInput,
|
|
4657
|
-
{
|
|
4658
|
-
placeholder: "Search by name or email...",
|
|
4659
|
-
leftSection: /* @__PURE__ */ jsx(IconSearch, { size: 16 }),
|
|
4660
|
-
style: { minWidth: 250 },
|
|
4661
|
-
size: "sm",
|
|
4662
|
-
value: contactSearch,
|
|
4663
|
-
onChange: (e) => setContactSearch(e.target.value)
|
|
4664
|
-
}
|
|
4665
|
-
)
|
|
4666
|
-
]
|
|
4667
|
-
}
|
|
4668
|
-
),
|
|
4669
|
-
contactsLoading ? /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) : contactsError ? /* @__PURE__ */ jsx(CenteredErrorState, { error: contactsError, title: "Failed to load contacts" }) : !contactRows.length ? /* @__PURE__ */ jsx(EmptyState, { icon: IconUsers, title: "No contacts yet", description: "Add one to get started." }) : /* @__PURE__ */ jsxs(Table, { children: [
|
|
4670
|
-
/* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
|
|
4671
|
-
/* @__PURE__ */ jsx(Table.Th, { w: 40, children: /* @__PURE__ */ jsx(
|
|
4672
|
-
Checkbox,
|
|
4673
|
-
{
|
|
4674
|
-
checked: selection.isPageAllSelected,
|
|
4675
|
-
indeterminate: selection.isPagePartiallySelected,
|
|
4676
|
-
onChange: selection.togglePage
|
|
4677
|
-
}
|
|
4678
|
-
) }),
|
|
4679
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Name" }),
|
|
4680
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Email" }),
|
|
4681
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Company" }),
|
|
4682
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Title" }),
|
|
4683
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Status" }),
|
|
4684
|
-
/* @__PURE__ */ jsx(Table.Th, { children: "Personalized" })
|
|
4685
|
-
] }) }),
|
|
4686
|
-
/* @__PURE__ */ jsx(Table.Tbody, { children: contactRows.map((contact) => {
|
|
4687
|
-
const fullName = [contact.firstName, contact.lastName].filter(Boolean).join(" ") || contact.email;
|
|
4688
|
-
const hasPersonalization = !!contact.openingLine;
|
|
4689
|
-
return /* @__PURE__ */ jsxs(
|
|
4690
|
-
Table.Tr,
|
|
4691
|
-
{
|
|
4692
|
-
style: { cursor: "pointer" },
|
|
4693
|
-
onClick: () => navigate({ to: "/crm/contacts/$contactId", params: { contactId: contact.id } }),
|
|
4694
|
-
children: [
|
|
4695
|
-
/* @__PURE__ */ jsx(
|
|
4696
|
-
Table.Td,
|
|
4697
|
-
{
|
|
4698
|
-
onClick: (e) => {
|
|
4699
|
-
e.stopPropagation();
|
|
4700
|
-
selection.toggle(contact.id);
|
|
4701
|
-
},
|
|
4702
|
-
children: /* @__PURE__ */ jsx(
|
|
4703
|
-
Checkbox,
|
|
4704
|
-
{
|
|
4705
|
-
checked: selection.isSelected(contact.id),
|
|
4706
|
-
onChange: () => selection.toggle(contact.id),
|
|
4707
|
-
onClick: (e) => e.stopPropagation()
|
|
4708
|
-
}
|
|
4709
|
-
)
|
|
4710
|
-
}
|
|
4711
|
-
),
|
|
4712
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { fw: 500, children: fullName }) }),
|
|
4713
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: contact.email }) }),
|
|
4714
|
-
/* @__PURE__ */ jsx(Table.Td, { children: contact.company?.name || "-" }),
|
|
4715
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: contact.title || "-" }) }),
|
|
4716
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { variant: "light", color: getStatusColor(contact.status), size: "sm", children: contact.status || "unknown" }) }),
|
|
4717
|
-
/* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { variant: "light", color: hasPersonalization ? "green" : "gray", size: "sm", children: hasPersonalization ? "Yes" : "No" }) })
|
|
4718
|
-
]
|
|
4719
|
-
},
|
|
4720
|
-
contact.id
|
|
4721
|
-
);
|
|
4722
|
-
}) })
|
|
4723
|
-
] }),
|
|
4724
|
-
(contacts?.total ?? 0) > PAGE_SIZE_DEFAULT3 ? /* @__PURE__ */ jsx(Group, { justify: "center", children: /* @__PURE__ */ jsx(
|
|
4725
|
-
Pagination,
|
|
4726
|
-
{
|
|
4727
|
-
value: pagination.page,
|
|
4728
|
-
onChange: pagination.setPage,
|
|
4729
|
-
total: pagination.totalPages(contacts?.total ?? 0),
|
|
4730
|
-
size: "sm"
|
|
4731
|
-
}
|
|
4732
|
-
) }) : null
|
|
4733
|
-
] }) }),
|
|
4734
|
-
/* @__PURE__ */ jsx(CustomModal, { opened: showBatchDelete, onClose: () => setShowBatchDelete(false), size: "sm", children: /* @__PURE__ */ jsxs(Stack, { gap: "md", children: [
|
|
4735
|
-
/* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
|
|
4736
|
-
/* @__PURE__ */ jsx(IconAlertTriangle, { size: 20, color: "var(--mantine-color-red-6)" }),
|
|
4737
|
-
/* @__PURE__ */ jsxs(Title, { order: 5, children: [
|
|
4738
|
-
"Delete ",
|
|
4739
|
-
selection.selectedCount,
|
|
4740
|
-
" contacts?"
|
|
4741
|
-
] })
|
|
4742
|
-
] }),
|
|
4743
|
-
/* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "This will permanently delete the selected contacts and cannot be undone." }),
|
|
4744
|
-
/* @__PURE__ */ jsxs(Group, { justify: "flex-end", gap: "sm", children: [
|
|
4745
|
-
/* @__PURE__ */ jsx(Button, { variant: "default", size: "sm", onClick: () => setShowBatchDelete(false), children: "Cancel" }),
|
|
4746
|
-
/* @__PURE__ */ jsx(Button, { color: "red", size: "sm", loading: deleteContactsMutation.isPending, onClick: handleBatchDelete, children: "Delete" })
|
|
4747
|
-
] })
|
|
4748
|
-
] }) })
|
|
4749
|
-
] }) });
|
|
4750
|
-
}
|
|
4751
|
-
|
|
4752
|
-
export { LEAD_GEN_ROUTE_LINKS, LeadGenCompaniesPage, LeadGenContactsPage, LeadGenListDetailPage, LeadGenListsPage, LeadGenOverviewPage, LeadGenRouteShell, LeadGenSidebar, LeadGenSidebarTop, ListBuilderIndexPage, ListBuilderPage, ORPHAN_STAGE_ORDER, RunWorkflowModal, StepConfigForm, TabSection, deriveBusinessProgress, formatDate, getEnrichmentColor, getEnrichmentStatus, getStateKeyColor, getStatusColor, getStepActionLabel, leadGenManifest, resolveBuildPlanSteps, resolveBuildState, sortStageKeys, useDeleteLists };
|