@flowselections/floriday-klanten-module 1.0.99 → 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.
- package/dist-lib/components/klanten/BulkStickerUploadDialog.d.ts +10 -1
- package/dist-lib/components/klanten/BulkStickerUploadDialog.d.ts.map +1 -1
- package/dist-lib/components/klanten/BulkStickerUploadDialog.js +55 -25
- package/dist-lib/components/klanten/CustomerAssortmentTab.d.ts.map +1 -1
- package/dist-lib/components/klanten/CustomerAssortmentTab.js +19 -5
- package/dist-lib/components/klanten/CustomerStickerCell.d.ts +4 -1
- package/dist-lib/components/klanten/CustomerStickerCell.d.ts.map +1 -1
- package/dist-lib/components/klanten/CustomerStickerCell.js +6 -4
- package/dist-lib/components/klanten/CustomerStickerFormatDialog.d.ts +3 -1
- package/dist-lib/components/klanten/CustomerStickerFormatDialog.d.ts.map +1 -1
- package/dist-lib/components/klanten/CustomerStickerFormatDialog.js +5 -4
- package/dist-lib/components/klanten/StickerSizeLine.d.ts +3 -1
- package/dist-lib/components/klanten/StickerSizeLine.d.ts.map +1 -1
- package/dist-lib/components/klanten/StickerSizeLine.js +4 -4
- package/dist-lib/index.d.ts +1 -1
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +3261 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/customer-stickers.functions.d.ts +37 -1
- package/dist-lib/lib/customer-stickers.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-stickers.functions.js +132 -82
- package/dist-lib/lib/pdf-thumbnail.d.ts +4 -0
- package/dist-lib/lib/pdf-thumbnail.d.ts.map +1 -0
- package/dist-lib/lib/pdf-thumbnail.js +49 -0
- package/dist-lib/lib/sticker-filter.d.ts +9 -0
- package/dist-lib/lib/sticker-filter.d.ts.map +1 -0
- package/dist-lib/lib/sticker-filter.js +12 -0
- package/dist-lib/lib/sticker-soort.d.ts +20 -0
- package/dist-lib/lib/sticker-soort.d.ts.map +1 -0
- package/dist-lib/lib/sticker-soort.js +20 -0
- package/package.json +2 -1
- package/schema/klanten.sql +44 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StickerSoort } from "../../lib/sticker-soort.js";
|
|
1
2
|
export type BulkProduct = {
|
|
2
3
|
key: string;
|
|
3
4
|
name: string;
|
|
@@ -5,10 +6,18 @@ export type BulkProduct = {
|
|
|
5
6
|
vbn: string | null;
|
|
6
7
|
botanical: string | null;
|
|
7
8
|
hasSticker: boolean;
|
|
9
|
+
/** Optioneel: heeft dit product al een fuststicker (alleen nodig bij fuststickers). */
|
|
10
|
+
hasFustSticker?: boolean;
|
|
8
11
|
};
|
|
9
|
-
|
|
12
|
+
/** "Bestaand" kijkt alleen naar stickers van de gekozen soort. */
|
|
13
|
+
export declare function heeftStickerVanSoort(p: BulkProduct | null | undefined, soort: StickerSoort): boolean;
|
|
14
|
+
export declare function BulkStickerUploadDialog({ customerKey, products, onDone, soort: soortProp, soortKiezen, }: {
|
|
10
15
|
customerKey: string;
|
|
11
16
|
products: BulkProduct[];
|
|
12
17
|
onDone: () => void;
|
|
18
|
+
/** Optioneel; standaard 'product' (gedrag zoals altijd). */
|
|
19
|
+
soort?: StickerSoort;
|
|
20
|
+
/** Optioneel: eerst laten kiezen tussen productstickers en fuststickers. */
|
|
21
|
+
soortKiezen?: boolean;
|
|
13
22
|
}): import("react").JSX.Element;
|
|
14
23
|
//# sourceMappingURL=BulkStickerUploadDialog.d.ts.map
|
|
@@ -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":"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"}
|
|
@@ -9,9 +9,17 @@ import { ALLOWED_STICKER_MIME, commitStickerBatch, discardStickerBatch, suggestS
|
|
|
9
9
|
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
|
+
import { renderPdfThumbnail } from "../../lib/pdf-thumbnail.js";
|
|
13
|
+
import { filterStickerRows, telStickerFilters } from "../../lib/sticker-filter.js";
|
|
12
14
|
const BUCKET = "customer-stickers";
|
|
13
15
|
const MAX_SIZE = 10 * 1024 * 1024;
|
|
14
16
|
const ACCEPT = ".pdf,.png,.jpg,.jpeg,.svg";
|
|
17
|
+
/** "Bestaand" kijkt alleen naar stickers van de gekozen soort. */
|
|
18
|
+
export function heeftStickerVanSoort(p, soort) {
|
|
19
|
+
if (!p)
|
|
20
|
+
return false;
|
|
21
|
+
return soort === "fust" ? p.hasFustSticker === true : p.hasSticker;
|
|
22
|
+
}
|
|
15
23
|
function safeKey(value) {
|
|
16
24
|
return value.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
17
25
|
}
|
|
@@ -19,6 +27,9 @@ function extOf(name) {
|
|
|
19
27
|
return (/\.([a-z0-9]+)$/i.exec(name)?.[1] ?? "bin").toLowerCase();
|
|
20
28
|
}
|
|
21
29
|
async function makeThumbnail(file) {
|
|
30
|
+
if (file.type === "application/pdf" || /\.pdf$/i.test(file.name)) {
|
|
31
|
+
return renderPdfThumbnail(file);
|
|
32
|
+
}
|
|
22
33
|
if (!file.type.startsWith("image/"))
|
|
23
34
|
return null;
|
|
24
35
|
try {
|
|
@@ -47,7 +58,8 @@ async function makeThumbnail(file) {
|
|
|
47
58
|
return null;
|
|
48
59
|
}
|
|
49
60
|
}
|
|
50
|
-
export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
61
|
+
export function BulkStickerUploadDialog({ customerKey, products, onDone, soort: soortProp = "product", soortKiezen = false, }) {
|
|
62
|
+
const [soort, setSoort] = useState(soortProp);
|
|
51
63
|
const [open, setOpen] = useState(false);
|
|
52
64
|
const [batchId, setBatchId] = useState(null);
|
|
53
65
|
const [rows, setRows] = useState([]);
|
|
@@ -61,7 +73,7 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
61
73
|
const discard = useServerFn(discardStickerBatch);
|
|
62
74
|
const productOptions = useMemo(() => products.map((p) => ({
|
|
63
75
|
value: p.key,
|
|
64
|
-
label: (_jsxs("span", { className: "flex min-w-0 flex-col leading-tight", children: [_jsx("span", { className: "truncate", children: p.name }), p.code && (_jsx("span", { className: "truncate text-xs text-muted-foreground", children: p.code }))] })),
|
|
76
|
+
label: (_jsxs("span", { className: "flex min-w-0 flex-col leading-tight", children: [_jsx("span", { className: "truncate", title: p.name, children: p.name }), p.code && (_jsx("span", { className: "truncate text-xs text-muted-foreground", children: p.code }))] })),
|
|
65
77
|
search: [p.name, p.code, p.vbn, p.botanical].filter(Boolean).join(" "),
|
|
66
78
|
})), [products]);
|
|
67
79
|
const productByKey = useMemo(() => new Map(products.map((p) => [p.key, p])), [products]);
|
|
@@ -72,8 +84,16 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
72
84
|
count.set(r.tradeItemKey, (count.get(r.tradeItemKey) ?? 0) + 1);
|
|
73
85
|
return new Set([...count.entries()].filter(([, n]) => n > 1).map(([k]) => k));
|
|
74
86
|
}, [rows]);
|
|
87
|
+
const [filter, setFilter] = useState("alles");
|
|
88
|
+
const tellingen = useMemo(() => telStickerFilters(rows), [rows]);
|
|
89
|
+
const zichtbareRows = useMemo(() => filterStickerRows(rows, filter), [rows, filter]);
|
|
75
90
|
const reset = () => {
|
|
76
|
-
setRows(
|
|
91
|
+
setRows((prev) => {
|
|
92
|
+
for (const x of prev)
|
|
93
|
+
if (x.localUrl)
|
|
94
|
+
URL.revokeObjectURL(x.localUrl);
|
|
95
|
+
return [];
|
|
96
|
+
});
|
|
77
97
|
setBatchId(null);
|
|
78
98
|
setPhase("idle");
|
|
79
99
|
setProgress({ done: 0, total: 0 });
|
|
@@ -118,6 +138,9 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
118
138
|
fileSize: file.size,
|
|
119
139
|
inboxPath: path,
|
|
120
140
|
thumbnail: await makeThumbnail(file),
|
|
141
|
+
localUrl: file.type === "application/pdf" || /\.pdf$/i.test(file.name)
|
|
142
|
+
? URL.createObjectURL(file)
|
|
143
|
+
: null,
|
|
121
144
|
tradeItemKey: null,
|
|
122
145
|
confidence: 0,
|
|
123
146
|
reason: null,
|
|
@@ -167,7 +190,7 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
167
190
|
confidence: s.confidence,
|
|
168
191
|
reason: s.reason,
|
|
169
192
|
replaceExisting: s.tradeItemKey
|
|
170
|
-
? (productByKey.get(s.tradeItemKey)
|
|
193
|
+
? heeftStickerVanSoort(productByKey.get(s.tradeItemKey), soort)
|
|
171
194
|
: false,
|
|
172
195
|
}
|
|
173
196
|
: r;
|
|
@@ -214,7 +237,7 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
214
237
|
}
|
|
215
238
|
setPhase("saving");
|
|
216
239
|
try {
|
|
217
|
-
const res = await commit({ data: { customerKey, batchId: batchId, items } });
|
|
240
|
+
const res = await commit({ data: { customerKey, batchId: batchId, items, soort } });
|
|
218
241
|
const parts = [
|
|
219
242
|
`${res.linked} nieuw`,
|
|
220
243
|
res.replaced ? `${res.replaced} vervangen` : null,
|
|
@@ -249,30 +272,37 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
249
272
|
e.target.value = "";
|
|
250
273
|
} }), phase === "uploading" || phase === "matching" ? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: true, children: [_jsx(Loader2, { className: "h-4 w-4 mr-1.5 animate-spin" }), phase === "uploading"
|
|
251
274
|
? `Stickers laden… ${progress.done}/${progress.total}`
|
|
252
|
-
: "AI koppelt stickers…"] })) : phase === "review" || phase === "saving" ? (_jsxs(Button, { type: "button", size: "sm", className: "bg-success text-success-foreground hover:bg-success/90", onClick: () => setOpen(true), children: [_jsx(Sparkles, { className: "h-4 w-4 mr-1.5" }), "Keuren (", rows.filter((r) => r.tradeItemKey).length, ")"] })) : (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: () => setOpen(true), children: [_jsx(Upload, { className: "h-4 w-4 mr-1.5" }), "Stickers in bulk"] })), _jsx(Dialog, { open: open, onOpenChange: (v) => (v ? setOpen(true) : void close(true)), children: _jsxs(DialogContent, { className: "max-w-
|
|
275
|
+
: "AI koppelt stickers…"] })) : phase === "review" || phase === "saving" ? (_jsxs(Button, { type: "button", size: "sm", className: "bg-success text-success-foreground hover:bg-success/90", onClick: () => setOpen(true), children: [_jsx(Sparkles, { className: "h-4 w-4 mr-1.5" }), "Keuren (", rows.filter((r) => r.tradeItemKey).length, ")"] })) : (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: () => setOpen(true), children: [_jsx(Upload, { className: "h-4 w-4 mr-1.5" }), "Stickers in bulk"] })), _jsx(Dialog, { open: open, onOpenChange: (v) => (v ? setOpen(true) : void close(true)), children: _jsxs(DialogContent, { className: "flex max-h-[90vh] w-full max-w-[min(1400px,95vw)] flex-col", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: soortKiezen || soort === "fust"
|
|
276
|
+
? `${soort === "fust" ? "Fuststickers" : "Productstickers"} in bulk uploaden`
|
|
277
|
+
: "Stickers in bulk uploaden" }) }), phase === "idle" && soortKiezen && (_jsx("div", { className: "flex gap-2", role: "radiogroup", "aria-label": "Soort sticker", children: ["product", "fust"].map((k) => (_jsx(Button, { type: "button", size: "sm", role: "radio", "aria-checked": soort === k, variant: soort === k ? "default" : "outline", onClick: () => setSoort(k), children: k === "product" ? "Productstickers" : "Fuststickers" }, k))) })), phase === "idle" && (_jsxs("div", { className: "rounded-lg border border-dashed p-10 text-center", onDragOver: (e) => e.preventDefault(), onDrop: (e) => {
|
|
253
278
|
e.preventDefault();
|
|
254
279
|
void handleFiles(e.dataTransfer.files);
|
|
255
280
|
}, 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"
|
|
256
281
|
? `Bestanden uploaden… ${progress.done}/${progress.total}`
|
|
257
282
|
: progress.total > 1
|
|
258
283
|
? `Koppelen ${progress.done} van ${progress.total}…`
|
|
259
|
-
: "AI zoekt bij elke sticker het juiste product…"] })), (phase === "review" || phase === "saving") && (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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" }) }))] }) })] }));
|
|
278
308
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerAssortmentTab.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerAssortmentTab.tsx"],"names":[],"mappings":"AA0BA,wBAAgB,qBAAqB,CAAC,EACpC,WAAW,EACX,cAAc,GACf,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,+
|
|
1
|
+
{"version":3,"file":"CustomerAssortmentTab.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerAssortmentTab.tsx"],"names":[],"mappings":"AA0BA,wBAAgB,qBAAqB,CAAC,EACpC,WAAW,EACX,cAAc,GACf,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,+BA0YA"}
|
|
@@ -47,6 +47,19 @@ export function CustomerAssortmentTab({ customerKey, organizationId, }) {
|
|
|
47
47
|
m.set(s.trade_item_key, s);
|
|
48
48
|
return m;
|
|
49
49
|
}, [stickerData]);
|
|
50
|
+
// Fuststickers: aparte lijst, zodat een fuststicker nooit een productsticker overschrijft.
|
|
51
|
+
const { data: fustData } = useQuery({
|
|
52
|
+
queryKey: ["customer-stickers", customerKey, "fust"],
|
|
53
|
+
queryFn: () => listStickers({ data: { customerKey, soort: "fust" } }),
|
|
54
|
+
enabled: !!customerKey,
|
|
55
|
+
});
|
|
56
|
+
const fustMap = useMemo(() => {
|
|
57
|
+
const m = new Map();
|
|
58
|
+
for (const s of fustData?.stickers ?? [])
|
|
59
|
+
m.set(s.trade_item_key, s);
|
|
60
|
+
return m;
|
|
61
|
+
}, [fustData]);
|
|
62
|
+
const fustFormat = fustData?.format ?? null;
|
|
50
63
|
const items = Array.isArray(data?.items) ? data.items : [];
|
|
51
64
|
const bronLabel = data?.bron === "voorraad" ? "Bron: voorraad" : "Bron: Floriday";
|
|
52
65
|
const ownCount = items.filter((i) => i.in_assortment).length;
|
|
@@ -101,16 +114,17 @@ export function CustomerAssortmentTab({ customerKey, organizationId, }) {
|
|
|
101
114
|
}
|
|
102
115
|
return (_jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: [_jsx("span", { className: "font-medium text-foreground", children: bronLabel }), _jsxs("span", { children: [_jsx("strong", { className: "text-foreground", children: ownCount }), " geselecteerd assortiment"] }), _jsxs("span", { children: [_jsx("strong", { className: "text-foreground", children: data?.summary.total ?? 0 }), " artikelen in ons aanbod"] }), _jsxs("span", { children: [_jsx("strong", { className: "text-foreground", children: data?.summary.priced ?? 0 }), " met klantprijs"] }), pg ? (_jsxs("span", { children: ["Prijsgroep: ", _jsx("strong", { className: "text-foreground", children: pg.name }), pg.pricing_mode === "calculated" && pg.calc_value
|
|
103
116
|
? ` (${pg.calc_type === "surcharge" ? "toeslag" : "korting"} ${pg.calc_value}${pg.calc_value_type === "percentage" ? "%" : ` ${currency}`})`
|
|
104
|
-
: ""] })) : (_jsx("span", { className: "text-warning-soft-foreground", children: "Geen prijsgroep ingesteld voor deze klant" })), data?.summary.last_synced_at && (_jsxs("span", { children: ["laatste sync: ", formatDateTime(data.summary.last_synced_at)] }))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [_jsxs("span", { children: ["
|
|
117
|
+
: ""] })) : (_jsx("span", { className: "text-warning-soft-foreground", children: "Geen prijsgroep ingesteld voor deze klant" })), data?.summary.last_synced_at && (_jsxs("span", { children: ["laatste sync: ", formatDateTime(data.summary.last_synced_at)] }))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [_jsxs("span", { children: ["Formaat productsticker:", " ", _jsx("strong", { className: "text-foreground", children: defaultFormat
|
|
105
118
|
? `${defaultFormat.width_mm} × ${defaultFormat.height_mm} mm`
|
|
106
|
-
: "—" })] }), _jsx(CustomerStickerFormatDialog, { customerKey: customerKey, format: defaultFormat }), _jsxs("span", { children: [_jsx("strong", { className: "text-foreground", children: stickerMap.size }), " artikelen met
|
|
119
|
+
: "—" })] }), _jsx(CustomerStickerFormatDialog, { customerKey: customerKey, format: defaultFormat }), _jsxs("span", { children: ["Formaat fuststicker:", " ", _jsx("strong", { className: "text-foreground", children: fustFormat ? `${fustFormat.width_mm} × ${fustFormat.height_mm} mm` : "—" })] }), _jsx(CustomerStickerFormatDialog, { customerKey: customerKey, format: fustFormat, soort: "fust" }), _jsxs("span", { children: [_jsx("strong", { className: "text-foreground", children: stickerMap.size }), " artikelen met productsticker", " · ", _jsx("strong", { className: "text-foreground", children: fustMap.size }), " met fuststicker"] }), _jsx(BulkStickerUploadDialog, { customerKey: customerKey, products: items.map((i) => ({
|
|
107
120
|
key: i.key,
|
|
108
121
|
name: i.name,
|
|
109
122
|
code: i.supplier_article_code,
|
|
110
123
|
vbn: i.vbn_code,
|
|
111
124
|
botanical: i.botanical_name,
|
|
112
125
|
hasSticker: stickerMap.has(i.key),
|
|
113
|
-
|
|
126
|
+
hasFustSticker: fustMap.has(i.key),
|
|
127
|
+
})), soortKiezen: true, onDone: () => qc.invalidateQueries({ queryKey: ["customer-stickers", customerKey] }) }), _jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: floridayImport.isPending, onClick: () => floridayImport.mutate(), children: [_jsx(RefreshCw, { className: "h-4 w-4 mr-1.5 " + (floridayImport.isPending ? "animate-spin" : "") }), "Stickers ophalen uit Floriday"] })] }), hasOwnAssortment && (_jsx("div", { className: "flex flex-wrap items-center gap-2", children: _jsx("div", { className: "inline-flex rounded-lg border p-0.5", children: [
|
|
114
128
|
["own", `Eigen assortiment (${ownCount})`],
|
|
115
129
|
["other", `Overige producten (${otherCount})`],
|
|
116
130
|
].map(([value, label]) => (_jsx("button", { type: "button", onClick: () => setGroup(value), className: "rounded-md px-3 py-1 text-xs transition-colors " +
|
|
@@ -122,7 +136,7 @@ export function CustomerAssortmentTab({ customerKey, organizationId, }) {
|
|
|
122
136
|
: "bg-card text-muted-foreground border-border hover:bg-muted"), children: "Alleen met prijs" }), _jsx("button", { type: "button", onClick: () => setOnlyWithoutSticker((v) => !v), className: "inline-flex items-center rounded-full border px-3 py-1 text-xs transition-colors " +
|
|
123
137
|
(onlyWithoutSticker
|
|
124
138
|
? "bg-primary text-primary-foreground border-primary"
|
|
125
|
-
: "bg-card text-muted-foreground border-border hover:bg-muted"), children: "Alleen zonder sticker" }), _jsx("div", { className: "ml-auto", children: _jsx(FloridayPriceImportDialog, { customerKey: customerKey, organizationId: organizationId }) })] }), _jsx(Card, { children: _jsx(CardContent, { className: "p-0", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { className: "w-[64px]" }), _jsx(TableHead, { children: "Artikel" }), hasOwnAssortment && _jsx(TableHead, { children: "Assortiment" }), _jsx(TableHead, { children: "Verpakking" }), _jsx(TableHead, { className: "text-right", children: "Basisprijs" }), _jsx(TableHead, { className: "text-right", children: "Prijs voor klant" }), _jsx(TableHead, { children: "
|
|
139
|
+
: "bg-card text-muted-foreground border-border hover:bg-muted"), children: "Alleen zonder sticker" }), _jsx("div", { className: "ml-auto", children: _jsx(FloridayPriceImportDialog, { customerKey: customerKey, organizationId: organizationId }) })] }), _jsx(Card, { children: _jsx(CardContent, { className: "p-0", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { className: "w-[64px]" }), _jsx(TableHead, { children: "Artikel" }), hasOwnAssortment && _jsx(TableHead, { children: "Assortiment" }), _jsx(TableHead, { children: "Verpakking" }), _jsx(TableHead, { className: "text-right", children: "Basisprijs" }), _jsx(TableHead, { className: "text-right", children: "Prijs voor klant" }), _jsx(TableHead, { children: "Productsticker" }), _jsx(TableHead, { children: "Fuststicker" })] }) }), _jsx(TableBody, { children: filtered.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: hasOwnAssortment ? 8 : 7, className: "text-center py-6 text-muted-foreground text-sm", children: "Geen resultaten voor deze zoekopdracht." }) })) : filtered.map((i) => {
|
|
126
140
|
const packing = [
|
|
127
141
|
i.pieces_per_package != null ? `${i.pieces_per_package} per fust` : null,
|
|
128
142
|
i.packages_per_layer != null ? `${i.packages_per_layer} per laag` : null,
|
|
@@ -139,6 +153,6 @@ export function CustomerAssortmentTab({ customerKey, organizationId, }) {
|
|
|
139
153
|
i.vbn_code ? `VBN ${i.vbn_code}` : null,
|
|
140
154
|
i.botanical_name,
|
|
141
155
|
i.country_of_origin,
|
|
142
|
-
].filter(Boolean).join(" · ") || "—" })] }), hasOwnAssortment && (_jsx(TableCell, { children: i.in_assortment ? (_jsx(Badge, { children: "Eigen assortiment" })) : (_jsx("span", { className: "text-xs text-muted-foreground", children: "Overig" })) })), _jsxs(TableCell, { className: "text-sm text-muted-foreground", children: [_jsx("div", { children: i.packaging ?? "—" }), packing.length > 0 && (_jsx("div", { className: "text-xs", children: packing.join(" · ") }))] }), _jsx(TableCell, { className: "text-right whitespace-nowrap tabular-nums text-muted-foreground", children: money(i.base_price, i.currency) }), _jsxs(TableCell, { className: "text-right whitespace-nowrap tabular-nums", children: [_jsx("div", { className: "font-medium", children: money(i.price, i.currency) }), i.base_price_source && (_jsx("div", { className: "text-[10px] text-muted-foreground", children: i.base_price_source }))] }), _jsx(TableCell, { children: _jsxs("div", { className: "space-y-1", children: [_jsx(CustomerStickerCell, { customerKey: customerKey, tradeItemKey: i.key, sticker: sticker }), sticker ? (_jsxs("div", { className: "flex items-center gap-1.5 text-[10px] text-muted-foreground", children: [_jsx(Badge, { variant: sticker.source === "floriday" ? "default" : "secondary", children: sticker.source === "floriday" ? "Uit Floriday" : "Handmatig" }), fmt && _jsx("span", { children: fmt })] })) : _jsx("div", { className: "text-[10px] text-muted-foreground", children: "\u2014" })] }) })] }, i.key));
|
|
156
|
+
].filter(Boolean).join(" · ") || "—" })] }), hasOwnAssortment && (_jsx(TableCell, { children: i.in_assortment ? (_jsx(Badge, { children: "Eigen assortiment" })) : (_jsx("span", { className: "text-xs text-muted-foreground", children: "Overig" })) })), _jsxs(TableCell, { className: "text-sm text-muted-foreground", children: [_jsx("div", { children: i.packaging ?? "—" }), packing.length > 0 && (_jsx("div", { className: "text-xs", children: packing.join(" · ") }))] }), _jsx(TableCell, { className: "text-right whitespace-nowrap tabular-nums text-muted-foreground", children: money(i.base_price, i.currency) }), _jsxs(TableCell, { className: "text-right whitespace-nowrap tabular-nums", children: [_jsx("div", { className: "font-medium", children: money(i.price, i.currency) }), i.base_price_source && (_jsx("div", { className: "text-[10px] text-muted-foreground", children: i.base_price_source }))] }), _jsx(TableCell, { children: _jsxs("div", { className: "space-y-1", children: [_jsx(CustomerStickerCell, { customerKey: customerKey, tradeItemKey: i.key, sticker: sticker }), sticker ? (_jsxs("div", { className: "flex items-center gap-1.5 text-[10px] text-muted-foreground", children: [_jsx(Badge, { variant: sticker.source === "floriday" ? "default" : "secondary", children: sticker.source === "floriday" ? "Uit Floriday" : "Handmatig" }), fmt && _jsx("span", { children: fmt })] })) : _jsx("div", { className: "text-[10px] text-muted-foreground", children: "\u2014" })] }) }), _jsx(TableCell, { children: _jsx(CustomerStickerCell, { customerKey: customerKey, tradeItemKey: i.key, sticker: fustMap.get(i.key) ?? null, soort: "fust" }) })] }, i.key));
|
|
143
157
|
}) })] }) }) })] }));
|
|
144
158
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type CustomerSticker } from "../../lib/customer-stickers.functions.js";
|
|
2
|
-
|
|
2
|
+
import { type StickerSoort } from "../../lib/sticker-soort.js";
|
|
3
|
+
export declare function CustomerStickerCell({ customerKey, tradeItemKey, sticker, soort, }: {
|
|
3
4
|
customerKey: string;
|
|
4
5
|
tradeItemKey: string;
|
|
5
6
|
sticker: CustomerSticker | null;
|
|
7
|
+
/** Optioneel; standaard 'product' (gedrag zoals altijd). */
|
|
8
|
+
soort?: StickerSoort;
|
|
6
9
|
}): import("react").JSX.Element;
|
|
7
10
|
//# sourceMappingURL=CustomerStickerCell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerStickerCell.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerStickerCell.tsx"],"names":[],"mappings":"AASA,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomerStickerCell.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerStickerCell.tsx"],"names":[],"mappings":"AASA,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAiBxE,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,YAAY,EACZ,OAAO,EACP,KAAiB,GAClB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAChC,4DAA4D;IAC5D,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,+BA6LA"}
|
|
@@ -7,6 +7,7 @@ import { Upload, FileText, Trash2, Eye, RefreshCw } from "lucide-react";
|
|
|
7
7
|
import { toast } from "sonner";
|
|
8
8
|
import { supabase } from "../../integrations/supabase/client.js";
|
|
9
9
|
import { ALLOWED_STICKER_MIME, confirmStickerUpload, deleteCustomerSticker, } from "../../lib/customer-stickers.functions.js";
|
|
10
|
+
import { stickerDoelpad } from "../../lib/sticker-soort.js";
|
|
10
11
|
import { StickerSizeLine } from "./StickerSizeLine.js";
|
|
11
12
|
import { friendlyError } from "../../lib/errors.js";
|
|
12
13
|
const BUCKET = "customer-stickers";
|
|
@@ -19,7 +20,7 @@ function extOf(name) {
|
|
|
19
20
|
function safeKey(value) {
|
|
20
21
|
return value.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
21
22
|
}
|
|
22
|
-
export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, }) {
|
|
23
|
+
export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, soort = "product", }) {
|
|
23
24
|
const qc = useQueryClient();
|
|
24
25
|
const confirm = useServerFn(confirmStickerUpload);
|
|
25
26
|
const remove = useServerFn(deleteCustomerSticker);
|
|
@@ -42,7 +43,7 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, }) {
|
|
|
42
43
|
}
|
|
43
44
|
setBusy(true);
|
|
44
45
|
try {
|
|
45
|
-
const path =
|
|
46
|
+
const path = stickerDoelpad(safeKey(customerKey), safeKey(tradeItemKey), soort, `${crypto.randomUUID()}.${extOf(file.name)}`);
|
|
46
47
|
const { error } = await supabase.storage.from(BUCKET).upload(path, file, {
|
|
47
48
|
contentType: type,
|
|
48
49
|
upsert: false,
|
|
@@ -57,6 +58,7 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, }) {
|
|
|
57
58
|
fileName: file.name,
|
|
58
59
|
mimeType: type,
|
|
59
60
|
fileSize: file.size,
|
|
61
|
+
soort,
|
|
60
62
|
},
|
|
61
63
|
});
|
|
62
64
|
setLastDet({ method: res.method, size: res.size, suggestion: res.suggestion });
|
|
@@ -74,7 +76,7 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, }) {
|
|
|
74
76
|
}
|
|
75
77
|
};
|
|
76
78
|
const del = useMutation({
|
|
77
|
-
mutationFn: () => remove({ data: { customerKey, tradeItemKey } }),
|
|
79
|
+
mutationFn: () => remove({ data: { customerKey, tradeItemKey, soort } }),
|
|
78
80
|
onSuccess: () => {
|
|
79
81
|
invalidate();
|
|
80
82
|
toast.success("Sticker verwijderd");
|
|
@@ -92,5 +94,5 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, }) {
|
|
|
92
94
|
: "Formaat nog onbekend" })] })] })) : (_jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: busy, onClick: () => inputRef.current?.click(), children: [_jsx(Upload, { className: "h-4 w-4 mr-1.5" }), "Uploaden"] })), _jsx(Dialog, { open: open, onOpenChange: (o) => { setOpen(o); if (!o)
|
|
93
95
|
setLastDet(null); }, children: _jsxs(DialogContent, { className: "max-w-md", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: "Sticker" }) }), sticker && (_jsxs("div", { className: "space-y-3", children: [isImage && sticker.url ? (_jsx("img", { src: sticker.url, alt: sticker.file_name, className: "max-h-64 w-full rounded border object-contain bg-muted" })) : (_jsxs("div", { className: "rounded border bg-muted p-6 flex items-center justify-center gap-2 text-sm text-muted-foreground", children: [_jsx(FileText, { className: "h-5 w-5" }), sticker.file_name] })), _jsxs("p", { className: "text-xs text-muted-foreground", children: [sticker.file_name, sticker.file_size != null
|
|
94
96
|
? ` · ${(sticker.file_size / 1024).toFixed(0)} kB`
|
|
95
|
-
: ""] }), _jsx(StickerSizeLine, { customerKey: customerKey, tradeItemKey: tradeItemKey, widthMm: sticker.width_mm, heightMm: sticker.height_mm, initialDetection: lastDet, onSaved: invalidate }, sticker.file_path)] })), _jsxs(DialogFooter, { className: "gap-2 sm:justify-between", children: [_jsxs(Button, { type: "button", variant: "destructive", disabled: del.isPending || busy, onClick: () => del.mutate(), children: [_jsx(Trash2, { className: "h-4 w-4 mr-1.5" }), "Verwijderen"] }), _jsxs("div", { className: "flex gap-2", children: [sticker?.url && (_jsx(Button, { type: "button", variant: "outline", asChild: true, children: _jsxs("a", { href: sticker.url, target: "_blank", rel: "noreferrer", children: [_jsx(Eye, { className: "h-4 w-4 mr-1.5" }), "Bekijken"] }) })), _jsxs(Button, { type: "button", disabled: busy, onClick: () => inputRef.current?.click(), children: [_jsx(RefreshCw, { className: "h-4 w-4 mr-1.5" }), "Vervangen"] })] })] })] }) })] }));
|
|
97
|
+
: ""] }), _jsx(StickerSizeLine, { customerKey: customerKey, tradeItemKey: tradeItemKey, soort: soort, widthMm: sticker.width_mm, heightMm: sticker.height_mm, initialDetection: lastDet, onSaved: invalidate }, sticker.file_path)] })), _jsxs(DialogFooter, { className: "gap-2 sm:justify-between", children: [_jsxs(Button, { type: "button", variant: "destructive", disabled: del.isPending || busy, onClick: () => del.mutate(), children: [_jsx(Trash2, { className: "h-4 w-4 mr-1.5" }), "Verwijderen"] }), _jsxs("div", { className: "flex gap-2", children: [sticker?.url && (_jsx(Button, { type: "button", variant: "outline", asChild: true, children: _jsxs("a", { href: sticker.url, target: "_blank", rel: "noreferrer", children: [_jsx(Eye, { className: "h-4 w-4 mr-1.5" }), "Bekijken"] }) })), _jsxs(Button, { type: "button", disabled: busy, onClick: () => inputRef.current?.click(), children: [_jsx(RefreshCw, { className: "h-4 w-4 mr-1.5" }), "Vervangen"] })] })] })] }) })] }));
|
|
96
98
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type StickerFormat } from "../../lib/customer-stickers.functions.js";
|
|
2
|
-
export declare function CustomerStickerFormatDialog({ customerKey, format, trigger, }: {
|
|
2
|
+
export declare function CustomerStickerFormatDialog({ customerKey, format, trigger, soort, }: {
|
|
3
3
|
customerKey: string;
|
|
4
4
|
format: StickerFormat | null;
|
|
5
5
|
trigger?: React.ReactNode;
|
|
6
|
+
/** Optioneel; standaard 'product' (gedrag zoals altijd). */
|
|
7
|
+
soort?: "product" | "fust";
|
|
6
8
|
}): import("react").JSX.Element;
|
|
7
9
|
//# sourceMappingURL=CustomerStickerFormatDialog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomerStickerFormatDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerStickerFormatDialog.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGnG,wBAAgB,2BAA2B,CAAC,EAC1C,WAAW,EACX,MAAM,EACN,OAAO,
|
|
1
|
+
{"version":3,"file":"CustomerStickerFormatDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerStickerFormatDialog.tsx"],"names":[],"mappings":"AAQA,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGnG,wBAAgB,2BAA2B,CAAC,EAC1C,WAAW,EACX,MAAM,EACN,OAAO,EACP,KAAiB,GAClB,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,4DAA4D;IAC5D,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;CAC5B,+BAqFA"}
|
|
@@ -7,7 +7,8 @@ import { Ruler } from "lucide-react";
|
|
|
7
7
|
import { toast } from "sonner";
|
|
8
8
|
import { setCustomerStickerSettings } from "../../lib/customer-stickers.functions.js";
|
|
9
9
|
import { friendlyError } from "../../lib/errors.js";
|
|
10
|
-
export function CustomerStickerFormatDialog({ customerKey, format, trigger, }) {
|
|
10
|
+
export function CustomerStickerFormatDialog({ customerKey, format, trigger, soort = "product", }) {
|
|
11
|
+
const fust = soort === "fust";
|
|
11
12
|
const qc = useQueryClient();
|
|
12
13
|
const save = useServerFn(setCustomerStickerSettings);
|
|
13
14
|
const [open, setOpen] = useState(false);
|
|
@@ -21,16 +22,16 @@ export function CustomerStickerFormatDialog({ customerKey, format, trigger, }) {
|
|
|
21
22
|
}, [open, format?.width_mm, format?.height_mm]);
|
|
22
23
|
const mut = useMutation({
|
|
23
24
|
mutationFn: () => save({
|
|
24
|
-
data: { customerKey, widthMm: Number(width), heightMm: Number(height) },
|
|
25
|
+
data: { customerKey, widthMm: Number(width), heightMm: Number(height), soort },
|
|
25
26
|
}),
|
|
26
27
|
onSuccess: () => {
|
|
27
28
|
qc.invalidateQueries({ queryKey: ["customer-stickers", customerKey] });
|
|
28
29
|
qc.invalidateQueries({ queryKey: ["customer-sticker-format", customerKey] });
|
|
29
|
-
toast.success("Stickerformaat opgeslagen");
|
|
30
|
+
toast.success(fust ? "Formaat fuststicker opgeslagen" : "Stickerformaat opgeslagen");
|
|
30
31
|
setOpen(false);
|
|
31
32
|
},
|
|
32
33
|
onError: (e) => toast.error(friendlyError(e, "Opslaan mislukt")),
|
|
33
34
|
});
|
|
34
35
|
const valid = Number(width) > 0 && Number(height) > 0;
|
|
35
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { onClick: () => setOpen(true), children: trigger ?? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", children: [_jsx(Ruler, { className: "h-4 w-4 mr-2" }), "Stickerformaat"] })) }), _jsx(Dialog, { open: open, onOpenChange: setOpen, children: _jsxs(DialogContent, { className: "max-w-sm", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: "Stickerformaat van deze klant" }) }), _jsxs("div", { className: "grid grid-cols-2 gap-3", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "sticker-width", children: "Breedte (mm)" }), _jsx(Input, { id: "sticker-width", type: "number", min: "1", step: "0.1", value: width, onChange: (e) => setWidth(e.target.value) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "sticker-height", children: "Hoogte (mm)" }), _jsx(Input, { id: "sticker-height", type: "number", min: "1", step: "0.1", value: height, onChange: (e) => setHeight(e.target.value) })] })] }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Stickers worden bij het printen passend geschaald naar dit formaat." }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => setOpen(false), children: "Annuleren" }), _jsx(Button, { type: "button", disabled: !valid || mut.isPending, onClick: () => mut.mutate(), children: "Opslaan" })] })] }) })] }));
|
|
36
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { onClick: () => setOpen(true), children: trigger ?? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", children: [_jsx(Ruler, { className: "h-4 w-4 mr-2" }), fust ? "Formaat fuststicker" : "Stickerformaat"] })) }), _jsx(Dialog, { open: open, onOpenChange: setOpen, children: _jsxs(DialogContent, { className: "max-w-sm", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: fust ? "Formaat fuststicker van deze klant" : "Stickerformaat van deze klant" }) }), _jsxs("div", { className: "grid grid-cols-2 gap-3", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: fust ? "fust-sticker-width" : "sticker-width", children: "Breedte (mm)" }), _jsx(Input, { id: fust ? "fust-sticker-width" : "sticker-width", type: "number", min: "1", step: "0.1", value: width, onChange: (e) => setWidth(e.target.value) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: fust ? "fust-sticker-height" : "sticker-height", children: "Hoogte (mm)" }), _jsx(Input, { id: fust ? "fust-sticker-height" : "sticker-height", type: "number", min: "1", step: "0.1", value: height, onChange: (e) => setHeight(e.target.value) })] })] }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Stickers worden bij het printen passend geschaald naar dit formaat." }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => setOpen(false), children: "Annuleren" }), _jsx(Button, { type: "button", disabled: !valid || mut.isPending, onClick: () => mut.mutate(), children: "Opslaan" })] })] }) })] }));
|
|
36
37
|
}
|
|
@@ -3,9 +3,11 @@ import { type StickerUploadSize } from "../../lib/customer-stickers.functions.js
|
|
|
3
3
|
* "Formaat: 48 × 48 mm (wijzigen)". Zonder maat: voorstel via geladen etiket
|
|
4
4
|
* (één klik bevestigen) of pas dan om breedte en hoogte vragen.
|
|
5
5
|
*/
|
|
6
|
-
export declare function StickerSizeLine({ customerKey, tradeItemKey, widthMm, heightMm, initialDetection, onSaved, }: {
|
|
6
|
+
export declare function StickerSizeLine({ customerKey, tradeItemKey, soort, widthMm, heightMm, initialDetection, onSaved, }: {
|
|
7
7
|
customerKey: string;
|
|
8
8
|
tradeItemKey: string;
|
|
9
|
+
/** Optioneel; standaard 'product'. */
|
|
10
|
+
soort?: "product" | "fust";
|
|
9
11
|
widthMm: number | null;
|
|
10
12
|
heightMm: number | null;
|
|
11
13
|
initialDetection?: StickerUploadSize | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StickerSizeLine.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/StickerSizeLine.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,mCAAmC,CAAC;AAK3C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,OAAO,GACR,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,+BA4GA"}
|
|
1
|
+
{"version":3,"file":"StickerSizeLine.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/StickerSizeLine.tsx"],"names":[],"mappings":"AAIA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,mCAAmC,CAAC;AAK3C;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAC9B,WAAW,EACX,YAAY,EACZ,KAAiB,EACjB,OAAO,EACP,QAAQ,EACR,gBAAgB,EAChB,OAAO,GACR,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,KAAK,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,gBAAgB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,+BA4GA"}
|
|
@@ -10,7 +10,7 @@ const fmt = (v) => v.toLocaleString("nl-NL", { maximumFractionDigits: 1 });
|
|
|
10
10
|
* "Formaat: 48 × 48 mm (wijzigen)". Zonder maat: voorstel via geladen etiket
|
|
11
11
|
* (één klik bevestigen) of pas dan om breedte en hoogte vragen.
|
|
12
12
|
*/
|
|
13
|
-
export function StickerSizeLine({ customerKey, tradeItemKey, widthMm, heightMm, initialDetection, onSaved, }) {
|
|
13
|
+
export function StickerSizeLine({ customerKey, tradeItemKey, soort = "product", widthMm, heightMm, initialDetection, onSaved, }) {
|
|
14
14
|
const save = useServerFn(setStickerSize);
|
|
15
15
|
const suggest = useServerFn(suggestStickerSize);
|
|
16
16
|
const known = widthMm != null && heightMm != null;
|
|
@@ -23,17 +23,17 @@ export function StickerSizeLine({ customerKey, tradeItemKey, widthMm, heightMm,
|
|
|
23
23
|
if (known || det)
|
|
24
24
|
return;
|
|
25
25
|
let alive = true;
|
|
26
|
-
suggest({ data: { customerKey, tradeItemKey } })
|
|
26
|
+
suggest({ data: { customerKey, tradeItemKey, soort } })
|
|
27
27
|
.then((r) => alive && setDet(r))
|
|
28
28
|
.catch(() => alive && setDet({ method: "onbekend", size: null, suggestion: null }));
|
|
29
29
|
return () => {
|
|
30
30
|
alive = false;
|
|
31
31
|
};
|
|
32
|
-
}, [known, det, customerKey, tradeItemKey, suggest]);
|
|
32
|
+
}, [known, det, customerKey, tradeItemKey, soort, suggest]);
|
|
33
33
|
const store = async (wm, hm) => {
|
|
34
34
|
setBusy(true);
|
|
35
35
|
try {
|
|
36
|
-
await save({ data: { customerKey, tradeItemKey, widthMm: wm, heightMm: hm } });
|
|
36
|
+
await save({ data: { customerKey, tradeItemKey, widthMm: wm, heightMm: hm, soort } });
|
|
37
37
|
setEditing(false);
|
|
38
38
|
onSaved();
|
|
39
39
|
toast.success("Formaat opgeslagen");
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { FloridayPriceImportDialog } from "./components/klanten/FloridayPriceImp
|
|
|
27
27
|
export { CustomerStickerCell } from "./components/klanten/CustomerStickerCell.js";
|
|
28
28
|
export { CustomerStickerFormatDialog } from "./components/klanten/CustomerStickerFormatDialog.js";
|
|
29
29
|
export { BulkStickerUploadDialog } from "./components/klanten/BulkStickerUploadDialog.js";
|
|
30
|
-
export { listCustomerStickers, confirmStickerUpload, deleteCustomerSticker, getCustomerStickerSettings, setCustomerStickerSettings, getStickerForPrint, suggestStickerMatches, commitStickerBatch, discardStickerBatch, ALLOWED_STICKER_MIME, type CustomerSticker, type CustomerStickersResult, type StickerFormat, } from "./lib/customer-stickers.functions.js";
|
|
30
|
+
export { listCustomerStickers, confirmStickerUpload, deleteCustomerSticker, getCustomerStickerSettings, setCustomerStickerSettings, getStickerForPrint, suggestStickerMatches, commitStickerBatch, discardStickerBatch, ALLOWED_STICKER_MIME, type CustomerSticker, type CustomerStickersResult, type StickerFormat, type StickerSoort, } from "./lib/customer-stickers.functions.js";
|
|
31
31
|
export { previewFloridayPriceImport, applyFloridayPriceImport, } from "./lib/floriday-price-import.functions.js";
|
|
32
32
|
export { getPriceGroupsForCustomer, setPriceGroupForCustomer, resolveCustomerKeyForLocalCustomer, listPriceGroupItemPrices, setPriceGroupItemPrice, } from "./lib/price-groups-local.functions.js";
|
|
33
33
|
export { PriceGroupItemPrices } from "./components/klanten/pricegroups/PriceGroupItemPrices.js";
|
package/dist-lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIvD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7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