@flowselections/floriday-klanten-module 1.0.60 → 1.0.64

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.
Files changed (38) hide show
  1. package/dist-lib/components/klanten/BulkStickerUploadDialog.d.ts.map +1 -1
  2. package/dist-lib/components/klanten/BulkStickerUploadDialog.js +4 -0
  3. package/dist-lib/components/klanten/CustomerStickerCell.d.ts.map +1 -1
  4. package/dist-lib/components/klanten/CustomerStickerCell.js +11 -5
  5. package/dist-lib/components/klanten/FloridayAutoPromoteCard.d.ts +1 -1
  6. package/dist-lib/components/klanten/FloridayAutoPromoteCard.d.ts.map +1 -1
  7. package/dist-lib/components/klanten/FloridayAutoPromoteCard.js +11 -31
  8. package/dist-lib/components/klanten/KlantenOverzicht.d.ts.map +1 -1
  9. package/dist-lib/components/klanten/KlantenOverzicht.js +2 -1
  10. package/dist-lib/components/klanten/StickerSizeLine.d.ts +14 -0
  11. package/dist-lib/components/klanten/StickerSizeLine.d.ts.map +1 -0
  12. package/dist-lib/components/klanten/StickerSizeLine.js +74 -0
  13. package/dist-lib/components/klanten/StickerSizePreviewCard.d.ts +3 -0
  14. package/dist-lib/components/klanten/StickerSizePreviewCard.d.ts.map +1 -0
  15. package/dist-lib/components/klanten/StickerSizePreviewCard.js +27 -0
  16. package/dist-lib/index.js +1 -1
  17. package/dist-lib/integrations/supabase/types.d.ts +45 -0
  18. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  19. package/dist-lib/lib/auto-promote.d.ts +1 -0
  20. package/dist-lib/lib/auto-promote.d.ts.map +1 -1
  21. package/dist-lib/lib/auto-promote.functions.d.ts +1 -13
  22. package/dist-lib/lib/auto-promote.functions.d.ts.map +1 -1
  23. package/dist-lib/lib/auto-promote.functions.js +0 -13
  24. package/dist-lib/lib/customer-stickers.functions.d.ts +55 -0
  25. package/dist-lib/lib/customer-stickers.functions.d.ts.map +1 -1
  26. package/dist-lib/lib/customer-stickers.functions.js +137 -5
  27. package/dist-lib/lib/customers.functions.d.ts.map +1 -1
  28. package/dist-lib/lib/customers.functions.js +9 -6
  29. package/dist-lib/lib/external-customers.functions.d.ts.map +1 -1
  30. package/dist-lib/lib/external-customers.functions.js +7 -1
  31. package/dist-lib/lib/sticker-size.d.ts +59 -0
  32. package/dist-lib/lib/sticker-size.d.ts.map +1 -0
  33. package/dist-lib/lib/sticker-size.js +233 -0
  34. package/dist-lib/lib/twinfield-enqueue-rule.d.ts +13 -0
  35. package/dist-lib/lib/twinfield-enqueue-rule.d.ts.map +1 -0
  36. package/dist-lib/lib/twinfield-enqueue-rule.js +16 -0
  37. package/package.json +1 -1
  38. package/schema/klanten.sql +82 -21
@@ -1 +1 @@
1
- {"version":3,"file":"BulkStickerUploadDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/BulkStickerUploadDialog.tsx"],"names":[],"mappings":"AA2BA,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAiDF,wBAAgB,uBAAuB,CAAC,EACtC,WAAW,EACX,QAAQ,EACR,MAAM,GACP,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,+BA0cA"}
1
+ {"version":3,"file":"BulkStickerUploadDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/BulkStickerUploadDialog.tsx"],"names":[],"mappings":"AA2BA,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAiDF,wBAAgB,uBAAuB,CAAC,EACtC,WAAW,EACX,QAAQ,EACR,MAAM,GACP,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,+BAgdA"}
@@ -203,6 +203,10 @@ export function BulkStickerUploadDialog({ customerKey, products, onDone, }) {
203
203
  res.failed.length ? `${res.failed.length} mislukt` : null,
204
204
  ].filter(Boolean);
205
205
  toast.success(`Stickers opgeslagen: ${parts.join(", ")}`);
206
+ const open = (res.sizes ?? []).filter((s) => !s.size).length;
207
+ if (open) {
208
+ toast.message(`Bij ${open} ${open === 1 ? "sticker" : "stickers"} is het formaat nog niet bekend. Klik op de sticker om het voorstel te bevestigen of de maat in te vullen.`);
209
+ }
206
210
  if (res.failed.length) {
207
211
  toast.error(res.failed.map((f) => `${f.fileName}: ${f.reason}`).join(" · "));
208
212
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CustomerStickerCell.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/CustomerStickerCell.tsx"],"names":[],"mappings":"AASA,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,mCAAmC,CAAC;AAgB3C,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,YAAY,EACZ,OAAO,GACR,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CACjC,+BAyKA"}
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;AAiB3C,wBAAgB,mBAAmB,CAAC,EAClC,WAAW,EACX,YAAY,EACZ,OAAO,GACR,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CACjC,+BA2LA"}
@@ -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 { StickerSizeLine } from "./StickerSizeLine.js";
10
11
  import { friendlyError } from "../../lib/errors.js";
11
12
  const BUCKET = "customer-stickers";
12
13
  const MAX_SIZE = 10 * 1024 * 1024;
@@ -25,6 +26,7 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, }) {
25
26
  const inputRef = useRef(null);
26
27
  const [open, setOpen] = useState(false);
27
28
  const [busy, setBusy] = useState(false);
29
+ const [lastDet, setLastDet] = useState(null);
28
30
  const invalidate = () => {
29
31
  qc.invalidateQueries({ queryKey: ["customer-stickers", customerKey] });
30
32
  };
@@ -47,7 +49,7 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, }) {
47
49
  });
48
50
  if (error)
49
51
  throw error;
50
- await confirm({
52
+ const res = await confirm({
51
53
  data: {
52
54
  customerKey,
53
55
  tradeItemKey,
@@ -57,9 +59,10 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, }) {
57
59
  fileSize: file.size,
58
60
  },
59
61
  });
60
- invalidate();
62
+ setLastDet({ method: res.method, size: res.size, suggestion: res.suggestion });
63
+ await qc.invalidateQueries({ queryKey: ["customer-stickers", customerKey] });
61
64
  toast.success("Sticker opgeslagen");
62
- setOpen(false);
65
+ setOpen(true);
63
66
  }
64
67
  catch (e) {
65
68
  toast.error(friendlyError(e, "Uploaden mislukt"));
@@ -84,7 +87,10 @@ export function CustomerStickerCell({ customerKey, tradeItemKey, sticker, }) {
84
87
  const f = e.target.files?.[0];
85
88
  if (f)
86
89
  void upload(f);
87
- } }), sticker ? (_jsxs("button", { type: "button", onClick: () => setOpen(true), className: "flex items-center gap-2 text-left hover:opacity-80", title: sticker.file_name, children: [isImage && sticker.url ? (_jsx("img", { src: sticker.url, alt: "", className: "h-9 w-9 rounded border object-contain bg-muted" })) : (_jsx("div", { className: "h-9 w-9 rounded border bg-muted flex items-center justify-center", children: _jsx(FileText, { className: "h-4 w-4 text-muted-foreground" }) })), _jsx("span", { className: "text-xs max-w-[120px] truncate", children: sticker.file_name })] })) : (_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: setOpen, 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
90
+ } }), sticker ? (_jsxs("button", { type: "button", onClick: () => setOpen(true), className: "flex items-center gap-2 text-left hover:opacity-80", title: sticker.file_name, children: [isImage && sticker.url ? (_jsx("img", { src: sticker.url, alt: "", className: "h-9 w-9 rounded border object-contain bg-muted" })) : (_jsx("div", { className: "h-9 w-9 rounded border bg-muted flex items-center justify-center", children: _jsx(FileText, { className: "h-4 w-4 text-muted-foreground" }) })), _jsxs("span", { className: "flex flex-col", children: [_jsx("span", { className: "text-xs max-w-[120px] truncate", children: sticker.file_name }), _jsx("span", { className: "text-[11px] text-muted-foreground", children: sticker.width_mm != null && sticker.height_mm != null
91
+ ? `${sticker.width_mm.toLocaleString("nl-NL")} × ${sticker.height_mm.toLocaleString("nl-NL")} mm`
92
+ : "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
+ 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
88
94
  ? ` · ${(sticker.file_size / 1024).toFixed(0)} kB`
89
- : ""] })] })), _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"] })] })] })] }) })] }));
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"] })] })] })] }) })] }));
90
96
  }
@@ -1,3 +1,3 @@
1
- /** Alleen voor beheerders: schakelaars voor automatisch aanmaken van Floriday-klanten. */
1
+ /** Alleen voor beheerders: telling van het automatisch aanmaken van Floriday-klanten (geen schakelaars). */
2
2
  export declare function FloridayAutoPromoteCard(): import("react").JSX.Element | null;
3
3
  //# sourceMappingURL=FloridayAutoPromoteCard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FloridayAutoPromoteCard.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/FloridayAutoPromoteCard.tsx"],"names":[],"mappings":"AAeA,0FAA0F;AAC1F,wBAAgB,uBAAuB,uCAItC"}
1
+ {"version":3,"file":"FloridayAutoPromoteCard.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/FloridayAutoPromoteCard.tsx"],"names":[],"mappings":"AAQA,4GAA4G;AAC5G,wBAAgB,uBAAuB,uCAItC"}
@@ -1,13 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
- import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { useQuery } from "@tanstack/react-query";
4
4
  import { useServerFn } from "@tanstack/react-start";
5
- import { Card, CardContent, Switch, toast, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@flowselections/core";
6
5
  import { useCustomerDefaults } from "./useCustomerDefaults.js";
7
- import { getAutoPromoteStatus, setAutoPromote } from "../../lib/auto-promote.functions.js";
6
+ import { getAutoPromoteStatus } from "../../lib/auto-promote.functions.js";
8
7
  import { skipReasons, skippedTotal, roundSummary } from "../../lib/auto-promote.js";
9
8
  import { friendlyError } from "../../lib/errors.js";
10
- /** Alleen voor beheerders: schakelaars voor automatisch aanmaken van Floriday-klanten. */
9
+ /** Alleen voor beheerders: telling van het automatisch aanmaken van Floriday-klanten (geen schakelaars). */
11
10
  export function FloridayAutoPromoteCard() {
12
11
  const { isAdmin } = useCustomerDefaults();
13
12
  if (isAdmin !== true)
@@ -15,37 +14,18 @@ export function FloridayAutoPromoteCard() {
15
14
  return _jsx(Inner, {});
16
15
  }
17
16
  function Inner() {
18
- const qc = useQueryClient();
17
+ const [open, setOpen] = useState(false);
19
18
  const getStatus = useServerFn(getAutoPromoteStatus);
20
- const setFn = useServerFn(setAutoPromote);
21
- const q = useQuery({ queryKey: ["klanten-auto-promote"], queryFn: () => getStatus() });
22
- const [confirm, setConfirm] = useState(null);
23
- const [result, setResult] = useState(null);
24
- const [showDetails, setShowDetails] = useState(false);
25
- const m = useMutation({
26
- mutationFn: (v) => setFn({ data: v }),
27
- onSuccess: (r, v) => {
28
- if (v.on)
29
- setResult({ kind: v.kind, r });
30
- qc.invalidateQueries({ queryKey: ["klanten-auto-promote"] });
31
- qc.invalidateQueries({ queryKey: ["customers"] });
32
- },
33
- onError: (e) => toast.error(friendlyError(e)),
34
- });
19
+ const q = useQuery({ queryKey: ["klanten-auto-promote"], queryFn: () => getStatus(), enabled: open });
35
20
  const s = q.data;
36
21
  const rows = s
37
22
  ? [
38
- { kind: "relations", label: "Uit inkooprelaties", on: s.relaties_aan, c: s.inkooprelatie ?? {} },
39
- { kind: "orders", label: "Uit Floriday-orders", on: s.orders_aan, c: s.order ?? {} },
23
+ { label: "Uit inkooprelaties", c: s.inkooprelatie ?? {} },
24
+ { label: "Uit Floriday-orders", c: s.order ?? {} },
40
25
  ]
41
26
  : [];
42
- const pending = rows.find((r) => r.kind === confirm);
43
- return (_jsxs(Card, { children: [_jsxs(CardContent, { className: "p-4 space-y-3", children: [_jsxs("div", { children: [_jsx("h2", { className: "font-semibold", children: "Floriday-klanten automatisch aanmaken" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "Kopers uit Floriday worden klant. Er gaat niets naar Floriday of naar de boekhouding." })] }), q.isLoading && _jsx("p", { className: "text-sm text-muted-foreground", children: "Telling ophalen\u2026" }), q.error && _jsx("p", { className: "text-sm text-destructive", children: friendlyError(q.error) }), rows.map((r) => {
27
+ return (_jsxs("div", { className: "text-xs text-muted-foreground", children: [_jsx("button", { type: "button", className: "underline", onClick: () => setOpen((v) => !v), children: "Details voor beheer: Floriday-klanten" }), open && (_jsxs("div", { className: "mt-2 space-y-2 rounded border p-3", children: [_jsx("p", { children: "Kopers uit Floriday worden elke 5 minuten vanzelf klant. Ze gaan niet vanzelf naar de boekhouding." }), q.isLoading && _jsx("p", { children: "Telling ophalen\u2026" }), q.error && _jsx("p", { className: "text-destructive", children: friendlyError(q.error) }), s?.laatste_ronde && _jsxs("p", { children: ["Laatste ronde: ", roundSummary(s.laatste_ronde)] }), rows.map((r) => {
44
28
  const reasons = skipReasons(r.c);
45
- return (_jsxs("div", { className: "flex items-start justify-between gap-4 border-t pt-3", children: [_jsxs("div", { className: "min-w-0 text-sm", children: [_jsx("div", { className: "font-medium", children: r.label }), _jsxs("div", { className: "text-muted-foreground", children: [r.c.nieuw ?? 0, " nieuw \u00B7 ", r.c.koppelen_op_gln ?? 0, " koppelen op GLN \u00B7 ", skippedTotal(r.c), " overgeslagen"] }), reasons.length > 0 && _jsxs("div", { className: "text-muted-foreground", children: ["Overgeslagen: ", reasons.join("; ")] }), result?.kind === r.kind && _jsxs("div", { className: "mt-1", children: ["Laatste ronde: ", roundSummary(result.r)] })] }), _jsx(Switch, { checked: r.on, disabled: m.isPending, onCheckedChange: (v) => (v ? setConfirm(r.kind) : m.mutate({ kind: r.kind, on: false })), "aria-label": r.label })] }, r.kind));
46
- }), s && (_jsxs("div", { className: "border-t pt-3 text-xs text-muted-foreground", children: [_jsx("button", { type: "button", className: "underline", onClick: () => setShowDetails((v) => !v), children: "Details voor beheer" }), showDetails && (_jsxs("div", { className: "mt-2 space-y-1", children: [_jsxs("p", { children: ["Kopers met een order \u00E9n een inkooprelatie: ", s.order_ook_inkooprelatie] }), _jsxs("p", { children: ["Nog niet opgehaald maar wel in het netwerk: inkooprelaties", " ", s.inkooprelatie?.zonder_gegevens_wel_in_netwerk ?? 0, ", orders ", s.order?.zonder_gegevens_wel_in_netwerk ?? 0] }), _jsx("p", { children: "Steekproef van niet gevonden organisaties:" }), _jsx("pre", { className: "overflow-x-auto whitespace-pre-wrap break-all rounded bg-muted p-2", children: s.steekproef })] }))] }))] }), _jsx(AlertDialog, { open: !!pending, onOpenChange: (o) => !o && setConfirm(null), children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsxs(AlertDialogTitle, { children: [pending?.label, " aanzetten?"] }), _jsxs(AlertDialogDescription, { children: ["Er worden nu ", pending?.c.nieuw ?? 0, " klanten aangemaakt en ", pending?.c.koppelen_op_gln ?? 0, " bestaande klanten gekoppeld op GLN. Daarna gebeurt dit elke 5 minuten automatisch. Er gaat niets naar Floriday of naar de boekhouding, en de klanten krijgen geen eigen klantnummer."] })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { children: "Annuleren" }), _jsx(AlertDialogAction, { onClick: () => {
47
- if (pending)
48
- m.mutate({ kind: pending.kind, on: true });
49
- setConfirm(null);
50
- }, children: "Aanzetten" })] })] }) })] }));
29
+ return (_jsxs("div", { children: [_jsxs("span", { className: "font-medium", children: [r.label, ":"] }), " nog ", r.c.nieuw ?? 0, " nieuw \u00B7", " ", r.c.koppelen_op_gln ?? 0, " koppelen op GLN \u00B7 ", skippedTotal(r.c), " overgeslagen", reasons.length > 0 && _jsxs("div", { children: ["Overgeslagen: ", reasons.join("; ")] })] }, r.label));
30
+ }), s && (_jsxs(_Fragment, { children: [_jsxs("p", { children: ["Kopers met een order \u00E9n een inkooprelatie: ", s.order_ook_inkooprelatie] }), _jsx("p", { children: "Steekproef van niet gevonden organisaties:" }), _jsx("pre", { className: "overflow-x-auto whitespace-pre-wrap break-all rounded bg-muted p-2", children: s.steekproef })] }))] }))] }));
51
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KlantenOverzicht.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantenOverzicht.tsx"],"names":[],"mappings":"AAiEA,wBAAgB,gBAAgB,gCA02B/B"}
1
+ {"version":3,"file":"KlantenOverzicht.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/KlantenOverzicht.tsx"],"names":[],"mappings":"AAkEA,wBAAgB,gBAAgB,gCA22B/B"}
@@ -22,6 +22,7 @@ import { PriceGroupBadges } from "./PriceGroupBadges.js";
22
22
  import { KlantBewerkenDialog } from "./KlantBewerkenDialog.js";
23
23
  import { ChannelBadges } from "./ChannelBadges.js";
24
24
  import { FloridayAutoPromoteCard } from "./FloridayAutoPromoteCard.js";
25
+ import { StickerSizePreviewCard } from "./StickerSizePreviewCard.js";
25
26
  import { derivePaymentMethod, paymentToneClasses } from "../../lib/payment-method.js";
26
27
  import { formatCountry, getCountryFlagAndName, countryNameToFlag } from "../../lib/countries.js";
27
28
  import { MultiSearchableSelect } from "./MultiSearchableSelect.js";
@@ -473,7 +474,7 @@ export function KlantenOverzicht() {
473
474
  });
474
475
  const toggleSort = (col) => setSort((s) => (s.col === col ? { col, dir: s.dir === "asc" ? "desc" : "asc" } : { col, dir: "asc" }));
475
476
  const lastUpdated = externalData?.last_fetched_at ?? null;
476
- return (_jsx(TooltipPrimitive.Provider, { delayDuration: 200, children: _jsxs("main", { className: "p-4 sm:p-6 space-y-5 min-w-0 max-w-full overflow-x-hidden", children: [_jsxs("div", { className: "flex items-start justify-between gap-4 flex-wrap", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: "Klanten" }), _jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Beheer en doorzoek al je klanten." })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs(Button, { variant: "outline", onClick: () => goTo({ to: "/klanten/import" }), children: [_jsx(Upload, { className: "h-4 w-4 mr-2" }), " Importeren"] }), _jsxs(Button, { onClick: () => goTo({ to: "/klanten/nieuw" }), children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), " Nieuwe klant"] })] })] }), _jsx(FloridayAutoPromoteCard, {}), loadError && (_jsxs("div", { className: "flex flex-wrap items-center gap-3 rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3", children: [_jsx(AlertCircle, { className: "h-5 w-5 text-destructive shrink-0" }), _jsxs("div", { className: "text-sm", children: [_jsx("div", { className: "font-medium", children: isBackendUnavailable(loadError)
477
+ return (_jsx(TooltipPrimitive.Provider, { delayDuration: 200, children: _jsxs("main", { className: "p-4 sm:p-6 space-y-5 min-w-0 max-w-full overflow-x-hidden", children: [_jsxs("div", { className: "flex items-start justify-between gap-4 flex-wrap", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: "Klanten" }), _jsx("p", { className: "text-sm text-muted-foreground mt-1", children: "Beheer en doorzoek al je klanten." })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs(Button, { variant: "outline", onClick: () => goTo({ to: "/klanten/import" }), children: [_jsx(Upload, { className: "h-4 w-4 mr-2" }), " Importeren"] }), _jsxs(Button, { onClick: () => goTo({ to: "/klanten/nieuw" }), children: [_jsx(Plus, { className: "h-4 w-4 mr-2" }), " Nieuwe klant"] })] })] }), _jsx(FloridayAutoPromoteCard, {}), _jsx(StickerSizePreviewCard, {}), loadError && (_jsxs("div", { className: "flex flex-wrap items-center gap-3 rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3", children: [_jsx(AlertCircle, { className: "h-5 w-5 text-destructive shrink-0" }), _jsxs("div", { className: "text-sm", children: [_jsx("div", { className: "font-medium", children: isBackendUnavailable(loadError)
477
478
  ? "De database is tijdelijk niet bereikbaar"
478
479
  : "De klanten konden niet geladen worden" }), _jsx("div", { className: "text-muted-foreground", children: isBackendUnavailable(loadError)
479
480
  ? "Je bent niet uitgelogd. Probeer het over een paar minuten opnieuw."
@@ -0,0 +1,14 @@
1
+ import { type StickerUploadSize } from "../../lib/customer-stickers.functions.js";
2
+ /**
3
+ * "Formaat: 48 × 48 mm (wijzigen)". Zonder maat: voorstel via geladen etiket
4
+ * (één klik bevestigen) of pas dan om breedte en hoogte vragen.
5
+ */
6
+ export declare function StickerSizeLine({ customerKey, tradeItemKey, widthMm, heightMm, initialDetection, onSaved, }: {
7
+ customerKey: string;
8
+ tradeItemKey: string;
9
+ widthMm: number | null;
10
+ heightMm: number | null;
11
+ initialDetection?: StickerUploadSize | null;
12
+ onSaved: () => void;
13
+ }): import("react").JSX.Element;
14
+ //# sourceMappingURL=StickerSizeLine.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,74 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { useServerFn } from "@tanstack/react-start";
4
+ import { Button, Input } from "@flowselections/core";
5
+ import { toast } from "sonner";
6
+ import { setStickerSize, suggestStickerSize, } from "../../lib/customer-stickers.functions.js";
7
+ import { friendlyError } from "../../lib/errors.js";
8
+ const fmt = (v) => v.toLocaleString("nl-NL", { maximumFractionDigits: 1 });
9
+ /**
10
+ * "Formaat: 48 × 48 mm (wijzigen)". Zonder maat: voorstel via geladen etiket
11
+ * (één klik bevestigen) of pas dan om breedte en hoogte vragen.
12
+ */
13
+ export function StickerSizeLine({ customerKey, tradeItemKey, widthMm, heightMm, initialDetection, onSaved, }) {
14
+ const save = useServerFn(setStickerSize);
15
+ const suggest = useServerFn(suggestStickerSize);
16
+ const known = widthMm != null && heightMm != null;
17
+ const [editing, setEditing] = useState(false);
18
+ const [det, setDet] = useState(initialDetection ?? null);
19
+ const [w, setW] = useState("");
20
+ const [h, setH] = useState("");
21
+ const [busy, setBusy] = useState(false);
22
+ useEffect(() => {
23
+ if (known || det)
24
+ return;
25
+ let alive = true;
26
+ suggest({ data: { customerKey, tradeItemKey } })
27
+ .then((r) => alive && setDet(r))
28
+ .catch(() => alive && setDet({ method: "onbekend", size: null, suggestion: null }));
29
+ return () => {
30
+ alive = false;
31
+ };
32
+ }, [known, det, customerKey, tradeItemKey, suggest]);
33
+ const store = async (wm, hm) => {
34
+ setBusy(true);
35
+ try {
36
+ await save({ data: { customerKey, tradeItemKey, widthMm: wm, heightMm: hm } });
37
+ setEditing(false);
38
+ onSaved();
39
+ toast.success("Formaat opgeslagen");
40
+ }
41
+ catch (e) {
42
+ toast.error(friendlyError(e, "Opslaan mislukt"));
43
+ }
44
+ finally {
45
+ setBusy(false);
46
+ }
47
+ };
48
+ const parse = (v) => Number(v.replace(",", "."));
49
+ const manual = (_jsxs("form", { className: "flex items-center gap-2", onSubmit: (e) => {
50
+ e.preventDefault();
51
+ const wm = parse(w), hm = parse(h);
52
+ if (!(wm > 0 && hm > 0)) {
53
+ toast.error("Vul een breedte en hoogte in millimeters in.");
54
+ return;
55
+ }
56
+ void store(wm, hm);
57
+ }, children: [_jsx(Input, { "aria-label": "Breedte in mm", inputMode: "decimal", placeholder: "Breedte", value: w, onChange: (e) => setW(e.target.value), className: "h-8 w-20" }), _jsx("span", { className: "text-xs text-muted-foreground", children: "\u00D7" }), _jsx(Input, { "aria-label": "Hoogte in mm", inputMode: "decimal", placeholder: "Hoogte", value: h, onChange: (e) => setH(e.target.value), className: "h-8 w-20" }), _jsx("span", { className: "text-xs text-muted-foreground", children: "mm" }), _jsx(Button, { type: "submit", size: "sm", disabled: busy, children: "Opslaan" }), known && (_jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: () => setEditing(false), children: "Annuleren" }))] }));
58
+ if (known && !editing) {
59
+ return (_jsxs("p", { className: "text-sm", children: ["Formaat: ", fmt(widthMm), " \u00D7 ", fmt(heightMm), " mm", " ", _jsx("button", { type: "button", className: "text-xs text-primary underline-offset-2 hover:underline", onClick: () => {
60
+ setW(fmt(widthMm));
61
+ setH(fmt(heightMm));
62
+ setEditing(true);
63
+ }, children: "wijzigen" })] }));
64
+ }
65
+ if (editing)
66
+ return manual;
67
+ if (!det)
68
+ return _jsx("p", { className: "text-xs text-muted-foreground", children: "Formaat bepalen\u2026" });
69
+ if (det.suggestion) {
70
+ const s = det.suggestion;
71
+ return (_jsxs("div", { className: "space-y-2", children: [_jsxs("p", { className: "text-sm", children: ["Lijkt op ", fmt(s.width_mm), " \u00D7 ", fmt(s.height_mm), " mm", s.printer ? ` – etiket in ${s.printer}` : s.label ? ` – etiket ${s.label}` : ""] }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { type: "button", size: "sm", disabled: busy, onClick: () => void store(s.width_mm, s.height_mm), children: "Klopt" }), _jsx(Button, { type: "button", size: "sm", variant: "ghost", onClick: () => setDet({ ...det, suggestion: null }), children: "Andere maat" })] })] }));
72
+ }
73
+ return (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-sm", children: "We konden het formaat niet uit het bestand halen. Hoe groot is deze sticker?" }), manual] }));
74
+ }
@@ -0,0 +1,3 @@
1
+ /** Alleen beheerders, alleen lezen: welke maat bestaande stickers zonder maat zouden krijgen. */
2
+ export declare function StickerSizePreviewCard(): import("react").JSX.Element | null;
3
+ //# sourceMappingURL=StickerSizePreviewCard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StickerSizePreviewCard.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/StickerSizePreviewCard.tsx"],"names":[],"mappings":"AAeA,iGAAiG;AACjG,wBAAgB,sBAAsB,uCAIrC"}
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { useQuery } from "@tanstack/react-query";
4
+ import { useServerFn } from "@tanstack/react-start";
5
+ import { useCustomerDefaults } from "./useCustomerDefaults.js";
6
+ import { previewStickerSizes } from "../../lib/customer-stickers.functions.js";
7
+ import { friendlyError } from "../../lib/errors.js";
8
+ const METHOD = {
9
+ pdf: "uit de PDF",
10
+ dpi: "uit de resolutie",
11
+ svg: "uit het bestand",
12
+ verhouding: "voorstel via etiket",
13
+ onbekend: "niet te bepalen",
14
+ };
15
+ /** Alleen beheerders, alleen lezen: welke maat bestaande stickers zonder maat zouden krijgen. */
16
+ export function StickerSizePreviewCard() {
17
+ const { isAdmin } = useCustomerDefaults();
18
+ if (isAdmin !== true)
19
+ return null;
20
+ return _jsx(Inner, {});
21
+ }
22
+ function Inner() {
23
+ const [open, setOpen] = useState(false);
24
+ const run = useServerFn(previewStickerSizes);
25
+ const q = useQuery({ queryKey: ["sticker-size-preview"], queryFn: () => run(), enabled: open });
26
+ return (_jsxs("div", { className: "text-xs text-muted-foreground", children: [_jsx("button", { type: "button", className: "underline", onClick: () => setOpen((v) => !v), children: "Details voor beheer: stickers zonder formaat" }), open && (_jsxs("div", { className: "mt-2 rounded border p-3 space-y-2", children: [_jsx("p", { children: "Overzicht, er wordt nog niets opgeslagen." }), q.isLoading && _jsx("p", { children: "Bestanden bekijken\u2026" }), q.error && _jsx("p", { className: "text-destructive", children: friendlyError(q.error) }), q.data && q.data.length === 0 && _jsx("p", { children: "Alle stickers hebben een formaat." }), q.data && q.data.length > 0 && (_jsxs("table", { className: "w-full", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-left", children: [_jsx("th", { children: "Klant" }), _jsx("th", { children: "Artikel" }), _jsx("th", { children: "Bestand" }), _jsx("th", { children: "Formaat" }), _jsx("th", { children: "Hoe" })] }) }), _jsx("tbody", { children: q.data.map((r) => (_jsxs("tr", { children: [_jsx("td", { children: r.customer_key }), _jsx("td", { children: r.trade_item_key }), _jsx("td", { className: "max-w-[160px] truncate", children: r.file_name }), _jsx("td", { children: r.width_mm != null ? `${r.width_mm} × ${r.height_mm} mm` : "–" }), _jsxs("td", { children: [METHOD[r.method] ?? r.method, r.printer ? ` (${r.printer})` : ""] })] }, `${r.customer_key}|${r.trade_item_key}`))) })] }))] }))] }));
27
+ }
package/dist-lib/index.js CHANGED
@@ -52,7 +52,7 @@ export { emitLogisticsEvent } from "./lib/logistics-events.functions.js";
52
52
  export const floridayKlantenModule = {
53
53
  id: "customers",
54
54
  name: "Klanten",
55
- version: "1.0.59",
55
+ version: "1.0.61",
56
56
  nav: {
57
57
  label: "Klanten",
58
58
  href: "/klanten",
@@ -14188,6 +14188,7 @@ export type Database = {
14188
14188
  bron_id: string;
14189
14189
  cart_id: string | null;
14190
14190
  created_at: string;
14191
+ eigen_sticker_id: string | null;
14191
14192
  fulfillment_order_id: string | null;
14192
14193
  handled_at: string | null;
14193
14194
  handled_error: string | null;
@@ -14214,6 +14215,7 @@ export type Database = {
14214
14215
  bron_id: string;
14215
14216
  cart_id?: string | null;
14216
14217
  created_at?: string;
14218
+ eigen_sticker_id?: string | null;
14217
14219
  fulfillment_order_id?: string | null;
14218
14220
  handled_at?: string | null;
14219
14221
  handled_error?: string | null;
@@ -14240,6 +14242,7 @@ export type Database = {
14240
14242
  bron_id?: string;
14241
14243
  cart_id?: string | null;
14242
14244
  created_at?: string;
14245
+ eigen_sticker_id?: string | null;
14243
14246
  fulfillment_order_id?: string | null;
14244
14247
  handled_at?: string | null;
14245
14248
  handled_error?: string | null;
@@ -31910,6 +31913,10 @@ export type Database = {
31910
31913
  Args: never;
31911
31914
  Returns: Json;
31912
31915
  };
31916
+ klanten_refresh_grouped_if_stale: {
31917
+ Args: never;
31918
+ Returns: boolean;
31919
+ };
31913
31920
  klanten_set_auto_promote: {
31914
31921
  Args: {
31915
31922
  p_kind: string;
@@ -33062,6 +33069,13 @@ export type Database = {
33062
33069
  };
33063
33070
  Returns: Json;
33064
33071
  };
33072
+ logistics_document_for_order: {
33073
+ Args: {
33074
+ p_documenttype: string;
33075
+ p_order_id: string;
33076
+ };
33077
+ Returns: Json;
33078
+ };
33065
33079
  logistics_document_layout: {
33066
33080
  Args: {
33067
33081
  _document_code: string;
@@ -33075,6 +33089,10 @@ export type Database = {
33075
33089
  };
33076
33090
  Returns: Json;
33077
33091
  };
33092
+ logistics_document_selection_status: {
33093
+ Args: never;
33094
+ Returns: Json;
33095
+ };
33078
33096
  logistics_document_station: {
33079
33097
  Args: {
33080
33098
  _document_code: string;
@@ -33893,6 +33911,12 @@ export type Database = {
33893
33911
  Args: never;
33894
33912
  Returns: Json;
33895
33913
  };
33914
+ logistics_own_sticker_sync: {
33915
+ Args: {
33916
+ p_limit?: number;
33917
+ };
33918
+ Returns: Json;
33919
+ };
33896
33920
  logistics_own_transport_departure: {
33897
33921
  Args: {
33898
33922
  p_delivery_date: string;
@@ -38602,6 +38626,15 @@ export type Database = {
38602
38626
  };
38603
38627
  Returns: Json;
38604
38628
  };
38629
+ voorraad_alert_floriday_not_updated: {
38630
+ Args: {
38631
+ p_key: string;
38632
+ p_order_id: string;
38633
+ p_order_item_id: string;
38634
+ p_qty: number;
38635
+ };
38636
+ Returns: undefined;
38637
+ };
38605
38638
  voorraad_can_write: {
38606
38639
  Args: never;
38607
38640
  Returns: boolean;
@@ -38624,6 +38657,12 @@ export type Database = {
38624
38657
  };
38625
38658
  Returns: string[];
38626
38659
  };
38660
+ voorraad_floriday_leads_key: {
38661
+ Args: {
38662
+ p_key: string;
38663
+ };
38664
+ Returns: boolean;
38665
+ };
38627
38666
  voorraad_hook_base_url: {
38628
38667
  Args: never;
38629
38668
  Returns: string;
@@ -38641,6 +38680,12 @@ export type Database = {
38641
38680
  };
38642
38681
  Returns: undefined;
38643
38682
  };
38683
+ voorraad_mark_floriday_sold_before_switch: {
38684
+ Args: {
38685
+ p_product_id: string;
38686
+ };
38687
+ Returns: number;
38688
+ };
38644
38689
  voorraad_production_enabled: {
38645
38690
  Args: never;
38646
38691
  Returns: boolean;