@flowselections/scan-module 1.0.28 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/ScanModulePage.d.ts.map +1 -1
- package/dist-lib/components/ScanModulePage.js +3 -2
- package/dist-lib/components/scanners/ApparaatPoort.d.ts +8 -0
- package/dist-lib/components/scanners/ApparaatPoort.d.ts.map +1 -0
- package/dist-lib/components/scanners/ApparaatPoort.js +182 -0
- package/dist-lib/components/scanners/ApparatenBeheer.d.ts +6 -0
- package/dist-lib/components/scanners/ApparatenBeheer.d.ts.map +1 -0
- package/dist-lib/components/scanners/ApparatenBeheer.js +125 -0
- package/dist-lib/components/scanners/EindcontroleScanner.d.ts +18 -0
- package/dist-lib/components/scanners/EindcontroleScanner.d.ts.map +1 -1
- package/dist-lib/components/scanners/EindcontroleScanner.js +9 -3
- package/dist-lib/components/scanners/KoppelQr.d.ts +4 -0
- package/dist-lib/components/scanners/KoppelQr.d.ts.map +1 -0
- package/dist-lib/components/scanners/KoppelQr.js +19 -0
- package/dist-lib/components/scanners/ScannerBySlug.d.ts.map +1 -1
- package/dist-lib/components/scanners/ScannerBySlug.js +3 -1
- package/dist-lib/hooks/useKarIndeling.js +2 -2
- package/dist-lib/hooks/useKarScanner.d.ts.map +1 -1
- package/dist-lib/hooks/useKarScanner.js +49 -14
- package/dist-lib/integrations/supabase/types.d.ts +4563 -112
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/pakbonScan.js +2 -2
- package/dist-lib/lib/scanApparaat.d.ts +19 -0
- package/dist-lib/lib/scanApparaat.d.ts.map +1 -0
- package/dist-lib/lib/scanApparaat.js +106 -0
- package/dist-lib/lib/veilingbonPrint.d.ts.map +1 -1
- package/dist-lib/lib/veilingbonPrint.js +11 -7
- package/package.json +7 -5
|
@@ -8,10 +8,11 @@
|
|
|
8
8
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
9
9
|
import { toast, useAuth } from "@flowselections/core";
|
|
10
10
|
import { supabase } from "../integrations/supabase/client.js";
|
|
11
|
+
import { scanDb, heeftApparaatSleutel } from "../lib/scanApparaat.js";
|
|
11
12
|
import { engineMelding, engineOrders, isVerouderdePakbon, isTechnischeFout, magProductLookup, resolvePakbonScan, } from "../lib/pakbonScan.js";
|
|
12
13
|
// De gegenereerde Supabase-types kennen de nieuwe scan-tabellen nog niet.
|
|
13
14
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
|
-
const db =
|
|
15
|
+
const db = scanDb;
|
|
15
16
|
const safeArray = (value) => Array.isArray(value) ? value : [];
|
|
16
17
|
/** Stabiel apparaat-id per browser, voor monitoring en audit */
|
|
17
18
|
function deviceId() {
|
|
@@ -56,15 +57,26 @@ export function useKarScanner(opties = {}) {
|
|
|
56
57
|
catch {
|
|
57
58
|
/* opruimen mag laden nooit blokkeren */
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
let pbs;
|
|
61
|
+
let lijstItems = null;
|
|
62
|
+
if (heeftApparaatSleutel()) {
|
|
63
|
+
const { data: pbRes, error: pbError } = await db.rpc("scan_pakbonnen_open", { p_limiet: limiet });
|
|
64
|
+
if (pbError)
|
|
65
|
+
throw pbError;
|
|
66
|
+
pbs = safeArray(pbRes?.pakbonnen);
|
|
67
|
+
lijstItems = safeArray(pbRes?.items);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
const { data: pbData, error: pbError } = await db
|
|
71
|
+
.from("scan_pakbonnen")
|
|
72
|
+
.select("*")
|
|
73
|
+
.in("status", ["open", "in_behandeling"])
|
|
74
|
+
.order("printed_at", { ascending: false })
|
|
75
|
+
.limit(limiet);
|
|
76
|
+
if (pbError)
|
|
77
|
+
throw pbError;
|
|
78
|
+
pbs = safeArray(pbData);
|
|
79
|
+
}
|
|
68
80
|
setPakbonnen(pbs);
|
|
69
81
|
const { data: openData, error: openError } = await db.rpc("scan_open_pakbonnen", {
|
|
70
82
|
p_dagen: null,
|
|
@@ -76,6 +88,10 @@ export function useKarScanner(opties = {}) {
|
|
|
76
88
|
setItems([]);
|
|
77
89
|
return;
|
|
78
90
|
}
|
|
91
|
+
if (lijstItems) {
|
|
92
|
+
setItems(lijstItems);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
79
95
|
const { data: itData, error: itError } = await db
|
|
80
96
|
.from("scan_pakbon_items")
|
|
81
97
|
.select("*")
|
|
@@ -192,6 +208,18 @@ export function useKarScanner(opties = {}) {
|
|
|
192
208
|
// ── Logging (met monitoring-gegevens) ─────────────────────────────────────
|
|
193
209
|
const log = useCallback(async (code, result, message, extra) => {
|
|
194
210
|
try {
|
|
211
|
+
if (heeftApparaatSleutel()) {
|
|
212
|
+
await db.rpc("scan_log_code", {
|
|
213
|
+
p_code: code,
|
|
214
|
+
p_result: result,
|
|
215
|
+
p_message: message ?? null,
|
|
216
|
+
p_scanner_key: "kar",
|
|
217
|
+
p_latency_ms: extra?.latencyMs ?? null,
|
|
218
|
+
p_medewerker: naam,
|
|
219
|
+
p_kar_id: stateRef.current.kar?.id ?? null,
|
|
220
|
+
});
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
195
223
|
await db.from("scan_logs").insert({
|
|
196
224
|
scanner_key: "kar",
|
|
197
225
|
kar_id: stateRef.current.kar?.id ?? null,
|
|
@@ -521,10 +549,17 @@ export function useKarScanner(opties = {}) {
|
|
|
521
549
|
return;
|
|
522
550
|
const stamp = field === "geprint" ? "geprint_op" : "naar_pickstation_op";
|
|
523
551
|
try {
|
|
524
|
-
|
|
525
|
-
.
|
|
526
|
-
|
|
527
|
-
|
|
552
|
+
if (heeftApparaatSleutel()) {
|
|
553
|
+
const { error } = await db.rpc("scan_kar_markeren", { p_kar_id: huidigeKar.id, p_veld: field });
|
|
554
|
+
if (error)
|
|
555
|
+
throw error;
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
await db
|
|
559
|
+
.from("scan_karren")
|
|
560
|
+
.update({ [field]: true, [stamp]: new Date().toISOString() })
|
|
561
|
+
.eq("id", huidigeKar.id);
|
|
562
|
+
}
|
|
528
563
|
setKar({ ...huidigeKar, [field]: true });
|
|
529
564
|
}
|
|
530
565
|
catch {
|