@flowselections/floriday-klanten-module 1.0.99 → 1.0.100
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 +32 -11
- 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 +243 -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-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 +27 -2
|
@@ -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;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"}
|
|
@@ -9,9 +9,16 @@ 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";
|
|
12
13
|
const BUCKET = "customer-stickers";
|
|
13
14
|
const MAX_SIZE = 10 * 1024 * 1024;
|
|
14
15
|
const ACCEPT = ".pdf,.png,.jpg,.jpeg,.svg";
|
|
16
|
+
/** "Bestaand" kijkt alleen naar stickers van de gekozen soort. */
|
|
17
|
+
export function heeftStickerVanSoort(p, soort) {
|
|
18
|
+
if (!p)
|
|
19
|
+
return false;
|
|
20
|
+
return soort === "fust" ? p.hasFustSticker === true : p.hasSticker;
|
|
21
|
+
}
|
|
15
22
|
function safeKey(value) {
|
|
16
23
|
return value.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
17
24
|
}
|
|
@@ -19,6 +26,9 @@ function extOf(name) {
|
|
|
19
26
|
return (/\.([a-z0-9]+)$/i.exec(name)?.[1] ?? "bin").toLowerCase();
|
|
20
27
|
}
|
|
21
28
|
async function makeThumbnail(file) {
|
|
29
|
+
if (file.type === "application/pdf" || /\.pdf$/i.test(file.name)) {
|
|
30
|
+
return renderPdfThumbnail(file);
|
|
31
|
+
}
|
|
22
32
|
if (!file.type.startsWith("image/"))
|
|
23
33
|
return null;
|
|
24
34
|
try {
|
|
@@ -47,7 +57,8 @@ async function makeThumbnail(file) {
|
|
|
47
57
|
return null;
|
|
48
58
|
}
|
|
49
59
|
}
|
|
50
|
-
export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
60
|
+
export function BulkStickerUploadDialog({ customerKey, products, onDone, soort: soortProp = "product", soortKiezen = false, }) {
|
|
61
|
+
const [soort, setSoort] = useState(soortProp);
|
|
51
62
|
const [open, setOpen] = useState(false);
|
|
52
63
|
const [batchId, setBatchId] = useState(null);
|
|
53
64
|
const [rows, setRows] = useState([]);
|
|
@@ -61,7 +72,7 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
61
72
|
const discard = useServerFn(discardStickerBatch);
|
|
62
73
|
const productOptions = useMemo(() => products.map((p) => ({
|
|
63
74
|
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 }))] })),
|
|
75
|
+
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
76
|
search: [p.name, p.code, p.vbn, p.botanical].filter(Boolean).join(" "),
|
|
66
77
|
})), [products]);
|
|
67
78
|
const productByKey = useMemo(() => new Map(products.map((p) => [p.key, p])), [products]);
|
|
@@ -73,7 +84,12 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
73
84
|
return new Set([...count.entries()].filter(([, n]) => n > 1).map(([k]) => k));
|
|
74
85
|
}, [rows]);
|
|
75
86
|
const reset = () => {
|
|
76
|
-
setRows(
|
|
87
|
+
setRows((prev) => {
|
|
88
|
+
for (const x of prev)
|
|
89
|
+
if (x.localUrl)
|
|
90
|
+
URL.revokeObjectURL(x.localUrl);
|
|
91
|
+
return [];
|
|
92
|
+
});
|
|
77
93
|
setBatchId(null);
|
|
78
94
|
setPhase("idle");
|
|
79
95
|
setProgress({ done: 0, total: 0 });
|
|
@@ -118,6 +134,9 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
118
134
|
fileSize: file.size,
|
|
119
135
|
inboxPath: path,
|
|
120
136
|
thumbnail: await makeThumbnail(file),
|
|
137
|
+
localUrl: file.type === "application/pdf" || /\.pdf$/i.test(file.name)
|
|
138
|
+
? URL.createObjectURL(file)
|
|
139
|
+
: null,
|
|
121
140
|
tradeItemKey: null,
|
|
122
141
|
confidence: 0,
|
|
123
142
|
reason: null,
|
|
@@ -167,7 +186,7 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
167
186
|
confidence: s.confidence,
|
|
168
187
|
reason: s.reason,
|
|
169
188
|
replaceExisting: s.tradeItemKey
|
|
170
|
-
? (productByKey.get(s.tradeItemKey)
|
|
189
|
+
? heeftStickerVanSoort(productByKey.get(s.tradeItemKey), soort)
|
|
171
190
|
: false,
|
|
172
191
|
}
|
|
173
192
|
: r;
|
|
@@ -214,7 +233,7 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
214
233
|
}
|
|
215
234
|
setPhase("saving");
|
|
216
235
|
try {
|
|
217
|
-
const res = await commit({ data: { customerKey, batchId: batchId, items } });
|
|
236
|
+
const res = await commit({ data: { customerKey, batchId: batchId, items, soort } });
|
|
218
237
|
const parts = [
|
|
219
238
|
`${res.linked} nieuw`,
|
|
220
239
|
res.replaced ? `${res.replaced} vervangen` : null,
|
|
@@ -249,30 +268,32 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
|
|
|
249
268
|
e.target.value = "";
|
|
250
269
|
} }), 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
270
|
? `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-
|
|
271
|
+
: "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"
|
|
272
|
+
? `${soort === "fust" ? "Fuststickers" : "Productstickers"} in bulk uploaden`
|
|
273
|
+
: "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
274
|
e.preventDefault();
|
|
254
275
|
void handleFiles(e.dataTransfer.files);
|
|
255
276
|
}, 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
277
|
? `Bestanden uploaden… ${progress.done}/${progress.total}`
|
|
257
278
|
: progress.total > 1
|
|
258
279
|
? `Koppelen ${progress.done} van ${progress.total}…`
|
|
259
|
-
: "AI zoekt bij elke sticker het juiste product…"] })), (phase === "review" || phase === "saving") && (_jsx("div", { className: "
|
|
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) => {
|
|
260
281
|
const product = r.tradeItemKey ? productByKey.get(r.tradeItemKey) : null;
|
|
261
282
|
const dup = r.tradeItemKey ? duplicates.has(r.tradeItemKey) : false;
|
|
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-
|
|
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
|
|
263
284
|
? {
|
|
264
285
|
...x,
|
|
265
286
|
tradeItemKey: v || null,
|
|
266
287
|
replaceExisting: v
|
|
267
|
-
? (productByKey.get(v)
|
|
288
|
+
? heeftStickerVanSoort(productByKey.get(v), soort)
|
|
268
289
|
: false,
|
|
269
290
|
}
|
|
270
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
|
|
271
292
|
? "default"
|
|
272
293
|
: r.confidence >= 0.5
|
|
273
294
|
? "secondary"
|
|
274
|
-
: "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: product
|
|
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
|
|
275
296
|
? { ...x, replaceExisting: e.target.checked }
|
|
276
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));
|
|
277
|
-
}) })] }) })), _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 && (_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" }) }))] }) })] }));
|
|
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" }) }))] }) })] }));
|
|
278
299
|
}
|
|
@@ -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;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mDAAmD,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,KAAK,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,
|
|
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;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mDAAmD,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,EAAE,wBAAwB,EAAE,MAAM,2DAA2D,CAAC;AACrG,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,yBAAyB,EAAE,KAAK,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,0BAA0B,EAC1B,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,kCAAkC,EAClC,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uDAAuD,CAAC;AAC7F,OAAO,EACL,uBAAuB,EACvB,2BAA2B,EAC3B,2BAA2B,EAC3B,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,eAAO,MAAM,qBAAqB,EAAE,UAiBnC,CAAC"}
|