@flowselections/floriday-klanten-module 1.0.97 → 1.0.99
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 +59 -38
- package/dist-lib/integrations/supabase/types.d.ts +644 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/customer-stickers.functions.d.ts +22 -0
- package/dist-lib/lib/customer-stickers.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-stickers.functions.js +161 -178
- package/dist-lib/lib/sticker-match.d.ts +19 -0
- package/dist-lib/lib/sticker-match.d.ts.map +1 -0
- package/dist-lib/lib/sticker-match.js +46 -0
- package/dist-lib/lib/sticker-porties.d.ts +7 -0
- package/dist-lib/lib/sticker-porties.d.ts.map +1 -0
- package/dist-lib/lib/sticker-porties.js +15 -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,+BAieA"}
|
|
@@ -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 { STICKER_AANVRAAG, 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,44 +132,57 @@ 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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
135
|
+
const porties = inPorties(staged, STICKER_AANVRAAG);
|
|
136
|
+
setProgress({ done: 1, total: porties.length });
|
|
137
|
+
let fout = null;
|
|
138
|
+
let aiFout = null;
|
|
139
|
+
for (let i = 0; i < porties.length; i++) {
|
|
140
|
+
setProgress({ done: i + 1, total: porties.length });
|
|
141
|
+
try {
|
|
142
|
+
const res = await suggest({
|
|
143
|
+
data: {
|
|
144
|
+
files: porties[i].map((s) => ({
|
|
145
|
+
fileId: s.fileId,
|
|
146
|
+
fileName: s.fileName,
|
|
147
|
+
thumbnail: s.thumbnail,
|
|
148
|
+
})),
|
|
149
|
+
products: products.map((p) => ({
|
|
150
|
+
key: p.key,
|
|
151
|
+
name: p.name,
|
|
152
|
+
code: p.code,
|
|
153
|
+
vbn: p.vbn,
|
|
154
|
+
botanical: p.botanical,
|
|
155
|
+
})),
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
if (res.aiError && !aiFout)
|
|
159
|
+
aiFout = res.aiError;
|
|
160
|
+
const byId = new Map(res.suggestions.map((s) => [s.fileId, s]));
|
|
161
|
+
setRows((prev) => prev.map((r) => {
|
|
162
|
+
const s = byId.get(r.fileId);
|
|
163
|
+
return s
|
|
164
|
+
? {
|
|
165
|
+
...r,
|
|
166
|
+
tradeItemKey: s.tradeItemKey,
|
|
167
|
+
confidence: s.confidence,
|
|
168
|
+
reason: s.reason,
|
|
169
|
+
replaceExisting: s.tradeItemKey
|
|
170
|
+
? (productByKey.get(s.tradeItemKey)?.hasSticker ?? false)
|
|
171
|
+
: false,
|
|
172
|
+
}
|
|
173
|
+
: r;
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
catch (e) {
|
|
177
|
+
console.error("Automatisch koppelen van stickers mislukt (portie", i + 1, ")", e);
|
|
178
|
+
if (!fout)
|
|
179
|
+
fout = friendlyError(e, "Een deel van de stickers kon niet automatisch gekoppeld worden. Koppel die handmatig.");
|
|
180
|
+
}
|
|
166
181
|
}
|
|
182
|
+
if (aiFout)
|
|
183
|
+
toast.warning(aiFout);
|
|
184
|
+
if (fout)
|
|
185
|
+
toast.error(fout);
|
|
167
186
|
setPhase("review");
|
|
168
187
|
};
|
|
169
188
|
const close = async (cancel) => {
|
|
@@ -235,7 +254,9 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
235
254
|
void handleFiles(e.dataTransfer.files);
|
|
236
255
|
}, 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
256
|
? `Bestanden uploaden… ${progress.done}/${progress.total}`
|
|
238
|
-
:
|
|
257
|
+
: progress.total > 1
|
|
258
|
+
? `Koppelen ${progress.done} van ${progress.total}…`
|
|
259
|
+
: "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
260
|
const product = r.tradeItemKey ? productByKey.get(r.tradeItemKey) : null;
|
|
240
261
|
const dup = r.tradeItemKey ? duplicates.has(r.tradeItemKey) : false;
|
|
241
262
|
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
|