@flowselections/floriday-klanten-module 1.0.100 → 1.0.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"BulkStickerUploadDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/BulkStickerUploadDialog.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAUxD,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;IACpB,uFAAuF;IACvF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAGpG;AAsDD,wBAAgB,uBAAuB,CAAC,EACtC,WAAW,EACX,QAAQ,EACR,MAAM,EACN,KAAK,EAAE,SAAqB,EAC5B,WAAmB,GACpB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,+BAyhBA"}
1
+ {"version":3,"file":"BulkStickerUploadDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/BulkStickerUploadDialog.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAWxD,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;IACpB,uFAAuF;IACvF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,kEAAkE;AAClE,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAGpG;AAsDD,wBAAgB,uBAAuB,CAAC,EACtC,WAAW,EACX,QAAQ,EACR,MAAM,EACN,KAAK,EAAE,SAAqB,EAC5B,WAAmB,GACpB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,+BAyhBA"}
@@ -10,6 +10,7 @@ import { friendlyError } from "../../lib/errors.js";
10
10
  import { STICKER_AANVRAAG, inPorties, teVeelStickerBestanden } from "../../lib/sticker-porties.js";
11
11
  import { SearchableSelect } from "./SearchableSelect.js";
12
12
  import { renderPdfThumbnail } from "../../lib/pdf-thumbnail.js";
13
+ import { filterStickerRows, telStickerFilters } from "../../lib/sticker-filter.js";
13
14
  const BUCKET = "customer-stickers";
14
15
  const MAX_SIZE = 10 * 1024 * 1024;
15
16
  const ACCEPT = ".pdf,.png,.jpg,.jpeg,.svg";
@@ -83,6 +84,9 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, soort:
83
84
  count.set(r.tradeItemKey, (count.get(r.tradeItemKey) ?? 0) + 1);
84
85
  return new Set([...count.entries()].filter(([, n]) => n > 1).map(([k]) => k));
85
86
  }, [rows]);
87
+ const [filter, setFilter] = useState("alles");
88
+ const tellingen = useMemo(() => telStickerFilters(rows), [rows]);
89
+ const zichtbareRows = useMemo(() => filterStickerRows(rows, filter), [rows, filter]);
86
90
  const reset = () => {
87
91
  setRows((prev) => {
88
92
  for (const x of prev)
@@ -277,23 +281,28 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, soort:
277
281
  ? `Bestanden uploaden… ${progress.done}/${progress.total}`
278
282
  : progress.total > 1
279
283
  ? `Koppelen ${progress.done} van ${progress.total}…`
280
- : "AI zoekt bij elke sticker het juiste product…"] })), (phase === "review" || phase === "saving") && (_jsx("div", { className: "min-h-0 flex-1 overflow-y-auto overflow-x-hidden", children: _jsxs("table", { className: "w-full table-fixed text-sm", children: [_jsxs("colgroup", { children: [_jsx("col", { className: "w-[120px]" }), _jsx("col", {}), _jsx("col", { className: "w-[380px]" }), _jsx("col", { className: "w-[100px]" }), _jsx("col", { className: "w-[110px]" }), _jsx("col", { className: "w-[48px]" })] }), _jsx("thead", { className: "sticky top-0 z-10 bg-background", children: _jsxs("tr", { className: "border-b text-left", children: [_jsx("th", { className: "py-2", children: "Sticker" }), _jsx("th", { className: "py-2", children: "Bestand" }), _jsx("th", { className: "py-2", children: "Product" }), _jsx("th", { className: "py-2", children: "Zekerheid" }), _jsx("th", { className: "py-2", children: "Bestaand" }), _jsx("th", { className: "py-2" })] }) }), _jsx("tbody", { children: rows.map((r) => {
281
- const product = r.tradeItemKey ? productByKey.get(r.tradeItemKey) : null;
282
- const dup = r.tradeItemKey ? duplicates.has(r.tradeItemKey) : false;
283
- 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-24 w-24 rounded border object-contain bg-white hover:ring-2 hover:ring-primary/50" }) })) : (r.localUrl ? (_jsx("button", { type: "button", className: "h-24 w-24 rounded border bg-muted flex items-center justify-center cursor-zoom-in hover:ring-2 hover:ring-primary/50", title: "Klik om de PDF te bekijken", onClick: () => setPreviewRow(r), children: _jsx(FileText, { className: "h-6 w-6 text-muted-foreground" }) })) : (_jsx("div", { className: "h-24 w-24 rounded border bg-muted flex items-center justify-center", children: _jsx(FileText, { className: "h-6 w-6 text-muted-foreground" }) }))) }), _jsxs("td", { className: "min-w-0 py-2 pr-3", children: [_jsx("div", { className: "truncate", title: r.fileName, children: r.fileName }), r.reason && (_jsx("div", { className: "text-xs text-muted-foreground truncate", title: r.reason, children: r.reason }))] }), _jsxs("td", { className: "min-w-0 py-2 pr-3", title: product ? product.name : undefined, children: [_jsx(SearchableSelect, { value: r.tradeItemKey ?? "", options: productOptions, placeholder: "Kies product\u2026", triggerClassName: "w-full min-w-0 max-w-full overflow-hidden", onValueChange: (v) => setRows((prev) => prev.map((x) => x.fileId === r.fileId
284
- ? {
285
- ...x,
286
- tradeItemKey: v || null,
287
- replaceExisting: v
288
- ? heeftStickerVanSoort(productByKey.get(v), soort)
289
- : false,
290
- }
291
- : x)) }), dup && (_jsx("div", { className: "text-xs text-destructive mt-1", children: "Meerdere stickers voor dit product" }))] }), _jsx("td", { className: "py-2", children: r.tradeItemKey ? (_jsx(Badge, { variant: r.confidence >= 0.8
292
- ? "default"
293
- : r.confidence >= 0.5
294
- ? "secondary"
295
- : "outline", children: r.confidence >= 0.8 ? "Hoog" : r.confidence >= 0.5 ? "Middel" : "Laag" })) : (_jsx(Badge, { variant: "outline", children: "Geen match" })) }), _jsx("td", { className: "py-2", children: heeftStickerVanSoort(product, soort) ? (_jsxs("label", { className: "flex items-center gap-2 text-xs", children: [_jsx("input", { type: "checkbox", checked: r.replaceExisting, onChange: (e) => setRows((prev) => prev.map((x) => x.fileId === r.fileId
296
- ? { ...x, replaceExisting: e.target.checked }
297
- : x)) }), "Vervangen"] })) : (_jsx("span", { className: "text-xs text-muted-foreground", children: "\u2014" })) }), _jsx("td", { className: "py-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "icon", onClick: () => setRows((prev) => prev.filter((x) => x.fileId !== r.fileId)), children: _jsx(Trash2, { className: "h-4 w-4" }) }) })] }, r.fileId));
298
- }) })] }) })), _jsxs(DialogFooter, { className: "gap-2 sm:justify-between", children: [_jsx("span", { className: "text-xs text-muted-foreground flex items-center gap-1.5", children: phase === "review" && (_jsxs(_Fragment, { children: [_jsx(Sparkles, { className: "h-3.5 w-3.5" }), rows.filter((r) => r.tradeItemKey).length, " van ", rows.length, " gekoppeld"] })) }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { type: "button", variant: "outline", disabled: busy, onClick: () => void close(true), children: "Annuleren" }), (phase === "review" || phase === "saving") && (_jsxs(Button, { type: "button", disabled: busy, onClick: () => void save(), children: [phase === "saving" && _jsx(Loader2, { className: "h-4 w-4 mr-1.5 animate-spin" }), "Bevestigen en opslaan"] }))] })] })] }) }), _jsx(Dialog, { open: previewRow !== null, onOpenChange: (v) => !v && setPreviewRow(null), children: _jsxs(DialogContent, { className: "max-w-5xl", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: previewRow?.fileName ?? "Sticker" }) }), !previewRow?.thumbnail && previewRow?.localUrl && (_jsx("iframe", { src: previewRow.localUrl, title: previewRow.fileName, className: "h-[70vh] w-full rounded border bg-white" })), previewRow?.thumbnail && (_jsx("div", { className: "flex items-center justify-center rounded border bg-white p-2", children: _jsx("img", { src: previewRow.thumbnail, alt: previewRow.fileName, className: "max-h-[70vh] w-auto max-w-full object-contain" }) }))] }) })] }));
284
+ : "AI zoekt bij elke sticker het juiste product…"] })), (phase === "review" || phase === "saving") && (_jsxs("div", { className: "min-h-0 flex-1 overflow-y-auto overflow-x-hidden", children: [_jsx("div", { className: "sticky top-0 z-10 flex flex-wrap gap-2 bg-background pb-3", role: "group", "aria-label": "Filter stickers", children: [
285
+ ["alles", "Alles"],
286
+ ["nog", "Nog koppelen"],
287
+ ["gekoppeld", "Gekoppeld"],
288
+ ].map(([k, label]) => (_jsxs(Button, { type: "button", size: "sm", variant: filter === k ? "default" : "outline", "aria-pressed": filter === k, onClick: () => setFilter(k), children: [label, " ", _jsxs("span", { className: "ml-1 tabular-nums", children: ["(", tellingen[k], ")"] })] }, k))) }), _jsx("ul", { className: "flex flex-col gap-3", children: zichtbareRows.map((r) => {
289
+ const product = r.tradeItemKey ? productByKey.get(r.tradeItemKey) : null;
290
+ const dup = r.tradeItemKey ? duplicates.has(r.tradeItemKey) : false;
291
+ const box = "flex h-[220px] w-[220px] shrink-0 items-center justify-center overflow-hidden rounded-md border bg-white";
292
+ return (_jsxs("li", { className: `flex min-w-0 flex-col gap-4 rounded-lg border p-4 md:flex-row ${r.tradeItemKey ? "" : "border-warning/60"}`, children: [r.thumbnail || r.localUrl ? (_jsx("button", { type: "button", className: `${box} cursor-zoom-in transition-shadow duration-150 ease-out hover:ring-2 hover:ring-primary/50 motion-reduce:transition-none`, title: r.thumbnail ? "Klik om te vergroten" : "Klik om de PDF te bekijken", onClick: () => setPreviewRow(r), children: r.thumbnail ? (_jsx("img", { src: r.thumbnail, alt: r.fileName, className: "h-full w-full object-contain" })) : (_jsx(FileText, { className: "h-10 w-10 text-muted-foreground" })) })) : (_jsx("div", { className: box, children: _jsx(FileText, { className: "h-10 w-10 text-muted-foreground" }) })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_jsx("div", { className: "line-clamp-2 break-words font-medium", title: r.fileName, children: r.fileName }), r.reason && (_jsx("div", { className: "line-clamp-2 break-words text-xs text-muted-foreground", title: r.reason, children: r.reason })), _jsxs("div", { className: "w-full min-w-0 max-w-[560px]", title: product ? product.name : undefined, children: [_jsx(SearchableSelect, { value: r.tradeItemKey ?? "", options: productOptions, placeholder: "Kies product\u2026", triggerClassName: "w-full min-w-0 max-w-full overflow-hidden", onValueChange: (v) => setRows((prev) => prev.map((x) => x.fileId === r.fileId
293
+ ? {
294
+ ...x,
295
+ tradeItemKey: v || null,
296
+ replaceExisting: v
297
+ ? heeftStickerVanSoort(productByKey.get(v), soort)
298
+ : false,
299
+ }
300
+ : x)) }), dup && (_jsx("div", { className: "text-xs text-destructive mt-1", children: "Meerdere stickers voor dit product" }))] }), _jsxs("div", { className: "flex items-center gap-3", children: [r.tradeItemKey ? (_jsx(Badge, { variant: r.confidence >= 0.8
301
+ ? "default"
302
+ : r.confidence >= 0.5
303
+ ? "secondary"
304
+ : "outline", children: r.confidence >= 0.8 ? "Hoog" : r.confidence >= 0.5 ? "Middel" : "Laag" })) : (_jsx(Badge, { variant: "outline", children: "Geen match" })), heeftStickerVanSoort(product, soort) && (_jsxs("label", { className: "flex items-center gap-2 text-xs", children: [_jsx("input", { type: "checkbox", checked: r.replaceExisting, onChange: (e) => setRows((prev) => prev.map((x) => x.fileId === r.fileId
305
+ ? { ...x, replaceExisting: e.target.checked }
306
+ : x)) }), "Vervangen"] })), _jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "ml-auto", "aria-label": "Sticker verwijderen", onClick: () => setRows((prev) => prev.filter((x) => x.fileId !== r.fileId)), children: _jsx(Trash2, { className: "h-4 w-4" }) })] })] })] }, r.fileId));
307
+ }) }), zichtbareRows.length === 0 && (_jsx("p", { className: "p-6 text-center text-sm text-muted-foreground", children: "Geen stickers in deze selectie." }))] })), _jsxs(DialogFooter, { className: "gap-2 sm:justify-between", children: [_jsx("span", { className: "text-xs text-muted-foreground flex items-center gap-1.5", children: phase === "review" && (_jsxs(_Fragment, { children: [_jsx(Sparkles, { className: "h-3.5 w-3.5" }), rows.filter((r) => r.tradeItemKey).length, " van ", rows.length, " gekoppeld"] })) }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { type: "button", variant: "outline", disabled: busy, onClick: () => void close(true), children: "Annuleren" }), (phase === "review" || phase === "saving") && (_jsxs(Button, { type: "button", disabled: busy, onClick: () => void save(), children: [phase === "saving" && _jsx(Loader2, { className: "h-4 w-4 mr-1.5 animate-spin" }), "Bevestigen en opslaan"] }))] })] })] }) }), _jsx(Dialog, { open: previewRow !== null, onOpenChange: (v) => !v && setPreviewRow(null), children: _jsxs(DialogContent, { className: "max-w-5xl", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: previewRow?.fileName ?? "Sticker" }) }), !previewRow?.thumbnail && previewRow?.localUrl && (_jsx("iframe", { src: previewRow.localUrl, title: previewRow.fileName, className: "h-[70vh] w-full rounded border bg-white" })), previewRow?.thumbnail && (_jsx("div", { className: "flex items-center justify-center rounded border bg-white p-2", children: _jsx("img", { src: previewRow.thumbnail, alt: previewRow.fileName, className: "max-h-[70vh] w-auto max-w-full object-contain" }) }))] }) })] }));
299
308
  }