@flowselections/floriday-klanten-module 1.0.97 → 1.0.98
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-lib/components/klanten/BulkStickerUploadDialog.d.ts.map +1 -1
- package/dist-lib/components/klanten/BulkStickerUploadDialog.js +57 -37
- package/dist-lib/integrations/supabase/types.d.ts +508 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/sticker-porties.d.ts +5 -0
- package/dist-lib/lib/sticker-porties.d.ts.map +1 -0
- package/dist-lib/lib/sticker-porties.js +13 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BulkStickerUploadDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/BulkStickerUploadDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BulkStickerUploadDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/BulkStickerUploadDialog.tsx"],"names":[],"mappings":"AA4BA,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAiDF,wBAAgB,uBAAuB,CAAC,EACtC,WAAW,EACX,QAAQ,EACR,MAAM,GACP,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,+BAqeA"}
|
|
@@ -7,6 +7,7 @@ import { toast } from "sonner";
|
|
|
7
7
|
import { supabase } from "../../integrations/supabase/client.js";
|
|
8
8
|
import { ALLOWED_STICKER_MIME, commitStickerBatch, discardStickerBatch, suggestStickerMatches, } from "../../lib/customer-stickers.functions.js";
|
|
9
9
|
import { friendlyError } from "../../lib/errors.js";
|
|
10
|
+
import { inPorties, teVeelStickerBestanden } from "../../lib/sticker-porties.js";
|
|
10
11
|
import { SearchableSelect } from "./SearchableSelect.js";
|
|
11
12
|
const BUCKET = "customer-stickers";
|
|
12
13
|
const MAX_SIZE = 10 * 1024 * 1024;
|
|
@@ -89,6 +90,11 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
89
90
|
toast.error(`${tooBig.length} bestand(en) zijn groter dan 10 MB en worden overgeslagen.`);
|
|
90
91
|
if (files.length === 0)
|
|
91
92
|
return;
|
|
93
|
+
const teVeel = teVeelStickerBestanden(files.length);
|
|
94
|
+
if (teVeel) {
|
|
95
|
+
toast.error(teVeel);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
92
98
|
const id = crypto.randomUUID();
|
|
93
99
|
setBatchId(id);
|
|
94
100
|
setPhase("uploading");
|
|
@@ -126,43 +132,55 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
126
132
|
return;
|
|
127
133
|
}
|
|
128
134
|
setPhase("matching");
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
135
|
+
const porties = inPorties(staged);
|
|
136
|
+
setProgress({ done: 1, total: porties.length });
|
|
137
|
+
let deelMislukt = false;
|
|
138
|
+
for (let i = 0; i < porties.length; i++) {
|
|
139
|
+
setProgress({ done: i + 1, total: porties.length });
|
|
140
|
+
try {
|
|
141
|
+
const res = await suggest({
|
|
142
|
+
data: {
|
|
143
|
+
files: porties[i].map((s) => ({
|
|
144
|
+
fileId: s.fileId,
|
|
145
|
+
fileName: s.fileName,
|
|
146
|
+
thumbnail: s.thumbnail,
|
|
147
|
+
})),
|
|
148
|
+
products: products.map((p) => ({
|
|
149
|
+
key: p.key,
|
|
150
|
+
name: p.name,
|
|
151
|
+
code: p.code,
|
|
152
|
+
vbn: p.vbn,
|
|
153
|
+
botanical: p.botanical,
|
|
154
|
+
})),
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
if (res.aiError)
|
|
158
|
+
toast.warning(res.aiError);
|
|
159
|
+
const byId = new Map(res.suggestions.map((s) => [s.fileId, s]));
|
|
160
|
+
setRows((prev) => prev.map((r) => {
|
|
161
|
+
const s = byId.get(r.fileId);
|
|
162
|
+
return s
|
|
163
|
+
? {
|
|
164
|
+
...r,
|
|
165
|
+
tradeItemKey: s.tradeItemKey,
|
|
166
|
+
confidence: s.confidence,
|
|
167
|
+
reason: s.reason,
|
|
168
|
+
replaceExisting: s.tradeItemKey
|
|
169
|
+
? (productByKey.get(s.tradeItemKey)?.hasSticker ?? false)
|
|
170
|
+
: false,
|
|
171
|
+
}
|
|
172
|
+
: r;
|
|
173
|
+
}));
|
|
174
|
+
}
|
|
175
|
+
catch (e) {
|
|
176
|
+
console.error("Automatisch koppelen van stickers mislukt (portie", i + 1, ")", e);
|
|
177
|
+
deelMislukt = true;
|
|
178
|
+
}
|
|
163
179
|
}
|
|
164
|
-
|
|
165
|
-
toast.error(
|
|
180
|
+
if (deelMislukt) {
|
|
181
|
+
toast.error(porties.length > 1
|
|
182
|
+
? "Een deel van de stickers kon niet automatisch gekoppeld worden. Koppel die handmatig."
|
|
183
|
+
: "De stickers konden niet automatisch gekoppeld worden. Koppel ze handmatig.");
|
|
166
184
|
}
|
|
167
185
|
setPhase("review");
|
|
168
186
|
};
|
|
@@ -235,7 +253,9 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
235
253
|
void handleFiles(e.dataTransfer.files);
|
|
236
254
|
}, children: [_jsx("p", { className: "text-sm text-muted-foreground mb-4", children: "Sleep een map of losse stickerbestanden hierheen (PDF, PNG, JPG of SVG, max. 10 MB per bestand)." }), _jsxs("div", { className: "flex justify-center gap-2", children: [_jsxs(Button, { type: "button", onClick: () => folderRef.current?.click(), children: [_jsx(FolderOpen, { className: "h-4 w-4 mr-1.5" }), "Map kiezen"] }), _jsx(Button, { type: "button", variant: "outline", onClick: () => filesRef.current?.click(), children: "Bestanden kiezen" })] })] })), (phase === "uploading" || phase === "matching") && (_jsxs("div", { className: "flex items-center gap-3 p-10 justify-center text-sm text-muted-foreground", children: [_jsx(Loader2, { className: "h-4 w-4 animate-spin" }), phase === "uploading"
|
|
237
255
|
? `Bestanden uploaden… ${progress.done}/${progress.total}`
|
|
238
|
-
:
|
|
256
|
+
: progress.total > 1
|
|
257
|
+
? `Koppelen ${progress.done} van ${progress.total}…`
|
|
258
|
+
: "AI zoekt bij elke sticker het juiste product…"] })), (phase === "review" || phase === "saving") && (_jsx("div", { className: "max-h-[60vh] overflow-auto", children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { className: "sticky top-0 bg-background", children: _jsxs("tr", { className: "border-b text-left", children: [_jsx("th", { className: "py-2 w-56", children: "Sticker" }), _jsx("th", { className: "py-2", children: "Bestand" }), _jsx("th", { className: "py-2 w-[340px]", children: "Product" }), _jsx("th", { className: "py-2 w-32", children: "Zekerheid" }), _jsx("th", { className: "py-2 w-40", children: "Bestaand" }), _jsx("th", { className: "py-2 w-10" })] }) }), _jsx("tbody", { children: rows.map((r) => {
|
|
239
259
|
const product = r.tradeItemKey ? productByKey.get(r.tradeItemKey) : null;
|
|
240
260
|
const dup = r.tradeItemKey ? duplicates.has(r.tradeItemKey) : false;
|
|
241
261
|
return (_jsxs("tr", { className: "border-b align-middle", children: [_jsx("td", { className: "py-2", children: r.thumbnail ? (_jsx("button", { type: "button", className: "block cursor-zoom-in", title: "Klik om te vergroten", onClick: () => setPreviewRow(r), children: _jsx("img", { src: r.thumbnail, alt: r.fileName, className: "h-44 w-44 rounded border object-contain bg-white hover:ring-2 hover:ring-primary/50" }) })) : (_jsx("div", { className: "h-44 w-44 rounded border bg-muted flex items-center justify-center", children: _jsx(FileText, { className: "h-6 w-6 text-muted-foreground" }) })) }), _jsxs("td", { className: "py-2 pr-3", children: [_jsx("div", { className: "truncate max-w-[220px]", title: r.fileName, children: r.fileName }), r.reason && (_jsx("div", { className: "text-xs text-muted-foreground truncate max-w-[220px]", children: r.reason }))] }), _jsxs("td", { className: "py-2 pr-3", children: [_jsx(SearchableSelect, { value: r.tradeItemKey ?? "", options: productOptions, placeholder: "Kies product\u2026", triggerClassName: "w-full", onValueChange: (v) => setRows((prev) => prev.map((x) => x.fileId === r.fileId
|