@flowselections/scan-module 1.0.20 → 1.0.22
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":"AAwGA,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,SAAS,GACV,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,+BA2hBA"}
|
|
@@ -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;
|
|
@@ -206,6 +225,8 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
206
225
|
}
|
|
207
226
|
}
|
|
208
227
|
}
|
|
228
|
+
if (uitkomst.ok && bevestigNietGeprint)
|
|
229
|
+
uitkomst.zonderPakbon = true;
|
|
209
230
|
playFeedback(uitkomst.ok || uitkomst.alAfgehandeld ? "ok" : "error");
|
|
210
231
|
if (uitkomst.ok)
|
|
211
232
|
toast.success(uitkomst.melding);
|
|
@@ -217,6 +238,35 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
217
238
|
setHistorie((vorig) => [uitkomst, ...vorig].slice(0, 10));
|
|
218
239
|
void laadOpenstaand();
|
|
219
240
|
}, [scannerId, laadOpenstaand]);
|
|
241
|
+
/** Pakbon niet geprint: toch afmelden (keuze wordt vastgelegd). */
|
|
242
|
+
const tochAfmelden = useCallback(() => {
|
|
243
|
+
if (!nietGeprint)
|
|
244
|
+
return;
|
|
245
|
+
const { rauw } = nietGeprint;
|
|
246
|
+
void logScan(rauw, "afgemeld_zonder_print", "Gekozen: Afmelden", scannerId);
|
|
247
|
+
setNietGeprint(null);
|
|
248
|
+
void scan(rauw, true);
|
|
249
|
+
}, [nietGeprint, scannerId, scan]);
|
|
250
|
+
/** Pakbon niet geprint: niet afmelden (keuze wordt vastgelegd). */
|
|
251
|
+
const annuleerNietGeprint = useCallback(() => {
|
|
252
|
+
if (!nietGeprint)
|
|
253
|
+
return;
|
|
254
|
+
const n = nietGeprint;
|
|
255
|
+
void logScan(n.rauw, "geannuleerd_niet_geprint", "Gekozen: Annuleren", scannerId);
|
|
256
|
+
setHistorie((vorig) => [
|
|
257
|
+
{
|
|
258
|
+
ok: false,
|
|
259
|
+
melding: "Niet afgemeld: pakbon nog niet geprint",
|
|
260
|
+
code: n.rauw,
|
|
261
|
+
orderNumber: n.orderNumber,
|
|
262
|
+
klant: n.klant,
|
|
263
|
+
karLabel: n.karLabel,
|
|
264
|
+
nietGeprint: true,
|
|
265
|
+
},
|
|
266
|
+
...vorig,
|
|
267
|
+
].slice(0, 10));
|
|
268
|
+
setNietGeprint(null);
|
|
269
|
+
}, [nietGeprint, scannerId]);
|
|
220
270
|
/** Oude pakbonnen van deze order weghalen en nieuwe uitprinten. */
|
|
221
271
|
const pakbonOpnieuw = useCallback(async () => {
|
|
222
272
|
const code = engine?.code ?? "";
|
|
@@ -247,7 +297,7 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
247
297
|
const actueel = openstaand.filter((p) => !p.ouder);
|
|
248
298
|
const ouder = openstaand.filter((p) => p.ouder);
|
|
249
299
|
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
|
|
300
|
+
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
301
|
? "border-primary"
|
|
252
302
|
: resultaat.alAfgehandeld
|
|
253
303
|
? "border-warning bg-warning-soft"
|
|
@@ -255,7 +305,17 @@ export function EindcontroleScanner({ naam, scannerId, }) {
|
|
|
255
305
|
? "font-semibold text-primary"
|
|
256
306
|
: resultaat.alAfgehandeld
|
|
257
307
|
? "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
|
|
308
|
+
: "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
|
|
309
|
+
? "bg-warning-soft text-warning-soft-foreground"
|
|
310
|
+
: undefined, children: h.zonderPakbon
|
|
311
|
+
? "Afgemeld zonder pakbon"
|
|
312
|
+
: h.ok
|
|
313
|
+
? "OK"
|
|
314
|
+
: h.nietGeprint
|
|
315
|
+
? "Niet geprint"
|
|
316
|
+
: h.alAfgehandeld
|
|
317
|
+
? "Al afgehandeld"
|
|
318
|
+
: "Let op" }), _jsx("span", { className: "truncate", children: h.onbekend || h.alAfgehandeld || h.nietGeprint || h.zonderPakbon
|
|
259
319
|
? h.code
|
|
260
320
|
: `${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
321
|
}
|
|
@@ -7153,7 +7153,11 @@ export type Database = {
|
|
|
7153
7153
|
quantity: number | null;
|
|
7154
7154
|
sales_order_id: string | null;
|
|
7155
7155
|
sequence_number: number;
|
|
7156
|
+
should_be_printed: boolean | null;
|
|
7156
7157
|
status: string | null;
|
|
7158
|
+
sticker_height_mm: number | null;
|
|
7159
|
+
sticker_type: string | null;
|
|
7160
|
+
sticker_width_mm: number | null;
|
|
7157
7161
|
trade_item_id: string | null;
|
|
7158
7162
|
updated_at: string;
|
|
7159
7163
|
};
|
|
@@ -7168,7 +7172,11 @@ export type Database = {
|
|
|
7168
7172
|
quantity?: number | null;
|
|
7169
7173
|
sales_order_id?: string | null;
|
|
7170
7174
|
sequence_number?: number;
|
|
7175
|
+
should_be_printed?: boolean | null;
|
|
7171
7176
|
status?: string | null;
|
|
7177
|
+
sticker_height_mm?: number | null;
|
|
7178
|
+
sticker_type?: string | null;
|
|
7179
|
+
sticker_width_mm?: number | null;
|
|
7172
7180
|
trade_item_id?: string | null;
|
|
7173
7181
|
updated_at?: string;
|
|
7174
7182
|
};
|
|
@@ -7183,7 +7191,11 @@ export type Database = {
|
|
|
7183
7191
|
quantity?: number | null;
|
|
7184
7192
|
sales_order_id?: string | null;
|
|
7185
7193
|
sequence_number?: number;
|
|
7194
|
+
should_be_printed?: boolean | null;
|
|
7186
7195
|
status?: string | null;
|
|
7196
|
+
sticker_height_mm?: number | null;
|
|
7197
|
+
sticker_type?: string | null;
|
|
7198
|
+
sticker_width_mm?: number | null;
|
|
7187
7199
|
trade_item_id?: string | null;
|
|
7188
7200
|
updated_at?: string;
|
|
7189
7201
|
};
|
|
@@ -28701,6 +28713,12 @@ export type Database = {
|
|
|
28701
28713
|
};
|
|
28702
28714
|
Returns: Json;
|
|
28703
28715
|
};
|
|
28716
|
+
_scan_kar_pakbon_geprint: {
|
|
28717
|
+
Args: {
|
|
28718
|
+
p_cart_id: string;
|
|
28719
|
+
};
|
|
28720
|
+
Returns: Json;
|
|
28721
|
+
};
|
|
28704
28722
|
_scan_kar_voortgang: {
|
|
28705
28723
|
Args: {
|
|
28706
28724
|
p_cart_id: string;
|
|
@@ -35698,6 +35716,7 @@ export type Database = {
|
|
|
35698
35716
|
scan_eindcontrole: {
|
|
35699
35717
|
Args: {
|
|
35700
35718
|
p_barcode: string;
|
|
35719
|
+
p_bevestig_niet_geprint?: boolean;
|
|
35701
35720
|
p_scanner_id?: string;
|
|
35702
35721
|
};
|
|
35703
35722
|
Returns: Json;
|