@nivaro/react 0.3.145 → 0.3.146
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.
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsx as e, jsxs as r, Fragment as
|
|
2
|
-
import { useQueryClient as Je, useQuery as
|
|
3
|
-
import { Upload as
|
|
4
|
-
import { useState as g, useMemo as
|
|
5
|
-
import { useNivaroClient as te, useNavigation as
|
|
6
|
-
import { get as
|
|
7
|
-
import { errorSentence as ve, rowErrorSentence as
|
|
8
|
-
import { formatNumber as P, toLocalDateString as
|
|
9
|
-
import { DataTable as
|
|
1
|
+
import { jsx as e, jsxs as r, Fragment as ut } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as Je, useQuery as K, useMutation as Q } from "@tanstack/react-query";
|
|
3
|
+
import { Upload as ht, Plus as Ee, ArrowLeft as Le, FileUp as xt, Link2 as bt, Loader2 as Y, Sparkles as ft, X as gt, ArrowRight as We, MoreHorizontal as wt, Download as Ve, Trash2 as kt, Square as He, ChevronsUpDown as vt, Check as Nt } from "lucide-react";
|
|
4
|
+
import { useState as g, useMemo as j, useEffect as Z, useRef as Ie } from "react";
|
|
5
|
+
import { useNivaroClient as te, useNavigation as yt } from "../../context.js";
|
|
6
|
+
import { get as J, del as _t, post as z } from "../../lib/commands.js";
|
|
7
|
+
import { errorSentence as ve, rowErrorSentence as Ue } from "../../lib/error-message.js";
|
|
8
|
+
import { formatNumber as P, toLocalDateString as Ct, cn as y, formatRelative as St, formatDateTime as ne } from "../../lib/utils.js";
|
|
9
|
+
import { DataTable as $t } from "../DataTable.js";
|
|
10
10
|
import { ConfirmButton as qt } from "../profile/primitives.js";
|
|
11
11
|
import { Button as F } from "../ui/button.js";
|
|
12
|
-
import { Command as
|
|
13
|
-
import { DropdownMenu as
|
|
14
|
-
import { Input as
|
|
12
|
+
import { Command as Pt, CommandInput as Mt, CommandList as Tt, CommandEmpty as Dt, CommandGroup as At, CommandItem as Ot } from "../ui/command.js";
|
|
13
|
+
import { DropdownMenu as Rt, DropdownMenuTrigger as Ft, DropdownMenuContent as Et, DropdownMenuItem as de } from "../ui/dropdown-menu.js";
|
|
14
|
+
import { Input as ze } from "../ui/input.js";
|
|
15
15
|
import { Label as X } from "../ui/label.js";
|
|
16
|
-
import { Popover as
|
|
16
|
+
import { Popover as Lt, PopoverTrigger as It, PopoverContent as Ut } from "../ui/popover.js";
|
|
17
17
|
import { SimpleSelect as zt } from "../ui/SimpleSelect.js";
|
|
18
18
|
import { Sheet as Kt, SheetContent as Qt } from "../ui/sheet.js";
|
|
19
|
-
import { Switch as
|
|
20
|
-
import { Textarea as
|
|
21
|
-
import { ImportDuplicatesNotice as
|
|
22
|
-
import { collectionPickerOptions as Jt, fieldPickerOptions as
|
|
23
|
-
import { parseMatchFields as
|
|
24
|
-
import { useDownload as
|
|
19
|
+
import { Switch as Ge } from "../ui/switch.js";
|
|
20
|
+
import { Textarea as Bt } from "../ui/textarea.js";
|
|
21
|
+
import { ImportDuplicatesNotice as jt } from "./ImportDuplicatesNotice.js";
|
|
22
|
+
import { collectionPickerOptions as Jt, fieldPickerOptions as Ke } from "./import-picker-options.js";
|
|
23
|
+
import { parseMatchFields as Xe, matchFieldOptions as Wt, canStartImport as Vt, noMatchWarning as Ht } from "./match-fields.js";
|
|
24
|
+
import { useDownload as Ye } from "./RunDetailSheet.js";
|
|
25
25
|
const ge = 25, we = ["Source", "Map columns", "Options", "Confirm"], ee = {
|
|
26
26
|
pending: { dot: "bg-slate-400", text: "text-slate-600 dark:text-slate-300", label: "Pending" },
|
|
27
27
|
processing: {
|
|
@@ -40,10 +40,10 @@ const ge = 25, we = ["Source", "Map columns", "Options", "Confirm"], ee = {
|
|
|
40
40
|
text: "text-amber-700 dark:text-amber-400",
|
|
41
41
|
label: "Cancelled"
|
|
42
42
|
}
|
|
43
|
-
}, ke = /* @__PURE__ */ new Set(["pending", "processing"]),
|
|
44
|
-
function
|
|
43
|
+
}, ke = /* @__PURE__ */ new Set(["pending", "processing"]), Gt = "Stop this import? Rows already written stay — roll the import back afterwards to undo them.", Xt = "Roll back this import? Created rows are deleted (to trash) and overwritten rows restored to their prior values. One-shot.";
|
|
44
|
+
function Ze({
|
|
45
45
|
disabled: n,
|
|
46
|
-
question:
|
|
46
|
+
question: d,
|
|
47
47
|
confirmLabel: o,
|
|
48
48
|
onConfirm: p,
|
|
49
49
|
children: c
|
|
@@ -65,69 +65,69 @@ function Ye({
|
|
|
65
65
|
k(!1), p();
|
|
66
66
|
},
|
|
67
67
|
children: s ? /* @__PURE__ */ r("span", { className: "block", children: [
|
|
68
|
-
|
|
68
|
+
d,
|
|
69
69
|
/* @__PURE__ */ e("span", { className: "mt-1 block text-[11px] font-semibold", children: o })
|
|
70
70
|
] }) : c
|
|
71
71
|
}
|
|
72
72
|
);
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function Yt({
|
|
75
75
|
disabled: n,
|
|
76
|
-
rolledBack:
|
|
76
|
+
rolledBack: d,
|
|
77
77
|
onConfirm: o
|
|
78
78
|
}) {
|
|
79
79
|
return /* @__PURE__ */ e(
|
|
80
|
-
|
|
80
|
+
Ze,
|
|
81
81
|
{
|
|
82
82
|
disabled: n,
|
|
83
|
-
question:
|
|
83
|
+
question: Xt,
|
|
84
84
|
confirmLabel: "Choose again to roll back",
|
|
85
85
|
onConfirm: o,
|
|
86
|
-
children:
|
|
86
|
+
children: d ? "Rolled back" : "Roll back this import"
|
|
87
87
|
}
|
|
88
88
|
);
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function Zt({ onConfirm: n }) {
|
|
91
91
|
return /* @__PURE__ */ r(
|
|
92
|
-
|
|
92
|
+
Ze,
|
|
93
93
|
{
|
|
94
94
|
disabled: !1,
|
|
95
|
-
question:
|
|
95
|
+
question: Gt,
|
|
96
96
|
confirmLabel: "Choose again to stop",
|
|
97
97
|
onConfirm: n,
|
|
98
98
|
children: [
|
|
99
|
-
/* @__PURE__ */ e(
|
|
99
|
+
/* @__PURE__ */ e(He, { className: "h-3.5 w-3.5" }),
|
|
100
100
|
" Stop import"
|
|
101
101
|
]
|
|
102
102
|
}
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
|
-
function
|
|
106
|
-
const
|
|
107
|
-
return /* @__PURE__ */ r("span", { className: y("flex items-center gap-1.5 text-[12px] font-medium",
|
|
105
|
+
function et({ status: n }) {
|
|
106
|
+
const d = ee[n] ?? ee.pending;
|
|
107
|
+
return /* @__PURE__ */ r("span", { className: y("flex items-center gap-1.5 text-[12px] font-medium", d.text), children: [
|
|
108
108
|
/* @__PURE__ */ r("span", { className: "relative flex h-1.5 w-1.5 shrink-0", children: [
|
|
109
109
|
n === "processing" && /* @__PURE__ */ e(
|
|
110
110
|
"span",
|
|
111
111
|
{
|
|
112
112
|
className: y(
|
|
113
113
|
"absolute inline-flex h-full w-full rounded-full opacity-75 motion-safe:animate-ping",
|
|
114
|
-
|
|
114
|
+
d.dot
|
|
115
115
|
)
|
|
116
116
|
}
|
|
117
117
|
),
|
|
118
|
-
/* @__PURE__ */ e("span", { className: y("relative inline-flex h-1.5 w-1.5 rounded-full",
|
|
118
|
+
/* @__PURE__ */ e("span", { className: y("relative inline-flex h-1.5 w-1.5 rounded-full", d.dot) })
|
|
119
119
|
] }),
|
|
120
|
-
|
|
120
|
+
d.label
|
|
121
121
|
] });
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function er({
|
|
124
124
|
processed: n,
|
|
125
|
-
total:
|
|
125
|
+
total: d,
|
|
126
126
|
failed: o,
|
|
127
127
|
stopped: p
|
|
128
128
|
}) {
|
|
129
|
-
if (!
|
|
130
|
-
const c = Math.min(100, Math.round((n ?? 0) /
|
|
129
|
+
if (!d) return /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-300", children: "—" });
|
|
130
|
+
const c = Math.min(100, Math.round((n ?? 0) / d * 100));
|
|
131
131
|
return /* @__PURE__ */ r("div", { className: "flex min-w-[92px] items-center gap-2", children: [
|
|
132
132
|
/* @__PURE__ */ e("div", { className: "h-1.5 flex-1 overflow-hidden rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ e(
|
|
133
133
|
"div",
|
|
@@ -146,34 +146,34 @@ function Zt({
|
|
|
146
146
|
] });
|
|
147
147
|
}
|
|
148
148
|
function ie(n) {
|
|
149
|
-
const
|
|
149
|
+
const d = [];
|
|
150
150
|
let o = "", p = !1;
|
|
151
151
|
for (let c = 0; c < n.length; c++) {
|
|
152
152
|
const s = n[c];
|
|
153
|
-
p ? s === '"' && n[c + 1] === '"' ? (o += '"', c++) : s === '"' ? p = !1 : o += s : s === '"' ? p = !0 : s === "," ? (
|
|
153
|
+
p ? s === '"' && n[c + 1] === '"' ? (o += '"', c++) : s === '"' ? p = !1 : o += s : s === '"' ? p = !0 : s === "," ? (d.push(o), o = "") : o += s;
|
|
154
154
|
}
|
|
155
|
-
return
|
|
155
|
+
return d.push(o), d.map((c) => c.trim());
|
|
156
156
|
}
|
|
157
|
-
function
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
160
|
-
const o = ie(
|
|
161
|
-
return { headers: o, rows: p, rowCount: Math.max(0,
|
|
157
|
+
function tr(n) {
|
|
158
|
+
const d = n.split(/\r?\n/).filter((c) => c.trim());
|
|
159
|
+
if (d.length === 0) return { headers: [], rows: [], rowCount: 0 };
|
|
160
|
+
const o = ie(d[0]), p = d.slice(1, 6).map(ie);
|
|
161
|
+
return { headers: o, rows: p, rowCount: Math.max(0, d.length - 1) };
|
|
162
162
|
}
|
|
163
163
|
function se({
|
|
164
164
|
value: n,
|
|
165
|
-
onChange:
|
|
165
|
+
onChange: d,
|
|
166
166
|
options: o,
|
|
167
167
|
placeholder: p = "Select…",
|
|
168
168
|
className: c,
|
|
169
169
|
wide: s = !1
|
|
170
170
|
}) {
|
|
171
|
-
const [k, T] = g(!1), x = o.find((b) => b.value === n),
|
|
171
|
+
const [k, T] = g(!1), x = o.find((b) => b.value === n), S = [];
|
|
172
172
|
for (const b of o) {
|
|
173
|
-
const m =
|
|
174
|
-
m && m.name === b.group ? m.items.push(b) :
|
|
173
|
+
const m = S[S.length - 1];
|
|
174
|
+
m && m.name === b.group ? m.items.push(b) : S.push({ name: b.group, items: [b] });
|
|
175
175
|
}
|
|
176
|
-
return /* @__PURE__ */ r(
|
|
176
|
+
return /* @__PURE__ */ r(Lt, { open: k, onOpenChange: T, children: [
|
|
177
177
|
/* @__PURE__ */ e(It, { asChild: !0, children: /* @__PURE__ */ r(
|
|
178
178
|
"button",
|
|
179
179
|
{
|
|
@@ -194,25 +194,25 @@ function se({
|
|
|
194
194
|
children: (x == null ? void 0 : x.label) ?? p
|
|
195
195
|
}
|
|
196
196
|
),
|
|
197
|
-
/* @__PURE__ */ e(
|
|
197
|
+
/* @__PURE__ */ e(vt, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
198
198
|
]
|
|
199
199
|
}
|
|
200
200
|
) }),
|
|
201
|
-
/* @__PURE__ */ e(
|
|
202
|
-
/* @__PURE__ */ e(
|
|
203
|
-
/* @__PURE__ */ r(
|
|
204
|
-
/* @__PURE__ */ e(
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
/* @__PURE__ */ e(Ut, { className: y("p-0", s ? "w-[320px]" : "w-[260px]"), align: "start", children: /* @__PURE__ */ r(Pt, { children: [
|
|
202
|
+
/* @__PURE__ */ e(Mt, { placeholder: "Search by name…", className: "h-8 text-[12px]" }),
|
|
203
|
+
/* @__PURE__ */ r(Tt, { className: "max-h-[340px]", children: [
|
|
204
|
+
/* @__PURE__ */ e(Dt, { children: "Nothing matches." }),
|
|
205
|
+
S.map((b, m) => /* @__PURE__ */ e(At, { heading: b.name, children: b.items.map((h) => /* @__PURE__ */ r(
|
|
206
|
+
Ot,
|
|
207
207
|
{
|
|
208
208
|
value: `${h.label} ${h.hint ?? ""} ${h.value}`,
|
|
209
209
|
onSelect: () => {
|
|
210
|
-
|
|
210
|
+
d(h.value), T(!1);
|
|
211
211
|
},
|
|
212
212
|
className: "items-start text-[12.5px]",
|
|
213
213
|
children: [
|
|
214
214
|
/* @__PURE__ */ e(
|
|
215
|
-
|
|
215
|
+
Nt,
|
|
216
216
|
{
|
|
217
217
|
className: y(
|
|
218
218
|
"mt-0.5 h-3.5 w-3.5 shrink-0",
|
|
@@ -232,8 +232,8 @@ function se({
|
|
|
232
232
|
] }) })
|
|
233
233
|
] });
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
const
|
|
235
|
+
function rr({ confidence: n }) {
|
|
236
|
+
const d = Math.round(n * 100), o = d >= 80 ? "text-emerald-700 dark:text-emerald-400" : d >= 50 ? "text-amber-700 dark:text-amber-400" : "text-slate-500";
|
|
237
237
|
return /* @__PURE__ */ r(
|
|
238
238
|
"span",
|
|
239
239
|
{
|
|
@@ -241,72 +241,72 @@ function tr({ confidence: n }) {
|
|
|
241
241
|
title: "AI mapping confidence",
|
|
242
242
|
children: [
|
|
243
243
|
"AI ",
|
|
244
|
-
|
|
244
|
+
d,
|
|
245
245
|
"%"
|
|
246
246
|
]
|
|
247
247
|
}
|
|
248
248
|
);
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function Tr({
|
|
251
251
|
initialJobId: n,
|
|
252
|
-
onJobOpen:
|
|
252
|
+
onJobOpen: d
|
|
253
253
|
}) {
|
|
254
254
|
var V;
|
|
255
|
-
const o = te(), p = Je(), [c, s] = g("list"), [k, T] = g(n ?? null), [x,
|
|
255
|
+
const o = te(), p = Je(), [c, s] = g("list"), [k, T] = g(n ?? null), [x, S] = g("all"), [b, m] = g(1), [h, C] = g(null), i = K({
|
|
256
256
|
queryKey: ["collection-import-jobs"],
|
|
257
257
|
// The endpoint returns every job the caller may see, so the counters below
|
|
258
258
|
// are exact rather than page-scoped.
|
|
259
|
-
queryFn: () => o.request(
|
|
259
|
+
queryFn: () => o.request(J("/imports")),
|
|
260
260
|
refetchInterval: (a) => {
|
|
261
|
-
var
|
|
262
|
-
return (((
|
|
261
|
+
var q;
|
|
262
|
+
return (((q = a.state.data) == null ? void 0 : q.data) ?? []).some((I) => I.status === "pending" || I.status === "processing") ? 3e3 : !1;
|
|
263
263
|
},
|
|
264
264
|
placeholderData: (a) => a
|
|
265
|
-
}),
|
|
265
|
+
}), _ = j(() => {
|
|
266
266
|
var a;
|
|
267
|
-
return ((a =
|
|
268
|
-
}, [(V =
|
|
267
|
+
return ((a = i.data) == null ? void 0 : a.data) ?? [];
|
|
268
|
+
}, [(V = i.data) == null ? void 0 : V.data]), v = j(() => {
|
|
269
269
|
const a = {};
|
|
270
|
-
for (const
|
|
270
|
+
for (const q of _) a[q.status] = (a[q.status] ?? 0) + 1;
|
|
271
271
|
return a;
|
|
272
|
-
}, [
|
|
273
|
-
() =>
|
|
274
|
-
(a,
|
|
275
|
-
created: a.created + (
|
|
276
|
-
updated: a.updated + (
|
|
277
|
-
skipped: a.skipped + (
|
|
278
|
-
errors: a.errors + (
|
|
272
|
+
}, [_]), O = j(
|
|
273
|
+
() => _.reduce(
|
|
274
|
+
(a, q) => ({
|
|
275
|
+
created: a.created + (q.created_rows ?? 0),
|
|
276
|
+
updated: a.updated + (q.updated_rows ?? 0),
|
|
277
|
+
skipped: a.skipped + (q.skipped_rows ?? 0),
|
|
278
|
+
errors: a.errors + (q.error_rows ?? 0)
|
|
279
279
|
}),
|
|
280
280
|
{ created: 0, updated: 0, skipped: 0, errors: 0 }
|
|
281
281
|
),
|
|
282
|
-
[
|
|
283
|
-
), E = x === "all" ?
|
|
282
|
+
[_]
|
|
283
|
+
), E = x === "all" ? _ : _.filter((a) => a.status === x), re = E.slice((b - 1) * ge, b * ge);
|
|
284
284
|
Z(() => m(1), [x]);
|
|
285
|
-
const
|
|
286
|
-
mutationFn: (a) => o.request(
|
|
285
|
+
const U = Q({
|
|
286
|
+
mutationFn: (a) => o.request(_t(`/imports/${a}`)),
|
|
287
287
|
onSuccess: () => {
|
|
288
|
-
|
|
288
|
+
C(null), p.invalidateQueries({ queryKey: ["collection-import-jobs"] });
|
|
289
289
|
},
|
|
290
|
-
onError: (a) =>
|
|
291
|
-
}), ae =
|
|
292
|
-
mutationFn: (a) => o.request(
|
|
290
|
+
onError: (a) => C(a.message)
|
|
291
|
+
}), ae = Q({
|
|
292
|
+
mutationFn: (a) => o.request(z(`/imports/${a}/rollback`, {})),
|
|
293
293
|
onSuccess: () => {
|
|
294
|
-
|
|
294
|
+
C(null), p.invalidateQueries({ queryKey: ["collection-import-jobs"] });
|
|
295
295
|
},
|
|
296
|
-
onError: (a) =>
|
|
297
|
-
}),
|
|
296
|
+
onError: (a) => C(a.message)
|
|
297
|
+
}), $ = tt((a) => C(a ? ve(a) : null)), R = Ye();
|
|
298
298
|
Z(() => {
|
|
299
|
-
R.error &&
|
|
299
|
+
R.error && C(`Could not download the file: ${R.error}`);
|
|
300
300
|
}, [R.error]);
|
|
301
|
-
function
|
|
302
|
-
T(a),
|
|
301
|
+
function L(a) {
|
|
302
|
+
T(a), d == null || d(a);
|
|
303
303
|
}
|
|
304
304
|
const W = [
|
|
305
305
|
{
|
|
306
306
|
key: "status",
|
|
307
307
|
header: "Status",
|
|
308
308
|
className: "w-[110px]",
|
|
309
|
-
render: (a) => /* @__PURE__ */ e(
|
|
309
|
+
render: (a) => /* @__PURE__ */ e(et, { status: a.status })
|
|
310
310
|
},
|
|
311
311
|
{
|
|
312
312
|
key: "file_name",
|
|
@@ -332,7 +332,7 @@ function Mr({
|
|
|
332
332
|
header: "Progress",
|
|
333
333
|
className: "w-[130px]",
|
|
334
334
|
render: (a) => /* @__PURE__ */ e(
|
|
335
|
-
|
|
335
|
+
er,
|
|
336
336
|
{
|
|
337
337
|
processed: a.processed_rows,
|
|
338
338
|
total: a.total_rows,
|
|
@@ -378,7 +378,7 @@ function Mr({
|
|
|
378
378
|
{
|
|
379
379
|
className: "text-[12px] text-slate-500 dark:text-muted-foreground",
|
|
380
380
|
title: ne(a.created_at),
|
|
381
|
-
children:
|
|
381
|
+
children: St(a.created_at)
|
|
382
382
|
}
|
|
383
383
|
)
|
|
384
384
|
},
|
|
@@ -386,32 +386,32 @@ function Mr({
|
|
|
386
386
|
key: "__actions__",
|
|
387
387
|
header: "",
|
|
388
388
|
className: "w-[44px]",
|
|
389
|
-
render: (a) => /* @__PURE__ */ e("div", { onClick: (
|
|
390
|
-
/* @__PURE__ */ e(
|
|
389
|
+
render: (a) => /* @__PURE__ */ e("div", { onClick: (q) => q.stopPropagation(), onKeyDown: (q) => q.stopPropagation(), children: /* @__PURE__ */ r(Rt, { children: [
|
|
390
|
+
/* @__PURE__ */ e(Ft, { asChild: !0, children: /* @__PURE__ */ e(
|
|
391
391
|
"button",
|
|
392
392
|
{
|
|
393
393
|
type: "button",
|
|
394
394
|
className: "rounded p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
|
|
395
395
|
"aria-label": `Actions for ${a.file_name}`,
|
|
396
|
-
children: /* @__PURE__ */ e(
|
|
396
|
+
children: /* @__PURE__ */ e(wt, { className: "h-4 w-4" })
|
|
397
397
|
}
|
|
398
398
|
) }),
|
|
399
|
-
/* @__PURE__ */ r(
|
|
400
|
-
/* @__PURE__ */ e(de, { onSelect: () =>
|
|
401
|
-
ke.has(a.status) && /* @__PURE__ */ e(
|
|
399
|
+
/* @__PURE__ */ r(Et, { align: "end", className: "text-[12.5px]", children: [
|
|
400
|
+
/* @__PURE__ */ e(de, { onSelect: () => L(a.id), children: "View details" }),
|
|
401
|
+
ke.has(a.status) && /* @__PURE__ */ e(Zt, { onConfirm: () => $.mutate(a.id) }),
|
|
402
402
|
/* @__PURE__ */ r(
|
|
403
403
|
de,
|
|
404
404
|
{
|
|
405
405
|
disabled: !!R.busy,
|
|
406
406
|
onSelect: () => void R.download(`/imports/${a.id}/file`, a.file_name || "import.csv"),
|
|
407
407
|
children: [
|
|
408
|
-
/* @__PURE__ */ e(
|
|
408
|
+
/* @__PURE__ */ e(Ve, { className: "h-3.5 w-3.5" }),
|
|
409
409
|
" Download file"
|
|
410
410
|
]
|
|
411
411
|
}
|
|
412
412
|
),
|
|
413
413
|
/* @__PURE__ */ e(
|
|
414
|
-
|
|
414
|
+
Yt,
|
|
415
415
|
{
|
|
416
416
|
disabled: a.status !== "complete" && a.status !== "cancelled" || !!a.rolled_back_at,
|
|
417
417
|
rolledBack: !!a.rolled_back_at,
|
|
@@ -422,9 +422,9 @@ function Mr({
|
|
|
422
422
|
de,
|
|
423
423
|
{
|
|
424
424
|
disabled: ke.has(a.status),
|
|
425
|
-
onSelect: () =>
|
|
425
|
+
onSelect: () => U.mutate(a.id),
|
|
426
426
|
children: [
|
|
427
|
-
/* @__PURE__ */ e(
|
|
427
|
+
/* @__PURE__ */ e(kt, { className: "h-3.5 w-3.5" }),
|
|
428
428
|
" Delete job"
|
|
429
429
|
]
|
|
430
430
|
}
|
|
@@ -434,33 +434,33 @@ function Mr({
|
|
|
434
434
|
}
|
|
435
435
|
];
|
|
436
436
|
return c === "wizard" ? /* @__PURE__ */ e(
|
|
437
|
-
|
|
437
|
+
ar,
|
|
438
438
|
{
|
|
439
439
|
onCancel: () => s("list"),
|
|
440
440
|
onCreated: (a) => {
|
|
441
|
-
s("list"), p.invalidateQueries({ queryKey: ["collection-import-jobs"] }),
|
|
441
|
+
s("list"), p.invalidateQueries({ queryKey: ["collection-import-jobs"] }), L(a);
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
) : /* @__PURE__ */ r("div", { className: "flex min-h-0 flex-1 flex-col gap-3", children: [
|
|
445
445
|
h && /* @__PURE__ */ e("p", { className: "rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[12px] text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-400", children: h }),
|
|
446
446
|
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-stretch divide-x divide-slate-200 overflow-hidden rounded-lg border border-slate-200 bg-white dark:divide-border dark:border-border dark:bg-card", children: [
|
|
447
447
|
/* @__PURE__ */ e(
|
|
448
|
-
|
|
448
|
+
Qe,
|
|
449
449
|
{
|
|
450
450
|
label: "All",
|
|
451
|
-
count:
|
|
451
|
+
count: _.length,
|
|
452
452
|
active: x === "all",
|
|
453
|
-
onClick: () =>
|
|
453
|
+
onClick: () => S("all")
|
|
454
454
|
}
|
|
455
455
|
),
|
|
456
456
|
Object.keys(ee).map((a) => /* @__PURE__ */ e(
|
|
457
|
-
|
|
457
|
+
Qe,
|
|
458
458
|
{
|
|
459
459
|
label: ee[a].label,
|
|
460
460
|
dot: ee[a].dot,
|
|
461
461
|
count: v[a] ?? 0,
|
|
462
462
|
active: x === a,
|
|
463
|
-
onClick: () =>
|
|
463
|
+
onClick: () => S(x === a ? "all" : a)
|
|
464
464
|
},
|
|
465
465
|
a
|
|
466
466
|
)),
|
|
@@ -478,8 +478,8 @@ function Mr({
|
|
|
478
478
|
)
|
|
479
479
|
] })
|
|
480
480
|
] }),
|
|
481
|
-
|
|
482
|
-
/* @__PURE__ */ e(
|
|
481
|
+
_.length === 0 && !i.isLoading ? /* @__PURE__ */ e("div", { className: "rounded-lg border border-dashed border-slate-300 bg-white px-6 py-12 dark:border-border dark:bg-card", children: /* @__PURE__ */ r("div", { className: "max-w-[58ch]", children: [
|
|
482
|
+
/* @__PURE__ */ e(ht, { className: "h-5 w-5 text-slate-300" }),
|
|
483
483
|
/* @__PURE__ */ e("h3", { className: "mt-3 text-[15px] font-semibold text-slate-900 dark:text-foreground", children: "No collection imports yet" }),
|
|
484
484
|
/* @__PURE__ */ e("p", { className: "mt-1.5 text-[12.5px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: "This is the row-by-row importer: a CSV's columns are mapped onto a collection's fields, and each row is created or updated through the normal item API — so validation, hooks and permissions all apply. Use it when you want records, not a staging table." }),
|
|
485
485
|
/* @__PURE__ */ r(F, { size: "sm", className: "mt-4", onClick: () => s("wizard"), children: [
|
|
@@ -487,7 +487,7 @@ function Mr({
|
|
|
487
487
|
" Start an import"
|
|
488
488
|
] })
|
|
489
489
|
] }) }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ e(
|
|
490
|
-
|
|
490
|
+
$t,
|
|
491
491
|
{
|
|
492
492
|
columns: W,
|
|
493
493
|
rows: re,
|
|
@@ -496,8 +496,8 @@ function Mr({
|
|
|
496
496
|
page: b,
|
|
497
497
|
limit: ge,
|
|
498
498
|
onPageChange: m,
|
|
499
|
-
isLoading:
|
|
500
|
-
onRowClick: (a) =>
|
|
499
|
+
isLoading: i.isLoading,
|
|
500
|
+
onRowClick: (a) => L(a.id),
|
|
501
501
|
nowrapCells: !0,
|
|
502
502
|
minBodyHeight: 280,
|
|
503
503
|
emptyMessage: "No import jobs match this filter.",
|
|
@@ -508,13 +508,13 @@ function Mr({
|
|
|
508
508
|
] })
|
|
509
509
|
}
|
|
510
510
|
) }),
|
|
511
|
-
/* @__PURE__ */ e(
|
|
511
|
+
/* @__PURE__ */ e(lr, { jobId: k, onClose: () => L(null) })
|
|
512
512
|
] });
|
|
513
513
|
}
|
|
514
514
|
function le({ n }) {
|
|
515
515
|
return /* @__PURE__ */ e("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-600 dark:text-muted-foreground", children: P(n ?? 0) });
|
|
516
516
|
}
|
|
517
|
-
function oe({ label: n, value:
|
|
517
|
+
function oe({ label: n, value: d, tone: o }) {
|
|
518
518
|
return /* @__PURE__ */ r("div", { className: "px-3.5 py-2", children: [
|
|
519
519
|
/* @__PURE__ */ e("p", { className: "text-[10.5px] font-medium text-slate-400 dark:text-muted-foreground", children: n }),
|
|
520
520
|
/* @__PURE__ */ e(
|
|
@@ -524,14 +524,14 @@ function oe({ label: n, value: i, tone: o }) {
|
|
|
524
524
|
"mt-0.5 text-[15px] font-semibold leading-none tabular-nums",
|
|
525
525
|
o === "red" ? "text-red-600 dark:text-red-400" : "text-slate-900 dark:text-foreground"
|
|
526
526
|
),
|
|
527
|
-
children:
|
|
527
|
+
children: d
|
|
528
528
|
}
|
|
529
529
|
)
|
|
530
530
|
] });
|
|
531
531
|
}
|
|
532
|
-
function
|
|
532
|
+
function Qe({
|
|
533
533
|
label: n,
|
|
534
|
-
count:
|
|
534
|
+
count: d,
|
|
535
535
|
dot: o,
|
|
536
536
|
active: p,
|
|
537
537
|
onClick: c
|
|
@@ -545,105 +545,105 @@ function Ue({
|
|
|
545
545
|
className: y(
|
|
546
546
|
"flex items-center gap-1.5 px-3 py-2 transition-colors hover:bg-slate-50 dark:hover:bg-muted/40",
|
|
547
547
|
p && "bg-nvr-cyan/10 ring-1 ring-inset ring-nvr-cyan dark:bg-nvr-cyan/15",
|
|
548
|
-
!p &&
|
|
548
|
+
!p && d === 0 && "opacity-45"
|
|
549
549
|
),
|
|
550
550
|
children: [
|
|
551
551
|
o && /* @__PURE__ */ e("span", { className: y("h-1.5 w-1.5 shrink-0 rounded-full", o) }),
|
|
552
|
-
/* @__PURE__ */ e("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: P(
|
|
552
|
+
/* @__PURE__ */ e("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: P(d) }),
|
|
553
553
|
/* @__PURE__ */ e("span", { className: "text-[11px] font-medium leading-none text-slate-400 dark:text-muted-foreground", children: n })
|
|
554
554
|
]
|
|
555
555
|
}
|
|
556
556
|
);
|
|
557
557
|
}
|
|
558
|
-
function
|
|
558
|
+
function ar({
|
|
559
559
|
onCancel: n,
|
|
560
|
-
onCreated:
|
|
560
|
+
onCreated: d
|
|
561
561
|
}) {
|
|
562
562
|
var Me, Te, De, Ae;
|
|
563
|
-
const o = te(), p =
|
|
563
|
+
const o = te(), p = Ie(null), [c, s] = g(0), [k, T] = g(""), [x, S] = g({}), [b, m] = g(""), [h, C] = g(""), [i, _] = g(""), [v, O] = g({}), [E, re] = g({}), [U, ae] = g("skip"), [$, R] = g([]), [L, W] = g(!1);
|
|
564
564
|
Z(() => {
|
|
565
|
-
|
|
566
|
-
}, [
|
|
567
|
-
const [V, a] = g(!1), [
|
|
565
|
+
$.length > 0 && W(!1);
|
|
566
|
+
}, [$.length]);
|
|
567
|
+
const [V, a] = g(!1), [q, I] = g(null), [rt, ce] = g(!1), [at, st] = g(null), Ne = Ie(null), { headers: M, rows: ye, rowCount: me } = j(() => tr(k), [k]);
|
|
568
568
|
Z(() => {
|
|
569
|
-
if (!
|
|
570
|
-
const t = `${
|
|
571
|
-
Ne.current !== t && (Ne.current = t, o.request(
|
|
569
|
+
if (!i || M.length === 0) return;
|
|
570
|
+
const t = `${i}|${M.join("")}`;
|
|
571
|
+
Ne.current !== t && (Ne.current = t, o.request(z("/imports/mappings/lookup", { collection: i, headers: M })).then((l) => {
|
|
572
572
|
const u = l.data;
|
|
573
573
|
u && O((N) => {
|
|
574
574
|
if (Object.values(N).some((w) => w == null ? void 0 : w.trim())) return N;
|
|
575
575
|
const A = {};
|
|
576
576
|
for (const w of M) u.column_map[w] && (A[w] = u.column_map[w]);
|
|
577
577
|
if (Object.keys(A).length === 0) return N;
|
|
578
|
-
|
|
579
|
-
u.updated_at ? `Applied your saved mapping from ${
|
|
578
|
+
st(
|
|
579
|
+
u.updated_at ? `Applied your saved mapping from ${Ct(u.updated_at)}` : "Applied your saved mapping"
|
|
580
580
|
);
|
|
581
|
-
const D = u.match_fields ??
|
|
581
|
+
const D = u.match_fields ?? Xe(u.id_field);
|
|
582
582
|
return D.length > 0 && R((w) => w.length ? w : D), u.duplicate_strategy && ae((w) => w === "skip" && u.duplicate_strategy || w), A;
|
|
583
583
|
});
|
|
584
584
|
}).catch(() => {
|
|
585
585
|
}));
|
|
586
|
-
}, [
|
|
587
|
-
const _e =
|
|
586
|
+
}, [i, M, o]);
|
|
587
|
+
const _e = K({
|
|
588
588
|
queryKey: [
|
|
589
589
|
"import-diff-preview",
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
590
|
+
i,
|
|
591
|
+
$.join(","),
|
|
592
|
+
U,
|
|
593
593
|
k.length,
|
|
594
594
|
JSON.stringify(v)
|
|
595
595
|
],
|
|
596
596
|
queryFn: () => o.request(
|
|
597
|
-
|
|
598
|
-
collection:
|
|
597
|
+
z("/imports/preview", {
|
|
598
|
+
collection: i,
|
|
599
599
|
csv_data: k,
|
|
600
600
|
column_map: v,
|
|
601
|
-
match_fields:
|
|
602
|
-
duplicate_strategy:
|
|
601
|
+
match_fields: $,
|
|
602
|
+
duplicate_strategy: U
|
|
603
603
|
})
|
|
604
604
|
),
|
|
605
|
-
enabled: c === 3 && !!
|
|
605
|
+
enabled: c === 3 && !!i && !!k,
|
|
606
606
|
staleTime: 3e4,
|
|
607
607
|
retry: !1
|
|
608
|
-
}), f = (Me = _e.data) == null ? void 0 : Me.data,
|
|
608
|
+
}), f = (Me = _e.data) == null ? void 0 : Me.data, lt = K({
|
|
609
609
|
queryKey: ["import-collections"],
|
|
610
|
-
queryFn: () => o.request(
|
|
610
|
+
queryFn: () => o.request(J("/collections")),
|
|
611
611
|
staleTime: 6e4
|
|
612
|
-
}),
|
|
612
|
+
}), ot = K({
|
|
613
613
|
queryKey: ["import-collections-links"],
|
|
614
|
-
queryFn: () => o.request(
|
|
614
|
+
queryFn: () => o.request(J("/collections/overview-stats")).then(
|
|
615
615
|
(t) => new Set(
|
|
616
616
|
Object.entries(t.data ?? {}).filter(([, l]) => l == null ? void 0 : l.link).map(([l]) => l)
|
|
617
617
|
)
|
|
618
618
|
).catch(() => /* @__PURE__ */ new Set()),
|
|
619
619
|
staleTime: 5 * 6e4,
|
|
620
620
|
retry: !1
|
|
621
|
-
}),
|
|
622
|
-
((Te =
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
), pe =
|
|
626
|
-
queryKey: ["import-collection-meta",
|
|
621
|
+
}), nt = Jt(
|
|
622
|
+
((Te = lt.data) == null ? void 0 : Te.data) ?? [],
|
|
623
|
+
ot.data,
|
|
624
|
+
i
|
|
625
|
+
), pe = K({
|
|
626
|
+
queryKey: ["import-collection-meta", i],
|
|
627
627
|
queryFn: () => o.request(
|
|
628
|
-
|
|
628
|
+
J(`/collections/${i}`)
|
|
629
629
|
),
|
|
630
|
-
enabled: !!
|
|
630
|
+
enabled: !!i,
|
|
631
631
|
staleTime: 6e4
|
|
632
|
-
}), H =
|
|
632
|
+
}), H = Ke(((Ae = (De = pe.data) == null ? void 0 : De.data) == null ? void 0 : Ae.fields) ?? []), dt = H.map((t) => t.value), ue = j(
|
|
633
633
|
() => new Set(Object.values(v).filter((t) => t == null ? void 0 : t.trim())),
|
|
634
634
|
[v]
|
|
635
|
-
), Ce =
|
|
635
|
+
), Ce = Wt(H, ue);
|
|
636
636
|
Z(() => {
|
|
637
637
|
R((t) => {
|
|
638
638
|
const l = t.filter((u) => ue.has(u));
|
|
639
639
|
return l.length === t.length ? t : l;
|
|
640
640
|
});
|
|
641
641
|
}, [ue]);
|
|
642
|
-
const
|
|
642
|
+
const it = (t) => {
|
|
643
643
|
var l, u;
|
|
644
644
|
return t && !H.some((N) => N.value === t) ? [
|
|
645
645
|
...H,
|
|
646
|
-
...
|
|
646
|
+
...Ke(((u = (l = pe.data) == null ? void 0 : l.data) == null ? void 0 : u.fields) ?? [], t).filter(
|
|
647
647
|
(N) => N.value === t
|
|
648
648
|
)
|
|
649
649
|
] : H;
|
|
@@ -651,21 +651,21 @@ function rr({
|
|
|
651
651
|
var N, A, D;
|
|
652
652
|
const l = t ? (D = (A = (N = pe.data) == null ? void 0 : N.data) == null ? void 0 : A.fields) == null ? void 0 : D.find((w) => w.field === t) : void 0, u = `${[(l == null ? void 0 : l.special) ?? ""].flat().join(" ")} ${(l == null ? void 0 : l.interface) ?? ""}`.toLowerCase();
|
|
653
653
|
return /m2m|many-to-many/.test(u) ? "Links several: separate names (or ids) with commas" : /m2o|many-to-one/.test(u) ? "Matched by name or id" : null;
|
|
654
|
-
}, he =
|
|
654
|
+
}, he = Q({
|
|
655
655
|
mutationFn: (t) => o.request(
|
|
656
|
-
|
|
656
|
+
z("/imports/from-url", {
|
|
657
657
|
url: t,
|
|
658
658
|
preview: !0
|
|
659
659
|
})
|
|
660
660
|
),
|
|
661
661
|
onSuccess: (t) => {
|
|
662
|
-
|
|
662
|
+
I(null), T(t.data.csv_data), m(t.data.file_name);
|
|
663
663
|
},
|
|
664
|
-
onError: (t) =>
|
|
665
|
-
}), xe =
|
|
664
|
+
onError: (t) => I(t.message)
|
|
665
|
+
}), xe = Q({
|
|
666
666
|
mutationFn: () => o.request(
|
|
667
|
-
|
|
668
|
-
collection:
|
|
667
|
+
z("/ai/map-columns", {
|
|
668
|
+
collection: i,
|
|
669
669
|
columns: M,
|
|
670
670
|
sample_rows: ye.slice(0, 5)
|
|
671
671
|
})
|
|
@@ -675,60 +675,60 @@ function rr({
|
|
|
675
675
|
const l = ((A = t.data) == null ? void 0 : A.mappings) ?? t.mappings ?? [], u = { ...v }, N = {};
|
|
676
676
|
for (const D of l)
|
|
677
677
|
M.includes(D.column) && (u[D.column] = D.field ?? "", D.field && (N[D.column] = D.confidence ?? 0));
|
|
678
|
-
O(u), re(N),
|
|
678
|
+
O(u), re(N), I(null);
|
|
679
679
|
},
|
|
680
|
-
onError: (t) =>
|
|
680
|
+
onError: (t) => I(
|
|
681
681
|
t.status === 503 ? "AI mapping needs an Anthropic API key — add one in Settings, or map the columns by hand." : t.message
|
|
682
682
|
)
|
|
683
|
-
}), be =
|
|
683
|
+
}), be = Q({
|
|
684
684
|
mutationFn: () => o.request(
|
|
685
|
-
|
|
686
|
-
collection:
|
|
685
|
+
z("/imports", {
|
|
686
|
+
collection: i,
|
|
687
687
|
csv_data: k,
|
|
688
688
|
column_map: v,
|
|
689
689
|
transforms: Object.fromEntries(Object.entries(x).filter(([, t]) => t)),
|
|
690
|
-
duplicate_strategy:
|
|
691
|
-
match_fields:
|
|
690
|
+
duplicate_strategy: U,
|
|
691
|
+
match_fields: $,
|
|
692
692
|
// Sent only after the explicit "create every row" confirm (the server refuses
|
|
693
693
|
// overwrite / merge without match fields otherwise).
|
|
694
|
-
confirm_no_match:
|
|
694
|
+
confirm_no_match: $.length === 0 && L,
|
|
695
695
|
file_name: b || "import.csv",
|
|
696
696
|
through_items: V
|
|
697
697
|
})
|
|
698
698
|
),
|
|
699
|
-
onSuccess: (t) =>
|
|
700
|
-
onError: (t) =>
|
|
699
|
+
onSuccess: (t) => d(t.data.id),
|
|
700
|
+
onError: (t) => I(t.message)
|
|
701
701
|
});
|
|
702
|
-
function
|
|
702
|
+
function $e(t, l) {
|
|
703
703
|
O((u) => ({ ...u, [t]: l })), E[t] !== void 0 && re((u) => {
|
|
704
704
|
const N = { ...u };
|
|
705
705
|
return delete N[t], N;
|
|
706
706
|
});
|
|
707
707
|
}
|
|
708
|
-
async function
|
|
709
|
-
t && (
|
|
708
|
+
async function qe(t) {
|
|
709
|
+
t && (I(null), T(await t.text()), m(t.name));
|
|
710
710
|
}
|
|
711
|
-
const B =
|
|
711
|
+
const B = j(() => {
|
|
712
712
|
const t = k.split(/\r?\n/).filter((A) => A.trim());
|
|
713
713
|
if (t.length < 2) return {};
|
|
714
714
|
const l = ie(t[0]), u = t.slice(1, 2001).map(ie), N = {};
|
|
715
715
|
return l.forEach((A, D) => {
|
|
716
716
|
let w = 0, Oe = 0, Re = 0, Fe = 0;
|
|
717
|
-
for (const
|
|
718
|
-
const G = (
|
|
717
|
+
for (const pt of u) {
|
|
718
|
+
const G = (pt[D] ?? "").trim();
|
|
719
719
|
G && (w++, /^-?\$?[\d,]+(\.\d+)?$/.test(G) ? Oe++ : /^\d{4}-\d{2}-\d{2}/.test(G) || /^\d{1,2}\/\d{1,2}\/\d{2,4}$/.test(G) ? Re++ : /^(true|false|yes|no|y|n)$/i.test(G) && Fe++);
|
|
720
720
|
}
|
|
721
|
-
const
|
|
722
|
-
N[A] = { fill: Math.round(w / u.length * 100), guess:
|
|
721
|
+
const mt = w === 0 ? "empty" : Oe / w > 0.9 ? "number" : Re / w > 0.9 ? "date" : Fe / w > 0.9 ? "boolean" : "text";
|
|
722
|
+
N[A] = { fill: Math.round(w / u.length * 100), guess: mt };
|
|
723
723
|
}), N;
|
|
724
724
|
}, [k]), fe = M.filter((t) => {
|
|
725
725
|
var l;
|
|
726
726
|
return (l = v[t]) == null ? void 0 : l.trim();
|
|
727
|
-
}).length, Pe =
|
|
727
|
+
}).length, Pe = at, ct = c === 0 ? M.length > 0 : c === 1 ? !!i && fe > 0 : !0;
|
|
728
728
|
return /* @__PURE__ */ r("div", { className: "flex min-h-0 flex-1 flex-col gap-4", children: [
|
|
729
729
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
|
|
730
730
|
/* @__PURE__ */ r(F, { variant: "ghost", size: "sm", className: "h-7 px-2", onClick: n, children: [
|
|
731
|
-
/* @__PURE__ */ e(
|
|
731
|
+
/* @__PURE__ */ e(Le, { className: "h-3.5 w-3.5" }),
|
|
732
732
|
" Back to jobs"
|
|
733
733
|
] }),
|
|
734
734
|
/* @__PURE__ */ e("ol", { className: "flex items-center gap-1.5", children: we.map((t, l) => /* @__PURE__ */ r("li", { className: "flex items-center gap-1.5", children: [
|
|
@@ -762,7 +762,7 @@ function rr({
|
|
|
762
762
|
className: "hidden",
|
|
763
763
|
onChange: (t) => {
|
|
764
764
|
var l;
|
|
765
|
-
|
|
765
|
+
qe(((l = t.target.files) == null ? void 0 : l[0]) ?? null), t.target.value = "";
|
|
766
766
|
}
|
|
767
767
|
}
|
|
768
768
|
),
|
|
@@ -781,14 +781,14 @@ function rr({
|
|
|
781
781
|
onDragLeave: () => ce(!1),
|
|
782
782
|
onDrop: (t) => {
|
|
783
783
|
var l;
|
|
784
|
-
t.preventDefault(), ce(!1),
|
|
784
|
+
t.preventDefault(), ce(!1), qe(((l = t.dataTransfer.files) == null ? void 0 : l[0]) ?? null);
|
|
785
785
|
},
|
|
786
786
|
className: y(
|
|
787
787
|
"flex flex-col items-center justify-center gap-1.5 rounded-md border border-dashed px-4 py-8 transition-colors",
|
|
788
|
-
|
|
788
|
+
rt ? "border-nvr-cyan bg-nvr-cyan/10" : "border-slate-300 hover:border-slate-400 hover:bg-slate-50 dark:border-border dark:hover:bg-muted/30"
|
|
789
789
|
),
|
|
790
790
|
children: [
|
|
791
|
-
/* @__PURE__ */ e(
|
|
791
|
+
/* @__PURE__ */ e(xt, { className: "h-4 w-4 text-slate-400" }),
|
|
792
792
|
/* @__PURE__ */ e("span", { className: "text-[12.5px] font-medium text-slate-700 dark:text-foreground", children: "Drop a CSV, or click to choose" }),
|
|
793
793
|
b && /* @__PURE__ */ e("span", { className: "font-mono text-[11px] text-slate-500", children: b })
|
|
794
794
|
]
|
|
@@ -796,7 +796,7 @@ function rr({
|
|
|
796
796
|
),
|
|
797
797
|
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
798
798
|
/* @__PURE__ */ r(X, { className: "flex items-center gap-1.5 text-[11.5px]", children: [
|
|
799
|
-
/* @__PURE__ */ e(
|
|
799
|
+
/* @__PURE__ */ e(bt, { className: "h-3.5 w-3.5 text-slate-400" }),
|
|
800
800
|
" Or fetch from a URL"
|
|
801
801
|
] }),
|
|
802
802
|
/* @__PURE__ */ r(
|
|
@@ -808,10 +808,10 @@ function rr({
|
|
|
808
808
|
},
|
|
809
809
|
children: [
|
|
810
810
|
/* @__PURE__ */ e(
|
|
811
|
-
|
|
811
|
+
ze,
|
|
812
812
|
{
|
|
813
813
|
value: h,
|
|
814
|
-
onChange: (t) =>
|
|
814
|
+
onChange: (t) => C(t.target.value),
|
|
815
815
|
placeholder: "https://example.com/data.csv",
|
|
816
816
|
className: "h-8 font-mono text-[12px]"
|
|
817
817
|
}
|
|
@@ -836,7 +836,7 @@ function rr({
|
|
|
836
836
|
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
837
837
|
/* @__PURE__ */ e(X, { className: "text-[11.5px]", children: "Or paste the rows" }),
|
|
838
838
|
/* @__PURE__ */ e(
|
|
839
|
-
|
|
839
|
+
Bt,
|
|
840
840
|
{
|
|
841
841
|
value: k,
|
|
842
842
|
onChange: (t) => {
|
|
@@ -860,7 +860,7 @@ val1,val2,val3`,
|
|
|
860
860
|
" ",
|
|
861
861
|
"columns"
|
|
862
862
|
] }),
|
|
863
|
-
/* @__PURE__ */ e(
|
|
863
|
+
/* @__PURE__ */ e(sr, { headers: M, rows: ye })
|
|
864
864
|
] })
|
|
865
865
|
] }),
|
|
866
866
|
c === 1 && // Bounded width: a mapping row is a form field, and stretching the
|
|
@@ -873,9 +873,9 @@ val1,val2,val3`,
|
|
|
873
873
|
/* @__PURE__ */ e("div", { className: "w-[260px]", children: /* @__PURE__ */ e(
|
|
874
874
|
se,
|
|
875
875
|
{
|
|
876
|
-
value:
|
|
877
|
-
onChange:
|
|
878
|
-
options:
|
|
876
|
+
value: i,
|
|
877
|
+
onChange: _,
|
|
878
|
+
options: nt,
|
|
879
879
|
placeholder: "Choose a collection…",
|
|
880
880
|
wide: !0
|
|
881
881
|
}
|
|
@@ -888,10 +888,10 @@ val1,val2,val3`,
|
|
|
888
888
|
variant: "outline",
|
|
889
889
|
size: "sm",
|
|
890
890
|
className: "h-8",
|
|
891
|
-
disabled: !
|
|
891
|
+
disabled: !i || M.length === 0 || xe.isPending,
|
|
892
892
|
onClick: () => xe.mutate(),
|
|
893
893
|
children: [
|
|
894
|
-
xe.isPending ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(
|
|
894
|
+
xe.isPending ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(ft, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
|
|
895
895
|
"Match columns with AI"
|
|
896
896
|
]
|
|
897
897
|
}
|
|
@@ -928,32 +928,32 @@ val1,val2,val3`,
|
|
|
928
928
|
] }),
|
|
929
929
|
/* @__PURE__ */ r("td", { className: "px-3 py-1.5", children: [
|
|
930
930
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
931
|
-
/* @__PURE__ */ e("div", { className: "w-[220px]", children:
|
|
931
|
+
/* @__PURE__ */ e("div", { className: "w-[220px]", children: dt.length > 0 ? /* @__PURE__ */ e(
|
|
932
932
|
se,
|
|
933
933
|
{
|
|
934
934
|
value: v[t] ?? "",
|
|
935
|
-
onChange: (l) =>
|
|
935
|
+
onChange: (l) => $e(t, l),
|
|
936
936
|
options: [
|
|
937
937
|
{ value: "", label: "Skip this column" },
|
|
938
|
-
...
|
|
938
|
+
...it(v[t])
|
|
939
939
|
],
|
|
940
940
|
placeholder: "Skip this column"
|
|
941
941
|
}
|
|
942
942
|
) : /* @__PURE__ */ e(
|
|
943
|
-
|
|
943
|
+
ze,
|
|
944
944
|
{
|
|
945
945
|
value: v[t] ?? "",
|
|
946
|
-
onChange: (l) =>
|
|
946
|
+
onChange: (l) => $e(t, l.target.value),
|
|
947
947
|
placeholder: "field_name",
|
|
948
948
|
className: "h-8 font-mono text-[12px]"
|
|
949
949
|
}
|
|
950
950
|
) }),
|
|
951
|
-
E[t] !== void 0 && v[t] && /* @__PURE__ */ e(
|
|
951
|
+
E[t] !== void 0 && v[t] && /* @__PURE__ */ e(rr, { confidence: E[t] }),
|
|
952
952
|
v[t] && /* @__PURE__ */ e("div", { className: "w-[120px]", children: /* @__PURE__ */ e(
|
|
953
953
|
se,
|
|
954
954
|
{
|
|
955
955
|
value: x[t] ?? "",
|
|
956
|
-
onChange: (l) =>
|
|
956
|
+
onChange: (l) => S((u) => ({ ...u, [t]: l })),
|
|
957
957
|
options: [
|
|
958
958
|
{ value: "", label: "As-is" },
|
|
959
959
|
{ value: "trim", label: "Trim" },
|
|
@@ -987,7 +987,7 @@ val1,val2,val3`,
|
|
|
987
987
|
/* @__PURE__ */ e(
|
|
988
988
|
zt,
|
|
989
989
|
{
|
|
990
|
-
value:
|
|
990
|
+
value: U,
|
|
991
991
|
onChange: ae,
|
|
992
992
|
options: [
|
|
993
993
|
{ value: "skip", label: "Skip — leave the existing record alone" },
|
|
@@ -1000,7 +1000,7 @@ val1,val2,val3`,
|
|
|
1000
1000
|
] }),
|
|
1001
1001
|
/* @__PURE__ */ r("div", { className: "flex items-start gap-2.5 rounded-md border border-slate-200 bg-white px-3 py-2 dark:border-border dark:bg-card", children: [
|
|
1002
1002
|
/* @__PURE__ */ e(
|
|
1003
|
-
|
|
1003
|
+
Ge,
|
|
1004
1004
|
{
|
|
1005
1005
|
id: "csv-through-items",
|
|
1006
1006
|
checked: V,
|
|
@@ -1016,7 +1016,7 @@ val1,val2,val3`,
|
|
|
1016
1016
|
] }),
|
|
1017
1017
|
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
1018
1018
|
/* @__PURE__ */ e(X, { className: "text-[11.5px]", children: "Match records on" }),
|
|
1019
|
-
|
|
1019
|
+
$.length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", "data-csv-match-fields": !0, children: $.map((t) => {
|
|
1020
1020
|
var l;
|
|
1021
1021
|
return /* @__PURE__ */ r(
|
|
1022
1022
|
"span",
|
|
@@ -1031,7 +1031,7 @@ val1,val2,val3`,
|
|
|
1031
1031
|
className: "rounded p-0.5 text-slate-400 hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted dark:hover:text-foreground",
|
|
1032
1032
|
"aria-label": `Stop matching on ${t}`,
|
|
1033
1033
|
onClick: () => R((u) => u.filter((N) => N !== t)),
|
|
1034
|
-
children: /* @__PURE__ */ e(
|
|
1034
|
+
children: /* @__PURE__ */ e(gt, { className: "h-3 w-3" })
|
|
1035
1035
|
}
|
|
1036
1036
|
)
|
|
1037
1037
|
]
|
|
@@ -1046,8 +1046,8 @@ val1,val2,val3`,
|
|
|
1046
1046
|
onChange: (t) => {
|
|
1047
1047
|
t && R((l) => l.includes(t) ? l : [...l, t]);
|
|
1048
1048
|
},
|
|
1049
|
-
options: Ce.filter((t) =>
|
|
1050
|
-
placeholder:
|
|
1049
|
+
options: Ce.filter((t) => !$.includes(t.value)),
|
|
1050
|
+
placeholder: $.length ? "Add another match field…" : "Pick a match field…",
|
|
1051
1051
|
className: "w-[260px]"
|
|
1052
1052
|
}
|
|
1053
1053
|
),
|
|
@@ -1055,8 +1055,8 @@ val1,val2,val3`,
|
|
|
1055
1055
|
/* @__PURE__ */ e(
|
|
1056
1056
|
Be,
|
|
1057
1057
|
{
|
|
1058
|
-
matchFields:
|
|
1059
|
-
confirmed:
|
|
1058
|
+
matchFields: $,
|
|
1059
|
+
confirmed: L,
|
|
1060
1060
|
onConfirm: W
|
|
1061
1061
|
}
|
|
1062
1062
|
)
|
|
@@ -1066,8 +1066,8 @@ val1,val2,val3`,
|
|
|
1066
1066
|
/* @__PURE__ */ e(
|
|
1067
1067
|
Be,
|
|
1068
1068
|
{
|
|
1069
|
-
matchFields:
|
|
1070
|
-
confirmed:
|
|
1069
|
+
matchFields: $,
|
|
1070
|
+
confirmed: L,
|
|
1071
1071
|
onConfirm: W
|
|
1072
1072
|
}
|
|
1073
1073
|
),
|
|
@@ -1161,7 +1161,7 @@ val1,val2,val3`,
|
|
|
1161
1161
|
`${t.row}-${t.id}`
|
|
1162
1162
|
)) }),
|
|
1163
1163
|
f.conflicts > 0 && /* @__PURE__ */ e("p", { className: "text-[11.5px] text-red-600 dark:text-red-400", children: "Conflicts need a look before you start — they are rows the import will silently drop or resolve by last-write-wins." }),
|
|
1164
|
-
f.duplicates && /* @__PURE__ */ e(
|
|
1164
|
+
f.duplicates && /* @__PURE__ */ e(jt, { dup: f.duplicates }),
|
|
1165
1165
|
(f.value_error_rows ?? 0) > 0 && /* @__PURE__ */ r("div", { className: "rounded-md border border-red-200 bg-red-50 px-3 py-2 dark:border-red-500/30 dark:bg-red-500/10", children: [
|
|
1166
1166
|
/* @__PURE__ */ r("p", { className: "text-[12px] font-medium text-red-700 dark:text-red-300", children: [
|
|
1167
1167
|
P(f.value_error_rows ?? 0),
|
|
@@ -1203,17 +1203,17 @@ val1,val2,val3`,
|
|
|
1203
1203
|
] }),
|
|
1204
1204
|
/* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: [
|
|
1205
1205
|
{ label: "File", value: b || "pasted.csv", mono: !0 },
|
|
1206
|
-
{ label: "Collection", value:
|
|
1206
|
+
{ label: "Collection", value: i, mono: !0 },
|
|
1207
1207
|
{ label: "Data rows", value: P(me) },
|
|
1208
1208
|
{ label: "Mapped columns", value: `${fe} of ${M.length}` },
|
|
1209
1209
|
{
|
|
1210
1210
|
label: "Duplicates",
|
|
1211
|
-
value:
|
|
1211
|
+
value: U === "skip" ? "Skipped" : U === "overwrite" ? "Overwritten" : "Merged"
|
|
1212
1212
|
},
|
|
1213
1213
|
{
|
|
1214
1214
|
label: "Matched on",
|
|
1215
|
-
value:
|
|
1216
|
-
mono:
|
|
1215
|
+
value: $.join(" + ") || "nothing — every row is new",
|
|
1216
|
+
mono: $.length > 0
|
|
1217
1217
|
}
|
|
1218
1218
|
].map((t) => /* @__PURE__ */ r(
|
|
1219
1219
|
"div",
|
|
@@ -1240,7 +1240,7 @@ val1,val2,val3`,
|
|
|
1240
1240
|
P(me),
|
|
1241
1241
|
" rows into",
|
|
1242
1242
|
" ",
|
|
1243
|
-
/* @__PURE__ */ e("span", { className: "font-mono text-slate-700 dark:text-foreground", children:
|
|
1243
|
+
/* @__PURE__ */ e("span", { className: "font-mono text-slate-700 dark:text-foreground", children: i }),
|
|
1244
1244
|
" ",
|
|
1245
1245
|
"one at a time. Progress appears in the job list as it runs."
|
|
1246
1246
|
] })
|
|
@@ -1248,22 +1248,22 @@ val1,val2,val3`,
|
|
|
1248
1248
|
] }),
|
|
1249
1249
|
/* @__PURE__ */ r("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
1250
1250
|
c > 0 && /* @__PURE__ */ r(F, { variant: "ghost", size: "sm", onClick: () => s((t) => t - 1), children: [
|
|
1251
|
-
/* @__PURE__ */ e(
|
|
1251
|
+
/* @__PURE__ */ e(Le, { className: "h-3.5 w-3.5" }),
|
|
1252
1252
|
" Back"
|
|
1253
1253
|
] }),
|
|
1254
|
-
|
|
1254
|
+
q && /* @__PURE__ */ e("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: q }),
|
|
1255
1255
|
/* @__PURE__ */ r("div", { className: "ml-auto flex items-center gap-2", children: [
|
|
1256
1256
|
/* @__PURE__ */ e(F, { variant: "ghost", size: "sm", onClick: n, children: "Cancel" }),
|
|
1257
|
-
c < we.length - 1 ? /* @__PURE__ */ r(F, { size: "sm", disabled: !
|
|
1257
|
+
c < we.length - 1 ? /* @__PURE__ */ r(F, { size: "sm", disabled: !ct, onClick: () => s((t) => t + 1), children: [
|
|
1258
1258
|
"Next ",
|
|
1259
|
-
/* @__PURE__ */ e(
|
|
1259
|
+
/* @__PURE__ */ e(We, { className: "h-3.5 w-3.5" })
|
|
1260
1260
|
] }) : /* @__PURE__ */ e(
|
|
1261
1261
|
F,
|
|
1262
1262
|
{
|
|
1263
1263
|
size: "sm",
|
|
1264
|
-
disabled: be.isPending || !
|
|
1264
|
+
disabled: be.isPending || !Vt($, L),
|
|
1265
1265
|
onClick: () => be.mutate(),
|
|
1266
|
-
children: be.isPending ? /* @__PURE__ */ r(
|
|
1266
|
+
children: be.isPending ? /* @__PURE__ */ r(ut, { children: [
|
|
1267
1267
|
/* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
1268
1268
|
" Starting…"
|
|
1269
1269
|
] }) : "Start import"
|
|
@@ -1275,10 +1275,10 @@ val1,val2,val3`,
|
|
|
1275
1275
|
}
|
|
1276
1276
|
function Be({
|
|
1277
1277
|
matchFields: n,
|
|
1278
|
-
confirmed:
|
|
1278
|
+
confirmed: d,
|
|
1279
1279
|
onConfirm: o
|
|
1280
1280
|
}) {
|
|
1281
|
-
const p =
|
|
1281
|
+
const p = Ht(n);
|
|
1282
1282
|
return p ? /* @__PURE__ */ r(
|
|
1283
1283
|
"div",
|
|
1284
1284
|
{
|
|
@@ -1289,10 +1289,10 @@ function Be({
|
|
|
1289
1289
|
/* @__PURE__ */ e("p", { className: "mt-0.5 text-[11px] leading-snug text-amber-700 dark:text-amber-400", children: "Existing records are never updated or skipped, whatever you chose above. Running the same file twice creates every record twice." }),
|
|
1290
1290
|
/* @__PURE__ */ r("div", { className: "mt-2 flex items-center gap-2", children: [
|
|
1291
1291
|
/* @__PURE__ */ e(
|
|
1292
|
-
|
|
1292
|
+
Ge,
|
|
1293
1293
|
{
|
|
1294
1294
|
id: "csv-confirm-no-match",
|
|
1295
|
-
checked:
|
|
1295
|
+
checked: d,
|
|
1296
1296
|
onCheckedChange: o,
|
|
1297
1297
|
"data-csv-confirm-no-match": !0
|
|
1298
1298
|
}
|
|
@@ -1310,7 +1310,7 @@ function Be({
|
|
|
1310
1310
|
}
|
|
1311
1311
|
) : null;
|
|
1312
1312
|
}
|
|
1313
|
-
function
|
|
1313
|
+
function sr({ headers: n, rows: d }) {
|
|
1314
1314
|
return /* @__PURE__ */ e("div", { className: "overflow-x-auto rounded-md border border-slate-200 dark:border-border", children: /* @__PURE__ */ r("table", { className: "w-full border-collapse", children: [
|
|
1315
1315
|
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { className: "bg-slate-50 dark:bg-muted/40", children: n.map((o) => /* @__PURE__ */ e(
|
|
1316
1316
|
"th",
|
|
@@ -1320,7 +1320,7 @@ function ar({ headers: n, rows: i }) {
|
|
|
1320
1320
|
},
|
|
1321
1321
|
o
|
|
1322
1322
|
)) }) }),
|
|
1323
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
1323
|
+
/* @__PURE__ */ e("tbody", { children: d.map((o, p) => (
|
|
1324
1324
|
// eslint-disable-next-line react/no-array-index-key
|
|
1325
1325
|
/* @__PURE__ */ e("tr", { className: "border-b border-slate-100 last:border-b-0 dark:border-border/60", children: n.map((c, s) => /* @__PURE__ */ e(
|
|
1326
1326
|
"td",
|
|
@@ -1334,32 +1334,32 @@ function ar({ headers: n, rows: i }) {
|
|
|
1334
1334
|
)) })
|
|
1335
1335
|
] }) });
|
|
1336
1336
|
}
|
|
1337
|
-
function
|
|
1338
|
-
const
|
|
1339
|
-
return
|
|
1340
|
-
mutationFn: (p) =>
|
|
1337
|
+
function tt(n) {
|
|
1338
|
+
const d = te(), o = Je();
|
|
1339
|
+
return Q({
|
|
1340
|
+
mutationFn: (p) => d.request(z(`/imports/${p}/cancel`, {})),
|
|
1341
1341
|
onSuccess: (p, c) => {
|
|
1342
1342
|
n(null), o.invalidateQueries({ queryKey: ["collection-import-jobs"] }), o.invalidateQueries({ queryKey: ["collection-import-job", c] });
|
|
1343
1343
|
},
|
|
1344
1344
|
onError: (p) => n(p)
|
|
1345
1345
|
});
|
|
1346
1346
|
}
|
|
1347
|
-
function
|
|
1348
|
-
var h,
|
|
1349
|
-
const o =
|
|
1347
|
+
function lr({ jobId: n, onClose: d }) {
|
|
1348
|
+
var h, C;
|
|
1349
|
+
const o = yt(), p = te(), s = (h = K({
|
|
1350
1350
|
queryKey: ["collection-import-job", n],
|
|
1351
|
-
queryFn: () => p.request(
|
|
1351
|
+
queryFn: () => p.request(J(`/imports/${n}`)),
|
|
1352
1352
|
enabled: !!n,
|
|
1353
|
-
refetchInterval: (
|
|
1354
|
-
var
|
|
1355
|
-
return ((v = (
|
|
1353
|
+
refetchInterval: (i) => {
|
|
1354
|
+
var _, v, O, E;
|
|
1355
|
+
return ((v = (_ = i.state.data) == null ? void 0 : _.data) == null ? void 0 : v.status) === "processing" || ((E = (O = i.state.data) == null ? void 0 : O.data) == null ? void 0 : E.status) === "pending" ? 2e3 : !1;
|
|
1356
1356
|
}
|
|
1357
|
-
}).data) == null ? void 0 : h.data, [k, T] = g(null), x =
|
|
1358
|
-
(
|
|
1359
|
-
),
|
|
1360
|
-
return /* @__PURE__ */ e(Kt, { open: !!n, onOpenChange: (
|
|
1357
|
+
}).data) == null ? void 0 : h.data, [k, T] = g(null), x = tt(
|
|
1358
|
+
(i) => T(i ? ve(i, "The import could not be stopped") : null)
|
|
1359
|
+
), S = Ye(), b = Array.isArray(s == null ? void 0 : s.errors) ? s.errors : [], m = s != null && s.total_rows ? Math.min(100, Math.round((s.processed_rows ?? 0) / s.total_rows * 100)) : (s == null ? void 0 : s.status) === "complete" ? 100 : 0;
|
|
1360
|
+
return /* @__PURE__ */ e(Kt, { open: !!n, onOpenChange: (i) => !i && d(), children: /* @__PURE__ */ e(Qt, { side: "right", className: "w-[min(560px,94vw)] p-0 sm:max-w-none", children: s ? /* @__PURE__ */ r("div", { className: "flex h-full flex-col", children: [
|
|
1361
1361
|
/* @__PURE__ */ r("header", { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: [
|
|
1362
|
-
/* @__PURE__ */ e(
|
|
1362
|
+
/* @__PURE__ */ e(et, { status: s.status }),
|
|
1363
1363
|
/* @__PURE__ */ e("h2", { className: "mt-1.5 truncate font-mono text-[15px] font-semibold text-slate-900 dark:text-foreground", children: s.file_name }),
|
|
1364
1364
|
/* @__PURE__ */ r("p", { className: "text-[11.5px] text-slate-400", children: [
|
|
1365
1365
|
"into ",
|
|
@@ -1379,7 +1379,7 @@ function sr({ jobId: n, onClose: i }) {
|
|
|
1379
1379
|
className: "relative inline-flex h-7 items-center gap-1.5 rounded-md border border-red-200 bg-white px-2.5 text-[12px] font-medium text-red-700 transition-colors hover:bg-red-50 disabled:opacity-50 dark:border-red-500/30 dark:bg-card dark:text-red-400 dark:hover:bg-red-500/10",
|
|
1380
1380
|
armedClassName: "border-red-500 bg-red-600 text-white hover:bg-red-700 dark:bg-red-600 dark:text-white dark:hover:bg-red-700",
|
|
1381
1381
|
children: [
|
|
1382
|
-
x.isPending ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(
|
|
1382
|
+
x.isPending ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(He, { className: "h-3.5 w-3.5" }),
|
|
1383
1383
|
"Stop import"
|
|
1384
1384
|
]
|
|
1385
1385
|
}
|
|
@@ -1390,20 +1390,20 @@ function sr({ jobId: n, onClose: i }) {
|
|
|
1390
1390
|
size: "sm",
|
|
1391
1391
|
variant: "outline",
|
|
1392
1392
|
className: "h-7",
|
|
1393
|
-
disabled: !!
|
|
1394
|
-
onClick: () => void
|
|
1393
|
+
disabled: !!S.busy,
|
|
1394
|
+
onClick: () => void S.download(
|
|
1395
1395
|
`/imports/${s.id}/file`,
|
|
1396
1396
|
s.file_name || "import.csv"
|
|
1397
1397
|
),
|
|
1398
1398
|
"data-tip": "The file as it was uploaded",
|
|
1399
1399
|
children: [
|
|
1400
|
-
|
|
1400
|
+
S.busy ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(Ve, { className: "h-3.5 w-3.5" }),
|
|
1401
1401
|
"Download file"
|
|
1402
1402
|
]
|
|
1403
1403
|
}
|
|
1404
1404
|
)
|
|
1405
1405
|
] }),
|
|
1406
|
-
(k ||
|
|
1406
|
+
(k || S.error) && /* @__PURE__ */ e("p", { className: "mt-2 text-[11.5px] text-red-600 dark:text-red-400", children: k ?? `Could not download the file: ${S.error}` }),
|
|
1407
1407
|
s.status === "cancelled" && /* @__PURE__ */ e("p", { className: "mt-2 text-[11.5px] leading-snug text-amber-700 dark:text-amber-400", children: "This import was stopped. Rows it wrote before stopping stay — roll it back from the job list to undo them." })
|
|
1408
1408
|
] }),
|
|
1409
1409
|
/* @__PURE__ */ r("div", { className: "min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4", children: [
|
|
@@ -1438,19 +1438,19 @@ function sr({ jobId: n, onClose: i }) {
|
|
|
1438
1438
|
{ label: "Updated", value: s.updated_rows ?? 0 },
|
|
1439
1439
|
{ label: "Skipped", value: s.skipped_rows ?? 0 },
|
|
1440
1440
|
{ label: "Errors", value: s.error_rows ?? 0, bad: (s.error_rows ?? 0) > 0 }
|
|
1441
|
-
].map((
|
|
1442
|
-
/* @__PURE__ */ e("p", { className: "text-[10.5px] text-slate-400", children:
|
|
1441
|
+
].map((i) => /* @__PURE__ */ r("div", { className: "bg-white px-3 py-2 dark:bg-card", children: [
|
|
1442
|
+
/* @__PURE__ */ e("p", { className: "text-[10.5px] text-slate-400", children: i.label }),
|
|
1443
1443
|
/* @__PURE__ */ e(
|
|
1444
1444
|
"p",
|
|
1445
1445
|
{
|
|
1446
1446
|
className: y(
|
|
1447
1447
|
"text-[15px] font-semibold tabular-nums",
|
|
1448
|
-
|
|
1448
|
+
i.bad ? "text-red-600 dark:text-red-400" : "text-slate-900 dark:text-foreground"
|
|
1449
1449
|
),
|
|
1450
|
-
children: P(
|
|
1450
|
+
children: P(i.value)
|
|
1451
1451
|
}
|
|
1452
1452
|
)
|
|
1453
|
-
] },
|
|
1453
|
+
] }, i.label)) }),
|
|
1454
1454
|
/* @__PURE__ */ r("section", { children: [
|
|
1455
1455
|
/* @__PURE__ */ e("h3", { className: "mb-1 text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground", children: "Settings" }),
|
|
1456
1456
|
[
|
|
@@ -1461,7 +1461,7 @@ function sr({ jobId: n, onClose: i }) {
|
|
|
1461
1461
|
},
|
|
1462
1462
|
{
|
|
1463
1463
|
label: "Matched on",
|
|
1464
|
-
value: (s.match_fields ??
|
|
1464
|
+
value: (s.match_fields ?? Xe(s.id_field)).join(" + ") || "— always create"
|
|
1465
1465
|
},
|
|
1466
1466
|
{
|
|
1467
1467
|
label: "Started",
|
|
@@ -1471,42 +1471,40 @@ function sr({ jobId: n, onClose: i }) {
|
|
|
1471
1471
|
label: "Completed",
|
|
1472
1472
|
value: s.completed_at ? ne(s.completed_at) : "—"
|
|
1473
1473
|
}
|
|
1474
|
-
].map((
|
|
1474
|
+
].map((i) => /* @__PURE__ */ r(
|
|
1475
1475
|
"div",
|
|
1476
1476
|
{
|
|
1477
1477
|
className: "flex items-baseline justify-between gap-4 border-b border-slate-100 py-1.5 last:border-b-0 dark:border-border/60",
|
|
1478
1478
|
children: [
|
|
1479
|
-
/* @__PURE__ */ e("span", { className: "text-[11.5px] text-slate-400", children:
|
|
1480
|
-
/* @__PURE__ */ e("span", { className: "truncate text-[12px] text-slate-800 dark:text-foreground", children:
|
|
1479
|
+
/* @__PURE__ */ e("span", { className: "text-[11.5px] text-slate-400", children: i.label }),
|
|
1480
|
+
/* @__PURE__ */ e("span", { className: "truncate text-[12px] text-slate-800 dark:text-foreground", children: i.value })
|
|
1481
1481
|
]
|
|
1482
1482
|
},
|
|
1483
|
-
|
|
1483
|
+
i.label
|
|
1484
1484
|
))
|
|
1485
1485
|
] }),
|
|
1486
1486
|
s.column_map && Object.keys(s.column_map).length > 0 && /* @__PURE__ */ r("section", { children: [
|
|
1487
1487
|
/* @__PURE__ */ e("h3", { className: "mb-1.5 text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground", children: "Column mapping" }),
|
|
1488
|
-
/* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: Object.entries(s.column_map).map(([
|
|
1488
|
+
/* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: Object.entries(s.column_map).map(([i, _]) => /* @__PURE__ */ r(
|
|
1489
1489
|
"div",
|
|
1490
1490
|
{
|
|
1491
1491
|
className: "flex items-center gap-2 border-b border-slate-100 px-3 py-1.5 font-mono text-[11.5px] last:border-b-0 dark:border-border/60",
|
|
1492
1492
|
children: [
|
|
1493
|
-
/* @__PURE__ */ e("span", { className: "flex-1 truncate text-slate-500 dark:text-muted-foreground", children:
|
|
1494
|
-
/* @__PURE__ */ e(
|
|
1495
|
-
/* @__PURE__ */ e("span", { className: "flex-1 truncate text-slate-800 dark:text-foreground", children:
|
|
1493
|
+
/* @__PURE__ */ e("span", { className: "flex-1 truncate text-slate-500 dark:text-muted-foreground", children: i }),
|
|
1494
|
+
/* @__PURE__ */ e(We, { className: "h-3 w-3 shrink-0 text-slate-300" }),
|
|
1495
|
+
/* @__PURE__ */ e("span", { className: "flex-1 truncate text-slate-800 dark:text-foreground", children: _ || /* @__PURE__ */ e("span", { className: "font-sans text-slate-400", children: "skipped" }) })
|
|
1496
1496
|
]
|
|
1497
1497
|
},
|
|
1498
|
-
|
|
1498
|
+
i
|
|
1499
1499
|
)) })
|
|
1500
1500
|
] }),
|
|
1501
|
-
s.created_ids && (((
|
|
1501
|
+
s.created_ids && (((C = s.created_ids) == null ? void 0 : C.length) ?? 0) > 0 && je(o, s.collection, []) !== null && /* @__PURE__ */ e("section", { children: /* @__PURE__ */ r(
|
|
1502
1502
|
"button",
|
|
1503
1503
|
{
|
|
1504
1504
|
type: "button",
|
|
1505
1505
|
onClick: () => {
|
|
1506
|
-
const
|
|
1507
|
-
o.navigate(
|
|
1508
|
-
`/collections/${s.collection}?ids=${encodeURIComponent(d)}`
|
|
1509
|
-
);
|
|
1506
|
+
const i = (s.created_ids ?? []).map(String).join(","), _ = je(o, s.collection, i.split(","));
|
|
1507
|
+
_ && o.navigate(_);
|
|
1510
1508
|
},
|
|
1511
1509
|
className: "inline-flex h-8 items-center gap-1.5 rounded-md border border-nvr-cyan/40 bg-nvr-cyan/5 px-3 text-[12px] font-medium text-[#007a99] dark:text-nvr-cyan",
|
|
1512
1510
|
children: [
|
|
@@ -1520,32 +1518,32 @@ function sr({ jobId: n, onClose: i }) {
|
|
|
1520
1518
|
]
|
|
1521
1519
|
}
|
|
1522
1520
|
) }),
|
|
1523
|
-
b.length > 0 && /* @__PURE__ */ e(
|
|
1521
|
+
b.length > 0 && /* @__PURE__ */ e(or, { jobId: String(s.id), errors: b })
|
|
1524
1522
|
] })
|
|
1525
1523
|
] }) : /* @__PURE__ */ e("div", { className: "p-5 text-[12.5px] text-slate-400", children: "Loading job…" }) }) });
|
|
1526
1524
|
}
|
|
1527
|
-
function
|
|
1525
|
+
function or({
|
|
1528
1526
|
jobId: n,
|
|
1529
|
-
errors:
|
|
1527
|
+
errors: d
|
|
1530
1528
|
}) {
|
|
1531
|
-
const o = te(), [p, c] = g({}), [s, k] = g({}), { data: T } =
|
|
1529
|
+
const o = te(), [p, c] = g({}), [s, k] = g({}), { data: T } = K({
|
|
1532
1530
|
queryKey: ["import-failed-rows", n],
|
|
1533
1531
|
queryFn: () => o.request(
|
|
1534
|
-
|
|
1532
|
+
J(`/imports/${n}/failed-rows`)
|
|
1535
1533
|
).then((m) => m.data ?? []),
|
|
1536
1534
|
staleTime: 3e4
|
|
1537
|
-
}), x = T ?? [],
|
|
1538
|
-
mutationFn: ({ row: m, values: h }) => o.request(
|
|
1535
|
+
}), x = T ?? [], S = x[0] ? Object.keys(x[0].values) : [], b = Q({
|
|
1536
|
+
mutationFn: ({ row: m, values: h }) => o.request(z(`/imports/${n}/repair-row`, { values: h })).then(() => m),
|
|
1539
1537
|
onSuccess: (m) => k((h) => ({ ...h, [m]: "ok" })),
|
|
1540
|
-
onError: (m, h) => k((
|
|
1538
|
+
onError: (m, h) => k((C) => ({ ...C, [h.row]: ve(m, "The row was not created") }))
|
|
1541
1539
|
});
|
|
1542
1540
|
return x.length === 0 ? /* @__PURE__ */ r("section", { children: [
|
|
1543
1541
|
/* @__PURE__ */ r("h3", { className: "mb-1.5 text-[11.5px] font-semibold text-red-700 dark:text-red-400", children: [
|
|
1544
1542
|
"Row errors (",
|
|
1545
|
-
|
|
1543
|
+
d.length,
|
|
1546
1544
|
")"
|
|
1547
1545
|
] }),
|
|
1548
|
-
/* @__PURE__ */ e("div", { className: "max-h-[200px] overflow-auto rounded-md border border-red-200 dark:border-red-900", children:
|
|
1546
|
+
/* @__PURE__ */ e("div", { className: "max-h-[200px] overflow-auto rounded-md border border-red-200 dark:border-red-900", children: d.map((m) => /* @__PURE__ */ e(
|
|
1549
1547
|
"div",
|
|
1550
1548
|
{
|
|
1551
1549
|
className: "flex gap-3 border-b border-red-100 px-3 py-1.5 text-[11.5px] last:border-b-0 dark:border-red-900/60",
|
|
@@ -1556,7 +1554,7 @@ function lr({
|
|
|
1556
1554
|
":"
|
|
1557
1555
|
] }),
|
|
1558
1556
|
" ",
|
|
1559
|
-
|
|
1557
|
+
Ue(m.error)
|
|
1560
1558
|
] })
|
|
1561
1559
|
},
|
|
1562
1560
|
`${m.row}-${m.error}`
|
|
@@ -1570,11 +1568,11 @@ function lr({
|
|
|
1570
1568
|
/* @__PURE__ */ e("div", { className: "max-h-[320px] overflow-auto rounded-md border border-red-200 dark:border-red-900", children: /* @__PURE__ */ r("table", { className: "w-full text-[11.5px]", children: [
|
|
1571
1569
|
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ r("tr", { className: "bg-red-50/60 text-left text-[10px] uppercase tracking-wide text-slate-400 dark:bg-red-950/30", children: [
|
|
1572
1570
|
/* @__PURE__ */ e("th", { className: "px-2 py-1", children: "Row" }),
|
|
1573
|
-
|
|
1571
|
+
S.map((m) => /* @__PURE__ */ e("th", { className: "px-2 py-1 font-mono normal-case", children: m }, m)),
|
|
1574
1572
|
/* @__PURE__ */ e("th", { className: "px-2 py-1" })
|
|
1575
1573
|
] }) }),
|
|
1576
1574
|
/* @__PURE__ */ e("tbody", { children: x.map((m) => {
|
|
1577
|
-
const h = p[m.row] ?? m.values,
|
|
1575
|
+
const h = p[m.row] ?? m.values, C = s[m.row];
|
|
1578
1576
|
return /* @__PURE__ */ r(
|
|
1579
1577
|
"tr",
|
|
1580
1578
|
{
|
|
@@ -1582,18 +1580,18 @@ function lr({
|
|
|
1582
1580
|
children: [
|
|
1583
1581
|
/* @__PURE__ */ r("td", { className: "px-2 py-1 font-mono tabular-nums text-slate-400", children: [
|
|
1584
1582
|
m.row,
|
|
1585
|
-
/* @__PURE__ */ e("p", { className: "max-w-[120px] whitespace-normal text-[10px] text-red-500", children:
|
|
1583
|
+
/* @__PURE__ */ e("p", { className: "max-w-[120px] whitespace-normal text-[10px] text-red-500", children: Ue(m.error) })
|
|
1586
1584
|
] }),
|
|
1587
|
-
|
|
1585
|
+
S.map((i) => /* @__PURE__ */ e("td", { className: "px-1 py-1", children: /* @__PURE__ */ e(
|
|
1588
1586
|
"input",
|
|
1589
1587
|
{
|
|
1590
|
-
value: String(h[
|
|
1591
|
-
disabled:
|
|
1592
|
-
onChange: (
|
|
1588
|
+
value: String(h[i] ?? ""),
|
|
1589
|
+
disabled: C === "ok",
|
|
1590
|
+
onChange: (_) => c((v) => ({ ...v, [m.row]: { ...h, [i]: _.target.value } })),
|
|
1593
1591
|
className: "h-6 w-full min-w-[80px] rounded border border-slate-200 bg-background px-1 text-[11px] dark:border-border"
|
|
1594
1592
|
}
|
|
1595
|
-
) },
|
|
1596
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children:
|
|
1593
|
+
) }, i)),
|
|
1594
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: C === "ok" ? /* @__PURE__ */ e("span", { className: "text-[10.5px] font-medium text-emerald-600", children: "✓ Created" }) : /* @__PURE__ */ r("div", { children: [
|
|
1597
1595
|
/* @__PURE__ */ e(
|
|
1598
1596
|
"button",
|
|
1599
1597
|
{
|
|
@@ -1604,7 +1602,7 @@ function lr({
|
|
|
1604
1602
|
children: "Resubmit"
|
|
1605
1603
|
}
|
|
1606
1604
|
),
|
|
1607
|
-
|
|
1605
|
+
C && C !== "ok" && /* @__PURE__ */ e("p", { className: "max-w-[140px] whitespace-normal text-[9.5px] text-red-500", children: C })
|
|
1608
1606
|
] }) })
|
|
1609
1607
|
]
|
|
1610
1608
|
},
|
|
@@ -1614,11 +1612,16 @@ function lr({
|
|
|
1614
1612
|
] }) })
|
|
1615
1613
|
] });
|
|
1616
1614
|
}
|
|
1615
|
+
function je(n, d, o) {
|
|
1616
|
+
const p = `/collections/${d}${o.length ? `?ids=${encodeURIComponent(o.join(","))}` : ""}`;
|
|
1617
|
+
return n.consoleUrl ? n.consoleUrl(p) : p;
|
|
1618
|
+
}
|
|
1617
1619
|
export {
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1620
|
+
Tr as CollectionImportPanel,
|
|
1621
|
+
Xt as ROLLBACK_QUESTION,
|
|
1622
|
+
Yt as RollbackJobItem,
|
|
1621
1623
|
ke as STOPPABLE,
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
+
Gt as STOP_QUESTION,
|
|
1625
|
+
Zt as StopJobItem,
|
|
1626
|
+
je as createdListUrl
|
|
1624
1627
|
};
|