@aglyn/plugins-crm 1.0.0-beta.177 → 1.0.0-beta.179
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/package.json +13 -13
- package/src/lib/components/contact-detail-page.js +1 -0
- package/src/lib/components/contact-detail-page.js.map +1 -1
- package/src/lib/components/contact-properties-card.d.ts +6 -0
- package/src/lib/components/contact-properties-card.js +25 -2
- package/src/lib/components/contact-properties-card.js.map +1 -1
- package/src/lib/components/csv-import-drawer.d.ts +7 -0
- package/src/lib/components/csv-import-drawer.js +7 -0
- package/src/lib/components/csv-import-drawer.js.map +1 -1
- package/src/lib/components/fields-section.js +6 -0
- package/src/lib/components/fields-section.js.map +1 -1
- package/src/lib/components/lead-import-drawer.d.ts +3 -0
- package/src/lib/components/lead-import-drawer.js +29 -6
- package/src/lib/components/lead-import-drawer.js.map +1 -1
- package/src/lib/components/lead-properties-card.js +10 -12
- package/src/lib/components/lead-properties-card.js.map +1 -1
- package/src/lib/components/lead-source-select.d.ts +30 -0
- package/src/lib/components/lead-source-select.js +96 -0
- package/src/lib/components/lead-source-select.js.map +1 -0
- package/src/lib/components/lead-source-values-card.d.ts +27 -0
- package/src/lib/components/lead-source-values-card.js +606 -0
- package/src/lib/components/lead-source-values-card.js.map +1 -0
- package/src/lib/components/leads-section.js +100 -4
- package/src/lib/components/leads-section.js.map +1 -1
- package/src/lib/components/new-lead-drawer.js +27 -11
- package/src/lib/components/new-lead-drawer.js.map +1 -1
- package/src/lib/hooks/use-lead-source-picklist.d.ts +23 -0
- package/src/lib/hooks/use-lead-source-picklist.js +50 -0
- package/src/lib/hooks/use-lead-source-picklist.js.map +1 -0
- package/src/lib/model/contact-record.d.ts +2 -0
- package/src/lib/model/contact-record.js +2 -1
- package/src/lib/model/contact-record.js.map +1 -1
- package/src/lib/model/contact-update.d.ts +6 -0
- package/src/lib/model/contact-update.js +1 -0
- package/src/lib/model/contact-update.js.map +1 -1
- package/src/lib/model/crm-lead-import.d.ts +10 -2
- package/src/lib/model/crm-lead-import.js +19 -1
- package/src/lib/model/crm-lead-import.js.map +1 -1
- package/src/lib/model/lead-filters.d.ts +13 -0
- package/src/lib/model/lead-filters.js +17 -1
- package/src/lib/model/lead-filters.js.map +1 -1
- package/src/lib/model/lead-source-values.d.ts +82 -0
- package/src/lib/model/lead-source-values.js +149 -0
- package/src/lib/model/lead-source-values.js.map +1 -0
- package/src/lib/server/contact-update.js +25 -2
- package/src/lib/server/contact-update.js.map +1 -1
- package/src/lib/server/lead-create.js +19 -0
- package/src/lib/server/lead-create.js.map +1 -1
- package/src/lib/server/lead-source-picklist.d.ts +42 -0
- package/src/lib/server/lead-source-picklist.js +52 -0
- package/src/lib/server/lead-source-picklist.js.map +1 -0
- package/src/lib/server/lead-source-values.d.ts +50 -0
- package/src/lib/server/lead-source-values.js +187 -0
- package/src/lib/server/lead-source-values.js.map +1 -0
- package/src/lib/server/leads-import.js +31 -2
- package/src/lib/server/leads-import.js.map +1 -1
- package/src/lib/server.js +5 -0
- package/src/lib/server.js.map +1 -1
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
import { CRM_COLLECTIONS, CRM_LEAD_SOURCE_PICKLIST, CRM_LEAD_TEXT_MAX, crmPicklistActiveValues, newResourceScopeFields, ORG_SCOPE_TOKEN } from "@aglyn/aglyn";
|
|
20
|
+
import { mdiArrowDown, mdiArrowUp, mdiDeleteOutline, mdiDragVertical, mdiEyeOffOutline, mdiEyeOutline, mdiPencilOutline, mdiStarOutline } from "@aglyn/shared-data-mdi";
|
|
21
|
+
import { MdiIcon, SrOnly } from "@aglyn/shared-ui-jsx";
|
|
22
|
+
import RowActionsMenu from "@aglyn/shared-ui-jsx/components/row-actions-menu.component";
|
|
23
|
+
import { ScrollTable } from "@aglyn/shared-ui-jsx/components/scroll-table.component";
|
|
24
|
+
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
25
|
+
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
26
|
+
import { useFirestore, useUser, writeGuardedBySeed } from "@aglyn/tenant-feature-instance";
|
|
27
|
+
import { Button, Chip, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, IconButton, MenuItem, Stack, TableBody, TableCell, TableHead, TableRow, TextField, Typography } from "@mui/material";
|
|
28
|
+
import { doc, serverTimestamp, setDoc } from "firebase/firestore";
|
|
29
|
+
import { useCallback, useState } from "react";
|
|
30
|
+
import { useLeadSourcePicklist } from "../hooks/use-lead-source-picklist.js";
|
|
31
|
+
import { addPicklistValue, crmLeadSourceValuesRouteUrl, movePicklistValue, setPicklistDefault, setPicklistValueActive, sortPicklistValues } from "../model/lead-source-values.js";
|
|
32
|
+
import { crmTaskCallScope } from "../model/task-routes.js";
|
|
33
|
+
/**
|
|
34
|
+
* THE LEAD SOURCE VALUES (AGL-3298) — Salesforce's Lead Source picklist,
|
|
35
|
+
* managed where the org's lead fields are.
|
|
36
|
+
*
|
|
37
|
+
* Every move that touches only the LIST — add, reorder by drag or arrows,
|
|
38
|
+
* sort A–Z, activate, deactivate, default — is one client write of the
|
|
39
|
+
* whole document, guarded against a cached read like every seeded save on
|
|
40
|
+
* the Fields page. The two that change RECORDS — rename, and delete with a
|
|
41
|
+
* replacement — go to `crm/lead-source-values`, which rewrites the list and
|
|
42
|
+
* every lead and contact holding the old label together; see that route.
|
|
43
|
+
*
|
|
44
|
+
* An org that has never edited its list reads the starter set, and the
|
|
45
|
+
* first move here writes it down as the org's own.
|
|
46
|
+
*/ export function LeadSourceValuesCard(props) {
|
|
47
|
+
var _ref;
|
|
48
|
+
const { hostId, orgId, createHostId } = props;
|
|
49
|
+
const firestore = useFirestore();
|
|
50
|
+
const { data: user } = useUser();
|
|
51
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
52
|
+
const { picklist, stored, ready, fromCache } = useLeadSourcePicklist(orgId);
|
|
53
|
+
const [busy, setBusy] = useState(false);
|
|
54
|
+
const [nameDialog, setNameDialog] = useState(null);
|
|
55
|
+
const [draftName, setDraftName] = useState('');
|
|
56
|
+
const [nameError, setNameError] = useState('');
|
|
57
|
+
const [deleting, setDeleting] = useState(null);
|
|
58
|
+
const [replaceWith, setReplaceWith] = useState('');
|
|
59
|
+
const [dragFrom, setDragFrom] = useState(null);
|
|
60
|
+
/** Write the whole list — the list-only moves above. */ const save = useCallback(async (next, done)=>{
|
|
61
|
+
if (!orgId || busy) return;
|
|
62
|
+
setBusy(true);
|
|
63
|
+
try {
|
|
64
|
+
const verdict = await writeGuardedBySeed({
|
|
65
|
+
subject: 'lead source list',
|
|
66
|
+
fromCache
|
|
67
|
+
}, ()=>setDoc(doc(firestore, 'orgs', orgId, CRM_COLLECTIONS.picklists, CRM_LEAD_SOURCE_PICKLIST), _extends({
|
|
68
|
+
values: next.values,
|
|
69
|
+
defaultValueId: next.defaultValueId,
|
|
70
|
+
updatedAt: serverTimestamp()
|
|
71
|
+
}, stored ? {} : _extends({
|
|
72
|
+
hostId: createHostId,
|
|
73
|
+
createdAt: serverTimestamp()
|
|
74
|
+
}, newResourceScopeFields([
|
|
75
|
+
ORG_SCOPE_TOKEN
|
|
76
|
+
]))), {
|
|
77
|
+
merge: true
|
|
78
|
+
}));
|
|
79
|
+
if (!verdict.ok) {
|
|
80
|
+
enqueueSnackbar(verdict.message, {
|
|
81
|
+
variant: 'warning',
|
|
82
|
+
persist: false
|
|
83
|
+
});
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
enqueueSnackbar(done, {
|
|
87
|
+
variant: 'success',
|
|
88
|
+
persist: false
|
|
89
|
+
});
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error(error);
|
|
92
|
+
enqueueSnackbar('The lead sources could not be saved.', {
|
|
93
|
+
variant: 'error',
|
|
94
|
+
allowDuplicate: true
|
|
95
|
+
});
|
|
96
|
+
} finally{
|
|
97
|
+
setBusy(false);
|
|
98
|
+
}
|
|
99
|
+
}, [
|
|
100
|
+
orgId,
|
|
101
|
+
busy,
|
|
102
|
+
fromCache,
|
|
103
|
+
firestore,
|
|
104
|
+
stored,
|
|
105
|
+
createHostId,
|
|
106
|
+
enqueueSnackbar
|
|
107
|
+
]);
|
|
108
|
+
/** A rename or a delete — the moves that change records too. */ const post = useCallback(async (request)=>{
|
|
109
|
+
const scope = crmTaskCallScope(hostId, orgId);
|
|
110
|
+
if (!scope || busy) return null;
|
|
111
|
+
setBusy(true);
|
|
112
|
+
try {
|
|
113
|
+
const response = await authorizedFetch(user, crmLeadSourceValuesRouteUrl(), {
|
|
114
|
+
method: 'POST',
|
|
115
|
+
headers: {
|
|
116
|
+
'Content-Type': 'application/json'
|
|
117
|
+
},
|
|
118
|
+
body: JSON.stringify(_extends({}, request, scope))
|
|
119
|
+
});
|
|
120
|
+
const payload = await response.json().catch(()=>({}));
|
|
121
|
+
if (!response.ok) {
|
|
122
|
+
enqueueSnackbar(payload.error || 'The lead sources could not be saved.', {
|
|
123
|
+
variant: 'warning',
|
|
124
|
+
persist: false
|
|
125
|
+
});
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return payload;
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.error(error);
|
|
131
|
+
enqueueSnackbar('The lead sources could not be saved.', {
|
|
132
|
+
variant: 'error',
|
|
133
|
+
allowDuplicate: true
|
|
134
|
+
});
|
|
135
|
+
return null;
|
|
136
|
+
} finally{
|
|
137
|
+
setBusy(false);
|
|
138
|
+
}
|
|
139
|
+
}, [
|
|
140
|
+
hostId,
|
|
141
|
+
orgId,
|
|
142
|
+
busy,
|
|
143
|
+
user,
|
|
144
|
+
enqueueSnackbar
|
|
145
|
+
]);
|
|
146
|
+
const moved = (result)=>{
|
|
147
|
+
const records = result.leads + result.contacts;
|
|
148
|
+
return records ? ` — ${result.leads.toLocaleString()} lead${result.leads === 1 ? '' : 's'} and ` + `${result.contacts.toLocaleString()} contact${result.contacts === 1 ? '' : 's'} updated` : '';
|
|
149
|
+
};
|
|
150
|
+
const openAdd = ()=>{
|
|
151
|
+
setDraftName('');
|
|
152
|
+
setNameError('');
|
|
153
|
+
setNameDialog({
|
|
154
|
+
mode: 'add'
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
const openRename = (value)=>{
|
|
158
|
+
setDraftName(value.label);
|
|
159
|
+
setNameError('');
|
|
160
|
+
setNameDialog({
|
|
161
|
+
mode: 'rename',
|
|
162
|
+
value
|
|
163
|
+
});
|
|
164
|
+
};
|
|
165
|
+
const submitName = async ()=>{
|
|
166
|
+
if (!nameDialog) return;
|
|
167
|
+
if (nameDialog.mode === 'add') {
|
|
168
|
+
const move = addPicklistValue(picklist, draftName);
|
|
169
|
+
if (move.ok === false) return void setNameError(move.error);
|
|
170
|
+
setNameDialog(null);
|
|
171
|
+
await save(move.picklist, `“${draftName.trim()}” added`);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const result = await post({
|
|
175
|
+
action: 'rename',
|
|
176
|
+
valueId: nameDialog.value.id,
|
|
177
|
+
label: draftName
|
|
178
|
+
});
|
|
179
|
+
if (!result) return;
|
|
180
|
+
setNameDialog(null);
|
|
181
|
+
enqueueSnackbar(`Renamed${moved(result)}`, {
|
|
182
|
+
variant: 'success',
|
|
183
|
+
persist: false
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
const openDelete = (value)=>{
|
|
187
|
+
setReplaceWith('');
|
|
188
|
+
setDeleting(value);
|
|
189
|
+
};
|
|
190
|
+
const submitDelete = async ()=>{
|
|
191
|
+
if (!deleting) return;
|
|
192
|
+
const result = await post({
|
|
193
|
+
action: 'delete',
|
|
194
|
+
valueId: deleting.id,
|
|
195
|
+
replaceWith: replaceWith || null
|
|
196
|
+
});
|
|
197
|
+
if (!result) return;
|
|
198
|
+
setDeleting(null);
|
|
199
|
+
enqueueSnackbar(`“${deleting.label}” deleted${moved(result)}`, {
|
|
200
|
+
variant: 'success',
|
|
201
|
+
persist: false
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
const move = (from, to)=>void save(movePicklistValue(picklist, from, to), 'Order saved');
|
|
205
|
+
const rowActions = (value)=>{
|
|
206
|
+
const isDefault = picklist.defaultValueId === value.id;
|
|
207
|
+
return [
|
|
208
|
+
{
|
|
209
|
+
key: 'rename',
|
|
210
|
+
label: 'Rename',
|
|
211
|
+
icon: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
212
|
+
path: mdiPencilOutline.path,
|
|
213
|
+
size: 0.8
|
|
214
|
+
}),
|
|
215
|
+
disabled: busy,
|
|
216
|
+
onClick: ()=>openRename(value)
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
key: 'default',
|
|
220
|
+
label: isDefault ? 'Clear default' : 'Make default',
|
|
221
|
+
icon: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
222
|
+
path: mdiStarOutline.path,
|
|
223
|
+
size: 0.8
|
|
224
|
+
}),
|
|
225
|
+
disabled: busy || !isDefault && !value.active,
|
|
226
|
+
disabledReason: !value.active ? 'An inactive value cannot be the default' : undefined,
|
|
227
|
+
onClick: ()=>void save(setPicklistDefault(picklist, isDefault ? null : value.id), isDefault ? 'Default cleared' : `New leads start as “${value.label}”`)
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
key: 'active',
|
|
231
|
+
label: value.active ? 'Deactivate' : 'Activate',
|
|
232
|
+
icon: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
233
|
+
path: value.active ? mdiEyeOffOutline.path : mdiEyeOutline.path,
|
|
234
|
+
size: 0.8
|
|
235
|
+
}),
|
|
236
|
+
disabled: busy,
|
|
237
|
+
onClick: ()=>void save(setPicklistValueActive(picklist, value.id, !value.active), value.active ? `“${value.label}” deactivated` : `“${value.label}” activated`)
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
key: 'delete',
|
|
241
|
+
label: 'Delete…',
|
|
242
|
+
icon: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
243
|
+
path: mdiDeleteOutline.path,
|
|
244
|
+
size: 0.8
|
|
245
|
+
}),
|
|
246
|
+
destructive: true,
|
|
247
|
+
disabled: busy,
|
|
248
|
+
onClick: ()=>openDelete(value)
|
|
249
|
+
}
|
|
250
|
+
];
|
|
251
|
+
};
|
|
252
|
+
const replacements = crmPicklistActiveValues(picklist).filter((value)=>value.id !== (deleting == null ? void 0 : deleting.id));
|
|
253
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
254
|
+
spacing: 1.5,
|
|
255
|
+
children: [
|
|
256
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
257
|
+
direction: {
|
|
258
|
+
xs: 'column',
|
|
259
|
+
sm: 'row'
|
|
260
|
+
},
|
|
261
|
+
spacing: 1,
|
|
262
|
+
sx: {
|
|
263
|
+
justifyContent: 'space-between',
|
|
264
|
+
alignItems: {
|
|
265
|
+
sm: 'center'
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
children: [
|
|
269
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
270
|
+
spacing: 0.25,
|
|
271
|
+
children: [
|
|
272
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
273
|
+
variant: "subtitle1",
|
|
274
|
+
children: 'Lead source values'
|
|
275
|
+
}),
|
|
276
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
277
|
+
variant: "body2",
|
|
278
|
+
color: "text.secondary",
|
|
279
|
+
children: 'The choices in every lead’s Lead source select, in this order. ' + 'An import or an API write naming anything else is refused. ' + 'A deactivated value stays on the records that hold it.'
|
|
280
|
+
})
|
|
281
|
+
]
|
|
282
|
+
}),
|
|
283
|
+
orgId ? /*#__PURE__*/ _jsxs(Stack, {
|
|
284
|
+
direction: "row",
|
|
285
|
+
spacing: 1,
|
|
286
|
+
sx: {
|
|
287
|
+
flexShrink: 0
|
|
288
|
+
},
|
|
289
|
+
children: [
|
|
290
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
291
|
+
size: "small",
|
|
292
|
+
disabled: busy || picklist.values.length < 2,
|
|
293
|
+
onClick: ()=>void save(sortPicklistValues(picklist), 'Sorted A–Z'),
|
|
294
|
+
children: 'Sort A–Z'
|
|
295
|
+
}),
|
|
296
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
297
|
+
size: "small",
|
|
298
|
+
variant: "outlined",
|
|
299
|
+
disabled: busy,
|
|
300
|
+
onClick: openAdd,
|
|
301
|
+
children: 'Add value'
|
|
302
|
+
})
|
|
303
|
+
]
|
|
304
|
+
}) : null
|
|
305
|
+
]
|
|
306
|
+
}),
|
|
307
|
+
!ready ? null : /*#__PURE__*/ _jsxs(ScrollTable, {
|
|
308
|
+
size: "small",
|
|
309
|
+
"aria-label": "Lead source values",
|
|
310
|
+
children: [
|
|
311
|
+
/*#__PURE__*/ _jsx(TableHead, {
|
|
312
|
+
children: /*#__PURE__*/ _jsxs(TableRow, {
|
|
313
|
+
children: [
|
|
314
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
315
|
+
sx: {
|
|
316
|
+
width: 120
|
|
317
|
+
},
|
|
318
|
+
children: 'Order'
|
|
319
|
+
}),
|
|
320
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
321
|
+
children: 'Value'
|
|
322
|
+
}),
|
|
323
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
324
|
+
children: 'Status'
|
|
325
|
+
}),
|
|
326
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
327
|
+
align: "right"
|
|
328
|
+
})
|
|
329
|
+
]
|
|
330
|
+
})
|
|
331
|
+
}),
|
|
332
|
+
/*#__PURE__*/ _jsxs(TableBody, {
|
|
333
|
+
children: [
|
|
334
|
+
picklist.values.length === 0 ? /*#__PURE__*/ _jsx(TableRow, {
|
|
335
|
+
children: /*#__PURE__*/ _jsx(TableCell, {
|
|
336
|
+
colSpan: 4,
|
|
337
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
338
|
+
variant: "body2",
|
|
339
|
+
color: "text.secondary",
|
|
340
|
+
children: 'No values yet. Add one, and every lead can be given it.'
|
|
341
|
+
})
|
|
342
|
+
})
|
|
343
|
+
}) : null,
|
|
344
|
+
picklist.values.map((value, index)=>/*#__PURE__*/ _jsxs(TableRow, {
|
|
345
|
+
hover: true,
|
|
346
|
+
// Native drag and drop for a pointer; the arrows beside the
|
|
347
|
+
// handle are the same move for a keyboard or a touch screen.
|
|
348
|
+
draggable: !busy,
|
|
349
|
+
onDragStart: (event)=>{
|
|
350
|
+
setDragFrom(index);
|
|
351
|
+
event.dataTransfer.effectAllowed = 'move';
|
|
352
|
+
},
|
|
353
|
+
onDragOver: (event)=>{
|
|
354
|
+
if (dragFrom === null) return;
|
|
355
|
+
event.preventDefault();
|
|
356
|
+
event.dataTransfer.dropEffect = 'move';
|
|
357
|
+
},
|
|
358
|
+
onDrop: (event)=>{
|
|
359
|
+
event.preventDefault();
|
|
360
|
+
if (dragFrom !== null && dragFrom !== index) move(dragFrom, index);
|
|
361
|
+
setDragFrom(null);
|
|
362
|
+
},
|
|
363
|
+
onDragEnd: ()=>setDragFrom(null),
|
|
364
|
+
sx: _extends({}, value.active ? {} : {
|
|
365
|
+
opacity: 0.6
|
|
366
|
+
}, dragFrom === index ? {
|
|
367
|
+
outline: 1,
|
|
368
|
+
outlineColor: 'primary.main'
|
|
369
|
+
} : {}),
|
|
370
|
+
children: [
|
|
371
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
372
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
373
|
+
direction: "row",
|
|
374
|
+
spacing: 0,
|
|
375
|
+
sx: {
|
|
376
|
+
alignItems: 'center'
|
|
377
|
+
},
|
|
378
|
+
children: [
|
|
379
|
+
/*#__PURE__*/ _jsx(MdiIcon, {
|
|
380
|
+
path: mdiDragVertical.path,
|
|
381
|
+
size: 0.8,
|
|
382
|
+
style: {
|
|
383
|
+
cursor: busy ? 'default' : 'grab'
|
|
384
|
+
},
|
|
385
|
+
"aria-hidden": true
|
|
386
|
+
}),
|
|
387
|
+
/*#__PURE__*/ _jsxs(IconButton, {
|
|
388
|
+
size: "small",
|
|
389
|
+
disabled: index === 0 || busy,
|
|
390
|
+
onClick: ()=>move(index, index - 1),
|
|
391
|
+
children: [
|
|
392
|
+
/*#__PURE__*/ _jsx(MdiIcon, {
|
|
393
|
+
path: mdiArrowUp.path,
|
|
394
|
+
size: 0.7
|
|
395
|
+
}),
|
|
396
|
+
/*#__PURE__*/ _jsx(SrOnly, {
|
|
397
|
+
children: `Move ${value.label} up`
|
|
398
|
+
})
|
|
399
|
+
]
|
|
400
|
+
}),
|
|
401
|
+
/*#__PURE__*/ _jsxs(IconButton, {
|
|
402
|
+
size: "small",
|
|
403
|
+
disabled: index === picklist.values.length - 1 || busy,
|
|
404
|
+
onClick: ()=>move(index, index + 1),
|
|
405
|
+
children: [
|
|
406
|
+
/*#__PURE__*/ _jsx(MdiIcon, {
|
|
407
|
+
path: mdiArrowDown.path,
|
|
408
|
+
size: 0.7
|
|
409
|
+
}),
|
|
410
|
+
/*#__PURE__*/ _jsx(SrOnly, {
|
|
411
|
+
children: `Move ${value.label} down`
|
|
412
|
+
})
|
|
413
|
+
]
|
|
414
|
+
})
|
|
415
|
+
]
|
|
416
|
+
})
|
|
417
|
+
}),
|
|
418
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
419
|
+
children: /*#__PURE__*/ _jsx(Typography, {
|
|
420
|
+
variant: "body2",
|
|
421
|
+
children: value.label
|
|
422
|
+
})
|
|
423
|
+
}),
|
|
424
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
425
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
426
|
+
direction: "row",
|
|
427
|
+
spacing: 1,
|
|
428
|
+
sx: {
|
|
429
|
+
flexWrap: 'wrap',
|
|
430
|
+
alignItems: 'center'
|
|
431
|
+
},
|
|
432
|
+
children: [
|
|
433
|
+
value.active ? null : /*#__PURE__*/ _jsx(Chip, {
|
|
434
|
+
size: "small",
|
|
435
|
+
variant: "outlined",
|
|
436
|
+
color: "warning",
|
|
437
|
+
label: "Inactive"
|
|
438
|
+
}),
|
|
439
|
+
picklist.defaultValueId === value.id ? /*#__PURE__*/ _jsx(Chip, {
|
|
440
|
+
size: "small",
|
|
441
|
+
variant: "outlined",
|
|
442
|
+
color: "primary",
|
|
443
|
+
label: "Default"
|
|
444
|
+
}) : null,
|
|
445
|
+
value.active && picklist.defaultValueId !== value.id ? /*#__PURE__*/ _jsx(Typography, {
|
|
446
|
+
variant: "body2",
|
|
447
|
+
color: "text.secondary",
|
|
448
|
+
children: 'Active'
|
|
449
|
+
}) : null
|
|
450
|
+
]
|
|
451
|
+
})
|
|
452
|
+
}),
|
|
453
|
+
/*#__PURE__*/ _jsx(TableCell, {
|
|
454
|
+
align: "right",
|
|
455
|
+
sx: {
|
|
456
|
+
width: 56
|
|
457
|
+
},
|
|
458
|
+
children: /*#__PURE__*/ _jsx(RowActionsMenu, {
|
|
459
|
+
label: value.label,
|
|
460
|
+
items: rowActions(value)
|
|
461
|
+
})
|
|
462
|
+
})
|
|
463
|
+
]
|
|
464
|
+
}, value.id))
|
|
465
|
+
]
|
|
466
|
+
})
|
|
467
|
+
]
|
|
468
|
+
}),
|
|
469
|
+
ready && !stored ? /*#__PURE__*/ _jsx(Typography, {
|
|
470
|
+
variant: "caption",
|
|
471
|
+
color: "text.secondary",
|
|
472
|
+
children: 'This is the starter list. Your first change here makes it your organization’s own.'
|
|
473
|
+
}) : null,
|
|
474
|
+
/*#__PURE__*/ _jsxs(Dialog, {
|
|
475
|
+
open: nameDialog !== null,
|
|
476
|
+
onClose: ()=>setNameDialog(null),
|
|
477
|
+
fullWidth: true,
|
|
478
|
+
maxWidth: "xs",
|
|
479
|
+
children: [
|
|
480
|
+
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
481
|
+
children: (nameDialog == null ? void 0 : nameDialog.mode) === 'rename' ? `Rename “${nameDialog.value.label}”` : 'Add a lead source'
|
|
482
|
+
}),
|
|
483
|
+
/*#__PURE__*/ _jsx(DialogContent, {
|
|
484
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
485
|
+
spacing: 1.5,
|
|
486
|
+
sx: {
|
|
487
|
+
pt: 1
|
|
488
|
+
},
|
|
489
|
+
children: [
|
|
490
|
+
(nameDialog == null ? void 0 : nameDialog.mode) === 'rename' ? /*#__PURE__*/ _jsx(DialogContentText, {
|
|
491
|
+
variant: "body2",
|
|
492
|
+
children: 'Every lead and contact holding this value is updated to the new name.'
|
|
493
|
+
}) : null,
|
|
494
|
+
/*#__PURE__*/ _jsx(TextField, {
|
|
495
|
+
size: "small",
|
|
496
|
+
label: "Value",
|
|
497
|
+
value: draftName,
|
|
498
|
+
onChange: (event)=>{
|
|
499
|
+
setDraftName(event.target.value);
|
|
500
|
+
setNameError('');
|
|
501
|
+
},
|
|
502
|
+
onKeyDown: (event)=>{
|
|
503
|
+
if (event.key === 'Enter') void submitName();
|
|
504
|
+
},
|
|
505
|
+
error: Boolean(nameError),
|
|
506
|
+
helperText: nameError || ' ',
|
|
507
|
+
slotProps: {
|
|
508
|
+
htmlInput: {
|
|
509
|
+
maxLength: CRM_LEAD_TEXT_MAX
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
autoFocus: true,
|
|
513
|
+
fullWidth: true
|
|
514
|
+
})
|
|
515
|
+
]
|
|
516
|
+
})
|
|
517
|
+
}),
|
|
518
|
+
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
519
|
+
children: [
|
|
520
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
521
|
+
onClick: ()=>setNameDialog(null),
|
|
522
|
+
children: 'Cancel'
|
|
523
|
+
}),
|
|
524
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
525
|
+
variant: "contained",
|
|
526
|
+
disabled: busy || !draftName.trim(),
|
|
527
|
+
onClick: ()=>void submitName(),
|
|
528
|
+
children: (nameDialog == null ? void 0 : nameDialog.mode) === 'rename' ? 'Rename' : 'Add'
|
|
529
|
+
})
|
|
530
|
+
]
|
|
531
|
+
})
|
|
532
|
+
]
|
|
533
|
+
}),
|
|
534
|
+
/*#__PURE__*/ _jsxs(Dialog, {
|
|
535
|
+
open: deleting !== null,
|
|
536
|
+
onClose: ()=>setDeleting(null),
|
|
537
|
+
fullWidth: true,
|
|
538
|
+
maxWidth: "xs",
|
|
539
|
+
children: [
|
|
540
|
+
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
541
|
+
children: `Delete “${(_ref = deleting == null ? void 0 : deleting.label) != null ? _ref : ''}”?`
|
|
542
|
+
}),
|
|
543
|
+
/*#__PURE__*/ _jsx(DialogContent, {
|
|
544
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
545
|
+
spacing: 1.5,
|
|
546
|
+
sx: {
|
|
547
|
+
pt: 1
|
|
548
|
+
},
|
|
549
|
+
children: [
|
|
550
|
+
/*#__PURE__*/ _jsx(DialogContentText, {
|
|
551
|
+
variant: "body2",
|
|
552
|
+
children: 'The value leaves the list for good. Leads and contacts that hold it ' + 'are moved to the value you pick here, or cleared. To keep it on ' + 'those records instead, deactivate it.'
|
|
553
|
+
}),
|
|
554
|
+
/*#__PURE__*/ _jsxs(TextField, {
|
|
555
|
+
select: true,
|
|
556
|
+
size: "small",
|
|
557
|
+
label: "Replace it on existing records with",
|
|
558
|
+
value: replaceWith,
|
|
559
|
+
onChange: (event)=>setReplaceWith(String(event.target.value)),
|
|
560
|
+
fullWidth: true,
|
|
561
|
+
slotProps: {
|
|
562
|
+
select: {
|
|
563
|
+
displayEmpty: true
|
|
564
|
+
},
|
|
565
|
+
inputLabel: {
|
|
566
|
+
shrink: true
|
|
567
|
+
}
|
|
568
|
+
},
|
|
569
|
+
children: [
|
|
570
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
571
|
+
value: "",
|
|
572
|
+
children: 'None — clear it'
|
|
573
|
+
}),
|
|
574
|
+
replacements.map((value)=>/*#__PURE__*/ _jsx(MenuItem, {
|
|
575
|
+
value: value.label,
|
|
576
|
+
children: value.label
|
|
577
|
+
}, value.id))
|
|
578
|
+
]
|
|
579
|
+
})
|
|
580
|
+
]
|
|
581
|
+
})
|
|
582
|
+
}),
|
|
583
|
+
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
584
|
+
children: [
|
|
585
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
586
|
+
onClick: ()=>setDeleting(null),
|
|
587
|
+
children: 'Cancel'
|
|
588
|
+
}),
|
|
589
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
590
|
+
variant: "contained",
|
|
591
|
+
color: "error",
|
|
592
|
+
disabled: busy,
|
|
593
|
+
onClick: ()=>void submitDelete(),
|
|
594
|
+
children: 'Delete value'
|
|
595
|
+
})
|
|
596
|
+
]
|
|
597
|
+
})
|
|
598
|
+
]
|
|
599
|
+
})
|
|
600
|
+
]
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
LeadSourceValuesCard.displayName = 'LeadSourceValuesCard';
|
|
604
|
+
export default LeadSourceValuesCard;
|
|
605
|
+
|
|
606
|
+
//# sourceMappingURL=lead-source-values-card.js.map
|