@flowselections/scan-module 1.0.58 → 1.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"ScanModulePage.d.ts","sourceRoot":"","sources":["../../src/components/ScanModulePage.tsx"],"names":[],"mappings":"AAwWA,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,+BA8H/E"}
1
+ {"version":3,"file":"ScanModulePage.d.ts","sourceRoot":"","sources":["../../src/components/ScanModulePage.tsx"],"names":[],"mappings":"AAydA,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,+BA2H/E"}
@@ -1,4 +1,4 @@
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
  // ============================================================================
3
3
  // src/components/ScanModulePage.tsx — SCANNERS (zoals Printen › Printplekken)
4
4
  // ============================================================================
@@ -8,8 +8,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
8
  // ============================================================================
9
9
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
10
10
  import { useRouter } from "@tanstack/react-router";
11
+ import { useShellModules, moduleKey } from "@flowselections/core";
11
12
  import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Input, Label, PageContainer, cn, formatTijd, meldFout, meldSucces, } from "@flowselections/core";
12
- import { AlertTriangle, Check, Copy, ExternalLink, KeyRound, Loader2, MoreHorizontal, Pencil, Printer, Search } from "lucide-react";
13
+ import { AlertTriangle, Check, Copy, ExternalLink, FileText, KeyRound, Loader2, MoreHorizontal, Pencil, Printer, Search } from "lucide-react";
13
14
  import { supabase } from "../integrations/supabase/client.js";
14
15
  import { useScanners } from "../hooks/useScanners.js";
15
16
  import { scannerType, normaliseerScannerType } from "../lib/scannerTypes.js";
@@ -30,6 +31,30 @@ function useScannerRoutePad() {
30
31
  return hit ? String(hit.fullPath).replace(/\/?\$slug\/?$/, "") : "/scanner";
31
32
  }, [router]);
32
33
  }
34
+ /** Rijen zoals Scan ze noemt, gekoppeld aan de soort van de Layout-maker. */
35
+ const PRINT_RIJEN = {
36
+ eind: [
37
+ { naam: "Afleverbrief", soort: "afleverbrief" },
38
+ { naam: "Controlelijst", soort: "controlelijst" },
39
+ { naam: "Pakbon (opnieuw)", soort: "pakbon" },
40
+ { naam: "Veilingbrief", soort: "veilingbrief", alleenFloriday: true },
41
+ ],
42
+ kar: [
43
+ { naam: "Verzendbrief", soort: "afleverbrief" },
44
+ { naam: "Restpakbon", soort: "pakbon" },
45
+ ],
46
+ };
47
+ /** Gebruikt deze shell Floriday? Uit de modulelijst van core; zonder lijst: nee. */
48
+ function useShellGebruiktFloriday() {
49
+ const shell = useShellModules();
50
+ return useMemo(() => {
51
+ const lijst = Array.isArray(shell?.modules) ? shell.modules : [];
52
+ return lijst.some((m) => /floriday/i.test(`${m?.id ?? ""} ${safeKey(m)}`));
53
+ }, [shell]);
54
+ }
55
+ function safeKey(m) {
56
+ return m && typeof m === "object" ? moduleKey(m) : "";
57
+ }
33
58
  /** Pad van de pagina Printplekken uit de geregistreerde routes; null als die er niet is. */
34
59
  function usePrintplekkenPad() {
35
60
  const router = useRouter();
@@ -39,57 +64,142 @@ function usePrintplekkenPad() {
39
64
  return hit ? String(hit.fullPath).replace(/\/$/, "") : null;
40
65
  }, [router]);
41
66
  }
42
- function PrintplekkenLink({ pad }) {
43
- if (!pad)
44
- return _jsx("span", { className: "text-muted-foreground", children: "Wijzig dit in Printen \u203A Printplekken." });
45
- return (_jsxs("a", { href: pad, className: "inline-flex items-center gap-1 font-semibold text-primary underline-offset-2 hover:underline", children: ["Aanpassen ", _jsx(ExternalLink, { className: "h-3.5 w-3.5", "aria-hidden": true })] }));
67
+ function tekst(v) {
68
+ return typeof v === "string" && v.trim() ? v.trim() : null;
46
69
  }
70
+ function isFunctieOnbekend(error) {
71
+ return error?.code === "PGRST202" || error?.code === "42883";
72
+ }
73
+ const LEEG = { laden: true, fout: false, plekId: null, plek: null, klaar: null, reden: null, melding: null, docs: null };
74
+ /** Plek, stand en documenten komen telkens uit de Layout-maker; elke 30 s en bij terugkomen ververst, zonder knipperen. */
47
75
  function usePrintStand(scanner) {
48
- const [stand, setStand] = useState({ laden: true, plek: null, probleem: null, fout: false });
76
+ const [stand, setStand] = useState(LEEG);
77
+ const scannerId = scanner?.id ?? null;
78
+ const eind = scanner ? normaliseerScannerType(scanner.type) === "eindcontrole" : false;
49
79
  useEffect(() => {
50
- if (!scanner)
80
+ if (!scannerId)
51
81
  return;
52
82
  let actief = true;
53
- setStand({ laden: true, plek: null, probleem: null, fout: false });
54
- void (async () => {
55
- const eind = normaliseerScannerType(scanner.type) === "eindcontrole";
56
- const { data, error } = eind
83
+ setStand(LEEG);
84
+ const lees = async () => {
85
+ const basis = eind
57
86
  ? await db.rpc("layouts_controleplek")
58
- : await db.rpc("print_plek_status_v1", { p_soort: "scanner", p_sleutel: scanner.id });
87
+ : await db.rpc("print_plek_status_v1", { p_soort: "scanner", p_sleutel: scannerId });
59
88
  if (!actief)
60
89
  return;
61
- if (error) {
62
- console.error("[scanners] printplek lezen", error);
63
- setStand({ laden: false, plek: null, probleem: null, fout: true });
90
+ if (basis.error) {
91
+ console.error("[scanners] printplek lezen", basis.error);
92
+ setStand((oud) => (oud.laden ? { ...LEEG, laden: false, fout: true } : oud));
64
93
  return;
65
94
  }
66
- const d = data ?? {};
67
- if (eind) {
68
- setStand({ laden: false, plek: d.print_plek_id ? (d.naam ?? null) : null, probleem: null, fout: false });
95
+ const d = basis.data ?? {};
96
+ const plekId = eind ? tekst(d.print_plek_id) : tekst(d.plek_id);
97
+ const plekNaam = eind ? (plekId ? tekst(d.naam) : null) : tekst(d.plek_naam);
98
+ const melding = eind ? null : tekst(d.melding);
99
+ let klaar = eind ? null : (plekId ? d.status === "werkt" : null);
100
+ let reden = null;
101
+ let docs = null;
102
+ let naam = plekNaam;
103
+ if (plekId) {
104
+ const v2 = await db.rpc("print_plek_documenten_v2", { p_plek: plekId });
105
+ if (!actief)
106
+ return;
107
+ if (v2.error) {
108
+ if (!isFunctieOnbekend(v2.error))
109
+ console.error("[scanners] documenten van printplek", v2.error);
110
+ }
111
+ else {
112
+ const r = v2.data ?? {};
113
+ const plek = r.plek ?? r;
114
+ naam = tekst(plek?.naam) ?? naam;
115
+ if (typeof plek?.kan_printen === "boolean")
116
+ klaar = plek.kan_printen;
117
+ else if (typeof plek?.status === "string")
118
+ klaar = /klaar|werkt|^ok$/i.test(plek.status);
119
+ reden = tekst(plek?.reden) ?? (klaar === false ? tekst(plek?.status) : null);
120
+ const lijst = Array.isArray(r.documenten) ? r.documenten : [];
121
+ docs = lijst.map((x) => ({
122
+ soort: String(x?.documenttype ?? x?.soort ?? ""),
123
+ versie: x?.versie == null ? null : String(x.versie),
124
+ formaat: tekst(x?.papierformaat),
125
+ kanPrinten: typeof x?.kan_printen === "boolean" ? x.kan_printen : null,
126
+ reden: tekst(x?.reden),
127
+ }));
128
+ }
69
129
  }
70
- else {
71
- const werkt = d.status === "werkt";
72
- setStand({ laden: false, plek: d.plek_naam ?? null, probleem: d.plek_naam && !werkt ? "Deze plek heeft een probleem" : null, fout: false });
73
- }
74
- })();
75
- return () => { actief = false; };
76
- }, [scanner]);
130
+ if (!actief)
131
+ return;
132
+ if (klaar === false && !reden)
133
+ reden = "Deze plek kan nu niet printen. Kijk bij Printen › Printplekken.";
134
+ setStand({ laden: false, fout: false, plekId, plek: naam, klaar, reden, melding, docs });
135
+ };
136
+ void lees();
137
+ const timer = window.setInterval(() => { if (document.visibilityState === "visible")
138
+ void lees(); }, 30000);
139
+ const terug = () => { if (document.visibilityState === "visible")
140
+ void lees(); };
141
+ document.addEventListener("visibilitychange", terug);
142
+ window.addEventListener("focus", terug);
143
+ return () => {
144
+ actief = false;
145
+ window.clearInterval(timer);
146
+ document.removeEventListener("visibilitychange", terug);
147
+ window.removeEventListener("focus", terug);
148
+ };
149
+ }, [scannerId, eind]);
77
150
  return stand;
78
151
  }
79
- function NaamDialoog({ scanner, onClose, onOpslaan }) {
80
- const [naam, setNaam] = useState("");
152
+ /** Naam in de kop direct bewerken, zoals "Naam printplek wijzigen" bij Printplekken. */
153
+ function BewerkbareNaam({ naam, bewerken, onKlaar, onOpslaan }) {
154
+ const [waarde, setWaarde] = useState(naam);
81
155
  const [bezig, setBezig] = useState(false);
82
- useEffect(() => { if (scanner)
83
- setNaam(scanner.naam); }, [scanner]);
156
+ const ref = useRef(null);
157
+ const afgehandeld = useRef(false);
158
+ useEffect(() => {
159
+ if (bewerken) {
160
+ setWaarde(naam);
161
+ afgehandeld.current = false;
162
+ window.setTimeout(() => ref.current?.select(), 0);
163
+ }
164
+ }, [bewerken, naam]);
165
+ if (!bewerken)
166
+ return _jsx("p", { className: "truncate text-lg font-semibold text-card-foreground", children: naam });
84
167
  const opslaan = async () => {
85
- if (!naam.trim())
168
+ if (afgehandeld.current || bezig)
169
+ return;
170
+ const nieuw = waarde.trim();
171
+ if (nieuw === naam.trim()) {
172
+ afgehandeld.current = true;
173
+ onKlaar();
174
+ return;
175
+ }
176
+ if (!nieuw) {
177
+ meldFout("Vul een naam in.");
178
+ ref.current?.focus();
86
179
  return;
180
+ }
87
181
  setBezig(true);
88
- await onOpslaan(naam.trim());
182
+ const ok = await onOpslaan(nieuw);
89
183
  setBezig(false);
184
+ if (ok) {
185
+ afgehandeld.current = true;
186
+ onKlaar();
187
+ }
188
+ else
189
+ ref.current?.focus();
90
190
  };
91
- return (_jsx(Dialog, { open: !!scanner, onOpenChange: (o) => !o && onClose(), children: _jsxs(DialogContent, { className: "sm:max-w-md", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Naam wijzigen" }), _jsx(DialogDescription, { children: "De link van de scanner blijft hetzelfde." })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "scanner-naam", required: true, children: "Naam" }), _jsx(Input, { id: "scanner-naam", value: naam, onChange: (e) => setNaam(e.target.value), onKeyDown: (e) => { if (e.key === "Enter")
92
- void opslaan(); } })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: onClose, children: "Annuleren" }), _jsxs(Button, { disabled: bezig || !naam.trim(), onClick: () => void opslaan(), children: [bezig ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : null, "Opslaan"] })] })] }) }));
191
+ return (_jsx(Input, { ref: ref, value: waarde, disabled: bezig, "aria-label": "Naam scanner", maxLength: 80, className: "h-8 text-lg font-semibold", onChange: (e) => setWaarde(e.target.value), onBlur: () => void opslaan(), onKeyDown: (e) => {
192
+ if (e.key === "Enter") {
193
+ e.preventDefault();
194
+ void opslaan();
195
+ }
196
+ if (e.key === "Escape") {
197
+ e.preventDefault();
198
+ e.stopPropagation();
199
+ afgehandeld.current = true;
200
+ onKlaar();
201
+ }
202
+ } }));
93
203
  }
94
204
  function PincodeDialoog({ scanner, onClose, onKlaar }) {
95
205
  const [pin, setPin] = useState("");
@@ -120,8 +230,11 @@ function PincodeDialoog({ scanner, onClose, onKlaar }) {
120
230
  return (_jsx(Dialog, { open: !!scanner, onOpenChange: (o) => !o && onClose(), children: _jsxs(DialogContent, { className: "sm:max-w-md", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Pincode wijzigen" }), _jsx(DialogDescription, { children: bevestigen ? "Na het wijzigen moeten alle telefoons van deze scanner de nieuwe pincode invoeren." : `Nieuwe pincode voor ${scanner?.naam ?? "deze scanner"}.` })] }), bevestigen ? null : (_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "scanner-pin", required: true, children: "Nieuwe pincode" }), _jsx(Input, { id: "scanner-pin", inputMode: "numeric", autoComplete: "off", value: pin, onChange: (e) => { setPin(e.target.value.replace(/\D/g, "").slice(0, 12)); setFout(null); }, onKeyDown: (e) => { if (e.key === "Enter")
121
231
  verder(); }, className: "font-mono tracking-[0.3em]" }), _jsx("p", { className: cn("text-sm", fout ? "text-destructive" : "text-muted-foreground"), children: fout ?? "Minimaal 4 cijfers." })] })), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: onClose, children: "Annuleren" }), bevestigen ? (_jsxs(Button, { disabled: bezig, onClick: () => void opslaan(), children: [bezig ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : null, "Pincode wijzigen"] })) : (_jsx(Button, { onClick: verder, children: "Verder" }))] })] }) }));
122
232
  }
123
- function ScannerDetail({ scanner, basis, pincode, onNaam, onPincode, onSlotOpheffen }) {
233
+ function ScannerDetail({ scanner, basis, pincode, onNaamOpslaan, onPincode, onSlotOpheffen }) {
234
+ const [naamBewerken, setNaamBewerken] = useState(false);
235
+ useEffect(() => { setNaamBewerken(false); }, [scanner.id]);
124
236
  const pad = usePrintplekkenPad();
237
+ const metFloriday = useShellGebruiktFloriday();
125
238
  const print = usePrintStand(scanner);
126
239
  const [gekopieerd, setGekopieerd] = useState(false);
127
240
  const routePad = useScannerRoutePad();
@@ -140,7 +253,11 @@ function ScannerDetail({ scanner, basis, pincode, onNaam, onPincode, onSlotOphef
140
253
  meldFout("Kopiëren lukt niet. Selecteer de link en kopieer hem zelf.", error);
141
254
  }
142
255
  };
143
- return (_jsxs("div", { children: [_jsxs("header", { className: "flex items-center gap-3 border-b border-border p-4", children: [_jsx("span", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-muted text-primary", children: _jsx(Icoon, { className: "h-5 w-5", "aria-hidden": true }) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("p", { className: "truncate text-lg font-semibold text-card-foreground", children: scanner.naam }), _jsx("span", { className: "text-xs text-muted-foreground", children: scannerSoortLabel(scanner.type) })] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": `Meer voor ${scanner.naam}`, children: _jsx(MoreHorizontal, { className: "h-4 w-4" }) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onSelect: onNaam, children: [_jsx(Pencil, { className: "mr-2 h-4 w-4" }), " Naam wijzigen"] }), _jsxs(DropdownMenuItem, { onSelect: onPincode, children: [_jsx(Pencil, { className: "mr-2 h-4 w-4" }), " Pincode wijzigen"] })] })] })] }), _jsxs("div", { className: "space-y-4 p-4", children: [_jsxs("section", { className: "space-y-2", children: [_jsx("h3", { className: "font-semibold text-card-foreground", children: "Openen" }), basis.staat === "laden" ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Link wordt opgehaald\u2026" })) : url ? (_jsxs("div", { className: "grid gap-4 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center", children: [_jsx(KoppelQr, { link: url, alt: `QR-code om ${scanner.naam} op een telefoon te openen` }), _jsxs("div", { className: "min-w-0 space-y-2", children: [_jsx("p", { className: "text-sm text-muted-foreground", children: "Scan de QR-code met de telefoon, of open of kopieer de link." }), _jsxs("div", { className: "relative", children: [_jsx(Input, { readOnly: true, value: url, onFocus: (e) => e.currentTarget.select(), "aria-label": "Scannerlink", className: "pr-11 text-sm" }), _jsx(Button, { type: "button", variant: "ghost", size: "icon", onClick: () => void kopieer(), "aria-label": gekopieerd ? "Link gekopieerd" : "Link kopiëren", title: gekopieerd ? "Gekopieerd" : "Link kopiëren", className: "absolute right-0.5 top-1/2 h-8 w-8 -translate-y-1/2", children: gekopieerd ? _jsx(Check, { className: "h-4 w-4" }) : _jsx(Copy, { className: "h-4 w-4" }) })] }), _jsx(Button, { asChild: true, className: "w-full", children: _jsxs("a", { href: url, target: "_blank", rel: "noreferrer", children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), "Scanner openen"] }) })] })] })) : (_jsx("p", { className: "text-sm text-destructive", children: "De link kan nu niet worden gemaakt. Probeer het later opnieuw; blijft het misgaan, neem contact op met de beheerder." }))] }), _jsxs("section", { className: "space-y-2 border-t border-border pt-4", children: [_jsx("h3", { className: "font-semibold text-card-foreground", children: "Printen" }), _jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 text-sm", children: [_jsx(Printer, { className: "h-4 w-4 shrink-0 text-muted-foreground", "aria-hidden": true }), print.laden ? (_jsx("span", { className: "text-muted-foreground", children: "Laden\u2026" })) : print.fout ? (_jsx("span", { className: "text-warning", children: "De printplek kan nu niet worden gelezen. Werk de Layout-maker bij of probeer het later opnieuw." })) : print.plek ? (_jsxs("span", { children: [eind ? "Afleverbrief, controlelijst en pakbon printen op: " : "Verzendbrief en restpakbon printen op: ", _jsx("strong", { children: print.plek }), print.probleem ? _jsxs("span", { className: "ml-2 inline-flex items-center gap-1 text-warning", children: [_jsx(AlertTriangle, { className: "h-3.5 w-3.5", "aria-hidden": true }), print.probleem] }) : null] })) : (_jsxs("span", { className: "inline-flex items-center gap-1 text-warning", children: [_jsx(AlertTriangle, { className: "h-3.5 w-3.5", "aria-hidden": true }), eind ? "Nog geen controleplek gekozen" : "Nog geen printplek gekozen"] })), _jsx(PrintplekkenLink, { pad: pad })] })] }), _jsxs("section", { className: "space-y-2 border-t border-border pt-4", children: [_jsx("h3", { className: "font-semibold text-card-foreground", children: "Pincode" }), _jsxs("div", { className: "flex flex-wrap items-center gap-2 text-sm", children: [_jsx(KeyRound, { className: "h-4 w-4 shrink-0 text-muted-foreground", "aria-hidden": true }), pincode === undefined ? (_jsx("span", { className: "text-muted-foreground", children: "Laden\u2026" })) : !pincode.ingesteld ? (_jsxs("span", { className: "inline-flex items-center gap-1 text-warning", children: [_jsx(AlertTriangle, { className: "h-4 w-4", "aria-hidden": true }), "Nog geen pincode: telefoons kunnen deze scanner nog niet openen"] })) : pincode.pincode ? (_jsxs("span", { children: ["Pincode ", _jsx("span", { className: "font-mono font-semibold tracking-widest", children: pincode.pincode })] })) : (_jsxs("span", { className: "inline-flex items-center gap-1 text-warning", children: [_jsx(AlertTriangle, { className: "h-4 w-4", "aria-hidden": true }), "Onbekend: stel opnieuw in"] })), _jsx(Button, { variant: "ghost", size: "icon", className: "h-8 w-8", onClick: onPincode, "aria-label": "Pincode wijzigen", title: "Pincode wijzigen", children: _jsx(Pencil, { className: "h-4 w-4" }) })] }), pincode?.standaard ? (_jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md bg-warning/10 p-3 text-sm text-warning", children: [_jsxs("span", { className: "inline-flex items-center gap-1", children: [_jsx(AlertTriangle, { className: "h-4 w-4 shrink-0", "aria-hidden": true }), "Standaardpincode 0000: wijzig hem, anders kan iedereen met de link scannen."] }), _jsx(Button, { variant: "link", className: "h-auto p-0", onClick: onPincode, children: "Pincode wijzigen" })] })) : null, pincode?.geblokkeerdTot ? (_jsxs("div", { className: "flex flex-wrap items-center gap-3 text-sm text-warning", children: [_jsxs("span", { children: ["Te vaak een verkeerde pincode: telefoons wachten tot ", formatTijd(pincode.geblokkeerdTot), "."] }), _jsx(Button, { variant: "outline", size: "sm", onClick: onSlotOpheffen, children: "Slot opheffen" })] })) : null] })] })] }));
256
+ return (_jsxs("div", { children: [_jsxs("header", { className: "flex items-center gap-3 border-b border-border p-4", children: [_jsx("span", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-muted text-primary", children: _jsx(Icoon, { className: "h-5 w-5", "aria-hidden": true }) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx(BewerkbareNaam, { naam: scanner.naam, bewerken: naamBewerken, onKlaar: () => setNaamBewerken(false), onOpslaan: onNaamOpslaan }), _jsx("span", { className: "text-xs text-muted-foreground", children: scannerSoortLabel(scanner.type) })] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": `Meer voor ${scanner.naam}`, children: _jsx(MoreHorizontal, { className: "h-4 w-4" }) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onSelect: () => window.setTimeout(() => setNaamBewerken(true), 0), children: [_jsx(Pencil, { className: "mr-2 h-4 w-4" }), " Naam wijzigen"] }), _jsxs(DropdownMenuItem, { onSelect: onPincode, children: [_jsx(Pencil, { className: "mr-2 h-4 w-4" }), " Pincode wijzigen"] })] })] })] }), _jsxs("div", { className: "space-y-4 p-4", children: [_jsxs("section", { className: "space-y-2", children: [_jsx("h3", { className: "font-semibold text-card-foreground", children: "Openen" }), basis.staat === "laden" ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Link wordt opgehaald\u2026" })) : url ? (_jsxs("div", { className: "grid gap-4 sm:grid-cols-[auto_minmax(0,1fr)] sm:items-center", children: [_jsx(KoppelQr, { link: url, alt: `QR-code om ${scanner.naam} op een telefoon te openen` }), _jsxs("div", { className: "min-w-0 space-y-2", children: [_jsx("p", { className: "text-sm text-muted-foreground", children: "Scan de QR-code met de telefoon, of open of kopieer de link." }), _jsxs("div", { className: "relative", children: [_jsx(Input, { readOnly: true, value: url, onFocus: (e) => e.currentTarget.select(), "aria-label": "Scannerlink", className: "pr-11 text-sm" }), _jsx(Button, { type: "button", variant: "ghost", size: "icon", onClick: () => void kopieer(), "aria-label": gekopieerd ? "Link gekopieerd" : "Link kopiëren", title: gekopieerd ? "Gekopieerd" : "Link kopiëren", className: "absolute right-0.5 top-1/2 h-8 w-8 -translate-y-1/2", children: gekopieerd ? _jsx(Check, { className: "h-4 w-4" }) : _jsx(Copy, { className: "h-4 w-4" }) })] }), _jsx(Button, { asChild: true, className: "w-full", children: _jsxs("a", { href: url, target: "_blank", rel: "noreferrer", children: [_jsx(ExternalLink, { className: "mr-2 h-4 w-4" }), "Scanner openen"] }) })] })] })) : (_jsx("p", { className: "text-sm text-destructive", children: "De link kan nu niet worden gemaakt. Probeer het later opnieuw; blijft het misgaan, neem contact op met de beheerder." }))] }), _jsxs("section", { className: "space-y-3 border-t border-border pt-4", children: [_jsx("h3", { className: "font-semibold text-card-foreground", children: "Printen" }), _jsxs("div", { className: "flex flex-wrap items-start gap-3 text-sm", children: [_jsx(Printer, { className: "mt-0.5 h-4 w-4 shrink-0 text-muted-foreground", "aria-hidden": true }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("p", { className: "text-xs text-muted-foreground", children: "Printen via" }), print.laden ? (_jsx("p", { className: "text-muted-foreground", children: "Laden\u2026" })) : print.fout ? (_jsx("p", { className: "text-warning", children: "De printplek kan nu niet worden gelezen. Probeer het later opnieuw." })) : print.plek ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "font-semibold text-card-foreground break-words", children: print.plek }), print.klaar === true ? (_jsxs("p", { className: "inline-flex items-center gap-1 text-primary", children: [_jsx(Check, { className: "h-3.5 w-3.5", "aria-hidden": true }), "Klaar om te printen"] })) : print.klaar === false ? (_jsxs("p", { className: "inline-flex items-start gap-1 text-warning", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-3.5 w-3.5 shrink-0", "aria-hidden": true }), print.reden] })) : null, print.melding ? _jsx("p", { className: "text-xs text-muted-foreground", children: print.melding }) : null] })) : (_jsxs("p", { className: "inline-flex items-center gap-1 text-warning", children: [_jsx(AlertTriangle, { className: "h-3.5 w-3.5", "aria-hidden": true }), eind ? "Nog geen controleplek gekozen" : "Nog geen printplek gekozen"] }))] }), pad ? (_jsx("a", { href: print.plekId ? `${pad}?plek=${encodeURIComponent(print.plekId)}` : pad, className: "shrink-0 font-semibold text-primary underline-offset-2 hover:underline", children: "Wijzigen" })) : (_jsx("span", { className: "w-full text-muted-foreground sm:w-auto", children: "Wijzig dit in Printen \u203A Printplekken" }))] }), _jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-sm font-semibold text-card-foreground", children: "Deze documenten worden hier geprint" }), _jsx("ul", { className: "overflow-hidden rounded-lg border border-border", children: PRINT_RIJEN[eind ? "eind" : "kar"].filter((rij) => !rij.alleenFloriday || metFloriday).map((rij, i) => {
257
+ const doc = print.docs?.find((d) => d.soort === rij.soort) ?? null;
258
+ const extra = doc ? [doc.versie, doc.formaat].filter(Boolean).join(" · ") : "";
259
+ return (_jsxs("li", { className: cn("flex items-start gap-3 px-3 py-2 text-sm", i > 0 && "border-t border-border"), children: [_jsx(FileText, { className: "mt-0.5 h-4 w-4 shrink-0 text-muted-foreground", "aria-hidden": true }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("p", { className: "break-words", children: [_jsx("span", { className: "text-card-foreground", children: rij.naam }), extra ? _jsxs("span", { className: "text-muted-foreground", children: [" \u00B7 ", extra] }) : null] }), doc && doc.kanPrinten === false ? (_jsxs("p", { className: "inline-flex items-start gap-1 text-warning", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-3.5 w-3.5 shrink-0", "aria-hidden": true }), doc.reden ?? "Dit document kan hier nu niet printen."] })) : null] })] }, rij.naam));
260
+ }) })] })] }), _jsxs("section", { className: "space-y-2 border-t border-border pt-4", children: [_jsx("h3", { className: "font-semibold text-card-foreground", children: "Pincode" }), _jsxs("div", { className: "flex flex-wrap items-center gap-2 text-sm", children: [_jsx(KeyRound, { className: "h-4 w-4 shrink-0 text-muted-foreground", "aria-hidden": true }), pincode === undefined ? (_jsx("span", { className: "text-muted-foreground", children: "Laden\u2026" })) : !pincode.ingesteld ? (_jsxs("span", { className: "inline-flex items-center gap-1 text-warning", children: [_jsx(AlertTriangle, { className: "h-4 w-4", "aria-hidden": true }), "Nog geen pincode: telefoons kunnen deze scanner nog niet openen"] })) : pincode.pincode ? (_jsxs("span", { children: ["Pincode ", _jsx("span", { className: "font-mono font-semibold tracking-widest", children: pincode.pincode })] })) : (_jsxs("span", { className: "inline-flex items-center gap-1 text-warning", children: [_jsx(AlertTriangle, { className: "h-4 w-4", "aria-hidden": true }), "Onbekend: stel opnieuw in"] })), _jsx(Button, { variant: "ghost", size: "icon", className: "h-8 w-8", onClick: onPincode, "aria-label": "Pincode wijzigen", title: "Pincode wijzigen", children: _jsx(Pencil, { className: "h-4 w-4" }) })] }), pincode?.standaard ? (_jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md bg-warning/10 p-3 text-sm text-warning", children: [_jsxs("span", { className: "inline-flex items-center gap-1", children: [_jsx(AlertTriangle, { className: "h-4 w-4 shrink-0", "aria-hidden": true }), "Standaardpincode 0000: wijzig hem, anders kan iedereen met de link scannen."] }), _jsx(Button, { variant: "link", className: "h-auto p-0", onClick: onPincode, children: "Pincode wijzigen" })] })) : null, pincode?.geblokkeerdTot ? (_jsxs("div", { className: "flex flex-wrap items-center gap-3 text-sm text-warning", children: [_jsxs("span", { children: ["Te vaak een verkeerde pincode: telefoons wachten tot ", formatTijd(pincode.geblokkeerdTot), "."] }), _jsx(Button, { variant: "outline", size: "sm", onClick: onSlotOpheffen, children: "Slot opheffen" })] })) : null] })] })] }));
144
261
  }
145
262
  const KOLOMMEN = "grid grid-cols-1 items-center gap-3 @2xl:grid-cols-[minmax(10rem,1.3fr)_minmax(0,1fr)_10rem]";
146
263
  function PincodeLabel({ pin }) {
@@ -165,7 +282,6 @@ export function ScanModulePage({ linkBasis } = {}) {
165
282
  const zoekRef = useRef(null);
166
283
  const [basis, setBasis] = useState({ staat: "laden" });
167
284
  const [pincodes, setPincodes] = useState(null);
168
- const [naamVoor, setNaamVoor] = useState(null);
169
285
  const [pinVoor, setPinVoor] = useState(null);
170
286
  const lijst = useMemo(() => {
171
287
  const volgorde = (s) => (normaliseerScannerType(s.type) === "eindcontrole" ? 0 : 1);
@@ -222,13 +338,12 @@ export function ScanModulePage({ linkBasis } = {}) {
222
338
  await laadPincodes();
223
339
  };
224
340
  const lijstBlok = (_jsxs("div", { className: "@container", children: [_jsxs("div", { className: "hidden gap-3 px-4 py-3 pr-11 text-sm font-semibold text-card-foreground @2xl:grid @2xl:grid-cols-[minmax(10rem,1.3fr)_minmax(0,1fr)_10rem]", children: [_jsx("span", { children: "Scanner" }), _jsx("span", { children: "Printplek" }), _jsx("span", { children: "Pincode" })] }), laden ? (_jsx("div", { className: "border-t border-border", children: _jsx(TableSkeleton, { widths: [280], rows: 2 }) })) : (zichtbaar.map((s) => (_jsx(ScannerRij, { scanner: s, gekozen: s.id === gekozenId, pin: pincodes?.[s.id], onKies: () => { setKeuze(s.id); setDetailOpen(true); } }, s.id)))), !laden && zichtbaar.length === 0 ? (_jsx("p", { className: "border-t border-border px-4 py-6 text-sm text-muted-foreground", children: lijst.length === 0 ? "Er zijn nog geen scanners. Vraag je beheerder de installatie van Scan te controleren." : "Niets gevonden." })) : null] }));
225
- const detail = gekozen ? (_jsx(ScannerDetail, { scanner: gekozen, basis: basis, pincode: pincodes ? (pincodes[gekozen.id] ?? { ingesteld: false, standaard: false, pincode: null, geblokkeerdTot: null }) : undefined, onNaam: () => setNaamVoor(gekozen), onPincode: () => setPinVoor(gekozen), onSlotOpheffen: () => void slotOpheffen(gekozen) })) : (_jsx("p", { className: "p-4 text-sm text-muted-foreground", children: "Kies een scanner." }));
341
+ const detail = gekozen ? (_jsx(ScannerDetail, { scanner: gekozen, basis: basis, pincode: pincodes ? (pincodes[gekozen.id] ?? { ingesteld: false, standaard: false, pincode: null, geblokkeerdTot: null }) : undefined, onNaamOpslaan: (naam) => wijzigScanner(gekozen.id, { naam }), onPincode: () => setPinVoor(gekozen), onSlotOpheffen: () => void slotOpheffen(gekozen) })) : (_jsx("p", { className: "p-4 text-sm text-muted-foreground", children: "Kies een scanner." }));
226
342
  return (_jsxs(PageContainer, { children: [_jsx("div", { className: "mb-4 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3", children: _jsx("h1", { className: "truncate text-2xl font-semibold text-foreground", children: "Scanners" }) }), _jsxs("div", { className: "relative mb-4 w-full sm:max-w-sm", children: [_jsx(Search, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground", "aria-hidden": true }), _jsx(Input, { ref: zoekRef, value: zoek, onChange: (e) => setZoek(e.target.value), placeholder: "Zoek scanner\u2026", className: "pl-9 pr-9", "aria-label": "Zoek scanner" }), _jsx("span", { className: "pointer-events-none absolute right-3 top-1/2 -translate-y-1/2", children: _jsx(Toetsje, { children: "/" }) })] }), _jsx(LijstDetail, { lijst: lijstBlok, detail: detail, detailOpen: detailOpen, onTerug: () => setDetailOpen(false), terugTekst: "Scanners" }), _jsx(ShortcutHelp, { open: hulp, onOpenChange: setHulp, shortcuts: [
227
343
  [["/"], "Zoeken"],
228
344
  [["J", "K"], "Volgende / vorige scanner"],
229
345
  [["Enter"], "Gekozen scanner openen"],
230
346
  [["Esc"], "Zoeken verlaten / sluiten"],
231
347
  [["?"], "Dit overzicht"],
232
- ] }), _jsx(NaamDialoog, { scanner: naamVoor, onClose: () => setNaamVoor(null), onOpslaan: async (naam) => { if (naamVoor && await wijzigScanner(naamVoor.id, { naam }))
233
- setNaamVoor(null); } }), _jsx(PincodeDialoog, { scanner: pinVoor, onClose: () => setPinVoor(null), onKlaar: () => { setPinVoor(null); void laadPincodes(); } })] }));
348
+ ] }), _jsx(PincodeDialoog, { scanner: pinVoor, onClose: () => setPinVoor(null), onKlaar: () => { setPinVoor(null); void laadPincodes(); } })] }));
234
349
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useScanners.d.ts","sourceRoot":"","sources":["../../src/hooks/useScanners.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,wFAAwF;IACxF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CACpC,IAAI,CACF,aAAa,EACX,MAAM,GACN,cAAc,GACd,QAAQ,GACR,MAAM,GACN,oBAAoB,GACpB,SAAS,GACT,uBAAuB,GACvB,UAAU,GACV,YAAY,CACf,CACF,CAAC;AAEF,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED,wBAAgB,WAAW;;;;;0BAqBR;QACb,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,iEAAiE;QACjE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC3B;wBAqCU,MAAM,aAAa,gBAAgB,KAAG,OAAO,CAAC,OAAO,CAAC;2BAkBtD,MAAM;EAapB"}
1
+ {"version":3,"file":"useScanners.d.ts","sourceRoot":"","sources":["../../src/hooks/useScanners.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,wFAAwF;IACxF,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CACpC,IAAI,CACF,aAAa,EACX,MAAM,GACN,cAAc,GACd,QAAQ,GACR,MAAM,GACN,oBAAoB,GACpB,SAAS,GACT,uBAAuB,GACvB,UAAU,GACV,YAAY,CACf,CACF,CAAC;AAEF,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED,wBAAgB,WAAW;;;;;0BAqBR;QACb,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,iEAAiE;QACjE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC3B;wBAqCU,MAAM,aAAa,gBAAgB,KAAG,OAAO,CAAC,OAAO,CAAC;2BAmBtD,MAAM;EAapB"}
@@ -78,7 +78,8 @@ export function useScanners() {
78
78
  const { data, error } = await db.rpc("scan_naam_wijzigen_v1", { p_scanner_id: id, p_naam: wijziging.naam });
79
79
  if (error || !data?.ok) {
80
80
  console.error("[scanners] naam wijzigen", error ?? data);
81
- toast.error("De naam kon niet worden opgeslagen. Probeer het opnieuw; blijft het misgaan, neem contact op met de beheerder.");
81
+ const melding = !error && typeof data?.melding === "string" && data.melding ? data.melding : null;
82
+ toast.error(melding ?? "De naam kon niet worden opgeslagen. Probeer het opnieuw; blijft het misgaan, neem contact op met de beheerder.");
82
83
  return false;
83
84
  }
84
85
  toast.success("Naam opgeslagen");
@@ -20,7 +20,7 @@ function createSupabaseAdminClient() {
20
20
  let _supabaseAdmin;
21
21
  // Server-side Supabase client with service role - bypasses RLS
22
22
  // SECURITY: Only use this for trusted server-side operations, never expose to client code
23
- // Import like: import { supabaseAdmin } from "./client.server.js";
23
+ // Import like: import { supabaseAdmin } from "../../integrations/supabase/client.server.js";
24
24
  export const supabaseAdmin = new Proxy({}, {
25
25
  get(_, prop, receiver) {
26
26
  if (!_supabaseAdmin)
@@ -56428,6 +56428,12 @@ export type Database = {
56428
56428
  Args: never;
56429
56429
  Returns: Json;
56430
56430
  };
56431
+ print_plek_documenten_v2: {
56432
+ Args: {
56433
+ p_plek: string;
56434
+ };
56435
+ Returns: Json;
56436
+ };
56431
56437
  print_plek_koppelen_v1: {
56432
56438
  Args: {
56433
56439
  p_bron: string;