@flowselections/floriday-afhandeling-module 1.0.109 → 1.0.111
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/afhandeling/AfgemeldView.d.ts +6 -0
- package/dist-lib/components/afhandeling/AfgemeldView.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/AfgemeldView.js +44 -0
- package/dist-lib/components/afhandeling/CameraScanner.d.ts +7 -0
- package/dist-lib/components/afhandeling/CameraScanner.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/CameraScanner.js +126 -0
- package/dist-lib/components/afhandeling/ControlePage.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/ControlePage.js +52 -13
- package/dist-lib/components/afhandeling/CorrectieDialog.d.ts +24 -0
- package/dist-lib/components/afhandeling/CorrectieDialog.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/CorrectieDialog.js +100 -0
- package/dist-lib/components/afhandeling/DagDetailDialog.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/DagDetailDialog.js +2 -1
- package/dist-lib/components/afhandeling/FloridayBriefHerprint.d.ts +10 -0
- package/dist-lib/components/afhandeling/FloridayBriefHerprint.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/FloridayBriefHerprint.js +47 -0
- package/dist-lib/components/afhandeling/LeveringCorrigerenDialog.d.ts +7 -0
- package/dist-lib/components/afhandeling/LeveringCorrigerenDialog.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/LeveringCorrigerenDialog.js +79 -0
- package/dist-lib/components/afhandeling/LeveringenPage.js +1 -1
- package/dist-lib/components/afhandeling/NuVersturenButton.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/NuVersturenButton.js +31 -6
- package/dist-lib/components/afhandeling/OrderInzicht.d.ts +6 -0
- package/dist-lib/components/afhandeling/OrderInzicht.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/OrderInzicht.js +90 -0
- package/dist-lib/components/afhandeling/ScanControleView.d.ts +2 -0
- package/dist-lib/components/afhandeling/ScanControleView.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/ScanControleView.js +121 -40
- package/dist-lib/components/afhandeling/TerugkoppelingStand.d.ts +6 -0
- package/dist-lib/components/afhandeling/TerugkoppelingStand.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/TerugkoppelingStand.js +47 -0
- package/dist-lib/components/afhandeling/VervoerderForm.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/VervoerderForm.js +26 -3
- package/dist-lib/components/afhandeling/VervoerderUitFloridayPage.d.ts +5 -0
- package/dist-lib/components/afhandeling/VervoerderUitFloridayPage.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/VervoerderUitFloridayPage.js +50 -0
- package/dist-lib/hooks/useOrderPlanning.d.ts +3 -0
- package/dist-lib/hooks/useOrderPlanning.d.ts.map +1 -1
- package/dist-lib/hooks/useOrderPlanning.js +21 -7
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +1 -0
- package/dist-lib/integrations/supabase/types.d.ts +3810 -2
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.js +1 -0
- package/dist-lib/lib/barcodeFormats.d.ts +5 -0
- package/dist-lib/lib/barcodeFormats.d.ts.map +1 -0
- package/dist-lib/lib/barcodeFormats.js +8 -0
- package/dist-lib/lib/barcodeFormats.test.d.ts +2 -0
- package/dist-lib/lib/barcodeFormats.test.d.ts.map +1 -0
- package/dist-lib/lib/barcodeFormats.test.js +10 -0
- package/dist-lib/lib/carriers.functions.d.ts +34 -0
- package/dist-lib/lib/carriers.functions.d.ts.map +1 -1
- package/dist-lib/lib/carriers.functions.js +57 -0
- package/dist-lib/lib/controleAfwijking.d.ts +50 -0
- package/dist-lib/lib/controleAfwijking.d.ts.map +1 -0
- package/dist-lib/lib/controleAfwijking.js +50 -0
- package/dist-lib/lib/controleAfwijking.test.d.ts +2 -0
- package/dist-lib/lib/controleAfwijking.test.d.ts.map +1 -0
- package/dist-lib/lib/controleAfwijking.test.js +53 -0
- package/dist-lib/lib/controleLijst.functions.d.ts +7 -7
- package/dist-lib/lib/controleLijst.functions.d.ts.map +1 -1
- package/dist-lib/lib/controleLijst.functions.js +12 -39
- package/dist-lib/lib/correctieTekst.d.ts +11 -0
- package/dist-lib/lib/correctieTekst.d.ts.map +1 -0
- package/dist-lib/lib/correctieTekst.js +75 -0
- package/dist-lib/lib/correcties.functions.d.ts +80 -0
- package/dist-lib/lib/correcties.functions.d.ts.map +1 -0
- package/dist-lib/lib/correcties.functions.js +188 -0
- package/dist-lib/lib/cronVak.test.d.ts +2 -0
- package/dist-lib/lib/cronVak.test.d.ts.map +1 -0
- package/dist-lib/lib/cronVak.test.js +17 -0
- package/dist-lib/lib/documentKeuze.d.ts +12 -0
- package/dist-lib/lib/documentKeuze.d.ts.map +1 -1
- package/dist-lib/lib/documentKeuze.functions.d.ts +6 -3
- package/dist-lib/lib/documentKeuze.functions.d.ts.map +1 -1
- package/dist-lib/lib/documentKeuze.functions.js +21 -7
- package/dist-lib/lib/documentKeuze.js +23 -4
- package/dist-lib/lib/documentKeuze.test.js +22 -1
- package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday.functions.js +40 -42
- package/dist-lib/lib/floridayCorrectie.d.ts +17 -0
- package/dist-lib/lib/floridayCorrectie.d.ts.map +1 -0
- package/dist-lib/lib/floridayCorrectie.js +50 -0
- package/dist-lib/lib/floridayCorrectie.test.d.ts +2 -0
- package/dist-lib/lib/floridayCorrectie.test.d.ts.map +1 -0
- package/dist-lib/lib/floridayCorrectie.test.js +30 -0
- package/dist-lib/lib/floridayCorrecties.server.d.ts +4 -0
- package/dist-lib/lib/floridayCorrecties.server.d.ts.map +1 -0
- package/dist-lib/lib/floridayCorrecties.server.js +33 -0
- package/dist-lib/lib/floridayLoading.functions.d.ts +12 -0
- package/dist-lib/lib/floridayLoading.functions.d.ts.map +1 -1
- package/dist-lib/lib/floridayLoading.functions.js +76 -12
- package/dist-lib/lib/floridayLoadingSend.test.d.ts +2 -0
- package/dist-lib/lib/floridayLoadingSend.test.d.ts.map +1 -0
- package/dist-lib/lib/floridayLoadingSend.test.js +58 -0
- package/dist-lib/lib/floridayTegengehouden.test.d.ts +2 -0
- package/dist-lib/lib/floridayTegengehouden.test.d.ts.map +1 -0
- package/dist-lib/lib/floridayTegengehouden.test.js +63 -0
- package/dist-lib/lib/floridayTerugkoppeling.d.ts +99 -0
- package/dist-lib/lib/floridayTerugkoppeling.d.ts.map +1 -0
- package/dist-lib/lib/floridayTerugkoppeling.js +153 -0
- package/dist-lib/lib/floridayTerugkoppeling.test.d.ts +2 -0
- package/dist-lib/lib/floridayTerugkoppeling.test.d.ts.map +1 -0
- package/dist-lib/lib/floridayTerugkoppeling.test.js +108 -0
- package/dist-lib/lib/floridayTransporteur.d.ts +24 -0
- package/dist-lib/lib/floridayTransporteur.d.ts.map +1 -0
- package/dist-lib/lib/floridayTransporteur.js +31 -0
- package/dist-lib/lib/floridayTransporteur.test.d.ts +2 -0
- package/dist-lib/lib/floridayTransporteur.test.d.ts.map +1 -0
- package/dist-lib/lib/floridayTransporteur.test.js +19 -0
- package/dist-lib/lib/orderInzicht.d.ts +66 -0
- package/dist-lib/lib/orderInzicht.d.ts.map +1 -0
- package/dist-lib/lib/orderInzicht.js +89 -0
- package/dist-lib/lib/orderInzicht.test.d.ts +2 -0
- package/dist-lib/lib/orderInzicht.test.d.ts.map +1 -0
- package/dist-lib/lib/orderInzicht.test.js +66 -0
- package/dist-lib/lib/serverRoutes/autoSend.handler.js +36 -14
- package/dist-lib/lib/terugkoppeling.functions.d.ts +22 -0
- package/dist-lib/lib/terugkoppeling.functions.d.ts.map +1 -0
- package/dist-lib/lib/terugkoppeling.functions.js +67 -0
- package/dist-lib/lib/terugkoppelingAangenomen.d.ts +62 -0
- package/dist-lib/lib/terugkoppelingAangenomen.d.ts.map +1 -0
- package/dist-lib/lib/terugkoppelingAangenomen.js +141 -0
- package/dist-lib/lib/terugkoppelingAangenomen.test.d.ts +2 -0
- package/dist-lib/lib/terugkoppelingAangenomen.test.d.ts.map +1 -0
- package/dist-lib/lib/terugkoppelingAangenomen.test.js +142 -0
- package/package.json +10 -2
- package/schema/90_afhandeling.sql +2640 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Badge, Button, Dialog, DialogContent, DialogHeader, DialogTitle, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, toast, } from "@flowselections/core";
|
|
4
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
5
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
6
|
+
import { CheckCircle2, PencilLine, RefreshCw, Scale } from "lucide-react";
|
|
7
|
+
import { FloridayBriefHerprint } from "./FloridayBriefHerprint.js";
|
|
8
|
+
import { supabase } from "../../integrations/supabase/moduleClient.js";
|
|
9
|
+
import { CorrectieDialog } from "./CorrectieDialog.js";
|
|
10
|
+
import { callServerFn } from "../../lib/serverFnError.js";
|
|
11
|
+
import { floridayCorrectiesLijst, floridayCorrectieVersturen, floridayOrderGelijk, } from "../../lib/correcties.functions.js";
|
|
12
|
+
import { STAND_TEKST, standVanKoppeling } from "../../lib/floridayCorrectie.js";
|
|
13
|
+
import { doorvoerOpnieuw, doorvoerZinnen, floridayOpnieuw, REDEN_TEKST, SOORT_TEKST, waardeTekst } from "../../lib/correctieTekst.js";
|
|
14
|
+
const fmt = (iso) => new Date(iso).toLocaleString("nl-NL", { timeZone: "Europe/Amsterdam", weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" });
|
|
15
|
+
const FL_SOORT = { fewer_packages: "Minder fusten", extra_layers: "Platen", load_carrier_type: "Andere ladingdrager", delivery_location: "Afleverlocatie" };
|
|
16
|
+
const VELD = { fusten: "fusten", platen: "platen", loadCarrierType: "soort ladingdrager", aantal_ladingdragers: "aantal ladingdragers", ontbreekt_in_floriday: "ontbreekt bij Floriday" };
|
|
17
|
+
/** Per levering: ladingdragers corrigeren, eigen log, en bij Floriday-orders de stand bij Floriday. */
|
|
18
|
+
export function LeveringCorrigerenDialog({ orderId, onClose, onGewijzigd }) {
|
|
19
|
+
const [kar, setKar] = useState(null);
|
|
20
|
+
const [gelijk, setGelijk] = useState(null);
|
|
21
|
+
const versturen = useServerFn(floridayCorrectieVersturen);
|
|
22
|
+
const lijstFn = useServerFn(floridayCorrectiesLijst);
|
|
23
|
+
const gelijkFn = useServerFn(floridayOrderGelijk);
|
|
24
|
+
const detailQ = useQuery({
|
|
25
|
+
queryKey: ["afh-levering-detail", orderId],
|
|
26
|
+
queryFn: async () => {
|
|
27
|
+
const { data, error } = await supabase.rpc("afh_levering_detail", { p_order_id: orderId });
|
|
28
|
+
if (error)
|
|
29
|
+
throw new Error(error.message);
|
|
30
|
+
return data;
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const isFl = detailQ.data?.order?.is_floriday === true;
|
|
34
|
+
const flQ = useQuery({
|
|
35
|
+
queryKey: ["afh-floriday-correcties", orderId],
|
|
36
|
+
enabled: isFl,
|
|
37
|
+
queryFn: () => callServerFn(() => lijstFn({ data: { orderId } }), "floridayCorrectiesLijst"),
|
|
38
|
+
});
|
|
39
|
+
const ververs = () => { void detailQ.refetch(); if (isFl)
|
|
40
|
+
void flQ.refetch(); onGewijzigd?.(); };
|
|
41
|
+
const opnieuwFl = useMutation({
|
|
42
|
+
mutationFn: (id) => callServerFn(() => versturen({ data: { correctieId: id } }), "floridayCorrectieVersturen", { maxAttempts: 1, timeoutMs: 30000 }),
|
|
43
|
+
onSuccess: (r) => { (r.ok ? toast.success : toast.error)(r.melding); ververs(); },
|
|
44
|
+
onError: (e) => { console.error("[correctie] opnieuw naar Floriday", e); toast.error("Opnieuw versturen is niet gelukt. Probeer het straks opnieuw."); },
|
|
45
|
+
});
|
|
46
|
+
const opnieuwDoor = useMutation({
|
|
47
|
+
mutationFn: async (id) => {
|
|
48
|
+
const { data, error } = await supabase.rpc("afh_correctie_doorvoeren", { p_correctie_id: id });
|
|
49
|
+
if (error)
|
|
50
|
+
throw new Error(error.message);
|
|
51
|
+
return data;
|
|
52
|
+
},
|
|
53
|
+
onSuccess: (r) => {
|
|
54
|
+
if (!r.ok)
|
|
55
|
+
toast.error(r.melding ?? "Opnieuw doorvoeren is niet gelukt.");
|
|
56
|
+
else
|
|
57
|
+
toast.success(doorvoerZinnen(r.doorvoer).join(". ") || "Doorgevoerd.");
|
|
58
|
+
ververs();
|
|
59
|
+
},
|
|
60
|
+
onError: (e) => { console.error("[correctie] doorvoeren", e); toast.error(e.message || "Opnieuw doorvoeren is niet gelukt."); },
|
|
61
|
+
});
|
|
62
|
+
const vergelijk = useMutation({
|
|
63
|
+
mutationFn: () => callServerFn(() => gelijkFn({ data: { orderId } }), "floridayOrderGelijk", { maxAttempts: 1 }),
|
|
64
|
+
onSuccess: (r) => { setGelijk(r); if (!r.ok)
|
|
65
|
+
toast.error(r.melding ?? "Vergelijken met Floriday lukte niet."); },
|
|
66
|
+
onError: (e) => { console.error("[correctie] vergelijken", e); toast.error("Vergelijken met Floriday lukte niet. Probeer het opnieuw."); },
|
|
67
|
+
});
|
|
68
|
+
const d = detailQ.data;
|
|
69
|
+
const karren = (d?.karren ?? []).map((k) => ({
|
|
70
|
+
cartId: k.cart_id, nummer: k.nummer, soort: k.soort,
|
|
71
|
+
partijen: k.items.map((i) => ({ orderItemId: i.order_item_id, naam: i.product ?? "Partij", fusten: i.fusten })),
|
|
72
|
+
}));
|
|
73
|
+
return (_jsx(Dialog, { open: true, onOpenChange: (v) => !v && onClose(), children: _jsxs(DialogContent, { className: "max-w-3xl", children: [_jsx(DialogHeader, { children: _jsxs(DialogTitle, { children: ["Levering ", d?.order?.order_number ?? "", d?.order?.customer_name ? ` – ${d.order.customer_name}` : ""] }) }), detailQ.isError && _jsx("p", { className: "text-sm text-destructive", children: "De levering kon niet worden opgehaald. Probeer het opnieuw." }), d && !d.ok && _jsx("p", { className: "text-sm text-destructive", children: d.reden }), d?.ok && (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "font-medium", children: "Ladingdragers" }), karren.length > 0 && _jsxs(Button, { size: "sm", variant: "outline", onClick: () => setKar("kies"), children: [_jsx(PencilLine, { className: "h-4 w-4 mr-2" }), "Levering corrigeren"] })] }), karren.length === 0 ? _jsx("p", { className: "text-sm text-muted-foreground", children: "Er zijn geen ladingdragers meer bekend voor deze order." }) : (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Ladingdrager" }), _jsx(TableHead, { children: "Wat erop staat" }), _jsx(TableHead, {})] }) }), _jsx(TableBody, { children: karren.map((k) => (_jsxs(TableRow, { children: [_jsxs(TableCell, { className: "font-medium", children: [k.soort, " ", k.nummer] }), _jsx(TableCell, { className: "text-sm", children: k.partijen.map((p) => `${p.naam} (${p.fusten} fust)`).join(", ") || "—" }), _jsx(TableCell, { className: "text-right", children: _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setKar(k), children: "Corrigeren" }) })] }, k.cartId))) })] }))] }), _jsxs("div", { className: "space-y-2", children: [_jsx("div", { className: "font-medium", children: "Correcties" }), d.correcties.length === 0 ? _jsx("p", { className: "text-sm text-muted-foreground", children: "Nog geen correcties." }) : (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Wanneer" }), _jsx(TableHead, { children: "Wat" }), _jsx(TableHead, { children: "Reden" }), _jsx(TableHead, { children: "Stand" }), _jsx(TableHead, {})] }) }), _jsx(TableBody, { children: d.correcties.map((c) => (_jsxs(TableRow, { children: [_jsxs(TableCell, { className: "whitespace-nowrap", children: [fmt(c.created_at), _jsx("div", { className: "text-xs text-muted-foreground", children: c.door_naam ?? "—" })] }), _jsxs(TableCell, { children: [SOORT_TEKST[c.soort] ?? c.soort, _jsxs("div", { className: "text-xs", children: [_jsx("span", { className: "line-through text-muted-foreground", children: waardeTekst(c.soort, c.oud) }), " \u2192 ", waardeTekst(c.soort, c.nieuw)] })] }), _jsxs(TableCell, { children: [REDEN_TEKST[c.reden] ?? c.reden, c.toelichting ? ` – ${c.toelichting}` : ""] }), _jsx(TableCell, { className: "text-xs", children: doorvoerZinnen(c.doorvoer).map((z) => _jsx("div", { children: z }, z)) }), _jsxs(TableCell, { className: "text-right space-y-1", children: [floridayOpnieuw(c.doorvoer) && (_jsxs(Button, { size: "sm", variant: "outline", disabled: opnieuwFl.isPending, onClick: () => opnieuwFl.mutate(c.id), children: [_jsx(RefreshCw, { className: "h-4 w-4 mr-2" }), "Opnieuw naar Floriday"] })), doorvoerOpnieuw(c.doorvoer) && (_jsx(Button, { size: "sm", variant: "ghost", disabled: opnieuwDoor.isPending, onClick: () => opnieuwDoor.mutate(c.id), children: "Opnieuw doorvoeren" }))] })] }, c.id))) })] }))] }), isFl && (_jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx("div", { className: "font-medium", children: "Bij Floriday" }), _jsxs("div", { className: "flex flex-wrap items-start gap-2", children: [_jsxs(Button, { size: "sm", variant: "outline", disabled: vergelijk.isPending, onClick: () => vergelijk.mutate(), children: [_jsx(Scale, { className: "h-4 w-4 mr-2" }), vergelijk.isPending ? "Vergelijken…" : "Gelijk aan Floriday?"] }), _jsx(FloridayBriefHerprint, { orderId: orderId, size: "sm" })] })] }), gelijk?.ok && (gelijk.gelijk === true ? _jsxs("p", { className: "text-sm", children: [_jsx(CheckCircle2, { className: "inline h-4 w-4 mr-1" }), "Gelijk aan Floriday."] })
|
|
74
|
+
: gelijk.gelijk == null ? _jsx("p", { className: "text-sm text-muted-foreground", children: gelijk.melding ?? "Nog niet te vergelijken." })
|
|
75
|
+
: (_jsxs("div", { className: "text-sm", children: [_jsx("p", { className: "font-medium", children: "Niet gelijk aan Floriday:" }), _jsx("ul", { className: "list-disc pl-5", children: (gelijk.verschillen ?? []).map((v, i) => (_jsxs("li", { children: [v.ladingdrager ? `Ladingdrager ${v.ladingdrager}: ` : "", VELD[v.veld] ?? v.veld, v.onze != null || v.floriday != null ? ` – bij ons ${v.onze ?? "—"}, bij Floriday ${v.floriday ?? "—"}` : ""] }, i))) })] }))), flQ.isLoading && _jsx("p", { className: "text-sm text-muted-foreground", children: "Correcties bij Floriday ophalen\u2026" }), flQ.isError && _jsx("p", { className: "text-sm text-destructive", children: "De correcties bij Floriday konden niet worden opgehaald. Probeer het opnieuw." }), flQ.data && !flQ.data.ok && _jsx("p", { className: "text-sm text-muted-foreground", children: flQ.data.melding }), flQ.data?.ok && (flQ.data.items.length === 0 ? _jsx("p", { className: "text-sm text-muted-foreground", children: "Floriday heeft geen correcties voor deze levering." }) : (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Wanneer" }), _jsx(TableHead, { children: "Wat" }), _jsx(TableHead, { children: "Door" }), _jsx(TableHead, { children: "Stand" })] }) }), _jsx(TableBody, { children: flQ.data.items.map((x) => {
|
|
76
|
+
const st = standVanKoppeling(x.status);
|
|
77
|
+
return (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "whitespace-nowrap", children: fmt(x.aangemaakt) }), _jsxs(TableCell, { children: [FL_SOORT[x.soort] ?? x.soort, x.reden ? _jsx("div", { className: "text-xs text-muted-foreground", children: x.reden }) : null] }), _jsx(TableCell, { children: x.door ?? "—" }), _jsxs(TableCell, { children: [_jsx(Badge, { variant: st === "geslaagd" ? "default" : st === "mislukt" || st === "geweigerd" ? "destructive" : "secondary", children: STAND_TEKST[st] }), x.floridayReden && _jsx("div", { className: "text-xs text-muted-foreground", children: x.floridayReden })] })] }, x.id));
|
|
78
|
+
}) })] })))] }))] })), kar && (_jsx(CorrectieDialog, { open: true, onClose: () => setKar(null), orderId: orderId, cartId: kar === "kies" ? null : kar.cartId, partijen: kar === "kies" ? undefined : kar.partijen, karren: kar === "kies" ? karren : undefined, onKlaar: ververs }))] }) }));
|
|
79
|
+
}
|
|
@@ -141,7 +141,7 @@ export function LeveringenPage() {
|
|
|
141
141
|
return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 pb-[calc(7rem+env(safe-area-inset-bottom))] sm:p-6 sm:pb-24", children: [_jsx(PageHeader, { title: "Leveringen", updatedAt: _jsx(UpdatedAt, { at: dataUpdatedAt, info: "Planning van de orders per leverdag. Klik op een dag voor de details." }), period: _jsx(PeriodPicker, { label: weekLabel(weekStart), onPrev: () => { setSelectedDay(null); setWeekStart((w) => addDays(w, -7)); }, onNext: () => { setSelectedDay(null); setWeekStart((w) => addDays(w, 7)); }, onToday: () => { setSelectedDay(null); setWeekStart(currentWeekStart()); }, todayLabel: "Deze week", isCurrent: isCurrent }) }), _jsx(NoticeStack, { children: [
|
|
142
142
|
_jsx(SignupMailMoments, { from: toDayKey(weekStart), to: toDayKey(addDays(weekStart, 6)), compact: true, notice: true }, "signup"),
|
|
143
143
|
error ? (_jsx(InlineAlert, { tone: "error", title: "De planning kon niet worden geladen", action: _jsx(Button, { size: "sm", variant: "outline", onClick: () => refetch(), children: "Opnieuw proberen" }), children: error }, "err")) : null,
|
|
144
|
-
warning && !error ? (_jsxs(InlineAlert, { tone: "warning", children: [warning, " De beschikbare orders blijven zichtbaar."] }, "warn")) : null,
|
|
144
|
+
warning && !error ? (_jsxs(InlineAlert, { tone: "warning", action: _jsx(Button, { size: "sm", variant: "outline", onClick: () => refetch(), children: "Opnieuw" }), children: [warning, " De beschikbare orders blijven zichtbaar."] }, "warn")) : null,
|
|
145
145
|
totals.nietAfgemeld > 0 ? (_jsx(InlineAlert, { tone: "warning", title: `${totals.nietAfgemeld} afgehandeld, nog niet gemeld bij Floriday`, children: "Open de dag om de belading te versturen." }, "fl")) : null,
|
|
146
146
|
] }), _jsxs(KpiRow, { children: [_jsx(KpiTile, { title: "Orders deze week", icon: _jsx(ShoppingCart, {}), loading: isLoading, value: actief.length, sub: `${totals.totaalStuks.toLocaleString("nl-NL")} stuks` }), _jsx(KpiTile, { title: "Karren", icon: _jsx(Package, {}), loading: isLoading, value: karren, sub: "volgens de orders" }), _jsx(KpiTile, { title: "Nog af te handelen", icon: _jsx(CalendarDays, {}), loading: isLoading, value: open, sub: "klik voor vandaag", onClick: () => { setHighlightOrderId(null); setDayDetailDate(today); } }), _jsx(KpiTile, { title: "Nog niet gepland", icon: _jsx(AlertTriangle, {}), loading: isLoading, value: zonderPlanning, tone: zonderPlanning ? "warning" : "default", sub: zonderPlanning ? "wacht op karindeling" : "alles ingepland" })] }), _jsx(PillTabs, { ariaLabel: "Status", value: tab, onChange: setTab, tabs: [
|
|
147
147
|
{ value: "alle", label: "Alle", icon: _jsx(List, {}), count: totals.leveringen },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NuVersturenButton.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/NuVersturenButton.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NuVersturenButton.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/NuVersturenButton.tsx"],"names":[],"mappings":"AAiBA,wFAAwF;AAExF,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,KAAsB,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,+BAuJ3G"}
|
|
@@ -8,6 +8,7 @@ import { Send, Loader2, CheckCircle2, XCircle } from "lucide-react";
|
|
|
8
8
|
import { prepareFloridayLoading, sendFloridayLoading, } from "../../lib/floridayLoading.functions.js";
|
|
9
9
|
import { platenTekst } from "../../lib/extraPlaten.js";
|
|
10
10
|
import { label as labelFor } from "../../lib/labels.js";
|
|
11
|
+
import { beoordeelSend, terugkoppelingRegel } from "../../lib/floridayTerugkoppeling.js";
|
|
11
12
|
/** "Nu versturen": toont eerst een samenvatting met controles en vraagt bevestiging. */
|
|
12
13
|
export function NuVersturenButton({ orderRef, label = "Nu versturen" }) {
|
|
13
14
|
const prepare = useServerFn(prepareFloridayLoading);
|
|
@@ -15,7 +16,7 @@ export function NuVersturenButton({ orderRef, label = "Nu versturen" }) {
|
|
|
15
16
|
const [loading, setLoading] = useState(false);
|
|
16
17
|
const [sending, setSending] = useState(false);
|
|
17
18
|
const [preview, setPreview] = useState(null);
|
|
18
|
-
const [sent, setSent] = useState(
|
|
19
|
+
const [sent, setSent] = useState(null);
|
|
19
20
|
const queryClient = useQueryClient();
|
|
20
21
|
const load = async () => setPreview(await prepare({ data: { orderRef } }));
|
|
21
22
|
const meldFout = (e, standaard) => {
|
|
@@ -43,17 +44,36 @@ export function NuVersturenButton({ orderRef, label = "Nu versturen" }) {
|
|
|
43
44
|
try {
|
|
44
45
|
const r = await send({ data: { orderRef } });
|
|
45
46
|
const results = Array.isArray(r?.results) ? r.results : [];
|
|
46
|
-
|
|
47
|
+
if (!results.length) {
|
|
48
|
+
toast.error("Er is niets verstuurd: de opdracht was leeg. Neem contact op met de beheerder.");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
let allOk = true;
|
|
52
|
+
let stand = "verstuurd";
|
|
47
53
|
for (const x of results) {
|
|
48
|
-
|
|
54
|
+
const soort = beoordeelSend(x.httpStatus, { ok: x.httpStatus === 200, code: x.code }).soort;
|
|
55
|
+
if (soort === "geaccepteerd")
|
|
49
56
|
toast.success(x.message);
|
|
57
|
+
else if (soort === "wacht_op_akkoord") {
|
|
58
|
+
toast.info(x.message);
|
|
59
|
+
stand = "wacht";
|
|
60
|
+
}
|
|
61
|
+
else if (soort === "niet_verstuurd_uit") {
|
|
62
|
+
toast.warning(x.message);
|
|
63
|
+
if (stand !== "wacht")
|
|
64
|
+
stand = "uit";
|
|
65
|
+
}
|
|
66
|
+
else if (soort === "later_opnieuw" || soort === "al_bezig" || soort === "tegengehouden") {
|
|
67
|
+
allOk = false;
|
|
68
|
+
toast.warning(x.message);
|
|
69
|
+
}
|
|
50
70
|
else {
|
|
51
71
|
allOk = false;
|
|
52
72
|
meldFout(new Error(x.message), "Versturen mislukt");
|
|
53
73
|
}
|
|
54
74
|
}
|
|
55
75
|
if (allOk) {
|
|
56
|
-
setSent(
|
|
76
|
+
setSent(stand);
|
|
57
77
|
setPreview(null);
|
|
58
78
|
void queryClient.invalidateQueries();
|
|
59
79
|
return;
|
|
@@ -69,9 +89,14 @@ export function NuVersturenButton({ orderRef, label = "Nu versturen" }) {
|
|
|
69
89
|
};
|
|
70
90
|
return (_jsxs(_Fragment, { children: [_jsxs(Button, { size: "sm", variant: "outline", onClick: open, disabled: loading, children: [loading ? _jsx(Loader2, { className: "h-3 w-3 mr-1 animate-spin" }) : _jsx(Send, { className: "h-3 w-3 mr-1" }), label] }), _jsx(AlertDialog, { open: !!preview, onOpenChange: (o) => !o && !sending && setPreview(null), children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Belading naar Floriday versturen?" }), _jsx(AlertDialogDescription, { children: "Na versturen maakt Floriday de verzendbrief, vooraanmelding en fustafrekening. Dit kun je niet terugdraaien." })] }), preview && (_jsxs("div", { className: "space-y-2 text-sm", children: [_jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: "Orders:" }), " ", preview.orderRefs.join(", ")] }), _jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: "Leveringen:" }), " ", preview.shipments.length] }), _jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: "Karren:" }), " ", preview.cartCount, preview.carriers.some((c) => c.shared) ? " (waarvan gedeeld)" : ""] }), Array.isArray(preview.carriers) && preview.carriers.length > 0 && (_jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: "Karkenmerk naar Floriday:" }), " ", _jsx("ul", { className: "mt-1 space-y-0.5", children: preview.carriers.map((c, i) => (_jsxs("li", { children: [_jsx("span", { className: "font-mono", children: c.loadCarrierReference || "—" }), " \u00B7 ", c.karTekst ?? platenTekst(c.additionalLayers)] }, (c.loadCarrierReference || "") + i))) })] })), _jsxs("div", { children: [_jsx("span", { className: "text-muted-foreground", children: "Regels:" }), " ", preview.lineCount] }), _jsx("ul", { className: "space-y-1", children: preview.orders.map((o) => (_jsxs("li", { className: "flex items-center gap-2", children: [o.controlled
|
|
71
91
|
? _jsx(CheckCircle2, { className: "h-3.5 w-3.5 text-primary" })
|
|
72
|
-
: _jsx(XCircle, { className: "h-3.5 w-3.5 text-destructive" }), _jsxs("span", { children: [o.orderRef, ": ", o.cartsControlled, " van ", o.cartsTotal, " karren goedgekeurd op de Scan-controle", o.controlled ? " — klaar voor verzending" : "", !o.controlled && o.pickStatus && o.pickStatus !== "geen_pickrij" ? ` · ${labelFor("pickStatus", o.pickStatus)}` : "", o.autoStatus ? ` · auto-verwerking: ${o.autoStatus}` : ""] })] }, o.orderRef))) }), preview.shipments.filter((sh) => sh.floridayStatus || preview.lastAttempts.some((a) => a.fulfillmentOrderId === sh.fulfillmentOrderId && (a.code === "created" || a.code === "already_fulfilled"))).map((sh) => (_jsxs("div", { className: "rounded border border-border p-2", children: ["Gemeld bij Floriday", sh.floridayStatus ? ` (Floriday: ${sh.floridayStatus})` : "", " \u00B7", " ", sh.deliveryNoteReady === true ? "verzendbrief klaar" : "verzendbrief wordt automatisch geprint"] }, sh.fulfillmentOrderId))), preview.
|
|
92
|
+
: _jsx(XCircle, { className: "h-3.5 w-3.5 text-destructive" }), _jsxs("span", { children: [o.orderRef, ": ", o.cartsControlled, " van ", o.cartsTotal, " karren goedgekeurd op de Scan-controle", o.controlled ? " — klaar voor verzending" : "", !o.controlled && o.pickStatus && o.pickStatus !== "geen_pickrij" ? ` · ${labelFor("pickStatus", o.pickStatus)}` : "", o.autoStatus ? ` · auto-verwerking: ${o.autoStatus}` : ""] })] }, o.orderRef))) }), preview.shipments.filter((sh) => sh.floridayStatus || preview.lastAttempts.some((a) => a.fulfillmentOrderId === sh.fulfillmentOrderId && (a.code === "created" || a.code === "already_fulfilled"))).map((sh) => (_jsxs("div", { className: "rounded border border-border p-2", children: ["Gemeld bij Floriday", sh.floridayStatus ? ` (Floriday: ${sh.floridayStatus})` : "", " \u00B7", " ", sh.deliveryNoteReady === true ? "verzendbrief klaar" : "verzendbrief wordt automatisch geprint"] }, sh.fulfillmentOrderId))), preview.shipments.map((sh) => {
|
|
93
|
+
if (!sh.terugkoppeling)
|
|
94
|
+
return sh.terugkoppelingFout ? _jsx("div", { className: "text-destructive", children: sh.terugkoppelingFout }, `tk-${sh.fulfillmentOrderId}`) : null;
|
|
95
|
+
const r = terugkoppelingRegel(sh.terugkoppeling);
|
|
96
|
+
return (_jsxs("div", { children: [_jsx("div", { className: r.toon === "fout" ? "text-destructive" : r.toon === "ok" ? "text-primary" : "text-foreground", children: r.tekst }), sh.terugkoppelingFout ? _jsx("div", { className: "text-destructive", children: sh.terugkoppelingFout }) : null] }, `tk-${sh.fulfillmentOrderId}`));
|
|
97
|
+
}), preview.lastAttempts.length > 0 && (_jsxs("div", { className: "rounded border border-border p-2", children: [_jsx("div", { className: "text-muted-foreground mb-1", children: "Laatste pogingen" }), preview.lastAttempts.slice(0, 4).map((a) => (_jsxs("div", { children: [fmtDayTime(a.createdAt), " \u00B7 versturen \u00B7 ", a.code === "created" || a.code === "already_fulfilled" ? "geaccepteerd" : (a.message ?? a.code)?.replace(/\s*\[[^\]]+\]$/, "")] }, a.createdAt + a.step)))] })), preview.blockers.length > 0 && (_jsx("ul", { className: "list-disc pl-5 text-destructive", children: preview.blockers.map((b) => {
|
|
73
98
|
// Begrijpelijke zin, technische code klein eronder.
|
|
74
99
|
const m = /^(.*?)\s*\[([^\]]+)\]$/s.exec(b);
|
|
75
100
|
return (_jsxs("li", { children: [m ? m[1] : b, m ? _jsx("div", { className: "text-xs text-muted-foreground", children: m[2] }) : null] }, b));
|
|
76
|
-
}) }))] })), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { disabled: sending, children: "Annuleren" }), _jsxs(Button, { onClick: doSend, disabled: !preview?.canSend || sending || sent, children: [sending ? _jsx(Loader2, { className: "h-3 w-3 mr-1 animate-spin" }) : null, sent ? "Gemeld bij Floriday" : "Versturen"] })] })] }) })] }));
|
|
101
|
+
}) }))] })), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { disabled: sending, children: "Annuleren" }), _jsxs(Button, { onClick: doSend, disabled: !preview?.canSend || sending || !!sent, children: [sending ? _jsx(Loader2, { className: "h-3 w-3 mr-1 animate-spin" }) : null, sent === "wacht" ? "Wacht op akkoord" : sent === "uit" ? "Niet verstuurd (uit)" : sent ? "Gemeld bij Floriday" : "Versturen"] })] })] }) })] }));
|
|
77
102
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** In de controle: orderverloop, documenten en kar-tekening uit de Engine (alleen lezen, plus CMR opnieuw printen). */
|
|
2
|
+
export declare function OrderInzicht({ orderId, cartId }: {
|
|
3
|
+
orderId: string;
|
|
4
|
+
cartId?: string | null;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=OrderInzicht.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderInzicht.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/OrderInzicht.tsx"],"names":[],"mappings":"AAwBA,uHAAuH;AACvH,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,+BAwI5F"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { Badge, Button, toast } from "@flowselections/core";
|
|
4
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { AlertTriangle, CheckCircle2, Circle, Printer } from "lucide-react";
|
|
6
|
+
import { supabase } from "../../integrations/supabase/moduleClient.js";
|
|
7
|
+
import { leesCmrMelding, leesDocumenten, leesTijdlijn, veiligeSvg } from "../../lib/orderInzicht.js";
|
|
8
|
+
const tijdNl = (iso) => {
|
|
9
|
+
if (!iso)
|
|
10
|
+
return null;
|
|
11
|
+
const d = new Date(iso);
|
|
12
|
+
return Number.isNaN(d.getTime()) ? null
|
|
13
|
+
: d.toLocaleString("nl-NL", { timeZone: "Europe/Amsterdam", weekday: "short", day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" });
|
|
14
|
+
};
|
|
15
|
+
const KLEUR = { groen: "default", oranje: "destructive", grijs: "outline" };
|
|
16
|
+
function SvgTekening({ svg, titel }) {
|
|
17
|
+
const veilig = useMemo(() => veiligeSvg(svg), [svg]);
|
|
18
|
+
if (!veilig)
|
|
19
|
+
return _jsx("div", { className: "text-xs text-muted-foreground", children: "Tekening niet beschikbaar." });
|
|
20
|
+
return _jsx("div", { role: "img", "aria-label": titel, className: "w-full [&_svg]:h-auto [&_svg]:w-full", dangerouslySetInnerHTML: { __html: veilig } });
|
|
21
|
+
}
|
|
22
|
+
/** In de controle: orderverloop, documenten en kar-tekening uit de Engine (alleen lezen, plus CMR opnieuw printen). */
|
|
23
|
+
export function OrderInzicht({ orderId, cartId }) {
|
|
24
|
+
const qc = useQueryClient();
|
|
25
|
+
const tijdlijnQ = useQuery({
|
|
26
|
+
queryKey: ["logistics-order-tijdlijn", orderId],
|
|
27
|
+
queryFn: async () => {
|
|
28
|
+
const { data, error } = await supabase.rpc("logistics_order_tijdlijn", { p_order_id: orderId });
|
|
29
|
+
if (error)
|
|
30
|
+
throw new Error(error.message);
|
|
31
|
+
return leesTijdlijn(data);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const docsQ = useQuery({
|
|
35
|
+
queryKey: ["logistics-order-documenten", orderId],
|
|
36
|
+
queryFn: async () => {
|
|
37
|
+
const { data, error } = await supabase.rpc("logistics_order_documenten", { p_order_id: orderId });
|
|
38
|
+
if (error)
|
|
39
|
+
throw new Error(error.message);
|
|
40
|
+
return leesDocumenten(data);
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const tekeningQ = useQuery({
|
|
44
|
+
queryKey: ["logistics-kar-tekening-v2", orderId],
|
|
45
|
+
queryFn: async () => {
|
|
46
|
+
const { data, error } = await supabase.rpc("logistics_kar_tekening_v2", { p_order_id: orderId, p_variant: "scherm", p_opties: {} });
|
|
47
|
+
if (error)
|
|
48
|
+
throw new Error(error.message);
|
|
49
|
+
return (data ?? {});
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
// Open CMR-melding van deze zending (bv. geen printer op de printplek), bewaard door afh_cmr_printen.
|
|
53
|
+
const cmrMeldingQ = useQuery({
|
|
54
|
+
queryKey: ["afh-cmr-melding", orderId],
|
|
55
|
+
queryFn: async () => {
|
|
56
|
+
const { data, error } = await supabase.rpc("afh_cmr_melding", { p_order_id: orderId });
|
|
57
|
+
if (error)
|
|
58
|
+
throw new Error(error.message);
|
|
59
|
+
return leesCmrMelding(data);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
const cmrM = useMutation({
|
|
63
|
+
mutationFn: async () => {
|
|
64
|
+
const { data, error } = await supabase.rpc("afh_cmr_printen", { p_order_id: orderId, p_herprint: true });
|
|
65
|
+
if (error)
|
|
66
|
+
throw new Error(error.message);
|
|
67
|
+
return data;
|
|
68
|
+
},
|
|
69
|
+
onSuccess: (r) => {
|
|
70
|
+
(r?.ok ? toast.success : toast.error)(r?.melding ?? (r?.ok ? "CMR is naar de printer gestuurd." : "CMR niet geprint."));
|
|
71
|
+
void qc.invalidateQueries({ queryKey: ["logistics-order-documenten", orderId] });
|
|
72
|
+
void qc.invalidateQueries({ queryKey: ["afh-cmr-melding", orderId] });
|
|
73
|
+
void qc.invalidateQueries({ queryKey: ["afh-cmr-aandacht"] });
|
|
74
|
+
},
|
|
75
|
+
onError: (e) => { console.error("[cmr]", e); toast.error("CMR printen is niet gelukt. Probeer het opnieuw of neem contact op met de beheerder."); },
|
|
76
|
+
});
|
|
77
|
+
const t = tijdlijnQ.data;
|
|
78
|
+
const docs = docsQ.data;
|
|
79
|
+
const tek = tekeningQ.data;
|
|
80
|
+
return (_jsxs("div", { className: "space-y-4 border-t pt-3", children: [_jsxs("section", { className: "space-y-2", children: [_jsx("div", { className: "text-sm font-medium", children: "Orderverloop" }), tijdlijnQ.isLoading ? _jsx("p", { className: "text-sm text-muted-foreground", children: "Laden\u2026" })
|
|
81
|
+
: tijdlijnQ.isError || !t?.ok ? _jsx("p", { className: "text-sm text-destructive", children: t?.reden ?? "Het orderverloop kon niet worden opgehaald." })
|
|
82
|
+
: (_jsx("ol", { className: "flex flex-wrap gap-x-4 gap-y-2", children: t.stappen.map((s) => (_jsxs("li", { className: "flex items-start gap-1.5 text-sm", title: s.reden ?? undefined, children: [s.klaar ? _jsx(CheckCircle2, { className: "mt-0.5 h-4 w-4 text-primary", "aria-label": "klaar" }) : _jsx(Circle, { className: "mt-0.5 h-4 w-4 text-muted-foreground", "aria-label": "nog niet" }), _jsxs("span", { children: [_jsx("span", { className: s.klaar ? "font-medium" : "text-muted-foreground", children: s.naam }), tijdNl(s.tijd) && _jsx("span", { className: "block text-xs text-muted-foreground", children: tijdNl(s.tijd) })] })] }, s.stap))) })), t?.floriday && _jsx(Badge, { variant: KLEUR[t.floriday.kleur] ?? "outline", children: t.floriday.tekst })] }), _jsxs("section", { className: "space-y-2", children: [_jsx("div", { className: "text-sm font-medium", children: "Documenten" }), docsQ.isLoading ? _jsx("p", { className: "text-sm text-muted-foreground", children: "Laden\u2026" })
|
|
83
|
+
: docsQ.isError || !docs ? _jsx("p", { className: "text-sm text-destructive", children: "De documenten van deze order konden niet worden opgehaald." })
|
|
84
|
+
: (_jsx("ul", { className: "space-y-1 text-sm", children: docs.map((d) => (_jsxs("li", { className: "flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "font-medium", children: d.naam }), _jsxs("span", { className: d.status === "mislukt" || d.status === "geen_layout" || d.status === "geblokkeerd" ? "text-destructive" : "text-muted-foreground", children: [d.statusTekst, d.printplek ? ` · ${d.printplek}` : ""] }), d.printplekReden && _jsx("span", { className: "text-destructive", children: d.printplekReden }), d.document === "cmr" && cmrMeldingQ.data && (_jsxs("span", { className: "flex items-center gap-1 text-destructive", children: [_jsx(AlertTriangle, { className: "h-4 w-4" }), cmrMeldingQ.data.melding] })), d.document === "cmr" && (_jsxs(Button, { size: "sm", variant: "outline", disabled: cmrM.isPending, onClick: () => cmrM.mutate(), children: [_jsx(Printer, { className: "h-4 w-4 mr-2" }), d.status === "geprint" ? "CMR opnieuw printen" : "CMR printen"] }))] }, d.document))) }))] }), _jsxs("section", { className: "space-y-2", children: [_jsx("div", { className: "text-sm font-medium", children: "Kar-tekening" }), tekeningQ.isLoading ? _jsx("p", { className: "text-sm text-muted-foreground", children: "Laden\u2026" })
|
|
85
|
+
: tekeningQ.isError || !tek?.ok ? _jsx("p", { className: "text-sm text-destructive", children: tek?.reden ?? "De kar-tekening kon niet worden opgehaald." })
|
|
86
|
+
: (_jsxs(_Fragment, { children: [(tek.meldingen ?? []).filter((m) => typeof m === "string").map((m) => (_jsx("p", { className: "text-sm text-muted-foreground", children: m }, m))), (tek.dragers ?? []).length === 0 ? _jsx("p", { className: "text-sm text-muted-foreground", children: "Geen ladingdragers bekend." }) : (_jsx("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4", children: (tek.dragers ?? []).map((d, i) => {
|
|
87
|
+
const deze = Boolean(cartId && d.id === cartId);
|
|
88
|
+
return (_jsxs("div", { className: `rounded-md border p-2 space-y-1 ${deze ? "border-primary ring-1 ring-primary" : ""}`, children: [_jsxs("div", { className: "flex items-center justify-between gap-1 text-xs", children: [_jsx("span", { className: "font-medium", children: d.label ?? d.naam ?? "Ladingdrager" }), deze && _jsx(Badge, { variant: "default", children: "Deze kar" })] }), d.svg ? _jsx(SvgTekening, { svg: d.svg, titel: d.label ?? "Ladingdrager" }) : _jsx("div", { className: "text-xs text-muted-foreground", children: "Geen tekening." }), d.markering_reden && (_jsxs("p", { className: "flex items-center gap-1 text-xs text-destructive", children: [_jsx(AlertTriangle, { className: "h-3 w-3" }), d.markering_reden] }))] }, d.id ?? i));
|
|
89
|
+
}) }))] }))] })] }));
|
|
90
|
+
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
/** Hier stel je de printplek en printers van de controle in (Layout-maker). */
|
|
2
|
+
export declare const PRINTPLEKKEN_PAD = "/layouts-printers/printplekken";
|
|
1
3
|
export declare function ScanControleView(): import("react").JSX.Element;
|
|
2
4
|
//# sourceMappingURL=ScanControleView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScanControleView.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/ScanControleView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScanControleView.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/ScanControleView.tsx"],"names":[],"mappings":"AA6CA,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,mCAAmC,CAAC;AAmEjE,wBAAgB,gBAAgB,gCAke/B"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { label } from "../../lib/labels.js";
|
|
4
4
|
import { supabase } from "../../integrations/supabase/moduleClient.js";
|
|
5
5
|
import { Button, Badge, Card, Input, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, toast, } from "@flowselections/core";
|
|
6
|
-
import { AlertTriangle, CheckCircle2, RefreshCw, ScanLine } from "lucide-react";
|
|
6
|
+
import { AlertTriangle, Camera, CheckCircle2, PencilLine, Printer, RefreshCw, ScanLine } from "lucide-react";
|
|
7
|
+
import { CameraScanner } from "./CameraScanner.js";
|
|
8
|
+
import { CorrectieDialog } from "./CorrectieDialog.js";
|
|
7
9
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
10
|
+
import { FloridayBriefHerprint } from "./FloridayBriefHerprint.js";
|
|
11
|
+
import { OrderInzicht } from "./OrderInzicht.js";
|
|
12
|
+
import { goedkeurMelding } from "../../lib/orderInzicht.js";
|
|
13
|
+
import { goedkeurFout, kloptNietUitkomst } from "../../lib/controleAfwijking.js";
|
|
14
|
+
/** Hier stel je de printplek en printers van de controle in (Layout-maker). */
|
|
15
|
+
export const PRINTPLEKKEN_PAD = "/layouts-printers/printplekken";
|
|
8
16
|
const AFGEROND_STATUS = "geprint";
|
|
9
17
|
function statusVariant(status) {
|
|
10
18
|
if (status === AFGEROND_STATUS)
|
|
@@ -27,6 +35,10 @@ export function ScanControleView() {
|
|
|
27
35
|
const [barcode, setBarcode] = useState("");
|
|
28
36
|
const [lookup, setLookup] = useState(null);
|
|
29
37
|
const inputRef = useRef(null);
|
|
38
|
+
const [camera, setCamera] = useState(false);
|
|
39
|
+
const [correctie, setCorrectie] = useState(false);
|
|
40
|
+
// Beslismoment 6 staat uit en de controleur meldt dat de kar niet klopt: goedkeuren pas na opnieuw scannen.
|
|
41
|
+
const [klopNiet, setKlopNiet] = useState(false);
|
|
30
42
|
const settingsQ = useQuery({
|
|
31
43
|
queryKey: ["logistics-control-settings"],
|
|
32
44
|
queryFn: async () => {
|
|
@@ -38,33 +50,18 @@ export function ScanControleView() {
|
|
|
38
50
|
});
|
|
39
51
|
const settings = settingsQ.data;
|
|
40
52
|
const scannerId = settings?.scannerId ?? null;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const postKlaar = Boolean(scannerId && (printerId || !printerNodig));
|
|
45
|
-
const ontbreekt = [
|
|
46
|
-
!scannerId ? "Er is nog geen scanner gekozen voor de controlepost." : null,
|
|
47
|
-
printerNodig && !printerId ? "Er is nog geen printer gekozen voor de controlepost." : null,
|
|
48
|
-
].filter(Boolean);
|
|
49
|
-
// Welke printer kreeg de laatste Floriday-verzendbrief (route "verzendbrief bij pakbon", printregel van de printplek).
|
|
50
|
-
const briefQ = useQuery({
|
|
51
|
-
queryKey: ["laatste-verzendbrief-printer"],
|
|
53
|
+
// Printen gebeurt op de printplek van de controle uit Printen › Printplekken; Afhandeling kiest of bewaart geen printer.
|
|
54
|
+
const plekQ = useQuery({
|
|
55
|
+
queryKey: ["afh-controleplek"],
|
|
52
56
|
queryFn: async () => {
|
|
53
|
-
const { data } = await supabase
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
.eq("herkomst", "floriday")
|
|
58
|
-
.order("created_at", { ascending: false })
|
|
59
|
-
.limit(1)
|
|
60
|
-
.maybeSingle();
|
|
61
|
-
if (!data)
|
|
62
|
-
return null;
|
|
63
|
-
const k = data.printer_keuze ?? {};
|
|
64
|
-
const regels = Array.isArray(k.regels) ? k.regels : [];
|
|
65
|
-
return { printer: typeof k.printer_naam === "string" ? k.printer_naam : null, regel: typeof regels[0] === "string" ? regels[0] : null };
|
|
57
|
+
const { data, error } = await supabase.rpc("afh_controleplek");
|
|
58
|
+
if (error)
|
|
59
|
+
throw new Error(error.message);
|
|
60
|
+
return (data ?? {});
|
|
66
61
|
},
|
|
67
62
|
});
|
|
63
|
+
const postKlaar = Boolean(scannerId);
|
|
64
|
+
const ontbreekt = [!scannerId ? "Er is nog geen scanner gekozen voor de controlepost." : null].filter(Boolean);
|
|
68
65
|
const overviewQ = useQuery({
|
|
69
66
|
queryKey: ["logistics-control-scan-overview", scannerId],
|
|
70
67
|
enabled: Boolean(scannerId),
|
|
@@ -112,7 +109,6 @@ export function ScanControleView() {
|
|
|
112
109
|
const { data, error } = await supabase.rpc("logistics_control_scan_approve", {
|
|
113
110
|
p_barcode: vars.code,
|
|
114
111
|
p_scanner_id: scannerId ?? undefined,
|
|
115
|
-
p_printer_id: printerId ?? undefined,
|
|
116
112
|
p_allow_reprint: vars.allowReprint,
|
|
117
113
|
});
|
|
118
114
|
if (error)
|
|
@@ -122,19 +118,100 @@ export function ScanControleView() {
|
|
|
122
118
|
onSuccess: (res) => {
|
|
123
119
|
void qc.invalidateQueries({ queryKey: ["logistics-control-scan-overview"] });
|
|
124
120
|
if (!res.ok) {
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
const fout = goedkeurFout(res);
|
|
122
|
+
if (fout.kloptNiet) {
|
|
123
|
+
// De database weigert: er staat een melding "Kar klopt niet" open. Kar blijft zichtbaar, blokkade aan.
|
|
124
|
+
setKlopNiet(true);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
setLookup((prev) => (prev ? { ...prev, ...res } : res));
|
|
128
|
+
}
|
|
129
|
+
toast.error(fout.tekst);
|
|
127
130
|
return;
|
|
128
131
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
// Documenten na goedkeuren (afleverbrief eigen order, CMR bij export) volgens de Engine-documentenlijst; geen Engine-printopdracht nodig.
|
|
133
|
+
const orderId = res.orderId ?? lookup?.orderId ?? null;
|
|
134
|
+
if (!orderId) {
|
|
135
|
+
toast.error("Goedgekeurd, maar de order is onbekend; afleverbrief en CMR zijn niet geprint. Neem contact op met de beheerder.");
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
void (async () => {
|
|
139
|
+
const { data, error } = await supabase.rpc("afh_documenten_na_goedkeuren", {
|
|
140
|
+
p_order_id: orderId, p_cart_id: res.cart?.cartId ?? lookup?.cart?.cartId ?? null,
|
|
141
|
+
});
|
|
142
|
+
if (error)
|
|
143
|
+
throw new Error(error.message);
|
|
144
|
+
return data;
|
|
145
|
+
})()
|
|
146
|
+
.then((d) => {
|
|
147
|
+
const m = goedkeurMelding(d);
|
|
148
|
+
(m.fout ? toast.error : toast.success)(m.tekst);
|
|
149
|
+
void qc.invalidateQueries({ queryKey: ["afh-cmr-aandacht"] });
|
|
150
|
+
void qc.invalidateQueries({ queryKey: ["afh-cmr-melding", orderId] });
|
|
151
|
+
})
|
|
152
|
+
.catch((e) => { console.error("[documenten na goedkeuren]", e); toast.error("Goedgekeurd, maar de documenten zijn niet geprint. Print ze opnieuw of neem contact op met de beheerder."); });
|
|
153
|
+
}
|
|
132
154
|
setLookup(null);
|
|
133
155
|
setBarcode("");
|
|
134
156
|
inputRef.current?.focus();
|
|
135
157
|
},
|
|
136
158
|
onError: (err) => toast.error(err.message),
|
|
137
159
|
});
|
|
160
|
+
// Koppelprompt #36: "Kar klopt niet" vastleggen bij de Engine; de database weigert dan goedkeuren (stand uit).
|
|
161
|
+
const klopNietM = useMutation({
|
|
162
|
+
mutationFn: async (v) => {
|
|
163
|
+
const { data, error } = await supabase.rpc("logistics_control_klopt_niet", { p_barcode: v.code, p_reden: v.reden });
|
|
164
|
+
if (error)
|
|
165
|
+
throw new Error(error.message);
|
|
166
|
+
return (data ?? null);
|
|
167
|
+
},
|
|
168
|
+
onSuccess: (res) => {
|
|
169
|
+
const u = kloptNietUitkomst(res);
|
|
170
|
+
if (!u.vastgelegd)
|
|
171
|
+
console.error("[kar klopt niet] niet vastgelegd", res);
|
|
172
|
+
setKlopNiet(u.blokkeer);
|
|
173
|
+
(u.vastgelegd ? toast.info : toast.error)(u.tekst);
|
|
174
|
+
},
|
|
175
|
+
onError: (err) => {
|
|
176
|
+
console.error("[kar klopt niet]", err);
|
|
177
|
+
setKlopNiet(true);
|
|
178
|
+
toast.error(kloptNietUitkomst(null).tekst);
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
// Kar opnieuw gescand: open melding "Kar klopt niet" afhandelen bij de Engine.
|
|
182
|
+
const opnieuwM = useMutation({
|
|
183
|
+
mutationFn: async (code) => {
|
|
184
|
+
const { data, error } = await supabase.rpc("logistics_control_opnieuw_gescand", { p_barcode: code });
|
|
185
|
+
if (error)
|
|
186
|
+
throw new Error(error.message);
|
|
187
|
+
return (data ?? null);
|
|
188
|
+
},
|
|
189
|
+
onSuccess: (res) => {
|
|
190
|
+
if (!res || res.ok !== true) {
|
|
191
|
+
console.error("[kar opnieuw gescand]", res);
|
|
192
|
+
setKlopNiet(true);
|
|
193
|
+
toast.error(`Het opnieuw scannen is niet vastgelegd${res?.reden || res?.error ? `: ${res.reden ?? res.error}` : ""}. Scan de kar nog een keer.`);
|
|
194
|
+
}
|
|
195
|
+
else if ((res.afgehandeld ?? 0) > 0) {
|
|
196
|
+
toast.success('De melding "Kar klopt niet" is afgehandeld. Je kunt de kar nu goedkeuren.');
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
onError: (err) => {
|
|
200
|
+
console.error("[kar opnieuw gescand]", err);
|
|
201
|
+
setKlopNiet(true);
|
|
202
|
+
toast.error("Het opnieuw scannen is niet vastgelegd. Scan de kar nog een keer of neem contact op met de beheerder.");
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
const briefM = useMutation({
|
|
206
|
+
mutationFn: async (v) => {
|
|
207
|
+
if (!v.orderId)
|
|
208
|
+
return { ok: false, melding: "Order onbekend; de afleverbrief is niet geprint." };
|
|
209
|
+
const { data, error } = await supabase.rpc("afh_afleverbrief_printen", { p_order_id: v.orderId, p_cart_id: v.cartId, p_herprint: v.herprint });
|
|
210
|
+
if (error)
|
|
211
|
+
throw new Error(error.message);
|
|
212
|
+
return data;
|
|
213
|
+
},
|
|
214
|
+
});
|
|
138
215
|
const retryM = useMutation({
|
|
139
216
|
mutationFn: async (id) => {
|
|
140
217
|
const { data, error } = await supabase.rpc("logistics_control_scan_retry", { _id: id });
|
|
@@ -151,7 +228,7 @@ export function ScanControleView() {
|
|
|
151
228
|
},
|
|
152
229
|
onError: (err) => toast.error(err.message),
|
|
153
230
|
});
|
|
154
|
-
const bezig = lookupM.isPending || approveM.isPending;
|
|
231
|
+
const bezig = lookupM.isPending || approveM.isPending || opnieuwM.isPending || klopNietM.isPending;
|
|
155
232
|
const rows = overviewQ.data ?? [];
|
|
156
233
|
const stats = useMemo(() => ({
|
|
157
234
|
totaal: rows.length,
|
|
@@ -164,23 +241,27 @@ export function ScanControleView() {
|
|
|
164
241
|
if (!c || !postKlaar)
|
|
165
242
|
return;
|
|
166
243
|
setLookup(null);
|
|
167
|
-
|
|
244
|
+
setKlopNiet(false);
|
|
245
|
+
// Echte scan (invoer of camera) = kar opnieuw gescand: daarna de Engine laten weten dat een open melding vervalt.
|
|
246
|
+
lookupM.mutate(c, { onSuccess: (res) => { if (res.ok)
|
|
247
|
+
opnieuwM.mutate(res.barcode ?? c); } });
|
|
168
248
|
}
|
|
169
249
|
if (settingsQ.isLoading) {
|
|
170
250
|
return _jsx("div", { className: "text-sm text-muted-foreground", children: "Controlepost laden\u2026" });
|
|
171
251
|
}
|
|
172
252
|
if (!postKlaar) {
|
|
173
|
-
return (_jsx(Card, { className: "p-4 border-destructive/40 bg-destructive/10", children: _jsxs("div", { className: "flex items-start gap-2 text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), _jsxs("div", { className: "text-sm", children: [_jsx("div", { className: "font-medium", children: "Controlepost nog niet ingesteld" }), ontbreekt.map((t) => _jsx("p", { children: t }, t)), _jsx("a", { href:
|
|
253
|
+
return (_jsx(Card, { className: "p-4 border-destructive/40 bg-destructive/10", children: _jsxs("div", { className: "flex items-start gap-2 text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), _jsxs("div", { className: "text-sm", children: [_jsx("div", { className: "font-medium", children: "Controlepost nog niet ingesteld" }), ontbreekt.map((t) => _jsx("p", { children: t }, t)), _jsx("a", { href: PRINTPLEKKEN_PAD, className: "underline font-medium", children: "Controlepost instellen" })] })] }) }));
|
|
174
254
|
}
|
|
175
255
|
const cart = lookup?.cart ?? null;
|
|
176
|
-
return (_jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "text-sm text-muted-foreground", children: ["
|
|
177
|
-
? _jsxs(_Fragment, { children: ["printer ", briefQ.data.printer, " (automatisch na acceptatie door Floriday", briefQ.data.regel ? ` · ${briefQ.data.regel}` : "", ")"] })
|
|
178
|
-
: "printer voor de verzendbrief onbekend", settings?.printsShippingNote === false ? " · de controlepost print zelf geen verzendbrief" : ""] }), _jsxs(Card, { className: "p-4 space-y-3", children: [_jsxs("form", { className: "flex gap-2", onSubmit: (e) => {
|
|
256
|
+
return (_jsxs("div", { className: "space-y-4", children: [plekQ.isError ? (_jsxs("div", { className: "flex items-start gap-2 text-sm text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), _jsxs("span", { children: ["De printplek van de controle kon niet worden gelezen.", " ", _jsx("button", { type: "button", className: "underline font-medium", onClick: () => void plekQ.refetch(), children: "Opnieuw" })] })] })) : plekQ.data && !plekQ.data.ok ? (_jsxs("div", { className: "flex items-start gap-2 text-sm text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), _jsxs("span", { children: [plekQ.data.reden || "Er is geen printplek voor de controle.", " ", _jsx("a", { href: PRINTPLEKKEN_PAD, className: "underline font-medium", children: "Naar Printen \u203A Printplekken" })] })] })) : plekQ.data?.ok ? (_jsxs("div", { className: "text-sm text-muted-foreground", children: [_jsx(Printer, { className: "mr-1 inline h-4 w-4", "aria-hidden": true }), "Printplek controle: ", _jsx("span", { className: "font-medium text-foreground", children: plekQ.data.naam || "onbekend" }), " ", "\u00B7 afleverbrief, CMR en Floriday-verzendbrief printen hier \u00B7", " ", _jsx("a", { href: PRINTPLEKKEN_PAD, className: "underline", children: "wijzigen in Printen \u203A Printplekken" })] })) : null, _jsxs(Card, { className: "p-4 space-y-3", children: [_jsxs("form", { className: "flex gap-2", onSubmit: (e) => {
|
|
179
257
|
e.preventDefault();
|
|
180
258
|
scan(barcode);
|
|
181
|
-
}, children: [_jsx(Input, { ref: inputRef, autoFocus: true, value: barcode, onChange: (e) => setBarcode(e.target.value), placeholder: "Scan de barcode op de pakbon\u2026", disabled: bezig }), _jsxs(Button, { type: "submit", disabled: bezig || !barcode.trim(), children: [_jsx(ScanLine, { className: "h-4 w-4 mr-2" }), lookupM.isPending ? "Zoeken…" : "Opzoeken"] })] }), lookup && !lookup.ok && (_jsx("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive", children: lookup.error ?? "Deze barcode is niet herkend." })), lookup?.ok && (_jsxs("div", { className: "rounded-md border p-3 space-y-3", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "font-semibold", children: lookup.order?.orderNumber ?? "—" }), _jsx(Badge, { variant: lookup.isFloriday ? "default" : "outline", children: lookup.isFloriday ? "Floriday-order (FO)" : "Eigen order" }), _jsx(Badge, { variant: "secondary", children: cart?.cartLabel ?? "Kar onbekend" }), lookup.alreadyControlled && (_jsxs(Badge, { variant: "destructive", children: ["Al gecontroleerd \u2014 ", lookup.scan?.status] }))] }), _jsxs("div", { className: "text-sm text-muted-foreground", children: [lookup.order?.customerName ?? "—", cart?.cartNumber ? ` · karnummer ${cart.cartNumber}` : "", typeof cart?.occupancyPct === "number" ? ` · ${Math.round(cart.occupancyPct)}% vol` : ""] }), _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Product" }), _jsx(TableHead, { className: "text-right", children: "Fusten" }), _jsx(TableHead, { className: "text-right", children: "Aantal" })] }) }), _jsx(TableBody, { children: (cart?.items ?? []).length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, className: "text-sm text-muted-foreground", children: "Geen belading gevonden op deze kar." }) })) : ((cart?.items ?? []).map((it, i) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: it.productName ?? "—" }), _jsx(TableCell, { className: "text-right", children: it.crates ?? "—" }), _jsx(TableCell, { className: "text-right", children: it.quantity ?? "—" })] }, it.itemId ?? i)))) })] }), _jsxs("div", { className: "flex gap-2", children: [_jsxs(Button, { disabled: approveM.isPending, onClick: () => approveM.mutate({ code: lookup.barcode ?? barcode, allowReprint: false }), children: [_jsx(CheckCircle2, { className: "h-4 w-4 mr-2" }), approveM.isPending ? "Bezig…" : "Goedkeuren"] }), lookup.alreadyControlled && (_jsx(Button, { variant: "outline", disabled:
|
|
259
|
+
}, children: [_jsx(Input, { ref: inputRef, autoFocus: true, value: barcode, onChange: (e) => setBarcode(e.target.value), placeholder: "Scan de barcode op de pakbon\u2026", disabled: bezig }), _jsx(Button, { type: "button", variant: "outline", disabled: bezig, onClick: () => setCamera(true), "aria-label": "Scan met de camera", children: _jsx(Camera, { className: "h-4 w-4" }) }), _jsxs(Button, { type: "submit", disabled: bezig || !barcode.trim(), children: [_jsx(ScanLine, { className: "h-4 w-4 mr-2" }), lookupM.isPending ? "Zoeken…" : "Opzoeken"] })] }), lookup && !lookup.ok && (_jsx("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive", children: lookup.error ?? "Deze barcode is niet herkend." })), lookup?.ok && (_jsxs("div", { className: "rounded-md border p-3 space-y-3", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "font-semibold", children: lookup.order?.orderNumber ?? "—" }), _jsx(Badge, { variant: lookup.isFloriday ? "default" : "outline", children: lookup.isFloriday ? "Floriday-order (FO)" : "Eigen order" }), _jsx(Badge, { variant: "secondary", children: cart?.cartLabel ?? "Kar onbekend" }), lookup.alreadyControlled && (_jsxs(Badge, { variant: "destructive", children: ["Al gecontroleerd \u2014 ", lookup.scan?.status] }))] }), _jsxs("div", { className: "text-sm text-muted-foreground", children: [lookup.order?.customerName ?? "—", cart?.cartNumber ? ` · karnummer ${cart.cartNumber}` : "", typeof cart?.occupancyPct === "number" ? ` · ${Math.round(cart.occupancyPct)}% vol` : ""] }), _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Product" }), _jsx(TableHead, { className: "text-right", children: "Fusten" }), _jsx(TableHead, { className: "text-right", children: "Aantal" })] }) }), _jsx(TableBody, { children: (cart?.items ?? []).length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, className: "text-sm text-muted-foreground", children: "Geen belading gevonden op deze kar." }) })) : ((cart?.items ?? []).map((it, i) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: it.productName ?? "—" }), _jsx(TableCell, { className: "text-right", children: it.crates ?? "—" }), _jsx(TableCell, { className: "text-right", children: it.quantity ?? "—" })] }, it.itemId ?? i)))) })] }), klopNiet && (_jsxs("div", { className: "flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), _jsx("span", { children: "Goedkeuren kan pas als de kar klopt. Laad de ontbrekende fusten bij en scan de kar opnieuw." })] })), _jsxs("div", { className: "flex gap-2", children: [_jsxs(Button, { disabled: approveM.isPending || opnieuwM.isPending || klopNietM.isPending || klopNiet, onClick: () => approveM.mutate({ code: lookup.barcode ?? barcode, allowReprint: false }), children: [_jsx(CheckCircle2, { className: "h-4 w-4 mr-2" }), approveM.isPending ? "Bezig…" : "Goedkeuren"] }), lookup.alreadyControlled && lookup.isFloriday && lookup.orderId && (_jsx(FloridayBriefHerprint, { orderId: lookup.orderId })), lookup.alreadyControlled && !lookup.isFloriday && (_jsxs(Button, { variant: "outline", disabled: briefM.isPending, onClick: () => briefM.mutateAsync({ orderId: lookup.orderId ?? null, cartId: lookup.cart?.cartId ?? null, herprint: true })
|
|
260
|
+
.then((b) => (b.ok === false ? toast.error(b.melding ?? "Opnieuw printen is niet gelukt.") : toast.success(b.melding ?? "Opnieuw geprint.")))
|
|
261
|
+
.catch((e) => { console.error("[afleverbrief]", e); toast.error("Opnieuw printen is niet gelukt. Probeer het opnieuw."); }), children: [_jsx(Printer, { className: "h-4 w-4 mr-2" }), "Afleverbrief opnieuw printen"] })), lookup.orderId && (_jsxs(Button, { variant: "outline", onClick: () => setCorrectie(true), children: [_jsx(PencilLine, { className: "h-4 w-4 mr-2" }), "Corrigeren"] })), _jsx(Button, { variant: "ghost", disabled: approveM.isPending, onClick: () => {
|
|
182
262
|
setLookup(null);
|
|
263
|
+
setKlopNiet(false);
|
|
183
264
|
setBarcode("");
|
|
184
265
|
inputRef.current?.focus();
|
|
185
|
-
}, children: "Annuleren" })] })] }))] }), _jsxs("div", { className: "flex flex-wrap gap-3", children: [_jsxs(Card, { className: "p-3", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Gescand vandaag" }), _jsx("div", { className: "text-2xl font-semibold", children: stats.totaal })] }), _jsxs(Card, { className: "p-3", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Geprint" }), _jsx("div", { className: "text-2xl font-semibold", children: stats.geprint })] }), _jsxs(Card, { className: "p-3", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "In behandeling" }), _jsx("div", { className: "text-2xl font-semibold", children: stats.wacht })] }), _jsxs(Card, { className: "p-3", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Mislukt" }), _jsx("div", { className: "text-2xl font-semibold", children: stats.mislukt })] })] }), _jsx(Card, { className: "p-0 overflow-hidden", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Ordernummer" }), _jsx(TableHead, { children: "Soort" }), _jsx(TableHead, { children: "Status" }), _jsx(TableHead, { children: "Melding" }), _jsx(TableHead, { children: "Bijgewerkt" }), _jsx(TableHead, {})] }) }), _jsx(TableBody, { children: overviewQ.isLoading ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 6, className: "text-sm text-muted-foreground", children: "Laden\u2026" }) })) : rows.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 6, className: "text-sm text-muted-foreground", children: "Vandaag nog niets gescand." }) })) : (rows.map((r) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: r.orderNumber ?? "—" }), _jsx(TableCell, { children: r.isFloriday ? "FO" : "Eigen" }), _jsx(TableCell, { children: _jsx(Badge, { variant: statusVariant(r.status), children: label("scanStatus", r.status) }) }), _jsx(TableCell, { className: "text-sm text-muted-foreground", children: r.error ?? "—" }), _jsx(TableCell, { children: tijd(r.updatedAt) }), _jsx(TableCell, { className: "text-right", children: r.status === "mislukt" && (_jsxs(Button, { size: "sm", variant: "outline", disabled: retryM.isPending, onClick: () => retryM.mutate(r.id), children: [_jsx(RefreshCw, { className: "h-4 w-4 mr-2" }), "Opnieuw proberen"] })) })] }, r.id)))) })] }) })] }));
|
|
266
|
+
}, children: "Annuleren" })] }), lookup.orderId && _jsx(OrderInzicht, { orderId: lookup.orderId, cartId: lookup.cart?.cartId ?? null })] }))] }), _jsx(CameraScanner, { open: camera, onClose: () => setCamera(false), onScan: (c) => { setBarcode(c); scan(c); } }), correctie && lookup?.orderId && (_jsx(CorrectieDialog, { open: true, onClose: () => setCorrectie(false), orderId: lookup.orderId, cartId: lookup.cart?.cartId ?? null, partijen: (lookup.cart?.items ?? []).filter((i) => i.orderItemId && i.belongsToOrder !== false).map((i) => ({ orderItemId: i.orderItemId, naam: i.productName ?? "Partij", fusten: i.crates ?? 0 })), onKlaar: () => lookupM.mutate(lookup.barcode ?? barcode), onKlopNiet: (reden) => { setKlopNiet(true); klopNietM.mutate({ code: lookup.barcode ?? barcode, reden }); } })), _jsxs("div", { className: "flex flex-wrap gap-3", children: [_jsxs(Card, { className: "p-3", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Gescand vandaag" }), _jsx("div", { className: "text-2xl font-semibold", children: stats.totaal })] }), _jsxs(Card, { className: "p-3", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Geprint" }), _jsx("div", { className: "text-2xl font-semibold", children: stats.geprint })] }), _jsxs(Card, { className: "p-3", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "In behandeling" }), _jsx("div", { className: "text-2xl font-semibold", children: stats.wacht })] }), _jsxs(Card, { className: "p-3", children: [_jsx("div", { className: "text-xs text-muted-foreground", children: "Mislukt" }), _jsx("div", { className: "text-2xl font-semibold", children: stats.mislukt })] })] }), _jsx(Card, { className: "p-0 overflow-hidden", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: "Ordernummer" }), _jsx(TableHead, { children: "Soort" }), _jsx(TableHead, { children: "Status" }), _jsx(TableHead, { children: "Melding" }), _jsx(TableHead, { children: "Bijgewerkt" }), _jsx(TableHead, {})] }) }), _jsx(TableBody, { children: overviewQ.isLoading ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 6, className: "text-sm text-muted-foreground", children: "Laden\u2026" }) })) : rows.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 6, className: "text-sm text-muted-foreground", children: "Vandaag nog niets gescand." }) })) : (rows.map((r) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: r.orderNumber ?? "—" }), _jsx(TableCell, { children: r.isFloriday ? "FO" : "Eigen" }), _jsx(TableCell, { children: _jsx(Badge, { variant: statusVariant(r.status), children: label("scanStatus", r.status) }) }), _jsx(TableCell, { className: "text-sm text-muted-foreground", children: r.error ?? "—" }), _jsx(TableCell, { children: tijd(r.updatedAt) }), _jsx(TableCell, { className: "text-right", children: r.status === "mislukt" && (_jsxs(Button, { size: "sm", variant: "outline", disabled: retryM.isPending, onClick: () => retryM.mutate(r.id), children: [_jsx(RefreshCw, { className: "h-4 w-4 mr-2" }), "Opnieuw proberen"] })) })] }, r.id)))) })] }) })] }));
|
|
186
267
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Stand van beslismoment 8 (Floriday-terugkoppeling) voor één levering; niets tonen = nog niet aangeboden. */
|
|
2
|
+
export declare function TerugkoppelingStand({ orderRef, deliveryOrderId }: {
|
|
3
|
+
orderRef?: string | null;
|
|
4
|
+
deliveryOrderId?: string | null;
|
|
5
|
+
}): import("react").JSX.Element | null;
|
|
6
|
+
//# sourceMappingURL=TerugkoppelingStand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TerugkoppelingStand.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/TerugkoppelingStand.tsx"],"names":[],"mappings":"AAcA,+GAA+G;AAC/G,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,sCA+C/H"}
|