@flowselections/scan-module 1.0.20 → 1.0.24
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":"EindcontroleScanner.d.ts","sourceRoot":"","sources":["../../../src/components/scanners/EindcontroleScanner.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EindcontroleScanner.d.ts","sourceRoot":"","sources":["../../../src/components/scanners/EindcontroleScanner.tsx"],"names":[],"mappings":"AA0GA,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,SAAS,GACV,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,+BAmiBA"}
|
|
@@ -53,6 +53,8 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
53
53
|
const [verouderdMelding, setVerouderdMelding] = useState(null);
|
|
54
54
|
// Technische fout (timeout/netwerk): neutraal, nooit de herprint-knop.
|
|
55
55
|
const [techFout, setTechFout] = useState(null);
|
|
56
|
+
// Pakbon van de kar nog niet geprint: vraag Afmelden / Annuleren.
|
|
57
|
+
const [nietGeprint, setNietGeprint] = useState(null);
|
|
56
58
|
const bezigRef = useRef(false);
|
|
57
59
|
const laadOpenstaand = useCallback(async () => {
|
|
58
60
|
try {
|
|
@@ -86,7 +88,7 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
86
88
|
setEngine(null);
|
|
87
89
|
setVerouderdMelding(null);
|
|
88
90
|
}, []);
|
|
89
|
-
const scan = useCallback(async (barcode) => {
|
|
91
|
+
const scan = useCallback(async (barcode, bevestigNietGeprint = false) => {
|
|
90
92
|
const rauw = (barcode ?? "").trim();
|
|
91
93
|
const code = pakbonBarcodeUit(rauw) ?? normaliseerScanCode(rauw);
|
|
92
94
|
if (!code || bezigRef.current)
|
|
@@ -96,6 +98,7 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
96
98
|
setEngine(null);
|
|
97
99
|
setVerouderdMelding(null);
|
|
98
100
|
setTechFout(null);
|
|
101
|
+
setNietGeprint(null);
|
|
99
102
|
// 1. Pakbonformaat? Dan is de Logistiek Engine leidend. Hoort de pakbon
|
|
100
103
|
// bij een kar die opnieuw is ingedeeld, dan stoppen we hier met een
|
|
101
104
|
// duidelijke melding en een herstelknop.
|
|
@@ -126,6 +129,7 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
126
129
|
const { data, error } = await db.rpc("scan_eindcontrole", {
|
|
127
130
|
p_barcode: code,
|
|
128
131
|
p_scanner_id: scannerId,
|
|
132
|
+
p_bevestig_niet_geprint: bevestigNietGeprint,
|
|
129
133
|
});
|
|
130
134
|
setBezig(false);
|
|
131
135
|
bezigRef.current = false;
|
|
@@ -145,6 +149,21 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
145
149
|
toast.error(tekst);
|
|
146
150
|
return;
|
|
147
151
|
}
|
|
152
|
+
// Pakbon van deze kar nog niet geprint: eerst vragen, niets afmelden.
|
|
153
|
+
if (!res0.ok && res0.errorCode === "niet_geprint") {
|
|
154
|
+
const c = res0.cart ?? {};
|
|
155
|
+
setResultaat(null);
|
|
156
|
+
setNietGeprint({
|
|
157
|
+
code,
|
|
158
|
+
rauw,
|
|
159
|
+
orderNumber: res0.order?.orderNumber ?? null,
|
|
160
|
+
klant: res0.order?.customerName ?? null,
|
|
161
|
+
karLabel: c.cartLabel ?? (c.cartIndex ? `Kar ${c.cartIndex} van ${c.cartTotal ?? "?"}` : null),
|
|
162
|
+
});
|
|
163
|
+
playFeedback("error");
|
|
164
|
+
void logScan(rauw, "pakbon_niet_geprint", "Waarschuwing getoond", scannerId);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
148
167
|
let uitkomst;
|
|
149
168
|
{
|
|
150
169
|
const res = res0;
|
|
@@ -190,7 +209,13 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
190
209
|
voortgang: alGescand ? voortgangTekst(vg) : null,
|
|
191
210
|
};
|
|
192
211
|
uitkomst.code = rauw;
|
|
193
|
-
|
|
212
|
+
const alFloriday = !res.ok && res.errorCode === "al_afgehandeld_floriday";
|
|
213
|
+
uitkomst.alAfgehandeld = alGescand || alFloriday;
|
|
214
|
+
if (alFloriday) {
|
|
215
|
+
uitkomst.alFloriday = true;
|
|
216
|
+
uitkomst.melding = "Deze order is al afgehandeld in Floriday";
|
|
217
|
+
void logScan(rauw, "al_afgehandeld_floriday", uitkomst.melding, scannerId);
|
|
218
|
+
}
|
|
194
219
|
// Klantnaam altijd op order-id uit de klantgegevens.
|
|
195
220
|
const orderId = onbekend ? null : (res.order?.orderId ?? null);
|
|
196
221
|
if (orderId) {
|
|
@@ -206,6 +231,8 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
206
231
|
}
|
|
207
232
|
}
|
|
208
233
|
}
|
|
234
|
+
if (uitkomst.ok && bevestigNietGeprint)
|
|
235
|
+
uitkomst.zonderPakbon = true;
|
|
209
236
|
playFeedback(uitkomst.ok || uitkomst.alAfgehandeld ? "ok" : "error");
|
|
210
237
|
if (uitkomst.ok)
|
|
211
238
|
toast.success(uitkomst.melding);
|
|
@@ -217,6 +244,35 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
217
244
|
setHistorie((vorig) => [uitkomst, ...vorig].slice(0, 10));
|
|
218
245
|
void laadOpenstaand();
|
|
219
246
|
}, [scannerId, laadOpenstaand]);
|
|
247
|
+
/** Pakbon niet geprint: toch afmelden (keuze wordt vastgelegd). */
|
|
248
|
+
const tochAfmelden = useCallback(() => {
|
|
249
|
+
if (!nietGeprint)
|
|
250
|
+
return;
|
|
251
|
+
const { rauw } = nietGeprint;
|
|
252
|
+
void logScan(rauw, "afgemeld_zonder_print", "Gekozen: Afmelden", scannerId);
|
|
253
|
+
setNietGeprint(null);
|
|
254
|
+
void scan(rauw, true);
|
|
255
|
+
}, [nietGeprint, scannerId, scan]);
|
|
256
|
+
/** Pakbon niet geprint: niet afmelden (keuze wordt vastgelegd). */
|
|
257
|
+
const annuleerNietGeprint = useCallback(() => {
|
|
258
|
+
if (!nietGeprint)
|
|
259
|
+
return;
|
|
260
|
+
const n = nietGeprint;
|
|
261
|
+
void logScan(n.rauw, "geannuleerd_niet_geprint", "Gekozen: Annuleren", scannerId);
|
|
262
|
+
setHistorie((vorig) => [
|
|
263
|
+
{
|
|
264
|
+
ok: false,
|
|
265
|
+
melding: "Niet afgemeld: pakbon nog niet geprint",
|
|
266
|
+
code: n.rauw,
|
|
267
|
+
orderNumber: n.orderNumber,
|
|
268
|
+
klant: n.klant,
|
|
269
|
+
karLabel: n.karLabel,
|
|
270
|
+
nietGeprint: true,
|
|
271
|
+
},
|
|
272
|
+
...vorig,
|
|
273
|
+
].slice(0, 10));
|
|
274
|
+
setNietGeprint(null);
|
|
275
|
+
}, [nietGeprint, scannerId]);
|
|
220
276
|
/** Oude pakbonnen van deze order weghalen en nieuwe uitprinten. */
|
|
221
277
|
const pakbonOpnieuw = useCallback(async () => {
|
|
222
278
|
const code = engine?.code ?? "";
|
|
@@ -247,7 +303,7 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
247
303
|
const actueel = openstaand.filter((p) => !p.ouder);
|
|
248
304
|
const ouder = openstaand.filter((p) => p.ouder);
|
|
249
305
|
const pakbonKnop = (p) => (_jsxs("button", { type: "button", disabled: bezig, onClick: () => void scan(p.barcode), className: "w-full rounded-xl border p-3 text-left transition hover:border-primary disabled:opacity-50", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "truncate font-bold", children: p.order_number ?? "Order onbekend" }), _jsx(Badge, { variant: p.soort === "hele_kar" ? "default" : "secondary", children: p.soort === "hele_kar" ? "Hele kar" : "Deelkar" })] }), _jsxs("p", { className: "mt-1 truncate text-sm text-muted-foreground", children: [p.klant_naam ?? "Klant onbekend", formatDag(p.leverdag) ? ` · Leverdag ${formatDag(p.leverdag)}` : ""] }), p.klant_bedrijf ? (_jsx("p", { className: "truncate text-xs text-muted-foreground", children: p.klant_bedrijf })) : null, _jsxs("p", { className: "mt-1 truncate font-mono text-xs text-muted-foreground", children: [p.barcode, p.cart_index != null ? ` · Kar ${p.cart_index} van ${p.cart_total ?? "?"}` : ""] })] }, p.cart_id ?? p.barcode));
|
|
250
|
-
return (_jsxs("main", { className: "mx-auto max-w-2xl space-y-4 p-4", children: [_jsxs("header", { className: "flex items-center gap-3", children: [_jsx("span", { className: "grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-primary/10 text-primary", children: _jsx(ClipboardCheck, { className: "h-6 w-6" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "truncate text-lg font-black", children: naam ?? "Eindcontrole scanner" }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Scan de pakbon van de kar" })] })] }), _jsx(StationNaamVeld, {}), _jsx(ScanInput, { onScan: (code) => void scan(code), variant: "zone", disabled: bezig, label: "Scan de pakbon", placeholder: "Barcode pakbon" }), bezig ? (_jsx("div", { className: "grid place-items-center py-6", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) })) : null, techFout ? (_jsx(Card, { children: _jsxs(CardContent, { className: "space-y-3 py-6", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0 text-muted-foreground" }), _jsx("p", { className: "text-sm font-semibold", children: techFout.melding })] }), _jsxs(Button, { className: "h-14 w-full text-base font-bold", disabled: bezig, onClick: () => void scan(techFout.code), children: [_jsx(RefreshCw, { className: "mr-2 h-5 w-5" }), "Opnieuw proberen"] }), _jsx(Button, { variant: "ghost", className: "h-11 w-full", onClick: () => setTechFout(null), children: "Sluiten" })] }) })) : null, verouderdMelding ? (_jsx(Card, { className: "border-destructive", children: _jsxs(CardContent, { className: "space-y-3 py-6", children: [_jsxs("div", { className: "flex items-start gap-2 text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0" }), _jsx("p", { className: "text-sm font-semibold", children: verouderdMelding })] }), verouderdeOrders.length > 0 ? (_jsx("div", { className: "space-y-1 rounded-xl border p-3 text-sm", children: verouderdeOrders.map((o, i) => (_jsxs("p", { className: "truncate", children: [_jsx("span", { className: "font-bold", children: o.orderNumber ?? "Order onbekend" }), o.customerName ? ` · ${o.customerName}` : ""] }, `${o.orderNumber ?? i}`))) })) : null, _jsx("p", { className: "text-xs text-muted-foreground", children: "Deze pakbon hoort bij een kar die opnieuw is ingedeeld. Print de pakbonnen opnieuw en scan daarna de nieuwe pakbon." }), _jsxs(Button, { className: "h-14 w-full text-base font-bold", disabled: bezig, onClick: () => void pakbonOpnieuw(), children: [bezig ? (_jsx(Loader2, { className: "mr-2 h-5 w-5 animate-spin" })) : (_jsx(RefreshCw, { className: "mr-2 h-5 w-5" })), "Oude pakbonnen verwijderen en nieuwe printen"] }), _jsx(Button, { variant: "ghost", className: "h-11 w-full", onClick: sluitVerouderd, children: "Sluiten" })] }) })) : null, resultaat ? (_jsx(Card, { className: resultaat.ok
|
|
306
|
+
return (_jsxs("main", { className: "mx-auto max-w-2xl space-y-4 p-4", children: [_jsxs("header", { className: "flex items-center gap-3", children: [_jsx("span", { className: "grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-primary/10 text-primary", children: _jsx(ClipboardCheck, { className: "h-6 w-6" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "truncate text-lg font-black", children: naam ?? "Eindcontrole scanner" }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Scan de pakbon van de kar" })] })] }), _jsx(StationNaamVeld, {}), _jsx(ScanInput, { onScan: (code) => void scan(code), variant: "zone", disabled: bezig, label: "Scan de pakbon", placeholder: "Barcode pakbon" }), bezig ? (_jsx("div", { className: "grid place-items-center py-6", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) })) : null, nietGeprint ? (_jsx(Card, { className: "border-warning bg-warning-soft", children: _jsxs(CardContent, { className: "space-y-3 py-6", children: [_jsxs("div", { className: "flex items-start gap-2 text-warning-soft-foreground", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0" }), _jsx("p", { className: "text-sm font-semibold", children: "Let op: de pakbon van deze kar is nog niet geprint. Toch afmelden?" })] }), _jsxs("div", { className: "rounded-xl border p-3 text-sm", children: [_jsx("p", { className: "truncate font-bold", children: nietGeprint.karLabel ?? "Kar" }), _jsxs("p", { className: "truncate text-muted-foreground", children: [nietGeprint.orderNumber ? `Order ${nietGeprint.orderNumber}` : "", nietGeprint.klant ? ` · ${nietGeprint.klant}` : ""] }), _jsx("p", { className: "break-all font-mono text-xs text-muted-foreground", children: nietGeprint.rauw })] }), _jsx(Button, { className: "h-14 w-full text-base font-bold", disabled: bezig, onClick: tochAfmelden, children: "Afmelden" }), _jsx(Button, { variant: "outline", className: "h-12 w-full", disabled: bezig, onClick: annuleerNietGeprint, children: "Annuleren" })] }) })) : null, techFout ? (_jsx(Card, { children: _jsxs(CardContent, { className: "space-y-3 py-6", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0 text-muted-foreground" }), _jsx("p", { className: "text-sm font-semibold", children: techFout.melding })] }), _jsxs(Button, { className: "h-14 w-full text-base font-bold", disabled: bezig, onClick: () => void scan(techFout.code), children: [_jsx(RefreshCw, { className: "mr-2 h-5 w-5" }), "Opnieuw proberen"] }), _jsx(Button, { variant: "ghost", className: "h-11 w-full", onClick: () => setTechFout(null), children: "Sluiten" })] }) })) : null, verouderdMelding ? (_jsx(Card, { className: "border-destructive", children: _jsxs(CardContent, { className: "space-y-3 py-6", children: [_jsxs("div", { className: "flex items-start gap-2 text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0" }), _jsx("p", { className: "text-sm font-semibold", children: verouderdMelding })] }), verouderdeOrders.length > 0 ? (_jsx("div", { className: "space-y-1 rounded-xl border p-3 text-sm", children: verouderdeOrders.map((o, i) => (_jsxs("p", { className: "truncate", children: [_jsx("span", { className: "font-bold", children: o.orderNumber ?? "Order onbekend" }), o.customerName ? ` · ${o.customerName}` : ""] }, `${o.orderNumber ?? i}`))) })) : null, _jsx("p", { className: "text-xs text-muted-foreground", children: "Deze pakbon hoort bij een kar die opnieuw is ingedeeld. Print de pakbonnen opnieuw en scan daarna de nieuwe pakbon." }), _jsxs(Button, { className: "h-14 w-full text-base font-bold", disabled: bezig, onClick: () => void pakbonOpnieuw(), children: [bezig ? (_jsx(Loader2, { className: "mr-2 h-5 w-5 animate-spin" })) : (_jsx(RefreshCw, { className: "mr-2 h-5 w-5" })), "Oude pakbonnen verwijderen en nieuwe printen"] }), _jsx(Button, { variant: "ghost", className: "h-11 w-full", onClick: sluitVerouderd, children: "Sluiten" })] }) })) : null, resultaat ? (_jsx(Card, { className: resultaat.ok
|
|
251
307
|
? "border-primary"
|
|
252
308
|
: resultaat.alAfgehandeld
|
|
253
309
|
? "border-warning bg-warning-soft"
|
|
@@ -255,7 +311,19 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
255
311
|
? "font-semibold text-primary"
|
|
256
312
|
: resultaat.alAfgehandeld
|
|
257
313
|
? "font-semibold text-warning-soft-foreground"
|
|
258
|
-
: "font-semibold text-destructive", children: resultaat.melding }), resultaat.voortgang ? (_jsx("p", { className: "text-sm font-semibold", children: resultaat.voortgang })) : null, _jsx(Button, { variant: "outline", className: "h-11", onClick: () => setResultaat(null), children: "Volgende kar" })] }) })) : null, historie.length > 0 ? (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-xs font-semibold uppercase text-muted-foreground", children: "Laatste scans" }), historie.map((h, i) => (_jsxs("div", { className: "flex items-center gap-2 rounded-lg border p-2 text-sm", children: [_jsx(Badge, { variant: h.ok ? "default" : "secondary", className: h.alAfgehandeld
|
|
314
|
+
: "font-semibold text-destructive", children: resultaat.melding }), resultaat.voortgang ? (_jsx("p", { className: "text-sm font-semibold", children: resultaat.voortgang })) : null, _jsx(Button, { variant: "outline", className: "h-11", onClick: () => setResultaat(null), children: "Volgende kar" })] }) })) : null, historie.length > 0 ? (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-xs font-semibold uppercase text-muted-foreground", children: "Laatste scans" }), historie.map((h, i) => (_jsxs("div", { className: "flex items-center gap-2 rounded-lg border p-2 text-sm", children: [_jsx(Badge, { variant: h.ok ? "default" : "secondary", className: h.alAfgehandeld || h.nietGeprint || h.zonderPakbon
|
|
315
|
+
? "bg-warning-soft text-warning-soft-foreground"
|
|
316
|
+
: undefined, children: h.zonderPakbon
|
|
317
|
+
? "Afgemeld zonder pakbon"
|
|
318
|
+
: h.ok
|
|
319
|
+
? "OK"
|
|
320
|
+
: h.nietGeprint
|
|
321
|
+
? "Niet geprint"
|
|
322
|
+
: h.alFloriday
|
|
323
|
+
? "Al afgehandeld in Floriday"
|
|
324
|
+
: h.alAfgehandeld
|
|
325
|
+
? "Al afgehandeld"
|
|
326
|
+
: "Let op" }), _jsx("span", { className: "truncate", children: h.onbekend || h.alAfgehandeld || h.nietGeprint || h.zonderPakbon
|
|
259
327
|
? h.code
|
|
260
328
|
: `${h.karLabel ?? "Kar"}${h.orderNumber ? ` · ${h.orderNumber}` : ""}` })] }, i)))] })) : null, _jsxs("section", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("h2", { className: "text-sm font-semibold uppercase text-muted-foreground", children: "Openstaande pakbonnen" }), _jsx(Badge, { variant: "secondary", className: "shrink-0 tabular-nums", children: actueel.length })] }), laden ? (_jsx("div", { className: "grid place-items-center py-8", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) })) : openstaand.length === 0 ? (_jsx(Card, { children: _jsx(CardContent, { className: "py-8 text-center text-sm text-muted-foreground", children: "Geen openstaande pakbonnen. Alles is afgehandeld." }) })) : (_jsxs("div", { className: "space-y-2", children: [actueel.map(pakbonKnop), ouder.length > 0 ? (_jsxs("details", { className: "rounded-xl border p-2", children: [_jsxs("summary", { className: "cursor-pointer select-none p-1 text-sm font-semibold text-muted-foreground", children: ["Ouder (", ouder.length, ") \u2014 leverdag meer dan 2 dagen voorbij"] }), _jsx("div", { className: "mt-2 space-y-2", children: ouder.map(pakbonKnop) })] })) : null] }))] })] }));
|
|
261
329
|
}
|