@nivaro/react 0.3.141 → 0.3.142
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/shared/components/imports/CollectionImportPanel.js +839 -601
- package/dist/shared/components/imports/RunDetailSheet.js +1 -1
- package/dist/shared/components/imports/match-fields.js +41 -0
- package/package.json +1 -1
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Upload as
|
|
4
|
-
import { useState as g, useMemo as
|
|
5
|
-
import { useNivaroClient as
|
|
6
|
-
import { get as
|
|
7
|
-
import { errorSentence as
|
|
8
|
-
import { formatNumber as P, toLocalDateString as
|
|
9
|
-
import { DataTable as
|
|
1
|
+
import { jsx as e, jsxs as r, Fragment as pt } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as Je, useQuery as Q, useMutation as U } from "@tanstack/react-query";
|
|
3
|
+
import { Upload as ut, Plus as Ee, ArrowLeft as Ie, FileUp as ht, Link2 as xt, Loader2 as Y, Sparkles as bt, X as ft, ArrowRight as je, MoreHorizontal as gt, Download as We, Trash2 as wt, Square as Ve, ChevronsUpDown as kt, Check as vt } from "lucide-react";
|
|
4
|
+
import { useState as g, useMemo as J, useEffect as Z, useRef as Le } from "react";
|
|
5
|
+
import { useNivaroClient as te, useNavigation as Nt } from "../../context.js";
|
|
6
|
+
import { get as j, del as yt, post as K } from "../../lib/commands.js";
|
|
7
|
+
import { errorSentence as ve, rowErrorSentence as ze } from "../../lib/error-message.js";
|
|
8
|
+
import { formatNumber as P, toLocalDateString as _t, cn as y, formatRelative as Ct, formatDateTime as ne } from "../../lib/utils.js";
|
|
9
|
+
import { DataTable as St } from "../DataTable.js";
|
|
10
|
+
import { ConfirmButton as qt } from "../profile/primitives.js";
|
|
10
11
|
import { Button as F } from "../ui/button.js";
|
|
11
|
-
import { Command as
|
|
12
|
-
import { DropdownMenu as
|
|
13
|
-
import { Input as
|
|
14
|
-
import { Label as
|
|
15
|
-
import { Popover as
|
|
16
|
-
import { SimpleSelect as
|
|
17
|
-
import { Sheet as
|
|
18
|
-
import { Switch as
|
|
19
|
-
import { Textarea as
|
|
20
|
-
import { ImportDuplicatesNotice as
|
|
21
|
-
import { collectionPickerOptions as
|
|
22
|
-
|
|
12
|
+
import { Command as $t, CommandInput as Pt, CommandList as Mt, CommandEmpty as Tt, CommandGroup as Dt, CommandItem as At } from "../ui/command.js";
|
|
13
|
+
import { DropdownMenu as Ot, DropdownMenuTrigger as Rt, DropdownMenuContent as Ft, DropdownMenuItem as de } from "../ui/dropdown-menu.js";
|
|
14
|
+
import { Input as Ke } from "../ui/input.js";
|
|
15
|
+
import { Label as X } from "../ui/label.js";
|
|
16
|
+
import { Popover as Et, PopoverTrigger as It, PopoverContent as Lt } from "../ui/popover.js";
|
|
17
|
+
import { SimpleSelect as zt } from "../ui/SimpleSelect.js";
|
|
18
|
+
import { Sheet as Kt, SheetContent as Qt } from "../ui/sheet.js";
|
|
19
|
+
import { Switch as He } from "../ui/switch.js";
|
|
20
|
+
import { Textarea as Ut } from "../ui/textarea.js";
|
|
21
|
+
import { ImportDuplicatesNotice as Bt } from "./ImportDuplicatesNotice.js";
|
|
22
|
+
import { collectionPickerOptions as Jt, fieldPickerOptions as Qe } from "./import-picker-options.js";
|
|
23
|
+
import { parseMatchFields as Ge, matchFieldOptions as jt, canStartImport as Wt, noMatchWarning as Vt } from "./match-fields.js";
|
|
24
|
+
import { useDownload as Xe } from "./RunDetailSheet.js";
|
|
25
|
+
const ge = 25, we = ["Source", "Map columns", "Options", "Confirm"], ee = {
|
|
23
26
|
pending: { dot: "bg-slate-400", text: "text-slate-600 dark:text-slate-300", label: "Pending" },
|
|
24
27
|
processing: {
|
|
25
28
|
dot: "bg-nvr-cyan",
|
|
@@ -31,120 +34,159 @@ const ue = 25, he = ["Source", "Map columns", "Options", "Confirm"], H = {
|
|
|
31
34
|
text: "text-emerald-700 dark:text-emerald-400",
|
|
32
35
|
label: "Complete"
|
|
33
36
|
},
|
|
34
|
-
failed: { dot: "bg-red-500", text: "text-red-700 dark:text-red-400", label: "Failed" }
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
failed: { dot: "bg-red-500", text: "text-red-700 dark:text-red-400", label: "Failed" },
|
|
38
|
+
cancelled: {
|
|
39
|
+
dot: "bg-amber-500",
|
|
40
|
+
text: "text-amber-700 dark:text-amber-400",
|
|
41
|
+
label: "Cancelled"
|
|
42
|
+
}
|
|
43
|
+
}, ke = /* @__PURE__ */ new Set(["pending", "processing"]), Ht = "Stop this import? Rows already written stay — roll the import back afterwards to undo them.", Gt = "Roll back this import? Created rows are deleted (to trash) and overwritten rows restored to their prior values. One-shot.";
|
|
44
|
+
function Ye({
|
|
45
|
+
disabled: n,
|
|
46
|
+
question: i,
|
|
47
|
+
confirmLabel: o,
|
|
48
|
+
onConfirm: p,
|
|
49
|
+
children: c
|
|
40
50
|
}) {
|
|
41
|
-
const [
|
|
51
|
+
const [s, k] = g(!1);
|
|
42
52
|
return /* @__PURE__ */ e(
|
|
43
|
-
|
|
53
|
+
de,
|
|
44
54
|
{
|
|
45
|
-
disabled:
|
|
46
|
-
"data-armed":
|
|
47
|
-
className:
|
|
48
|
-
|
|
55
|
+
disabled: n,
|
|
56
|
+
"data-armed": s ? "" : void 0,
|
|
57
|
+
className: y(
|
|
58
|
+
s && "max-w-[300px] whitespace-normal bg-red-50 font-medium text-red-700 focus:bg-red-100 focus:text-red-800 dark:bg-red-500/10 dark:text-red-400 dark:focus:bg-red-500/20 dark:focus:text-red-300"
|
|
49
59
|
),
|
|
50
|
-
onSelect: (
|
|
51
|
-
if (!
|
|
52
|
-
|
|
60
|
+
onSelect: (T) => {
|
|
61
|
+
if (!s) {
|
|
62
|
+
T.preventDefault(), k(!0);
|
|
53
63
|
return;
|
|
54
64
|
}
|
|
55
|
-
|
|
65
|
+
k(!1), p();
|
|
56
66
|
},
|
|
57
|
-
children:
|
|
58
|
-
|
|
59
|
-
/* @__PURE__ */ e("span", { className: "mt-1 block text-[11px] font-semibold", children:
|
|
60
|
-
] }) :
|
|
67
|
+
children: s ? /* @__PURE__ */ r("span", { className: "block", children: [
|
|
68
|
+
i,
|
|
69
|
+
/* @__PURE__ */ e("span", { className: "mt-1 block text-[11px] font-semibold", children: o })
|
|
70
|
+
] }) : c
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
function Xt({
|
|
75
|
+
disabled: n,
|
|
76
|
+
rolledBack: i,
|
|
77
|
+
onConfirm: o
|
|
78
|
+
}) {
|
|
79
|
+
return /* @__PURE__ */ e(
|
|
80
|
+
Ye,
|
|
81
|
+
{
|
|
82
|
+
disabled: n,
|
|
83
|
+
question: Gt,
|
|
84
|
+
confirmLabel: "Choose again to roll back",
|
|
85
|
+
onConfirm: o,
|
|
86
|
+
children: i ? "Rolled back" : "Roll back this import"
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
function Yt({ onConfirm: n }) {
|
|
91
|
+
return /* @__PURE__ */ r(
|
|
92
|
+
Ye,
|
|
93
|
+
{
|
|
94
|
+
disabled: !1,
|
|
95
|
+
question: Ht,
|
|
96
|
+
confirmLabel: "Choose again to stop",
|
|
97
|
+
onConfirm: n,
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ e(Ve, { className: "h-3.5 w-3.5" }),
|
|
100
|
+
" Stop import"
|
|
101
|
+
]
|
|
61
102
|
}
|
|
62
103
|
);
|
|
63
104
|
}
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
return /* @__PURE__ */
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
|
|
105
|
+
function Ze({ status: n }) {
|
|
106
|
+
const i = ee[n] ?? ee.pending;
|
|
107
|
+
return /* @__PURE__ */ r("span", { className: y("flex items-center gap-1.5 text-[12px] font-medium", i.text), children: [
|
|
108
|
+
/* @__PURE__ */ r("span", { className: "relative flex h-1.5 w-1.5 shrink-0", children: [
|
|
109
|
+
n === "processing" && /* @__PURE__ */ e(
|
|
69
110
|
"span",
|
|
70
111
|
{
|
|
71
|
-
className:
|
|
112
|
+
className: y(
|
|
72
113
|
"absolute inline-flex h-full w-full rounded-full opacity-75 motion-safe:animate-ping",
|
|
73
|
-
|
|
114
|
+
i.dot
|
|
74
115
|
)
|
|
75
116
|
}
|
|
76
117
|
),
|
|
77
|
-
/* @__PURE__ */ e("span", { className:
|
|
118
|
+
/* @__PURE__ */ e("span", { className: y("relative inline-flex h-1.5 w-1.5 rounded-full", i.dot) })
|
|
78
119
|
] }),
|
|
79
|
-
|
|
120
|
+
i.label
|
|
80
121
|
] });
|
|
81
122
|
}
|
|
82
|
-
function
|
|
83
|
-
processed:
|
|
84
|
-
total:
|
|
85
|
-
failed:
|
|
123
|
+
function Zt({
|
|
124
|
+
processed: n,
|
|
125
|
+
total: i,
|
|
126
|
+
failed: o,
|
|
127
|
+
stopped: p
|
|
86
128
|
}) {
|
|
87
|
-
if (!
|
|
88
|
-
const
|
|
89
|
-
return /* @__PURE__ */
|
|
129
|
+
if (!i) return /* @__PURE__ */ e("span", { className: "text-[12px] text-slate-300", children: "—" });
|
|
130
|
+
const c = Math.min(100, Math.round((n ?? 0) / i * 100));
|
|
131
|
+
return /* @__PURE__ */ r("div", { className: "flex min-w-[92px] items-center gap-2", children: [
|
|
90
132
|
/* @__PURE__ */ e("div", { className: "h-1.5 flex-1 overflow-hidden rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ e(
|
|
91
133
|
"div",
|
|
92
134
|
{
|
|
93
|
-
className:
|
|
135
|
+
className: y(
|
|
94
136
|
"h-full rounded-full transition-[width] duration-500",
|
|
95
|
-
|
|
137
|
+
o ? "bg-red-500" : p ? "bg-amber-500" : "bg-nvr-cyan"
|
|
96
138
|
),
|
|
97
|
-
style: { width: `${
|
|
139
|
+
style: { width: `${c}%` }
|
|
98
140
|
}
|
|
99
141
|
) }),
|
|
100
|
-
/* @__PURE__ */
|
|
101
|
-
|
|
142
|
+
/* @__PURE__ */ r("span", { className: "w-8 text-right text-[11px] tabular-nums text-slate-400", children: [
|
|
143
|
+
c,
|
|
102
144
|
"%"
|
|
103
145
|
] })
|
|
104
146
|
] });
|
|
105
147
|
}
|
|
106
|
-
function
|
|
107
|
-
const
|
|
108
|
-
let
|
|
109
|
-
for (let
|
|
110
|
-
const s = c
|
|
111
|
-
p ? s === '"' && c
|
|
148
|
+
function ie(n) {
|
|
149
|
+
const i = [];
|
|
150
|
+
let o = "", p = !1;
|
|
151
|
+
for (let c = 0; c < n.length; c++) {
|
|
152
|
+
const s = n[c];
|
|
153
|
+
p ? s === '"' && n[c + 1] === '"' ? (o += '"', c++) : s === '"' ? p = !1 : o += s : s === '"' ? p = !0 : s === "," ? (i.push(o), o = "") : o += s;
|
|
112
154
|
}
|
|
113
|
-
return
|
|
155
|
+
return i.push(o), i.map((c) => c.trim());
|
|
114
156
|
}
|
|
115
|
-
function
|
|
116
|
-
const
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
return { headers:
|
|
157
|
+
function er(n) {
|
|
158
|
+
const i = n.split(/\r?\n/).filter((c) => c.trim());
|
|
159
|
+
if (i.length === 0) return { headers: [], rows: [], rowCount: 0 };
|
|
160
|
+
const o = ie(i[0]), p = i.slice(1, 6).map(ie);
|
|
161
|
+
return { headers: o, rows: p, rowCount: Math.max(0, i.length - 1) };
|
|
120
162
|
}
|
|
121
|
-
function
|
|
122
|
-
value:
|
|
123
|
-
onChange:
|
|
124
|
-
options:
|
|
163
|
+
function se({
|
|
164
|
+
value: n,
|
|
165
|
+
onChange: i,
|
|
166
|
+
options: o,
|
|
125
167
|
placeholder: p = "Select…",
|
|
126
|
-
className:
|
|
168
|
+
className: c,
|
|
127
169
|
wide: s = !1
|
|
128
170
|
}) {
|
|
129
|
-
const [k,
|
|
130
|
-
for (const
|
|
131
|
-
const
|
|
132
|
-
|
|
171
|
+
const [k, T] = g(!1), x = o.find((b) => b.value === n), C = [];
|
|
172
|
+
for (const b of o) {
|
|
173
|
+
const m = C[C.length - 1];
|
|
174
|
+
m && m.name === b.group ? m.items.push(b) : C.push({ name: b.group, items: [b] });
|
|
133
175
|
}
|
|
134
|
-
return /* @__PURE__ */
|
|
135
|
-
/* @__PURE__ */ e(
|
|
176
|
+
return /* @__PURE__ */ r(Et, { open: k, onOpenChange: T, children: [
|
|
177
|
+
/* @__PURE__ */ e(It, { asChild: !0, children: /* @__PURE__ */ r(
|
|
136
178
|
"button",
|
|
137
179
|
{
|
|
138
180
|
type: "button",
|
|
139
|
-
className:
|
|
181
|
+
className: y(
|
|
140
182
|
"flex h-8 w-full items-center justify-between gap-2 rounded-md border border-slate-200 bg-white px-2.5 text-left text-[12.5px] transition-colors hover:border-slate-300 dark:border-border dark:bg-card",
|
|
141
|
-
|
|
183
|
+
c
|
|
142
184
|
),
|
|
143
185
|
children: [
|
|
144
186
|
/* @__PURE__ */ e(
|
|
145
187
|
"span",
|
|
146
188
|
{
|
|
147
|
-
className:
|
|
189
|
+
className: y(
|
|
148
190
|
"truncate",
|
|
149
191
|
x != null && x.value ? "text-slate-800 dark:text-foreground" : "text-slate-400"
|
|
150
192
|
),
|
|
@@ -152,127 +194,130 @@ function Y({
|
|
|
152
194
|
children: (x == null ? void 0 : x.label) ?? p
|
|
153
195
|
}
|
|
154
196
|
),
|
|
155
|
-
/* @__PURE__ */ e(
|
|
197
|
+
/* @__PURE__ */ e(kt, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
156
198
|
]
|
|
157
199
|
}
|
|
158
200
|
) }),
|
|
159
|
-
/* @__PURE__ */ e(
|
|
160
|
-
/* @__PURE__ */ e(
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
/* @__PURE__ */ e(
|
|
163
|
-
|
|
164
|
-
|
|
201
|
+
/* @__PURE__ */ e(Lt, { className: y("p-0", s ? "w-[320px]" : "w-[260px]"), align: "start", children: /* @__PURE__ */ r($t, { children: [
|
|
202
|
+
/* @__PURE__ */ e(Pt, { placeholder: "Search by name…", className: "h-8 text-[12px]" }),
|
|
203
|
+
/* @__PURE__ */ r(Mt, { className: "max-h-[340px]", children: [
|
|
204
|
+
/* @__PURE__ */ e(Tt, { children: "Nothing matches." }),
|
|
205
|
+
C.map((b, m) => /* @__PURE__ */ e(Dt, { heading: b.name, children: b.items.map((h) => /* @__PURE__ */ r(
|
|
206
|
+
At,
|
|
165
207
|
{
|
|
166
|
-
value: `${
|
|
208
|
+
value: `${h.label} ${h.hint ?? ""} ${h.value}`,
|
|
167
209
|
onSelect: () => {
|
|
168
|
-
|
|
210
|
+
i(h.value), T(!1);
|
|
169
211
|
},
|
|
170
212
|
className: "items-start text-[12.5px]",
|
|
171
213
|
children: [
|
|
172
214
|
/* @__PURE__ */ e(
|
|
173
|
-
|
|
215
|
+
vt,
|
|
174
216
|
{
|
|
175
|
-
className:
|
|
217
|
+
className: y(
|
|
176
218
|
"mt-0.5 h-3.5 w-3.5 shrink-0",
|
|
177
|
-
|
|
219
|
+
h.value === n ? "text-nvr-cyan opacity-100" : "opacity-0"
|
|
178
220
|
)
|
|
179
221
|
}
|
|
180
222
|
),
|
|
181
|
-
/* @__PURE__ */
|
|
182
|
-
/* @__PURE__ */ e("span", { className: "block truncate", children:
|
|
183
|
-
|
|
223
|
+
/* @__PURE__ */ r("span", { className: "min-w-0", children: [
|
|
224
|
+
/* @__PURE__ */ e("span", { className: "block truncate", children: h.label }),
|
|
225
|
+
h.hint && /* @__PURE__ */ e("span", { className: "block truncate font-mono text-[10.5px] text-slate-400 dark:text-slate-500", children: h.hint })
|
|
184
226
|
] })
|
|
185
227
|
]
|
|
186
228
|
},
|
|
187
|
-
|
|
188
|
-
)) }, `${
|
|
229
|
+
h.value || "__skip__"
|
|
230
|
+
)) }, `${b.name ?? ""}-${m}`))
|
|
189
231
|
] })
|
|
190
232
|
] }) })
|
|
191
233
|
] });
|
|
192
234
|
}
|
|
193
|
-
function
|
|
194
|
-
const
|
|
195
|
-
return /* @__PURE__ */
|
|
235
|
+
function tr({ confidence: n }) {
|
|
236
|
+
const i = Math.round(n * 100), o = i >= 80 ? "text-emerald-700 dark:text-emerald-400" : i >= 50 ? "text-amber-700 dark:text-amber-400" : "text-slate-500";
|
|
237
|
+
return /* @__PURE__ */ r(
|
|
196
238
|
"span",
|
|
197
239
|
{
|
|
198
|
-
className:
|
|
240
|
+
className: y("shrink-0 text-[10.5px] font-medium tabular-nums", o),
|
|
199
241
|
title: "AI mapping confidence",
|
|
200
242
|
children: [
|
|
201
243
|
"AI ",
|
|
202
|
-
|
|
244
|
+
i,
|
|
203
245
|
"%"
|
|
204
246
|
]
|
|
205
247
|
}
|
|
206
248
|
);
|
|
207
249
|
}
|
|
208
|
-
function
|
|
209
|
-
initialJobId:
|
|
210
|
-
onJobOpen:
|
|
250
|
+
function Mr({
|
|
251
|
+
initialJobId: n,
|
|
252
|
+
onJobOpen: i
|
|
211
253
|
}) {
|
|
212
|
-
var
|
|
213
|
-
const
|
|
254
|
+
var V;
|
|
255
|
+
const o = te(), p = Je(), [c, s] = g("list"), [k, T] = g(n ?? null), [x, C] = g("all"), [b, m] = g(1), [h, _] = g(null), d = Q({
|
|
214
256
|
queryKey: ["collection-import-jobs"],
|
|
215
257
|
// The endpoint returns every job the caller may see, so the counters below
|
|
216
258
|
// are exact rather than page-scoped.
|
|
217
|
-
queryFn: () =>
|
|
218
|
-
refetchInterval: (
|
|
219
|
-
var
|
|
220
|
-
return (((
|
|
259
|
+
queryFn: () => o.request(j("/imports")),
|
|
260
|
+
refetchInterval: (a) => {
|
|
261
|
+
var $;
|
|
262
|
+
return ((($ = a.state.data) == null ? void 0 : $.data) ?? []).some((L) => L.status === "pending" || L.status === "processing") ? 3e3 : !1;
|
|
221
263
|
},
|
|
222
|
-
placeholderData: (
|
|
223
|
-
}),
|
|
224
|
-
var
|
|
225
|
-
return ((
|
|
226
|
-
}, [(
|
|
227
|
-
const
|
|
228
|
-
for (const
|
|
229
|
-
return
|
|
230
|
-
}, [
|
|
231
|
-
() =>
|
|
232
|
-
(
|
|
233
|
-
created:
|
|
234
|
-
updated:
|
|
235
|
-
skipped:
|
|
236
|
-
errors:
|
|
264
|
+
placeholderData: (a) => a
|
|
265
|
+
}), S = J(() => {
|
|
266
|
+
var a;
|
|
267
|
+
return ((a = d.data) == null ? void 0 : a.data) ?? [];
|
|
268
|
+
}, [(V = d.data) == null ? void 0 : V.data]), v = J(() => {
|
|
269
|
+
const a = {};
|
|
270
|
+
for (const $ of S) a[$.status] = (a[$.status] ?? 0) + 1;
|
|
271
|
+
return a;
|
|
272
|
+
}, [S]), O = J(
|
|
273
|
+
() => S.reduce(
|
|
274
|
+
(a, $) => ({
|
|
275
|
+
created: a.created + ($.created_rows ?? 0),
|
|
276
|
+
updated: a.updated + ($.updated_rows ?? 0),
|
|
277
|
+
skipped: a.skipped + ($.skipped_rows ?? 0),
|
|
278
|
+
errors: a.errors + ($.error_rows ?? 0)
|
|
237
279
|
}),
|
|
238
280
|
{ created: 0, updated: 0, skipped: 0, errors: 0 }
|
|
239
281
|
),
|
|
240
|
-
[
|
|
241
|
-
),
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
mutationFn: (
|
|
282
|
+
[S]
|
|
283
|
+
), E = x === "all" ? S : S.filter((a) => a.status === x), re = E.slice((b - 1) * ge, b * ge);
|
|
284
|
+
Z(() => m(1), [x]);
|
|
285
|
+
const z = U({
|
|
286
|
+
mutationFn: (a) => o.request(yt(`/imports/${a}`)),
|
|
245
287
|
onSuccess: () => {
|
|
246
|
-
|
|
288
|
+
_(null), p.invalidateQueries({ queryKey: ["collection-import-jobs"] });
|
|
247
289
|
},
|
|
248
|
-
onError: (
|
|
249
|
-
}),
|
|
250
|
-
mutationFn: (
|
|
290
|
+
onError: (a) => _(a.message)
|
|
291
|
+
}), ae = U({
|
|
292
|
+
mutationFn: (a) => o.request(K(`/imports/${a}/rollback`, {})),
|
|
251
293
|
onSuccess: () => {
|
|
252
|
-
|
|
294
|
+
_(null), p.invalidateQueries({ queryKey: ["collection-import-jobs"] });
|
|
253
295
|
},
|
|
254
|
-
onError: (
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
|
|
296
|
+
onError: (a) => _(a.message)
|
|
297
|
+
}), q = et((a) => _(a ? ve(a) : null)), R = Xe();
|
|
298
|
+
Z(() => {
|
|
299
|
+
R.error && _(`Could not download the file: ${R.error}`);
|
|
300
|
+
}, [R.error]);
|
|
301
|
+
function I(a) {
|
|
302
|
+
T(a), i == null || i(a);
|
|
258
303
|
}
|
|
259
|
-
const
|
|
304
|
+
const W = [
|
|
260
305
|
{
|
|
261
306
|
key: "status",
|
|
262
307
|
header: "Status",
|
|
263
308
|
className: "w-[110px]",
|
|
264
|
-
render: (
|
|
309
|
+
render: (a) => /* @__PURE__ */ e(Ze, { status: a.status })
|
|
265
310
|
},
|
|
266
311
|
{
|
|
267
312
|
key: "file_name",
|
|
268
313
|
header: "File",
|
|
269
314
|
className: "max-w-[220px]",
|
|
270
|
-
render: (
|
|
315
|
+
render: (a) => /* @__PURE__ */ e(
|
|
271
316
|
"span",
|
|
272
317
|
{
|
|
273
318
|
className: "block truncate font-mono text-[11.5px] text-slate-800 dark:text-foreground",
|
|
274
|
-
title:
|
|
275
|
-
children:
|
|
319
|
+
title: a.file_name,
|
|
320
|
+
children: a.file_name
|
|
276
321
|
}
|
|
277
322
|
)
|
|
278
323
|
},
|
|
@@ -280,18 +325,19 @@ function da({
|
|
|
280
325
|
key: "collection",
|
|
281
326
|
header: "Collection",
|
|
282
327
|
className: "w-[170px]",
|
|
283
|
-
render: (
|
|
328
|
+
render: (a) => /* @__PURE__ */ e("span", { className: "truncate font-mono text-[11.5px] text-slate-600 dark:text-muted-foreground", children: a.collection })
|
|
284
329
|
},
|
|
285
330
|
{
|
|
286
331
|
key: "progress",
|
|
287
332
|
header: "Progress",
|
|
288
333
|
className: "w-[130px]",
|
|
289
|
-
render: (
|
|
290
|
-
|
|
334
|
+
render: (a) => /* @__PURE__ */ e(
|
|
335
|
+
Zt,
|
|
291
336
|
{
|
|
292
|
-
processed:
|
|
293
|
-
total:
|
|
294
|
-
failed:
|
|
337
|
+
processed: a.processed_rows,
|
|
338
|
+
total: a.total_rows,
|
|
339
|
+
failed: a.status === "failed",
|
|
340
|
+
stopped: a.status === "cancelled"
|
|
295
341
|
}
|
|
296
342
|
)
|
|
297
343
|
},
|
|
@@ -300,39 +346,39 @@ function da({
|
|
|
300
346
|
header: "Created",
|
|
301
347
|
className: "w-[76px] text-right",
|
|
302
348
|
headerClassName: "text-right",
|
|
303
|
-
render: (
|
|
349
|
+
render: (a) => /* @__PURE__ */ e(le, { n: a.created_rows })
|
|
304
350
|
},
|
|
305
351
|
{
|
|
306
352
|
key: "updated_rows",
|
|
307
353
|
header: "Updated",
|
|
308
354
|
className: "w-[76px] text-right",
|
|
309
355
|
headerClassName: "text-right",
|
|
310
|
-
render: (
|
|
356
|
+
render: (a) => /* @__PURE__ */ e(le, { n: a.updated_rows })
|
|
311
357
|
},
|
|
312
358
|
{
|
|
313
359
|
key: "skipped_rows",
|
|
314
360
|
header: "Skipped",
|
|
315
361
|
className: "w-[76px] text-right",
|
|
316
362
|
headerClassName: "text-right",
|
|
317
|
-
render: (
|
|
363
|
+
render: (a) => /* @__PURE__ */ e(le, { n: a.skipped_rows })
|
|
318
364
|
},
|
|
319
365
|
{
|
|
320
366
|
key: "error_rows",
|
|
321
367
|
header: "Errors",
|
|
322
368
|
className: "w-[70px] text-right",
|
|
323
369
|
headerClassName: "text-right",
|
|
324
|
-
render: (
|
|
370
|
+
render: (a) => (a.error_rows ?? 0) > 0 ? /* @__PURE__ */ e("span", { className: "font-mono text-[11.5px] font-medium tabular-nums text-red-600 dark:text-red-400", children: P(a.error_rows ?? 0) }) : /* @__PURE__ */ e(le, { n: 0 })
|
|
325
371
|
},
|
|
326
372
|
{
|
|
327
373
|
key: "created_at",
|
|
328
374
|
header: "Queued",
|
|
329
375
|
className: "w-[110px]",
|
|
330
|
-
render: (
|
|
376
|
+
render: (a) => /* @__PURE__ */ e(
|
|
331
377
|
"span",
|
|
332
378
|
{
|
|
333
379
|
className: "text-[12px] text-slate-500 dark:text-muted-foreground",
|
|
334
|
-
title:
|
|
335
|
-
children:
|
|
380
|
+
title: ne(a.created_at),
|
|
381
|
+
children: Ct(a.created_at)
|
|
336
382
|
}
|
|
337
383
|
)
|
|
338
384
|
},
|
|
@@ -340,33 +386,45 @@ function da({
|
|
|
340
386
|
key: "__actions__",
|
|
341
387
|
header: "",
|
|
342
388
|
className: "w-[44px]",
|
|
343
|
-
render: (
|
|
344
|
-
/* @__PURE__ */ e(
|
|
389
|
+
render: (a) => /* @__PURE__ */ e("div", { onClick: ($) => $.stopPropagation(), onKeyDown: ($) => $.stopPropagation(), children: /* @__PURE__ */ r(Ot, { children: [
|
|
390
|
+
/* @__PURE__ */ e(Rt, { asChild: !0, children: /* @__PURE__ */ e(
|
|
345
391
|
"button",
|
|
346
392
|
{
|
|
347
393
|
type: "button",
|
|
348
394
|
className: "rounded p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-700 dark:hover:bg-muted",
|
|
349
|
-
"aria-label": `Actions for ${
|
|
350
|
-
children: /* @__PURE__ */ e(
|
|
395
|
+
"aria-label": `Actions for ${a.file_name}`,
|
|
396
|
+
children: /* @__PURE__ */ e(gt, { className: "h-4 w-4" })
|
|
351
397
|
}
|
|
352
398
|
) }),
|
|
353
|
-
/* @__PURE__ */
|
|
354
|
-
/* @__PURE__ */ e(
|
|
399
|
+
/* @__PURE__ */ r(Ft, { align: "end", className: "text-[12.5px]", children: [
|
|
400
|
+
/* @__PURE__ */ e(de, { onSelect: () => I(a.id), children: "View details" }),
|
|
401
|
+
ke.has(a.status) && /* @__PURE__ */ e(Yt, { onConfirm: () => q.mutate(a.id) }),
|
|
402
|
+
/* @__PURE__ */ r(
|
|
403
|
+
de,
|
|
404
|
+
{
|
|
405
|
+
disabled: !!R.busy,
|
|
406
|
+
onSelect: () => void R.download(`/imports/${a.id}/file`, a.file_name || "import.csv"),
|
|
407
|
+
children: [
|
|
408
|
+
/* @__PURE__ */ e(We, { className: "h-3.5 w-3.5" }),
|
|
409
|
+
" Download file"
|
|
410
|
+
]
|
|
411
|
+
}
|
|
412
|
+
),
|
|
355
413
|
/* @__PURE__ */ e(
|
|
356
|
-
|
|
414
|
+
Xt,
|
|
357
415
|
{
|
|
358
|
-
disabled:
|
|
359
|
-
rolledBack: !!
|
|
360
|
-
onConfirm: () =>
|
|
416
|
+
disabled: a.status !== "complete" && a.status !== "cancelled" || !!a.rolled_back_at,
|
|
417
|
+
rolledBack: !!a.rolled_back_at,
|
|
418
|
+
onConfirm: () => ae.mutate(a.id)
|
|
361
419
|
}
|
|
362
420
|
),
|
|
363
|
-
/* @__PURE__ */
|
|
364
|
-
|
|
421
|
+
/* @__PURE__ */ r(
|
|
422
|
+
de,
|
|
365
423
|
{
|
|
366
|
-
disabled:
|
|
367
|
-
onSelect: () =>
|
|
424
|
+
disabled: ke.has(a.status),
|
|
425
|
+
onSelect: () => z.mutate(a.id),
|
|
368
426
|
children: [
|
|
369
|
-
/* @__PURE__ */ e(
|
|
427
|
+
/* @__PURE__ */ e(wt, { className: "h-3.5 w-3.5" }),
|
|
370
428
|
" Delete job"
|
|
371
429
|
]
|
|
372
430
|
}
|
|
@@ -375,294 +433,314 @@ function da({
|
|
|
375
433
|
] }) })
|
|
376
434
|
}
|
|
377
435
|
];
|
|
378
|
-
return
|
|
379
|
-
|
|
436
|
+
return c === "wizard" ? /* @__PURE__ */ e(
|
|
437
|
+
rr,
|
|
380
438
|
{
|
|
381
439
|
onCancel: () => s("list"),
|
|
382
|
-
onCreated: (
|
|
383
|
-
s("list"), p.invalidateQueries({ queryKey: ["collection-import-jobs"] }),
|
|
440
|
+
onCreated: (a) => {
|
|
441
|
+
s("list"), p.invalidateQueries({ queryKey: ["collection-import-jobs"] }), I(a);
|
|
384
442
|
}
|
|
385
443
|
}
|
|
386
|
-
) : /* @__PURE__ */
|
|
387
|
-
|
|
388
|
-
/* @__PURE__ */
|
|
444
|
+
) : /* @__PURE__ */ r("div", { className: "flex min-h-0 flex-1 flex-col gap-3", children: [
|
|
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
|
+
/* @__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: [
|
|
389
447
|
/* @__PURE__ */ e(
|
|
390
|
-
|
|
448
|
+
Ue,
|
|
391
449
|
{
|
|
392
450
|
label: "All",
|
|
393
|
-
count:
|
|
451
|
+
count: S.length,
|
|
394
452
|
active: x === "all",
|
|
395
|
-
onClick: () =>
|
|
453
|
+
onClick: () => C("all")
|
|
396
454
|
}
|
|
397
455
|
),
|
|
398
|
-
Object.keys(
|
|
399
|
-
|
|
456
|
+
Object.keys(ee).map((a) => /* @__PURE__ */ e(
|
|
457
|
+
Ue,
|
|
400
458
|
{
|
|
401
|
-
label:
|
|
402
|
-
dot:
|
|
403
|
-
count:
|
|
404
|
-
active: x ===
|
|
405
|
-
onClick: () =>
|
|
459
|
+
label: ee[a].label,
|
|
460
|
+
dot: ee[a].dot,
|
|
461
|
+
count: v[a] ?? 0,
|
|
462
|
+
active: x === a,
|
|
463
|
+
onClick: () => C(x === a ? "all" : a)
|
|
406
464
|
},
|
|
407
|
-
|
|
465
|
+
a
|
|
408
466
|
)),
|
|
409
|
-
/* @__PURE__ */
|
|
410
|
-
/* @__PURE__ */ e(
|
|
411
|
-
/* @__PURE__ */ e(
|
|
412
|
-
/* @__PURE__ */ e(
|
|
467
|
+
/* @__PURE__ */ r("div", { className: "ml-auto flex items-stretch divide-x divide-slate-200 dark:divide-border", children: [
|
|
468
|
+
/* @__PURE__ */ e(oe, { label: "Records created", value: P(O.created) }),
|
|
469
|
+
/* @__PURE__ */ e(oe, { label: "Records updated", value: P(O.updated) }),
|
|
470
|
+
/* @__PURE__ */ e(oe, { label: "Skipped", value: P(O.skipped) }),
|
|
413
471
|
/* @__PURE__ */ e(
|
|
414
|
-
|
|
472
|
+
oe,
|
|
415
473
|
{
|
|
416
474
|
label: "Row errors",
|
|
417
|
-
value: P(
|
|
418
|
-
tone:
|
|
475
|
+
value: P(O.errors),
|
|
476
|
+
tone: O.errors > 0 ? "red" : void 0
|
|
419
477
|
}
|
|
420
478
|
)
|
|
421
479
|
] })
|
|
422
480
|
] }),
|
|
423
|
-
|
|
424
|
-
/* @__PURE__ */ e(
|
|
481
|
+
S.length === 0 && !d.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(ut, { className: "h-5 w-5 text-slate-300" }),
|
|
425
483
|
/* @__PURE__ */ e("h3", { className: "mt-3 text-[15px] font-semibold text-slate-900 dark:text-foreground", children: "No collection imports yet" }),
|
|
426
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." }),
|
|
427
|
-
/* @__PURE__ */
|
|
428
|
-
/* @__PURE__ */ e(
|
|
485
|
+
/* @__PURE__ */ r(F, { size: "sm", className: "mt-4", onClick: () => s("wizard"), children: [
|
|
486
|
+
/* @__PURE__ */ e(Ee, { className: "h-3.5 w-3.5" }),
|
|
429
487
|
" Start an import"
|
|
430
488
|
] })
|
|
431
489
|
] }) }) : /* @__PURE__ */ e("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ e(
|
|
432
|
-
|
|
490
|
+
St,
|
|
433
491
|
{
|
|
434
|
-
columns:
|
|
435
|
-
rows:
|
|
436
|
-
rowKey: (
|
|
437
|
-
total:
|
|
438
|
-
page:
|
|
439
|
-
limit:
|
|
440
|
-
onPageChange:
|
|
441
|
-
isLoading:
|
|
442
|
-
onRowClick: (
|
|
492
|
+
columns: W,
|
|
493
|
+
rows: re,
|
|
494
|
+
rowKey: (a) => a.id,
|
|
495
|
+
total: E.length,
|
|
496
|
+
page: b,
|
|
497
|
+
limit: ge,
|
|
498
|
+
onPageChange: m,
|
|
499
|
+
isLoading: d.isLoading,
|
|
500
|
+
onRowClick: (a) => I(a.id),
|
|
443
501
|
nowrapCells: !0,
|
|
444
502
|
minBodyHeight: 280,
|
|
445
503
|
emptyMessage: "No import jobs match this filter.",
|
|
446
|
-
rowClassName: (
|
|
447
|
-
toolbarRight: /* @__PURE__ */
|
|
448
|
-
/* @__PURE__ */ e(
|
|
504
|
+
rowClassName: (a) => a.status === "processing" ? "bg-nvr-cyan/5 dark:bg-nvr-cyan/10" : void 0,
|
|
505
|
+
toolbarRight: /* @__PURE__ */ r(F, { size: "sm", className: "h-7", onClick: () => s("wizard"), children: [
|
|
506
|
+
/* @__PURE__ */ e(Ee, { className: "h-3.5 w-3.5" }),
|
|
449
507
|
" New collection import"
|
|
450
508
|
] })
|
|
451
509
|
}
|
|
452
510
|
) }),
|
|
453
|
-
/* @__PURE__ */ e(
|
|
511
|
+
/* @__PURE__ */ e(sr, { jobId: k, onClose: () => I(null) })
|
|
454
512
|
] });
|
|
455
513
|
}
|
|
456
|
-
function
|
|
457
|
-
return /* @__PURE__ */ e("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-600 dark:text-muted-foreground", children: P(
|
|
514
|
+
function le({ n }) {
|
|
515
|
+
return /* @__PURE__ */ e("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-600 dark:text-muted-foreground", children: P(n ?? 0) });
|
|
458
516
|
}
|
|
459
|
-
function
|
|
460
|
-
return /* @__PURE__ */
|
|
461
|
-
/* @__PURE__ */ e("p", { className: "text-[10.5px] font-medium text-slate-400 dark:text-muted-foreground", children:
|
|
517
|
+
function oe({ label: n, value: i, tone: o }) {
|
|
518
|
+
return /* @__PURE__ */ r("div", { className: "px-3.5 py-2", children: [
|
|
519
|
+
/* @__PURE__ */ e("p", { className: "text-[10.5px] font-medium text-slate-400 dark:text-muted-foreground", children: n }),
|
|
462
520
|
/* @__PURE__ */ e(
|
|
463
521
|
"p",
|
|
464
522
|
{
|
|
465
|
-
className:
|
|
523
|
+
className: y(
|
|
466
524
|
"mt-0.5 text-[15px] font-semibold leading-none tabular-nums",
|
|
467
|
-
|
|
525
|
+
o === "red" ? "text-red-600 dark:text-red-400" : "text-slate-900 dark:text-foreground"
|
|
468
526
|
),
|
|
469
|
-
children:
|
|
527
|
+
children: i
|
|
470
528
|
}
|
|
471
529
|
)
|
|
472
530
|
] });
|
|
473
531
|
}
|
|
474
|
-
function
|
|
475
|
-
label:
|
|
476
|
-
count:
|
|
477
|
-
dot:
|
|
532
|
+
function Ue({
|
|
533
|
+
label: n,
|
|
534
|
+
count: i,
|
|
535
|
+
dot: o,
|
|
478
536
|
active: p,
|
|
479
|
-
onClick:
|
|
537
|
+
onClick: c
|
|
480
538
|
}) {
|
|
481
|
-
return /* @__PURE__ */
|
|
539
|
+
return /* @__PURE__ */ r(
|
|
482
540
|
"button",
|
|
483
541
|
{
|
|
484
542
|
type: "button",
|
|
485
|
-
onClick:
|
|
543
|
+
onClick: c,
|
|
486
544
|
"aria-pressed": p,
|
|
487
|
-
className:
|
|
545
|
+
className: y(
|
|
488
546
|
"flex items-center gap-1.5 px-3 py-2 transition-colors hover:bg-slate-50 dark:hover:bg-muted/40",
|
|
489
547
|
p && "bg-nvr-cyan/10 ring-1 ring-inset ring-nvr-cyan dark:bg-nvr-cyan/15",
|
|
490
|
-
!p &&
|
|
548
|
+
!p && i === 0 && "opacity-45"
|
|
491
549
|
),
|
|
492
550
|
children: [
|
|
493
|
-
|
|
494
|
-
/* @__PURE__ */ e("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: P(
|
|
495
|
-
/* @__PURE__ */ e("span", { className: "text-[11px] font-medium leading-none text-slate-400 dark:text-muted-foreground", children:
|
|
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(i) }),
|
|
553
|
+
/* @__PURE__ */ e("span", { className: "text-[11px] font-medium leading-none text-slate-400 dark:text-muted-foreground", children: n })
|
|
496
554
|
]
|
|
497
555
|
}
|
|
498
556
|
);
|
|
499
557
|
}
|
|
500
|
-
function
|
|
501
|
-
onCancel:
|
|
502
|
-
onCreated:
|
|
558
|
+
function rr({
|
|
559
|
+
onCancel: n,
|
|
560
|
+
onCreated: i
|
|
503
561
|
}) {
|
|
504
|
-
var
|
|
505
|
-
const
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
562
|
+
var Me, Te, De, Ae;
|
|
563
|
+
const o = te(), p = Le(null), [c, s] = g(0), [k, T] = g(""), [x, C] = g({}), [b, m] = g(""), [h, _] = g(""), [d, S] = g(""), [v, O] = g({}), [E, re] = g({}), [z, ae] = g("skip"), [q, R] = g([]), [I, W] = g(!1);
|
|
564
|
+
Z(() => {
|
|
565
|
+
q.length > 0 && W(!1);
|
|
566
|
+
}, [q.length]);
|
|
567
|
+
const [V, a] = g(!1), [$, L] = g(null), [tt, ce] = g(!1), [rt, at] = g(null), Ne = Le(null), { headers: M, rows: ye, rowCount: me } = J(() => er(k), [k]);
|
|
568
|
+
Z(() => {
|
|
569
|
+
if (!d || M.length === 0) return;
|
|
570
|
+
const t = `${d}|${M.join("")}`;
|
|
571
|
+
Ne.current !== t && (Ne.current = t, o.request(K("/imports/mappings/lookup", { collection: d, headers: M })).then((l) => {
|
|
572
|
+
const u = l.data;
|
|
573
|
+
u && O((N) => {
|
|
574
|
+
if (Object.values(N).some((w) => w == null ? void 0 : w.trim())) return N;
|
|
575
|
+
const A = {};
|
|
576
|
+
for (const w of M) u.column_map[w] && (A[w] = u.column_map[w]);
|
|
577
|
+
if (Object.keys(A).length === 0) return N;
|
|
578
|
+
at(
|
|
579
|
+
u.updated_at ? `Applied your saved mapping from ${_t(u.updated_at)}` : "Applied your saved mapping"
|
|
580
|
+
);
|
|
581
|
+
const D = u.match_fields ?? Ge(u.id_field);
|
|
582
|
+
return D.length > 0 && R((w) => w.length ? w : D), u.duplicate_strategy && ae((w) => w === "skip" && u.duplicate_strategy || w), A;
|
|
518
583
|
});
|
|
519
584
|
}).catch(() => {
|
|
520
585
|
}));
|
|
521
|
-
}, [
|
|
522
|
-
const
|
|
586
|
+
}, [d, M, o]);
|
|
587
|
+
const _e = Q({
|
|
523
588
|
queryKey: [
|
|
524
589
|
"import-diff-preview",
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
590
|
+
d,
|
|
591
|
+
q.join(","),
|
|
592
|
+
z,
|
|
528
593
|
k.length,
|
|
529
|
-
JSON.stringify(
|
|
594
|
+
JSON.stringify(v)
|
|
530
595
|
],
|
|
531
|
-
queryFn: () =>
|
|
532
|
-
|
|
533
|
-
collection:
|
|
596
|
+
queryFn: () => o.request(
|
|
597
|
+
K("/imports/preview", {
|
|
598
|
+
collection: d,
|
|
534
599
|
csv_data: k,
|
|
535
|
-
column_map:
|
|
536
|
-
|
|
537
|
-
duplicate_strategy:
|
|
600
|
+
column_map: v,
|
|
601
|
+
match_fields: q,
|
|
602
|
+
duplicate_strategy: z
|
|
538
603
|
})
|
|
539
604
|
),
|
|
540
|
-
enabled:
|
|
605
|
+
enabled: c === 3 && !!d && !!k,
|
|
541
606
|
staleTime: 3e4,
|
|
542
607
|
retry: !1
|
|
543
|
-
}),
|
|
608
|
+
}), f = (Me = _e.data) == null ? void 0 : Me.data, st = Q({
|
|
544
609
|
queryKey: ["import-collections"],
|
|
545
|
-
queryFn: () =>
|
|
610
|
+
queryFn: () => o.request(j("/collections")),
|
|
546
611
|
staleTime: 6e4
|
|
547
|
-
}),
|
|
612
|
+
}), lt = Q({
|
|
548
613
|
queryKey: ["import-collections-links"],
|
|
549
|
-
queryFn: () =>
|
|
614
|
+
queryFn: () => o.request(j("/collections/overview-stats")).then(
|
|
550
615
|
(t) => new Set(
|
|
551
616
|
Object.entries(t.data ?? {}).filter(([, l]) => l == null ? void 0 : l.link).map(([l]) => l)
|
|
552
617
|
)
|
|
553
618
|
).catch(() => /* @__PURE__ */ new Set()),
|
|
554
619
|
staleTime: 5 * 6e4,
|
|
555
620
|
retry: !1
|
|
556
|
-
}),
|
|
557
|
-
((
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
),
|
|
561
|
-
queryKey: ["import-collection-meta",
|
|
562
|
-
queryFn: () =>
|
|
563
|
-
|
|
621
|
+
}), ot = Jt(
|
|
622
|
+
((Te = st.data) == null ? void 0 : Te.data) ?? [],
|
|
623
|
+
lt.data,
|
|
624
|
+
d
|
|
625
|
+
), pe = Q({
|
|
626
|
+
queryKey: ["import-collection-meta", d],
|
|
627
|
+
queryFn: () => o.request(
|
|
628
|
+
j(`/collections/${d}`)
|
|
564
629
|
),
|
|
565
|
-
enabled: !!
|
|
630
|
+
enabled: !!d,
|
|
566
631
|
staleTime: 6e4
|
|
567
|
-
}),
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
632
|
+
}), H = Qe(((Ae = (De = pe.data) == null ? void 0 : De.data) == null ? void 0 : Ae.fields) ?? []), nt = H.map((t) => t.value), ue = J(
|
|
633
|
+
() => new Set(Object.values(v).filter((t) => t == null ? void 0 : t.trim())),
|
|
634
|
+
[v]
|
|
635
|
+
), Ce = jt(H, ue);
|
|
636
|
+
Z(() => {
|
|
637
|
+
R((t) => {
|
|
638
|
+
const l = t.filter((u) => ue.has(u));
|
|
639
|
+
return l.length === t.length ? t : l;
|
|
640
|
+
});
|
|
641
|
+
}, [ue]);
|
|
642
|
+
const dt = (t) => {
|
|
643
|
+
var l, u;
|
|
644
|
+
return t && !H.some((N) => N.value === t) ? [
|
|
645
|
+
...H,
|
|
646
|
+
...Qe(((u = (l = pe.data) == null ? void 0 : l.data) == null ? void 0 : u.fields) ?? [], t).filter(
|
|
647
|
+
(N) => N.value === t
|
|
573
648
|
)
|
|
574
|
-
] :
|
|
575
|
-
},
|
|
576
|
-
var
|
|
577
|
-
const l = t ? (
|
|
578
|
-
return /m2m|many-to-many/.test(
|
|
579
|
-
},
|
|
580
|
-
mutationFn: (t) =>
|
|
581
|
-
|
|
649
|
+
] : H;
|
|
650
|
+
}, Se = (t) => {
|
|
651
|
+
var N, A, D;
|
|
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
|
+
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 = U({
|
|
655
|
+
mutationFn: (t) => o.request(
|
|
656
|
+
K("/imports/from-url", {
|
|
582
657
|
url: t,
|
|
583
658
|
preview: !0
|
|
584
659
|
})
|
|
585
660
|
),
|
|
586
661
|
onSuccess: (t) => {
|
|
587
|
-
|
|
662
|
+
L(null), T(t.data.csv_data), m(t.data.file_name);
|
|
588
663
|
},
|
|
589
|
-
onError: (t) =>
|
|
590
|
-
}),
|
|
591
|
-
mutationFn: () =>
|
|
592
|
-
|
|
593
|
-
collection:
|
|
594
|
-
columns:
|
|
595
|
-
sample_rows:
|
|
664
|
+
onError: (t) => L(t.message)
|
|
665
|
+
}), xe = U({
|
|
666
|
+
mutationFn: () => o.request(
|
|
667
|
+
K("/ai/map-columns", {
|
|
668
|
+
collection: d,
|
|
669
|
+
columns: M,
|
|
670
|
+
sample_rows: ye.slice(0, 5)
|
|
596
671
|
})
|
|
597
672
|
),
|
|
598
673
|
onSuccess: (t) => {
|
|
599
|
-
var
|
|
600
|
-
const l = ((
|
|
601
|
-
for (const
|
|
602
|
-
|
|
603
|
-
|
|
674
|
+
var A;
|
|
675
|
+
const l = ((A = t.data) == null ? void 0 : A.mappings) ?? t.mappings ?? [], u = { ...v }, N = {};
|
|
676
|
+
for (const D of l)
|
|
677
|
+
M.includes(D.column) && (u[D.column] = D.field ?? "", D.field && (N[D.column] = D.confidence ?? 0));
|
|
678
|
+
O(u), re(N), L(null);
|
|
604
679
|
},
|
|
605
|
-
onError: (t) =>
|
|
680
|
+
onError: (t) => L(
|
|
606
681
|
t.status === 503 ? "AI mapping needs an Anthropic API key — add one in Settings, or map the columns by hand." : t.message
|
|
607
682
|
)
|
|
608
|
-
}),
|
|
609
|
-
mutationFn: () =>
|
|
610
|
-
|
|
611
|
-
collection:
|
|
683
|
+
}), be = U({
|
|
684
|
+
mutationFn: () => o.request(
|
|
685
|
+
K("/imports", {
|
|
686
|
+
collection: d,
|
|
612
687
|
csv_data: k,
|
|
613
|
-
column_map:
|
|
688
|
+
column_map: v,
|
|
614
689
|
transforms: Object.fromEntries(Object.entries(x).filter(([, t]) => t)),
|
|
615
|
-
duplicate_strategy:
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
690
|
+
duplicate_strategy: z,
|
|
691
|
+
match_fields: q,
|
|
692
|
+
// Sent only after the explicit "create every row" confirm (the server refuses
|
|
693
|
+
// overwrite / merge without match fields otherwise).
|
|
694
|
+
confirm_no_match: q.length === 0 && I,
|
|
695
|
+
file_name: b || "import.csv",
|
|
696
|
+
through_items: V
|
|
619
697
|
})
|
|
620
698
|
),
|
|
621
|
-
onSuccess: (t) =>
|
|
622
|
-
onError: (t) =>
|
|
699
|
+
onSuccess: (t) => i(t.data.id),
|
|
700
|
+
onError: (t) => L(t.message)
|
|
623
701
|
});
|
|
624
|
-
function
|
|
625
|
-
|
|
626
|
-
const
|
|
627
|
-
return delete
|
|
702
|
+
function qe(t, l) {
|
|
703
|
+
O((u) => ({ ...u, [t]: l })), E[t] !== void 0 && re((u) => {
|
|
704
|
+
const N = { ...u };
|
|
705
|
+
return delete N[t], N;
|
|
628
706
|
});
|
|
629
707
|
}
|
|
630
|
-
async function
|
|
631
|
-
t && (
|
|
708
|
+
async function $e(t) {
|
|
709
|
+
t && (L(null), T(await t.text()), m(t.name));
|
|
632
710
|
}
|
|
633
|
-
const
|
|
634
|
-
const t = k.split(/\r?\n/).filter((
|
|
711
|
+
const B = J(() => {
|
|
712
|
+
const t = k.split(/\r?\n/).filter((A) => A.trim());
|
|
635
713
|
if (t.length < 2) return {};
|
|
636
|
-
const l =
|
|
637
|
-
return l.forEach((
|
|
638
|
-
let
|
|
639
|
-
for (const
|
|
640
|
-
const
|
|
641
|
-
|
|
714
|
+
const l = ie(t[0]), u = t.slice(1, 2001).map(ie), N = {};
|
|
715
|
+
return l.forEach((A, D) => {
|
|
716
|
+
let w = 0, Oe = 0, Re = 0, Fe = 0;
|
|
717
|
+
for (const mt of u) {
|
|
718
|
+
const G = (mt[D] ?? "").trim();
|
|
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++);
|
|
642
720
|
}
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
}),
|
|
646
|
-
}, [k]),
|
|
721
|
+
const ct = 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: ct };
|
|
723
|
+
}), N;
|
|
724
|
+
}, [k]), fe = M.filter((t) => {
|
|
647
725
|
var l;
|
|
648
|
-
return (l =
|
|
649
|
-
}).length,
|
|
650
|
-
return /* @__PURE__ */
|
|
651
|
-
/* @__PURE__ */
|
|
652
|
-
/* @__PURE__ */
|
|
653
|
-
/* @__PURE__ */ e(
|
|
726
|
+
return (l = v[t]) == null ? void 0 : l.trim();
|
|
727
|
+
}).length, Pe = rt, it = c === 0 ? M.length > 0 : c === 1 ? !!d && fe > 0 : !0;
|
|
728
|
+
return /* @__PURE__ */ r("div", { className: "flex min-h-0 flex-1 flex-col gap-4", children: [
|
|
729
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
|
|
730
|
+
/* @__PURE__ */ r(F, { variant: "ghost", size: "sm", className: "h-7 px-2", onClick: n, children: [
|
|
731
|
+
/* @__PURE__ */ e(Ie, { className: "h-3.5 w-3.5" }),
|
|
654
732
|
" Back to jobs"
|
|
655
733
|
] }),
|
|
656
|
-
/* @__PURE__ */ e("ol", { className: "flex items-center gap-1.5", children:
|
|
657
|
-
/* @__PURE__ */
|
|
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: [
|
|
735
|
+
/* @__PURE__ */ r(
|
|
658
736
|
"button",
|
|
659
737
|
{
|
|
660
738
|
type: "button",
|
|
661
|
-
onClick: () => l <
|
|
662
|
-
disabled: l >
|
|
663
|
-
className:
|
|
739
|
+
onClick: () => l < c && s(l),
|
|
740
|
+
disabled: l > c,
|
|
741
|
+
className: y(
|
|
664
742
|
"flex items-center gap-1.5 rounded-md px-2 py-1 text-[12px] font-medium transition-colors",
|
|
665
|
-
l ===
|
|
743
|
+
l === c ? "bg-nvr-cyan/15 text-nvr-navy dark:bg-nvr-cyan/20 dark:text-nvr-cyan" : l < c ? "text-slate-600 hover:bg-slate-100 dark:text-muted-foreground dark:hover:bg-muted" : "text-slate-300 dark:text-slate-600"
|
|
666
744
|
),
|
|
667
745
|
children: [
|
|
668
746
|
/* @__PURE__ */ e("span", { className: "tabular-nums", children: l + 1 }),
|
|
@@ -670,11 +748,11 @@ function Et({
|
|
|
670
748
|
]
|
|
671
749
|
}
|
|
672
750
|
),
|
|
673
|
-
l <
|
|
751
|
+
l < we.length - 1 && /* @__PURE__ */ e("span", { className: "text-slate-300", children: "›" })
|
|
674
752
|
] }, t)) })
|
|
675
753
|
] }),
|
|
676
|
-
/* @__PURE__ */
|
|
677
|
-
|
|
754
|
+
/* @__PURE__ */ r("div", { className: "min-h-0 flex-1 overflow-y-auto rounded-lg border border-slate-200 bg-white p-5 dark:border-border dark:bg-card", children: [
|
|
755
|
+
c === 0 && /* @__PURE__ */ r("div", { className: "max-w-[980px] space-y-5", children: [
|
|
678
756
|
/* @__PURE__ */ e(
|
|
679
757
|
"input",
|
|
680
758
|
{
|
|
@@ -684,12 +762,12 @@ function Et({
|
|
|
684
762
|
className: "hidden",
|
|
685
763
|
onChange: (t) => {
|
|
686
764
|
var l;
|
|
687
|
-
|
|
765
|
+
$e(((l = t.target.files) == null ? void 0 : l[0]) ?? null), t.target.value = "";
|
|
688
766
|
}
|
|
689
767
|
}
|
|
690
768
|
),
|
|
691
|
-
/* @__PURE__ */
|
|
692
|
-
/* @__PURE__ */
|
|
769
|
+
/* @__PURE__ */ r("div", { className: "grid gap-4 lg:grid-cols-2", children: [
|
|
770
|
+
/* @__PURE__ */ r(
|
|
693
771
|
"button",
|
|
694
772
|
{
|
|
695
773
|
type: "button",
|
|
@@ -698,42 +776,42 @@ function Et({
|
|
|
698
776
|
return (t = p.current) == null ? void 0 : t.click();
|
|
699
777
|
},
|
|
700
778
|
onDragOver: (t) => {
|
|
701
|
-
t.preventDefault(),
|
|
779
|
+
t.preventDefault(), ce(!0);
|
|
702
780
|
},
|
|
703
|
-
onDragLeave: () =>
|
|
781
|
+
onDragLeave: () => ce(!1),
|
|
704
782
|
onDrop: (t) => {
|
|
705
783
|
var l;
|
|
706
|
-
t.preventDefault(),
|
|
784
|
+
t.preventDefault(), ce(!1), $e(((l = t.dataTransfer.files) == null ? void 0 : l[0]) ?? null);
|
|
707
785
|
},
|
|
708
|
-
className:
|
|
786
|
+
className: y(
|
|
709
787
|
"flex flex-col items-center justify-center gap-1.5 rounded-md border border-dashed px-4 py-8 transition-colors",
|
|
710
|
-
|
|
788
|
+
tt ? "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"
|
|
711
789
|
),
|
|
712
790
|
children: [
|
|
713
|
-
/* @__PURE__ */ e(
|
|
791
|
+
/* @__PURE__ */ e(ht, { className: "h-4 w-4 text-slate-400" }),
|
|
714
792
|
/* @__PURE__ */ e("span", { className: "text-[12.5px] font-medium text-slate-700 dark:text-foreground", children: "Drop a CSV, or click to choose" }),
|
|
715
|
-
|
|
793
|
+
b && /* @__PURE__ */ e("span", { className: "font-mono text-[11px] text-slate-500", children: b })
|
|
716
794
|
]
|
|
717
795
|
}
|
|
718
796
|
),
|
|
719
|
-
/* @__PURE__ */
|
|
720
|
-
/* @__PURE__ */
|
|
721
|
-
/* @__PURE__ */ e(
|
|
797
|
+
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
798
|
+
/* @__PURE__ */ r(X, { className: "flex items-center gap-1.5 text-[11.5px]", children: [
|
|
799
|
+
/* @__PURE__ */ e(xt, { className: "h-3.5 w-3.5 text-slate-400" }),
|
|
722
800
|
" Or fetch from a URL"
|
|
723
801
|
] }),
|
|
724
|
-
/* @__PURE__ */
|
|
802
|
+
/* @__PURE__ */ r(
|
|
725
803
|
"form",
|
|
726
804
|
{
|
|
727
805
|
className: "flex items-center gap-2",
|
|
728
806
|
onSubmit: (t) => {
|
|
729
|
-
t.preventDefault(),
|
|
807
|
+
t.preventDefault(), h.trim() && he.mutate(h.trim());
|
|
730
808
|
},
|
|
731
809
|
children: [
|
|
732
810
|
/* @__PURE__ */ e(
|
|
733
|
-
|
|
811
|
+
Ke,
|
|
734
812
|
{
|
|
735
|
-
value:
|
|
736
|
-
onChange: (t) =>
|
|
813
|
+
value: h,
|
|
814
|
+
onChange: (t) => _(t.target.value),
|
|
737
815
|
placeholder: "https://example.com/data.csv",
|
|
738
816
|
className: "h-8 font-mono text-[12px]"
|
|
739
817
|
}
|
|
@@ -745,8 +823,8 @@ function Et({
|
|
|
745
823
|
variant: "outline",
|
|
746
824
|
size: "sm",
|
|
747
825
|
className: "h-8 shrink-0",
|
|
748
|
-
disabled: !
|
|
749
|
-
children:
|
|
826
|
+
disabled: !h.trim() || he.isPending,
|
|
827
|
+
children: he.isPending ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }) : "Fetch"
|
|
750
828
|
}
|
|
751
829
|
)
|
|
752
830
|
]
|
|
@@ -755,14 +833,14 @@ function Et({
|
|
|
755
833
|
/* @__PURE__ */ e("p", { className: "text-[11px] leading-snug text-slate-400", children: "The server fetches it (25MB max, CSV or plain text) so the file never has to round-trip through your machine." })
|
|
756
834
|
] })
|
|
757
835
|
] }),
|
|
758
|
-
/* @__PURE__ */
|
|
759
|
-
/* @__PURE__ */ e(
|
|
836
|
+
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
837
|
+
/* @__PURE__ */ e(X, { className: "text-[11.5px]", children: "Or paste the rows" }),
|
|
760
838
|
/* @__PURE__ */ e(
|
|
761
|
-
|
|
839
|
+
Ut,
|
|
762
840
|
{
|
|
763
841
|
value: k,
|
|
764
842
|
onChange: (t) => {
|
|
765
|
-
|
|
843
|
+
T(t.target.value), b || m("pasted.csv");
|
|
766
844
|
},
|
|
767
845
|
rows: 5,
|
|
768
846
|
spellCheck: !1,
|
|
@@ -772,110 +850,110 @@ val1,val2,val3`,
|
|
|
772
850
|
}
|
|
773
851
|
)
|
|
774
852
|
] }),
|
|
775
|
-
|
|
776
|
-
/* @__PURE__ */
|
|
777
|
-
/* @__PURE__ */ e("span", { className: "font-semibold text-slate-900 dark:text-foreground", children: P(
|
|
853
|
+
M.length > 0 && /* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
854
|
+
/* @__PURE__ */ r("p", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: [
|
|
855
|
+
/* @__PURE__ */ e("span", { className: "font-semibold text-slate-900 dark:text-foreground", children: P(me) }),
|
|
778
856
|
" ",
|
|
779
857
|
"data rows ×",
|
|
780
858
|
" ",
|
|
781
|
-
/* @__PURE__ */ e("span", { className: "font-semibold text-slate-900 dark:text-foreground", children:
|
|
859
|
+
/* @__PURE__ */ e("span", { className: "font-semibold text-slate-900 dark:text-foreground", children: M.length }),
|
|
782
860
|
" ",
|
|
783
861
|
"columns"
|
|
784
862
|
] }),
|
|
785
|
-
/* @__PURE__ */ e(
|
|
863
|
+
/* @__PURE__ */ e(ar, { headers: M, rows: ye })
|
|
786
864
|
] })
|
|
787
865
|
] }),
|
|
788
|
-
|
|
866
|
+
c === 1 && // Bounded width: a mapping row is a form field, and stretching the
|
|
789
867
|
// pickers to a 1600px viewport puts the CSV column and the field it
|
|
790
868
|
// maps to half a screen apart.
|
|
791
|
-
/* @__PURE__ */
|
|
792
|
-
/* @__PURE__ */
|
|
793
|
-
/* @__PURE__ */
|
|
794
|
-
/* @__PURE__ */ e(
|
|
869
|
+
/* @__PURE__ */ r("div", { className: "max-w-[860px] space-y-4", children: [
|
|
870
|
+
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-end justify-between gap-3", children: [
|
|
871
|
+
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
872
|
+
/* @__PURE__ */ e(X, { className: "text-[11.5px]", children: "Target collection" }),
|
|
795
873
|
/* @__PURE__ */ e("div", { className: "w-[260px]", children: /* @__PURE__ */ e(
|
|
796
|
-
|
|
874
|
+
se,
|
|
797
875
|
{
|
|
798
|
-
value:
|
|
799
|
-
onChange:
|
|
800
|
-
options:
|
|
876
|
+
value: d,
|
|
877
|
+
onChange: S,
|
|
878
|
+
options: ot,
|
|
801
879
|
placeholder: "Choose a collection…",
|
|
802
880
|
wide: !0
|
|
803
881
|
}
|
|
804
882
|
) }),
|
|
805
883
|
/* @__PURE__ */ e("p", { className: "text-[11px] text-slate-400", children: "Rows are written through the item API, so this collection's validation, hooks and permissions all apply." })
|
|
806
884
|
] }),
|
|
807
|
-
/* @__PURE__ */
|
|
885
|
+
/* @__PURE__ */ r(
|
|
808
886
|
F,
|
|
809
887
|
{
|
|
810
888
|
variant: "outline",
|
|
811
889
|
size: "sm",
|
|
812
890
|
className: "h-8",
|
|
813
|
-
disabled: !
|
|
814
|
-
onClick: () =>
|
|
891
|
+
disabled: !d || M.length === 0 || xe.isPending,
|
|
892
|
+
onClick: () => xe.mutate(),
|
|
815
893
|
children: [
|
|
816
|
-
|
|
894
|
+
xe.isPending ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(bt, { className: "h-3.5 w-3.5 text-nvr-cyan" }),
|
|
817
895
|
"Match columns with AI"
|
|
818
896
|
]
|
|
819
897
|
}
|
|
820
898
|
)
|
|
821
899
|
] }),
|
|
822
|
-
/* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: /* @__PURE__ */
|
|
823
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */
|
|
900
|
+
/* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: /* @__PURE__ */ r("table", { className: "w-full border-collapse", children: [
|
|
901
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ r("tr", { className: "bg-slate-50 dark:bg-muted/40", children: [
|
|
824
902
|
/* @__PURE__ */ e("th", { className: "w-[45%] border-b border-slate-200 px-3 py-1.5 text-left text-[10.5px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: "CSV column" }),
|
|
825
903
|
/* @__PURE__ */ e("th", { className: "border-b border-slate-200 px-3 py-1.5 text-left text-[10.5px] font-medium uppercase tracking-wide text-slate-400 dark:border-border", children: "Collection field" })
|
|
826
904
|
] }) }),
|
|
827
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
905
|
+
/* @__PURE__ */ e("tbody", { children: M.map((t) => /* @__PURE__ */ r(
|
|
828
906
|
"tr",
|
|
829
907
|
{
|
|
830
908
|
className: "border-b border-slate-100 last:border-b-0 dark:border-border/60",
|
|
831
909
|
children: [
|
|
832
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ r("td", { className: "px-3 py-1.5 font-mono text-[11.5px] text-slate-600 dark:text-muted-foreground", children: [
|
|
833
911
|
t,
|
|
834
|
-
|
|
912
|
+
B[t] && /* @__PURE__ */ r(
|
|
835
913
|
"span",
|
|
836
914
|
{
|
|
837
|
-
className:
|
|
915
|
+
className: y(
|
|
838
916
|
"ml-2 rounded px-1 py-0.5 font-sans text-[9.5px] font-medium",
|
|
839
|
-
|
|
917
|
+
B[t].fill < 50 ? "bg-amber-100 text-amber-700 dark:bg-amber-400/15 dark:text-amber-400" : "bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-400"
|
|
840
918
|
),
|
|
841
|
-
"data-tip": `${
|
|
919
|
+
"data-tip": `${B[t].fill}% of rows have a value · looks like ${B[t].guess}`,
|
|
842
920
|
children: [
|
|
843
|
-
|
|
921
|
+
B[t].guess,
|
|
844
922
|
" · ",
|
|
845
|
-
|
|
923
|
+
B[t].fill,
|
|
846
924
|
"%"
|
|
847
925
|
]
|
|
848
926
|
}
|
|
849
927
|
)
|
|
850
928
|
] }),
|
|
851
|
-
/* @__PURE__ */
|
|
852
|
-
/* @__PURE__ */
|
|
853
|
-
/* @__PURE__ */ e("div", { className: "w-[220px]", children:
|
|
854
|
-
|
|
929
|
+
/* @__PURE__ */ r("td", { className: "px-3 py-1.5", children: [
|
|
930
|
+
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
931
|
+
/* @__PURE__ */ e("div", { className: "w-[220px]", children: nt.length > 0 ? /* @__PURE__ */ e(
|
|
932
|
+
se,
|
|
855
933
|
{
|
|
856
|
-
value:
|
|
857
|
-
onChange: (l) =>
|
|
934
|
+
value: v[t] ?? "",
|
|
935
|
+
onChange: (l) => qe(t, l),
|
|
858
936
|
options: [
|
|
859
937
|
{ value: "", label: "Skip this column" },
|
|
860
|
-
...
|
|
938
|
+
...dt(v[t])
|
|
861
939
|
],
|
|
862
940
|
placeholder: "Skip this column"
|
|
863
941
|
}
|
|
864
942
|
) : /* @__PURE__ */ e(
|
|
865
|
-
|
|
943
|
+
Ke,
|
|
866
944
|
{
|
|
867
|
-
value:
|
|
868
|
-
onChange: (l) =>
|
|
945
|
+
value: v[t] ?? "",
|
|
946
|
+
onChange: (l) => qe(t, l.target.value),
|
|
869
947
|
placeholder: "field_name",
|
|
870
948
|
className: "h-8 font-mono text-[12px]"
|
|
871
949
|
}
|
|
872
950
|
) }),
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
951
|
+
E[t] !== void 0 && v[t] && /* @__PURE__ */ e(tr, { confidence: E[t] }),
|
|
952
|
+
v[t] && /* @__PURE__ */ e("div", { className: "w-[120px]", children: /* @__PURE__ */ e(
|
|
953
|
+
se,
|
|
876
954
|
{
|
|
877
955
|
value: x[t] ?? "",
|
|
878
|
-
onChange: (l) =>
|
|
956
|
+
onChange: (l) => C((u) => ({ ...u, [t]: l })),
|
|
879
957
|
options: [
|
|
880
958
|
{ value: "", label: "As-is" },
|
|
881
959
|
{ value: "trim", label: "Trim" },
|
|
@@ -888,29 +966,29 @@ val1,val2,val3`,
|
|
|
888
966
|
}
|
|
889
967
|
) })
|
|
890
968
|
] }),
|
|
891
|
-
|
|
969
|
+
Se(v[t]) && /* @__PURE__ */ e("p", { className: "mt-1 text-[11px] text-slate-500 dark:text-muted-foreground", children: Se(v[t]) })
|
|
892
970
|
] })
|
|
893
971
|
]
|
|
894
972
|
},
|
|
895
973
|
t
|
|
896
974
|
)) })
|
|
897
975
|
] }) }),
|
|
898
|
-
/* @__PURE__ */
|
|
899
|
-
|
|
976
|
+
/* @__PURE__ */ r("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
|
|
977
|
+
fe,
|
|
900
978
|
" of ",
|
|
901
|
-
|
|
979
|
+
M.length,
|
|
902
980
|
" columns mapped — unmapped columns are ignored.",
|
|
903
|
-
|
|
981
|
+
Pe && /* @__PURE__ */ e("span", { className: "ml-1.5 rounded bg-sky-500/10 px-1.5 py-0.5 text-[10.5px] font-medium text-sky-700 dark:text-sky-400", children: Pe })
|
|
904
982
|
] })
|
|
905
983
|
] }),
|
|
906
|
-
|
|
907
|
-
/* @__PURE__ */
|
|
908
|
-
/* @__PURE__ */ e(
|
|
984
|
+
c === 2 && /* @__PURE__ */ r("div", { className: "max-w-[520px] space-y-4", children: [
|
|
985
|
+
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
986
|
+
/* @__PURE__ */ e(X, { className: "text-[11.5px]", children: "When a record already exists" }),
|
|
909
987
|
/* @__PURE__ */ e(
|
|
910
|
-
|
|
988
|
+
zt,
|
|
911
989
|
{
|
|
912
|
-
value:
|
|
913
|
-
onChange:
|
|
990
|
+
value: z,
|
|
991
|
+
onChange: ae,
|
|
914
992
|
options: [
|
|
915
993
|
{ value: "skip", label: "Skip — leave the existing record alone" },
|
|
916
994
|
{ value: "overwrite", label: "Overwrite — replace every mapped field" },
|
|
@@ -920,73 +998,114 @@ val1,val2,val3`,
|
|
|
920
998
|
}
|
|
921
999
|
)
|
|
922
1000
|
] }),
|
|
923
|
-
/* @__PURE__ */
|
|
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: [
|
|
924
1002
|
/* @__PURE__ */ e(
|
|
925
|
-
|
|
1003
|
+
He,
|
|
926
1004
|
{
|
|
927
1005
|
id: "csv-through-items",
|
|
928
|
-
checked:
|
|
929
|
-
onCheckedChange:
|
|
1006
|
+
checked: V,
|
|
1007
|
+
onCheckedChange: a,
|
|
930
1008
|
className: "mt-0.5",
|
|
931
1009
|
"data-csv-through-items": !0
|
|
932
1010
|
}
|
|
933
1011
|
),
|
|
934
|
-
/* @__PURE__ */
|
|
1012
|
+
/* @__PURE__ */ r("label", { htmlFor: "csv-through-items", className: "cursor-pointer", children: [
|
|
935
1013
|
/* @__PURE__ */ e("span", { className: "block text-[12px] font-medium text-slate-800 dark:text-foreground", children: "Apply rules and keep history" }),
|
|
936
1014
|
/* @__PURE__ */ e("span", { className: "block text-[11px] leading-snug text-slate-500 dark:text-muted-foreground", children: "Each row is saved the way the form saves it: field rules, validation, automations, and a revision on every record, credited to you. Rows that break a rule are reported instead of written. Unchanged fields are left alone. Slower on large files." })
|
|
937
1015
|
] })
|
|
938
1016
|
] }),
|
|
939
|
-
/* @__PURE__ */
|
|
940
|
-
/* @__PURE__ */ e(
|
|
1017
|
+
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
1018
|
+
/* @__PURE__ */ e(X, { className: "text-[11.5px]", children: "Match records on" }),
|
|
1019
|
+
q.length > 0 && /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", "data-csv-match-fields": !0, children: q.map((t) => {
|
|
1020
|
+
var l;
|
|
1021
|
+
return /* @__PURE__ */ r(
|
|
1022
|
+
"span",
|
|
1023
|
+
{
|
|
1024
|
+
className: "inline-flex h-6 items-center gap-1 rounded-md border border-slate-200 bg-white pl-2 pr-1 font-mono text-[11.5px] text-slate-700 dark:border-border dark:bg-card dark:text-foreground",
|
|
1025
|
+
children: [
|
|
1026
|
+
((l = Ce.find((u) => u.value === t)) == null ? void 0 : l.label) ?? t,
|
|
1027
|
+
/* @__PURE__ */ e(
|
|
1028
|
+
"button",
|
|
1029
|
+
{
|
|
1030
|
+
type: "button",
|
|
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
|
+
"aria-label": `Stop matching on ${t}`,
|
|
1033
|
+
onClick: () => R((u) => u.filter((N) => N !== t)),
|
|
1034
|
+
children: /* @__PURE__ */ e(ft, { className: "h-3 w-3" })
|
|
1035
|
+
}
|
|
1036
|
+
)
|
|
1037
|
+
]
|
|
1038
|
+
},
|
|
1039
|
+
t
|
|
1040
|
+
);
|
|
1041
|
+
}) }),
|
|
941
1042
|
/* @__PURE__ */ e(
|
|
942
|
-
|
|
1043
|
+
se,
|
|
943
1044
|
{
|
|
944
|
-
value:
|
|
945
|
-
onChange:
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
...j.filter(
|
|
951
|
-
(t) => t.value !== "id" && !/links several/.test(t.hint ?? "")
|
|
952
|
-
)
|
|
953
|
-
],
|
|
954
|
-
placeholder: "Always create new records",
|
|
1045
|
+
value: "",
|
|
1046
|
+
onChange: (t) => {
|
|
1047
|
+
t && R((l) => l.includes(t) ? l : [...l, t]);
|
|
1048
|
+
},
|
|
1049
|
+
options: Ce.filter((t) => !q.includes(t.value)),
|
|
1050
|
+
placeholder: q.length ? "Add another match field…" : "Pick a match field…",
|
|
955
1051
|
className: "w-[260px]"
|
|
956
1052
|
}
|
|
957
1053
|
),
|
|
958
|
-
/* @__PURE__ */ e("p", { className: "text-[11px] leading-snug text-slate-400", children: "
|
|
1054
|
+
/* @__PURE__ */ e("p", { className: "text-[11px] leading-snug text-slate-400", children: "A row updates the existing record whose match fields ALL equal the row's (pick several when one is not unique, e.g. warehouse and item). Two matching records make that row an error. Only fields a column of the file is mapped to can be picked." }),
|
|
1055
|
+
/* @__PURE__ */ e(
|
|
1056
|
+
Be,
|
|
1057
|
+
{
|
|
1058
|
+
matchFields: q,
|
|
1059
|
+
confirmed: I,
|
|
1060
|
+
onConfirm: W
|
|
1061
|
+
}
|
|
1062
|
+
)
|
|
959
1063
|
] })
|
|
960
1064
|
] }),
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1065
|
+
c === 3 && /* @__PURE__ */ r("div", { className: "max-w-[620px] space-y-4", children: [
|
|
1066
|
+
/* @__PURE__ */ e(
|
|
1067
|
+
Be,
|
|
1068
|
+
{
|
|
1069
|
+
matchFields: q,
|
|
1070
|
+
confirmed: I,
|
|
1071
|
+
onConfirm: W
|
|
1072
|
+
}
|
|
1073
|
+
),
|
|
1074
|
+
_e.isLoading && /* @__PURE__ */ e("p", { className: "text-[12px] text-slate-400", children: "Comparing against the live data…" }),
|
|
1075
|
+
f && /* @__PURE__ */ r("div", { className: "space-y-2", children: [
|
|
1076
|
+
/* @__PURE__ */ r("div", { className: "flex flex-wrap gap-2", children: [
|
|
965
1077
|
[
|
|
966
1078
|
{
|
|
967
1079
|
label: "new",
|
|
968
|
-
n:
|
|
1080
|
+
n: f.new,
|
|
969
1081
|
cls: "border-emerald-300 text-emerald-700 dark:border-emerald-500/40 dark:text-emerald-400"
|
|
970
1082
|
},
|
|
971
1083
|
{
|
|
972
1084
|
label: "changed",
|
|
973
|
-
n:
|
|
1085
|
+
n: f.changed,
|
|
974
1086
|
cls: "border-amber-300 text-amber-700 dark:border-amber-500/40 dark:text-amber-400"
|
|
975
1087
|
},
|
|
976
1088
|
{
|
|
977
|
-
label:
|
|
978
|
-
n:
|
|
1089
|
+
label: f.conflicts === 1 ? "conflict" : "conflicts",
|
|
1090
|
+
n: f.conflicts,
|
|
979
1091
|
cls: "border-red-300 text-red-700 dark:border-red-500/40 dark:text-red-400"
|
|
980
1092
|
},
|
|
981
1093
|
{
|
|
982
1094
|
label: "unchanged",
|
|
983
|
-
n:
|
|
1095
|
+
n: f.unchanged,
|
|
984
1096
|
cls: "border-slate-200 text-slate-500 dark:border-border dark:text-slate-400"
|
|
985
|
-
}
|
|
986
|
-
|
|
1097
|
+
},
|
|
1098
|
+
...(f.ambiguous ?? 0) > 0 ? [
|
|
1099
|
+
{
|
|
1100
|
+
label: "match several records",
|
|
1101
|
+
n: f.ambiguous ?? 0,
|
|
1102
|
+
cls: "border-red-300 text-red-700 dark:border-red-500/40 dark:text-red-400"
|
|
1103
|
+
}
|
|
1104
|
+
] : []
|
|
1105
|
+
].map((t) => /* @__PURE__ */ r(
|
|
987
1106
|
"span",
|
|
988
1107
|
{
|
|
989
|
-
className:
|
|
1108
|
+
className: y(
|
|
990
1109
|
"inline-flex items-center gap-1.5 rounded-full border bg-white px-2.5 py-1 text-[12px] font-medium dark:bg-card",
|
|
991
1110
|
t.cls
|
|
992
1111
|
),
|
|
@@ -998,22 +1117,22 @@ val1,val2,val3`,
|
|
|
998
1117
|
},
|
|
999
1118
|
t.label
|
|
1000
1119
|
)),
|
|
1001
|
-
|
|
1120
|
+
f.truncated && /* @__PURE__ */ r("span", { className: "self-center text-[11px] text-slate-400", children: [
|
|
1002
1121
|
"(first ",
|
|
1003
|
-
P(
|
|
1122
|
+
P(f.total),
|
|
1004
1123
|
" rows scanned)"
|
|
1005
1124
|
] })
|
|
1006
1125
|
] }),
|
|
1007
|
-
|
|
1126
|
+
f.diffs.length > 0 && /* @__PURE__ */ e("div", { className: "max-h-56 overflow-y-auto rounded-md border border-slate-200 dark:border-border", children: f.diffs.map((t) => /* @__PURE__ */ r(
|
|
1008
1127
|
"div",
|
|
1009
1128
|
{
|
|
1010
1129
|
className: "border-b border-slate-100 px-3 py-2 text-[12px] last:border-b-0 dark:border-border/60",
|
|
1011
1130
|
children: [
|
|
1012
|
-
/* @__PURE__ */
|
|
1131
|
+
/* @__PURE__ */ r("p", { className: "flex items-center gap-2", children: [
|
|
1013
1132
|
/* @__PURE__ */ e(
|
|
1014
1133
|
"span",
|
|
1015
1134
|
{
|
|
1016
|
-
className:
|
|
1135
|
+
className: y(
|
|
1017
1136
|
"rounded px-1.5 py-0.5 text-[10.5px] font-semibold uppercase tracking-wide",
|
|
1018
1137
|
t.kind === "conflict" ? "bg-red-500/10 text-red-600 dark:text-red-400" : "bg-amber-400/10 text-amber-600 dark:text-amber-400"
|
|
1019
1138
|
),
|
|
@@ -1021,14 +1140,14 @@ val1,val2,val3`,
|
|
|
1021
1140
|
}
|
|
1022
1141
|
),
|
|
1023
1142
|
/* @__PURE__ */ e("span", { className: "font-mono text-[11.5px]", children: t.id }),
|
|
1024
|
-
/* @__PURE__ */
|
|
1143
|
+
/* @__PURE__ */ r("span", { className: "text-[11px] text-slate-400", children: [
|
|
1025
1144
|
"row ",
|
|
1026
1145
|
t.row
|
|
1027
1146
|
] })
|
|
1028
1147
|
] }),
|
|
1029
1148
|
t.reason && /* @__PURE__ */ e("p", { className: "mt-0.5 text-[11px] text-slate-500 dark:text-muted-foreground", children: t.reason }),
|
|
1030
|
-
t.fields.map((l) => /* @__PURE__ */
|
|
1031
|
-
/* @__PURE__ */
|
|
1149
|
+
t.fields.map((l) => /* @__PURE__ */ r("p", { className: "mt-0.5 font-mono text-[11px]", children: [
|
|
1150
|
+
/* @__PURE__ */ r("span", { className: "text-slate-400", children: [
|
|
1032
1151
|
l.field,
|
|
1033
1152
|
":"
|
|
1034
1153
|
] }),
|
|
@@ -1041,19 +1160,38 @@ val1,val2,val3`,
|
|
|
1041
1160
|
},
|
|
1042
1161
|
`${t.row}-${t.id}`
|
|
1043
1162
|
)) }),
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
(
|
|
1047
|
-
/* @__PURE__ */
|
|
1048
|
-
P(
|
|
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(Bt, { dup: f.duplicates }),
|
|
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
|
+
/* @__PURE__ */ r("p", { className: "text-[12px] font-medium text-red-700 dark:text-red-300", children: [
|
|
1167
|
+
P(f.value_error_rows ?? 0),
|
|
1049
1168
|
" ",
|
|
1050
|
-
|
|
1169
|
+
f.value_error_rows === 1 ? "row has a value" : "rows have values",
|
|
1170
|
+
" its field cannot hold — ",
|
|
1171
|
+
f.value_error_rows === 1 ? "it" : "they",
|
|
1172
|
+
" will not be imported"
|
|
1173
|
+
] }),
|
|
1174
|
+
/* @__PURE__ */ e("ul", { className: "mt-1 max-h-32 space-y-0.5 overflow-y-auto text-[11.5px] text-red-700 dark:text-red-300", children: (f.value_problems ?? []).map((t) => /* @__PURE__ */ r("li", { children: [
|
|
1175
|
+
/* @__PURE__ */ r("span", { className: "text-red-500/80 dark:text-red-400/70", children: [
|
|
1176
|
+
"Row ",
|
|
1177
|
+
t.row,
|
|
1178
|
+
":"
|
|
1179
|
+
] }),
|
|
1180
|
+
" ",
|
|
1181
|
+
t.error
|
|
1182
|
+
] }, `${t.row}-${t.error}`)) })
|
|
1183
|
+
] }),
|
|
1184
|
+
(f.link_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: [
|
|
1185
|
+
/* @__PURE__ */ r("p", { className: "text-[12px] font-medium text-red-700 dark:text-red-300", children: [
|
|
1186
|
+
P(f.link_error_rows ?? 0),
|
|
1187
|
+
" ",
|
|
1188
|
+
f.link_error_rows === 1 ? "row names" : "rows name",
|
|
1051
1189
|
" a record that does not exist — ",
|
|
1052
|
-
|
|
1190
|
+
f.link_error_rows === 1 ? "it" : "they",
|
|
1053
1191
|
" will not be imported"
|
|
1054
1192
|
] }),
|
|
1055
|
-
/* @__PURE__ */ e("ul", { className: "mt-1 max-h-32 space-y-0.5 overflow-y-auto text-[11.5px] text-red-700 dark:text-red-300", children: (
|
|
1056
|
-
/* @__PURE__ */
|
|
1193
|
+
/* @__PURE__ */ e("ul", { className: "mt-1 max-h-32 space-y-0.5 overflow-y-auto text-[11.5px] text-red-700 dark:text-red-300", children: (f.link_problems ?? []).map((t) => /* @__PURE__ */ r("li", { children: [
|
|
1194
|
+
/* @__PURE__ */ r("span", { className: "text-red-500/80 dark:text-red-400/70", children: [
|
|
1057
1195
|
"Row ",
|
|
1058
1196
|
t.row,
|
|
1059
1197
|
":"
|
|
@@ -1064,20 +1202,20 @@ val1,val2,val3`,
|
|
|
1064
1202
|
] })
|
|
1065
1203
|
] }),
|
|
1066
1204
|
/* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: [
|
|
1067
|
-
{ label: "File", value:
|
|
1068
|
-
{ label: "Collection", value:
|
|
1069
|
-
{ label: "Data rows", value: P(
|
|
1070
|
-
{ label: "Mapped columns", value: `${
|
|
1205
|
+
{ label: "File", value: b || "pasted.csv", mono: !0 },
|
|
1206
|
+
{ label: "Collection", value: d, mono: !0 },
|
|
1207
|
+
{ label: "Data rows", value: P(me) },
|
|
1208
|
+
{ label: "Mapped columns", value: `${fe} of ${M.length}` },
|
|
1071
1209
|
{
|
|
1072
1210
|
label: "Duplicates",
|
|
1073
|
-
value:
|
|
1211
|
+
value: z === "skip" ? "Skipped" : z === "overwrite" ? "Overwritten" : "Merged"
|
|
1074
1212
|
},
|
|
1075
1213
|
{
|
|
1076
1214
|
label: "Matched on",
|
|
1077
|
-
value:
|
|
1078
|
-
mono:
|
|
1215
|
+
value: q.join(" + ") || "nothing — every row is new",
|
|
1216
|
+
mono: q.length > 0
|
|
1079
1217
|
}
|
|
1080
|
-
].map((t) => /* @__PURE__ */
|
|
1218
|
+
].map((t) => /* @__PURE__ */ r(
|
|
1081
1219
|
"div",
|
|
1082
1220
|
{
|
|
1083
1221
|
className: "flex items-center gap-4 border-b border-slate-100 px-3.5 py-2 last:border-b-0 dark:border-border/60",
|
|
@@ -1086,7 +1224,7 @@ val1,val2,val3`,
|
|
|
1086
1224
|
/* @__PURE__ */ e(
|
|
1087
1225
|
"span",
|
|
1088
1226
|
{
|
|
1089
|
-
className:
|
|
1227
|
+
className: y(
|
|
1090
1228
|
"truncate text-[12.5px] text-slate-800 dark:text-foreground",
|
|
1091
1229
|
t.mono && "font-mono text-[12px]"
|
|
1092
1230
|
),
|
|
@@ -1097,103 +1235,197 @@ val1,val2,val3`,
|
|
|
1097
1235
|
},
|
|
1098
1236
|
t.label
|
|
1099
1237
|
)) }),
|
|
1100
|
-
/* @__PURE__ */
|
|
1238
|
+
/* @__PURE__ */ r("p", { className: "text-[12px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: [
|
|
1101
1239
|
"Starting the import writes ",
|
|
1102
|
-
P(
|
|
1240
|
+
P(me),
|
|
1103
1241
|
" rows into",
|
|
1104
1242
|
" ",
|
|
1105
|
-
/* @__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: d }),
|
|
1106
1244
|
" ",
|
|
1107
1245
|
"one at a time. Progress appears in the job list as it runs."
|
|
1108
1246
|
] })
|
|
1109
1247
|
] })
|
|
1110
1248
|
] }),
|
|
1111
|
-
/* @__PURE__ */
|
|
1112
|
-
|
|
1113
|
-
/* @__PURE__ */ e(
|
|
1249
|
+
/* @__PURE__ */ r("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
1250
|
+
c > 0 && /* @__PURE__ */ r(F, { variant: "ghost", size: "sm", onClick: () => s((t) => t - 1), children: [
|
|
1251
|
+
/* @__PURE__ */ e(Ie, { className: "h-3.5 w-3.5" }),
|
|
1114
1252
|
" Back"
|
|
1115
1253
|
] }),
|
|
1116
|
-
|
|
1117
|
-
/* @__PURE__ */
|
|
1118
|
-
/* @__PURE__ */ e(F, { variant: "ghost", size: "sm", onClick:
|
|
1119
|
-
|
|
1254
|
+
$ && /* @__PURE__ */ e("p", { className: "text-[12px] text-red-600 dark:text-red-400", children: $ }),
|
|
1255
|
+
/* @__PURE__ */ r("div", { className: "ml-auto flex items-center gap-2", children: [
|
|
1256
|
+
/* @__PURE__ */ e(F, { variant: "ghost", size: "sm", onClick: n, children: "Cancel" }),
|
|
1257
|
+
c < we.length - 1 ? /* @__PURE__ */ r(F, { size: "sm", disabled: !it, onClick: () => s((t) => t + 1), children: [
|
|
1120
1258
|
"Next ",
|
|
1121
|
-
/* @__PURE__ */ e(
|
|
1122
|
-
] }) : /* @__PURE__ */ e(
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1259
|
+
/* @__PURE__ */ e(je, { className: "h-3.5 w-3.5" })
|
|
1260
|
+
] }) : /* @__PURE__ */ e(
|
|
1261
|
+
F,
|
|
1262
|
+
{
|
|
1263
|
+
size: "sm",
|
|
1264
|
+
disabled: be.isPending || !Wt(q, I),
|
|
1265
|
+
onClick: () => be.mutate(),
|
|
1266
|
+
children: be.isPending ? /* @__PURE__ */ r(pt, { children: [
|
|
1267
|
+
/* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
1268
|
+
" Starting…"
|
|
1269
|
+
] }) : "Start import"
|
|
1270
|
+
}
|
|
1271
|
+
)
|
|
1126
1272
|
] })
|
|
1127
1273
|
] })
|
|
1128
1274
|
] });
|
|
1129
1275
|
}
|
|
1130
|
-
function
|
|
1131
|
-
|
|
1132
|
-
|
|
1276
|
+
function Be({
|
|
1277
|
+
matchFields: n,
|
|
1278
|
+
confirmed: i,
|
|
1279
|
+
onConfirm: o
|
|
1280
|
+
}) {
|
|
1281
|
+
const p = Vt(n);
|
|
1282
|
+
return p ? /* @__PURE__ */ r(
|
|
1283
|
+
"div",
|
|
1284
|
+
{
|
|
1285
|
+
className: "rounded-md border border-amber-300 bg-amber-50 px-3 py-2 dark:border-amber-500/40 dark:bg-amber-500/10",
|
|
1286
|
+
"data-csv-no-match": !0,
|
|
1287
|
+
children: [
|
|
1288
|
+
/* @__PURE__ */ e("p", { className: "text-[12px] font-medium text-amber-800 dark:text-amber-300", children: p }),
|
|
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
|
+
/* @__PURE__ */ r("div", { className: "mt-2 flex items-center gap-2", children: [
|
|
1291
|
+
/* @__PURE__ */ e(
|
|
1292
|
+
He,
|
|
1293
|
+
{
|
|
1294
|
+
id: "csv-confirm-no-match",
|
|
1295
|
+
checked: i,
|
|
1296
|
+
onCheckedChange: o,
|
|
1297
|
+
"data-csv-confirm-no-match": !0
|
|
1298
|
+
}
|
|
1299
|
+
),
|
|
1300
|
+
/* @__PURE__ */ e(
|
|
1301
|
+
"label",
|
|
1302
|
+
{
|
|
1303
|
+
htmlFor: "csv-confirm-no-match",
|
|
1304
|
+
className: "cursor-pointer text-[11.5px] font-medium text-amber-800 dark:text-amber-300",
|
|
1305
|
+
children: "Yes, create every row as a new record"
|
|
1306
|
+
}
|
|
1307
|
+
)
|
|
1308
|
+
] })
|
|
1309
|
+
]
|
|
1310
|
+
}
|
|
1311
|
+
) : null;
|
|
1312
|
+
}
|
|
1313
|
+
function ar({ headers: n, rows: i }) {
|
|
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
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ e("tr", { className: "bg-slate-50 dark:bg-muted/40", children: n.map((o) => /* @__PURE__ */ e(
|
|
1133
1316
|
"th",
|
|
1134
1317
|
{
|
|
1135
1318
|
className: "whitespace-nowrap border-b border-slate-200 px-2.5 py-1.5 text-left font-mono text-[10.5px] font-medium text-slate-500 dark:border-border dark:text-muted-foreground",
|
|
1136
|
-
children:
|
|
1319
|
+
children: o
|
|
1137
1320
|
},
|
|
1138
|
-
|
|
1321
|
+
o
|
|
1139
1322
|
)) }) }),
|
|
1140
|
-
/* @__PURE__ */ e("tbody", { children:
|
|
1323
|
+
/* @__PURE__ */ e("tbody", { children: i.map((o, p) => (
|
|
1141
1324
|
// eslint-disable-next-line react/no-array-index-key
|
|
1142
|
-
/* @__PURE__ */ e("tr", { className: "border-b border-slate-100 last:border-b-0 dark:border-border/60", children:
|
|
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(
|
|
1143
1326
|
"td",
|
|
1144
1327
|
{
|
|
1145
1328
|
className: "max-w-[200px] truncate whitespace-nowrap px-2.5 py-1 font-mono text-[11px] text-slate-700 dark:text-foreground",
|
|
1146
|
-
title:
|
|
1147
|
-
children:
|
|
1329
|
+
title: o[s] ?? "",
|
|
1330
|
+
children: o[s] || /* @__PURE__ */ e("span", { className: "text-slate-300", children: "—" })
|
|
1148
1331
|
},
|
|
1149
1332
|
s
|
|
1150
1333
|
)) }, p)
|
|
1151
1334
|
)) })
|
|
1152
1335
|
] }) });
|
|
1153
1336
|
}
|
|
1154
|
-
function
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1337
|
+
function et(n) {
|
|
1338
|
+
const i = te(), o = Je();
|
|
1339
|
+
return U({
|
|
1340
|
+
mutationFn: (p) => i.request(K(`/imports/${p}/cancel`, {})),
|
|
1341
|
+
onSuccess: (p, c) => {
|
|
1342
|
+
n(null), o.invalidateQueries({ queryKey: ["collection-import-jobs"] }), o.invalidateQueries({ queryKey: ["collection-import-job", c] });
|
|
1343
|
+
},
|
|
1344
|
+
onError: (p) => n(p)
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
function sr({ jobId: n, onClose: i }) {
|
|
1348
|
+
var h, _;
|
|
1349
|
+
const o = Nt(), p = te(), s = (h = Q({
|
|
1350
|
+
queryKey: ["collection-import-job", n],
|
|
1351
|
+
queryFn: () => p.request(j(`/imports/${n}`)),
|
|
1352
|
+
enabled: !!n,
|
|
1160
1353
|
refetchInterval: (d) => {
|
|
1161
|
-
var
|
|
1162
|
-
return ((
|
|
1354
|
+
var S, v, O, E;
|
|
1355
|
+
return ((v = (S = d.state.data) == null ? void 0 : S.data) == null ? void 0 : v.status) === "processing" || ((E = (O = d.state.data) == null ? void 0 : O.data) == null ? void 0 : E.status) === "pending" ? 2e3 : !1;
|
|
1163
1356
|
}
|
|
1164
|
-
}).data) == null ? void 0 :
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1357
|
+
}).data) == null ? void 0 : h.data, [k, T] = g(null), x = et(
|
|
1358
|
+
(d) => T(d ? ve(d, "The import could not be stopped") : null)
|
|
1359
|
+
), C = Xe(), 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: (d) => !d && i(), 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
|
+
/* @__PURE__ */ r("header", { className: "shrink-0 border-b border-slate-200 px-5 py-4 dark:border-border", children: [
|
|
1362
|
+
/* @__PURE__ */ e(Ze, { status: s.status }),
|
|
1168
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 }),
|
|
1169
|
-
/* @__PURE__ */
|
|
1364
|
+
/* @__PURE__ */ r("p", { className: "text-[11.5px] text-slate-400", children: [
|
|
1170
1365
|
"into ",
|
|
1171
1366
|
/* @__PURE__ */ e("span", { className: "font-mono", children: s.collection }),
|
|
1172
1367
|
" ·",
|
|
1173
1368
|
" ",
|
|
1174
|
-
|
|
1175
|
-
] })
|
|
1369
|
+
ne(s.created_at)
|
|
1370
|
+
] }),
|
|
1371
|
+
/* @__PURE__ */ r("div", { className: "mt-3 flex flex-wrap items-center gap-2", children: [
|
|
1372
|
+
ke.has(s.status) && /* @__PURE__ */ r(
|
|
1373
|
+
qt,
|
|
1374
|
+
{
|
|
1375
|
+
onConfirm: () => x.mutate(String(s.id)),
|
|
1376
|
+
disabled: x.isPending,
|
|
1377
|
+
title: "Stop this import",
|
|
1378
|
+
confirmLabel: "Stop now? Written rows stay",
|
|
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
|
+
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
|
+
children: [
|
|
1382
|
+
x.isPending ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(Ve, { className: "h-3.5 w-3.5" }),
|
|
1383
|
+
"Stop import"
|
|
1384
|
+
]
|
|
1385
|
+
}
|
|
1386
|
+
),
|
|
1387
|
+
/* @__PURE__ */ r(
|
|
1388
|
+
F,
|
|
1389
|
+
{
|
|
1390
|
+
size: "sm",
|
|
1391
|
+
variant: "outline",
|
|
1392
|
+
className: "h-7",
|
|
1393
|
+
disabled: !!C.busy,
|
|
1394
|
+
onClick: () => void C.download(
|
|
1395
|
+
`/imports/${s.id}/file`,
|
|
1396
|
+
s.file_name || "import.csv"
|
|
1397
|
+
),
|
|
1398
|
+
"data-tip": "The file as it was uploaded",
|
|
1399
|
+
children: [
|
|
1400
|
+
C.busy ? /* @__PURE__ */ e(Y, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ e(We, { className: "h-3.5 w-3.5" }),
|
|
1401
|
+
"Download file"
|
|
1402
|
+
]
|
|
1403
|
+
}
|
|
1404
|
+
)
|
|
1405
|
+
] }),
|
|
1406
|
+
(k || C.error) && /* @__PURE__ */ e("p", { className: "mt-2 text-[11.5px] text-red-600 dark:text-red-400", children: k ?? `Could not download the file: ${C.error}` }),
|
|
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." })
|
|
1176
1408
|
] }),
|
|
1177
|
-
/* @__PURE__ */
|
|
1178
|
-
/* @__PURE__ */
|
|
1179
|
-
/* @__PURE__ */
|
|
1409
|
+
/* @__PURE__ */ r("div", { className: "min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-4", children: [
|
|
1410
|
+
/* @__PURE__ */ r("section", { className: "space-y-2", children: [
|
|
1411
|
+
/* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
1180
1412
|
/* @__PURE__ */ e("h3", { className: "text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground", children: "Progress" }),
|
|
1181
|
-
/* @__PURE__ */
|
|
1182
|
-
|
|
1413
|
+
/* @__PURE__ */ r("span", { className: "text-[12px] font-medium tabular-nums text-slate-700 dark:text-foreground", children: [
|
|
1414
|
+
m,
|
|
1183
1415
|
"%"
|
|
1184
1416
|
] })
|
|
1185
1417
|
] }),
|
|
1186
1418
|
/* @__PURE__ */ e("div", { className: "h-2 overflow-hidden rounded-full bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ e(
|
|
1187
1419
|
"div",
|
|
1188
1420
|
{
|
|
1189
|
-
className:
|
|
1421
|
+
className: y(
|
|
1190
1422
|
"h-full rounded-full transition-[width] duration-500",
|
|
1191
|
-
s.status === "failed" ? "bg-red-500" : "bg-nvr-cyan"
|
|
1423
|
+
s.status === "failed" ? "bg-red-500" : s.status === "cancelled" ? "bg-amber-500" : "bg-nvr-cyan"
|
|
1192
1424
|
),
|
|
1193
|
-
style: { width: `${
|
|
1425
|
+
style: { width: `${m}%` }
|
|
1194
1426
|
}
|
|
1195
1427
|
) }),
|
|
1196
|
-
/* @__PURE__ */
|
|
1428
|
+
/* @__PURE__ */ r("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
|
|
1197
1429
|
P(s.processed_rows ?? 0),
|
|
1198
1430
|
" of",
|
|
1199
1431
|
" ",
|
|
@@ -1206,12 +1438,12 @@ function Lt({ jobId: c, onClose: o }) {
|
|
|
1206
1438
|
{ label: "Updated", value: s.updated_rows ?? 0 },
|
|
1207
1439
|
{ label: "Skipped", value: s.skipped_rows ?? 0 },
|
|
1208
1440
|
{ label: "Errors", value: s.error_rows ?? 0, bad: (s.error_rows ?? 0) > 0 }
|
|
1209
|
-
].map((d) => /* @__PURE__ */
|
|
1441
|
+
].map((d) => /* @__PURE__ */ r("div", { className: "bg-white px-3 py-2 dark:bg-card", children: [
|
|
1210
1442
|
/* @__PURE__ */ e("p", { className: "text-[10.5px] text-slate-400", children: d.label }),
|
|
1211
1443
|
/* @__PURE__ */ e(
|
|
1212
1444
|
"p",
|
|
1213
1445
|
{
|
|
1214
|
-
className:
|
|
1446
|
+
className: y(
|
|
1215
1447
|
"text-[15px] font-semibold tabular-nums",
|
|
1216
1448
|
d.bad ? "text-red-600 dark:text-red-400" : "text-slate-900 dark:text-foreground"
|
|
1217
1449
|
),
|
|
@@ -1219,7 +1451,7 @@ function Lt({ jobId: c, onClose: o }) {
|
|
|
1219
1451
|
}
|
|
1220
1452
|
)
|
|
1221
1453
|
] }, d.label)) }),
|
|
1222
|
-
/* @__PURE__ */
|
|
1454
|
+
/* @__PURE__ */ r("section", { children: [
|
|
1223
1455
|
/* @__PURE__ */ e("h3", { className: "mb-1 text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground", children: "Settings" }),
|
|
1224
1456
|
[
|
|
1225
1457
|
{ label: "Duplicates", value: s.duplicate_strategy },
|
|
@@ -1227,16 +1459,19 @@ function Lt({ jobId: c, onClose: o }) {
|
|
|
1227
1459
|
label: "Written",
|
|
1228
1460
|
value: s.through_items ? "Through the items service" : "Directly (raw)"
|
|
1229
1461
|
},
|
|
1230
|
-
{
|
|
1462
|
+
{
|
|
1463
|
+
label: "Matched on",
|
|
1464
|
+
value: (s.match_fields ?? Ge(s.id_field)).join(" + ") || "— always create"
|
|
1465
|
+
},
|
|
1231
1466
|
{
|
|
1232
1467
|
label: "Started",
|
|
1233
|
-
value: s.started_at ?
|
|
1468
|
+
value: s.started_at ? ne(s.started_at) : "—"
|
|
1234
1469
|
},
|
|
1235
1470
|
{
|
|
1236
1471
|
label: "Completed",
|
|
1237
|
-
value: s.completed_at ?
|
|
1472
|
+
value: s.completed_at ? ne(s.completed_at) : "—"
|
|
1238
1473
|
}
|
|
1239
|
-
].map((d) => /* @__PURE__ */
|
|
1474
|
+
].map((d) => /* @__PURE__ */ r(
|
|
1240
1475
|
"div",
|
|
1241
1476
|
{
|
|
1242
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",
|
|
@@ -1248,28 +1483,28 @@ function Lt({ jobId: c, onClose: o }) {
|
|
|
1248
1483
|
d.label
|
|
1249
1484
|
))
|
|
1250
1485
|
] }),
|
|
1251
|
-
s.column_map && Object.keys(s.column_map).length > 0 && /* @__PURE__ */
|
|
1486
|
+
s.column_map && Object.keys(s.column_map).length > 0 && /* @__PURE__ */ r("section", { children: [
|
|
1252
1487
|
/* @__PURE__ */ e("h3", { className: "mb-1.5 text-[11.5px] font-semibold text-slate-500 dark:text-muted-foreground", children: "Column mapping" }),
|
|
1253
|
-
/* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: Object.entries(s.column_map).map(([d,
|
|
1488
|
+
/* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-slate-200 dark:border-border", children: Object.entries(s.column_map).map(([d, S]) => /* @__PURE__ */ r(
|
|
1254
1489
|
"div",
|
|
1255
1490
|
{
|
|
1256
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",
|
|
1257
1492
|
children: [
|
|
1258
1493
|
/* @__PURE__ */ e("span", { className: "flex-1 truncate text-slate-500 dark:text-muted-foreground", children: d }),
|
|
1259
|
-
/* @__PURE__ */ e(
|
|
1260
|
-
/* @__PURE__ */ e("span", { className: "flex-1 truncate text-slate-800 dark:text-foreground", children:
|
|
1494
|
+
/* @__PURE__ */ e(je, { 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: S || /* @__PURE__ */ e("span", { className: "font-sans text-slate-400", children: "skipped" }) })
|
|
1261
1496
|
]
|
|
1262
1497
|
},
|
|
1263
1498
|
d
|
|
1264
1499
|
)) })
|
|
1265
1500
|
] }),
|
|
1266
|
-
s.created_ids && (((
|
|
1501
|
+
s.created_ids && (((_ = s.created_ids) == null ? void 0 : _.length) ?? 0) > 0 && /* @__PURE__ */ e("section", { children: /* @__PURE__ */ r(
|
|
1267
1502
|
"button",
|
|
1268
1503
|
{
|
|
1269
1504
|
type: "button",
|
|
1270
1505
|
onClick: () => {
|
|
1271
1506
|
const d = (s.created_ids ?? []).map(String).join(",");
|
|
1272
|
-
|
|
1507
|
+
o.navigate(
|
|
1273
1508
|
`/collections/${s.collection}?ids=${encodeURIComponent(d)}`
|
|
1274
1509
|
);
|
|
1275
1510
|
},
|
|
@@ -1285,102 +1520,105 @@ function Lt({ jobId: c, onClose: o }) {
|
|
|
1285
1520
|
]
|
|
1286
1521
|
}
|
|
1287
1522
|
) }),
|
|
1288
|
-
|
|
1523
|
+
b.length > 0 && /* @__PURE__ */ e(lr, { jobId: String(s.id), errors: b })
|
|
1289
1524
|
] })
|
|
1290
1525
|
] }) : /* @__PURE__ */ e("div", { className: "p-5 text-[12.5px] text-slate-400", children: "Loading job…" }) }) });
|
|
1291
1526
|
}
|
|
1292
|
-
function
|
|
1293
|
-
jobId:
|
|
1294
|
-
errors:
|
|
1527
|
+
function lr({
|
|
1528
|
+
jobId: n,
|
|
1529
|
+
errors: i
|
|
1295
1530
|
}) {
|
|
1296
|
-
const
|
|
1297
|
-
queryKey: ["import-failed-rows",
|
|
1298
|
-
queryFn: () =>
|
|
1299
|
-
|
|
1300
|
-
).then((
|
|
1531
|
+
const o = te(), [p, c] = g({}), [s, k] = g({}), { data: T } = Q({
|
|
1532
|
+
queryKey: ["import-failed-rows", n],
|
|
1533
|
+
queryFn: () => o.request(
|
|
1534
|
+
j(`/imports/${n}/failed-rows`)
|
|
1535
|
+
).then((m) => m.data ?? []),
|
|
1301
1536
|
staleTime: 3e4
|
|
1302
|
-
}), x =
|
|
1303
|
-
mutationFn: ({ row:
|
|
1304
|
-
onSuccess: (
|
|
1305
|
-
onError: (
|
|
1537
|
+
}), x = T ?? [], C = x[0] ? Object.keys(x[0].values) : [], b = U({
|
|
1538
|
+
mutationFn: ({ row: m, values: h }) => o.request(K(`/imports/${n}/repair-row`, { values: h })).then(() => m),
|
|
1539
|
+
onSuccess: (m) => k((h) => ({ ...h, [m]: "ok" })),
|
|
1540
|
+
onError: (m, h) => k((_) => ({ ..._, [h.row]: ve(m, "The row was not created") }))
|
|
1306
1541
|
});
|
|
1307
|
-
return x.length === 0 ? /* @__PURE__ */
|
|
1308
|
-
/* @__PURE__ */
|
|
1542
|
+
return x.length === 0 ? /* @__PURE__ */ r("section", { children: [
|
|
1543
|
+
/* @__PURE__ */ r("h3", { className: "mb-1.5 text-[11.5px] font-semibold text-red-700 dark:text-red-400", children: [
|
|
1309
1544
|
"Row errors (",
|
|
1310
|
-
|
|
1545
|
+
i.length,
|
|
1311
1546
|
")"
|
|
1312
1547
|
] }),
|
|
1313
|
-
/* @__PURE__ */ e("div", { className: "max-h-[200px] overflow-auto rounded-md border border-red-200 dark:border-red-900", children:
|
|
1548
|
+
/* @__PURE__ */ e("div", { className: "max-h-[200px] overflow-auto rounded-md border border-red-200 dark:border-red-900", children: i.map((m) => /* @__PURE__ */ e(
|
|
1314
1549
|
"div",
|
|
1315
1550
|
{
|
|
1316
1551
|
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",
|
|
1317
|
-
children: /* @__PURE__ */
|
|
1318
|
-
/* @__PURE__ */
|
|
1552
|
+
children: /* @__PURE__ */ r("span", { className: "text-red-700 dark:text-red-400", children: [
|
|
1553
|
+
/* @__PURE__ */ r("span", { className: "font-medium tabular-nums", children: [
|
|
1319
1554
|
"Row ",
|
|
1320
|
-
|
|
1555
|
+
m.row,
|
|
1321
1556
|
":"
|
|
1322
1557
|
] }),
|
|
1323
1558
|
" ",
|
|
1324
|
-
|
|
1559
|
+
ze(m.error)
|
|
1325
1560
|
] })
|
|
1326
1561
|
},
|
|
1327
|
-
`${
|
|
1562
|
+
`${m.row}-${m.error}`
|
|
1328
1563
|
)) })
|
|
1329
|
-
] }) : /* @__PURE__ */
|
|
1330
|
-
/* @__PURE__ */
|
|
1564
|
+
] }) : /* @__PURE__ */ r("section", { children: [
|
|
1565
|
+
/* @__PURE__ */ r("h3", { className: "mb-1.5 text-[11.5px] font-semibold text-red-700 dark:text-red-400", children: [
|
|
1331
1566
|
"Failed rows (",
|
|
1332
1567
|
x.length,
|
|
1333
1568
|
") — fix and resubmit"
|
|
1334
1569
|
] }),
|
|
1335
|
-
/* @__PURE__ */ e("div", { className: "max-h-[320px] overflow-auto rounded-md border border-red-200 dark:border-red-900", children: /* @__PURE__ */
|
|
1336
|
-
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */
|
|
1570
|
+
/* @__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
|
+
/* @__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: [
|
|
1337
1572
|
/* @__PURE__ */ e("th", { className: "px-2 py-1", children: "Row" }),
|
|
1338
|
-
|
|
1573
|
+
C.map((m) => /* @__PURE__ */ e("th", { className: "px-2 py-1 font-mono normal-case", children: m }, m)),
|
|
1339
1574
|
/* @__PURE__ */ e("th", { className: "px-2 py-1" })
|
|
1340
1575
|
] }) }),
|
|
1341
|
-
/* @__PURE__ */ e("tbody", { children: x.map((
|
|
1342
|
-
const
|
|
1343
|
-
return /* @__PURE__ */
|
|
1576
|
+
/* @__PURE__ */ e("tbody", { children: x.map((m) => {
|
|
1577
|
+
const h = p[m.row] ?? m.values, _ = s[m.row];
|
|
1578
|
+
return /* @__PURE__ */ r(
|
|
1344
1579
|
"tr",
|
|
1345
1580
|
{
|
|
1346
1581
|
className: "border-t border-red-100 align-top dark:border-red-900/50",
|
|
1347
1582
|
children: [
|
|
1348
|
-
/* @__PURE__ */
|
|
1349
|
-
|
|
1350
|
-
/* @__PURE__ */ e("p", { className: "max-w-[120px] whitespace-normal text-[10px] text-red-500", children:
|
|
1583
|
+
/* @__PURE__ */ r("td", { className: "px-2 py-1 font-mono tabular-nums text-slate-400", children: [
|
|
1584
|
+
m.row,
|
|
1585
|
+
/* @__PURE__ */ e("p", { className: "max-w-[120px] whitespace-normal text-[10px] text-red-500", children: ze(m.error) })
|
|
1351
1586
|
] }),
|
|
1352
|
-
|
|
1587
|
+
C.map((d) => /* @__PURE__ */ e("td", { className: "px-1 py-1", children: /* @__PURE__ */ e(
|
|
1353
1588
|
"input",
|
|
1354
1589
|
{
|
|
1355
|
-
value: String(
|
|
1356
|
-
disabled:
|
|
1357
|
-
onChange: (
|
|
1590
|
+
value: String(h[d] ?? ""),
|
|
1591
|
+
disabled: _ === "ok",
|
|
1592
|
+
onChange: (S) => c((v) => ({ ...v, [m.row]: { ...h, [d]: S.target.value } })),
|
|
1358
1593
|
className: "h-6 w-full min-w-[80px] rounded border border-slate-200 bg-background px-1 text-[11px] dark:border-border"
|
|
1359
1594
|
}
|
|
1360
|
-
) },
|
|
1361
|
-
/* @__PURE__ */ e("td", { className: "px-2 py-1", children:
|
|
1595
|
+
) }, d)),
|
|
1596
|
+
/* @__PURE__ */ e("td", { className: "px-2 py-1", children: _ === "ok" ? /* @__PURE__ */ e("span", { className: "text-[10.5px] font-medium text-emerald-600", children: "✓ Created" }) : /* @__PURE__ */ r("div", { children: [
|
|
1362
1597
|
/* @__PURE__ */ e(
|
|
1363
1598
|
"button",
|
|
1364
1599
|
{
|
|
1365
1600
|
type: "button",
|
|
1366
|
-
disabled:
|
|
1367
|
-
onClick: () =>
|
|
1601
|
+
disabled: b.isPending,
|
|
1602
|
+
onClick: () => b.mutate({ row: m.row, values: h }),
|
|
1368
1603
|
className: "rounded border border-slate-200 px-1.5 py-0.5 text-[10.5px] hover:bg-muted disabled:opacity-50 dark:border-border",
|
|
1369
1604
|
children: "Resubmit"
|
|
1370
1605
|
}
|
|
1371
1606
|
),
|
|
1372
|
-
|
|
1607
|
+
_ && _ !== "ok" && /* @__PURE__ */ e("p", { className: "max-w-[140px] whitespace-normal text-[9.5px] text-red-500", children: _ })
|
|
1373
1608
|
] }) })
|
|
1374
1609
|
]
|
|
1375
1610
|
},
|
|
1376
|
-
|
|
1611
|
+
m.row
|
|
1377
1612
|
);
|
|
1378
1613
|
}) })
|
|
1379
1614
|
] }) })
|
|
1380
1615
|
] });
|
|
1381
1616
|
}
|
|
1382
1617
|
export {
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1618
|
+
Mr as CollectionImportPanel,
|
|
1619
|
+
Gt as ROLLBACK_QUESTION,
|
|
1620
|
+
Xt as RollbackJobItem,
|
|
1621
|
+
ke as STOPPABLE,
|
|
1622
|
+
Ht as STOP_QUESTION,
|
|
1623
|
+
Yt as StopJobItem
|
|
1386
1624
|
};
|