@flowselections/pick-schermen-kwekers 1.0.19 → 1.0.21

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.
Files changed (35) hide show
  1. package/README.md +24 -24
  2. package/dist-lib/components/pick/PickScherm.d.ts.map +1 -1
  3. package/dist-lib/components/pick/PickScherm.js +322 -69
  4. package/dist-lib/components/pick/QueueTable.d.ts +6 -1
  5. package/dist-lib/components/pick/QueueTable.d.ts.map +1 -1
  6. package/dist-lib/components/pick/QueueTable.js +30 -22
  7. package/dist-lib/hooks/useShippingNoteStatus.d.ts +27 -0
  8. package/dist-lib/hooks/useShippingNoteStatus.d.ts.map +1 -0
  9. package/dist-lib/hooks/useShippingNoteStatus.js +132 -0
  10. package/dist-lib/index.d.ts +1 -0
  11. package/dist-lib/index.d.ts.map +1 -1
  12. package/dist-lib/index.js +1 -0
  13. package/dist-lib/integrations/supabase/auth-middleware.d.ts +740 -1
  14. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  15. package/dist-lib/integrations/supabase/client.d.ts +740 -1
  16. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  17. package/dist-lib/integrations/supabase/client.server.d.ts +740 -1
  18. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  19. package/dist-lib/integrations/supabase/types.d.ts +743 -2
  20. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  21. package/dist-lib/lib/layoutMaker/pakbonHtml.js +49 -49
  22. package/dist-lib/lib/layoutRenderer.js +17 -17
  23. package/dist-lib/lib/pickApi.d.ts +10 -0
  24. package/dist-lib/lib/pickApi.d.ts.map +1 -1
  25. package/dist-lib/lib/pickApi.js +21 -0
  26. package/dist-lib/lib/pickTypes.d.ts +59 -2
  27. package/dist-lib/lib/pickTypes.d.ts.map +1 -1
  28. package/dist-lib/lib/pickTypes.js +149 -24
  29. package/dist-lib/lib/shippingNoteStatus.d.ts +35 -0
  30. package/dist-lib/lib/shippingNoteStatus.d.ts.map +1 -0
  31. package/dist-lib/lib/shippingNoteStatus.js +118 -0
  32. package/package.json +2 -2
  33. package/dist-lib/components/TemplateModulePage.d.ts +0 -2
  34. package/dist-lib/components/TemplateModulePage.d.ts.map +0 -1
  35. package/dist-lib/components/TemplateModulePage.js +0 -44
@@ -0,0 +1,118 @@
1
+ // Verzendbriefstatus bij een geprinte pakbon. Alleen-lezen: deze module vraagt
2
+ // nooit een nieuwe verzendbrief of printopdracht aan.
3
+ import { pickDb } from "./pickApi";
4
+ const FALLBACK = {
5
+ klaar_voor_print: "Verzendbrief wordt klaargezet.",
6
+ wacht_op_floriday: "Pakbon geprint — wachten op officiële Floriday-afleverbrief.",
7
+ geprint: "Pakbon en verzendbrief zijn naar de printer gestuurd.",
8
+ mislukt: "De verzendbrief is niet gelukt.",
9
+ geblokkeerd: "De verzendbrief is geweigerd omdat het type niet bij de order past.",
10
+ };
11
+ const SOURCE_LABEL = {
12
+ floriday: "Officiële Floriday-afleverbrief",
13
+ eigen: "Eigen verzendbrief",
14
+ };
15
+ /** Leesbare aanduiding van het documenttype, of niets als de Engine het niet meldt. */
16
+ export function shippingNoteSourceLabel(state) {
17
+ return state.source ? SOURCE_LABEL[state.source] : null;
18
+ }
19
+ /** Een printactie is pas volledig geslaagd als de juiste verzendbrief geprint is. */
20
+ export function isShippingNoteComplete(state) {
21
+ return state.status === "geprint";
22
+ }
23
+ /**
24
+ * Vraagt de shell één keer om de verzendbrief nu op te halen, direct na een
25
+ * geslaagde pakbonprint. Idempotent en alleen-lezen richting Floriday. De
26
+ * publiceerbare sleutel komt uit de omgeving van de shell; ontbreekt die of
27
+ * faalt de aanroep, dan gebeurt er niets zichtbaars en werkt de
28
+ * achtergrondverwerking de status vanzelf bij.
29
+ */
30
+ export async function requestShippingNoteNow() {
31
+ try {
32
+ const key = import.meta.env?.VITE_SUPABASE_PUBLISHABLE_KEY;
33
+ if (typeof key !== "string" || key.length === 0)
34
+ return { ok: false, message: null };
35
+ const res = await fetch("/api/public/hooks/logistics-shipping-note-now", {
36
+ method: "POST",
37
+ headers: { "content-type": "application/json", apikey: key },
38
+ body: "{}",
39
+ });
40
+ if (!res.ok)
41
+ return { ok: false, message: null };
42
+ let message = null;
43
+ try {
44
+ const body = await res.json();
45
+ const b = (body && typeof body === "object" ? body : {});
46
+ message = str(b["message"]) ?? str(b["melding"]);
47
+ }
48
+ catch {
49
+ // Geen leesbaar antwoord; de status volgt uit de statusronde.
50
+ }
51
+ return { ok: true, message };
52
+ }
53
+ catch {
54
+ // Geen technische melding: de achtergrondronde werkt de status alsnog bij.
55
+ return { ok: false, message: null };
56
+ }
57
+ }
58
+ export function isWaitingShippingNote(status) {
59
+ return status === "klaar_voor_print" || status === "wacht_op_floriday";
60
+ }
61
+ export function shippingNoteMessage(state) {
62
+ if (state.message)
63
+ return state.message;
64
+ if (state.status)
65
+ return FALLBACK[state.status];
66
+ return null;
67
+ }
68
+ function str(v) {
69
+ return typeof v === "string" && v.length > 0 ? v : null;
70
+ }
71
+ function num(v) {
72
+ return typeof v === "number" && Number.isFinite(v) ? v : null;
73
+ }
74
+ function parseStatus(raw) {
75
+ const row = Array.isArray(raw) ? raw[0] : raw;
76
+ const r = (row && typeof row === "object" ? row : {});
77
+ const code = str(r["status"]);
78
+ const known = [
79
+ "klaar_voor_print",
80
+ "wacht_op_floriday",
81
+ "geprint",
82
+ "mislukt",
83
+ "geblokkeerd",
84
+ ];
85
+ const rawSource = (str(r["source"]) ??
86
+ str(r["orderSource"]) ??
87
+ str(r["order_source"]) ??
88
+ str(r["noteType"]) ??
89
+ str(r["note_type"]) ??
90
+ str(r["documentType"]) ??
91
+ str(r["document_type"]) ??
92
+ "").toLowerCase();
93
+ const source = rawSource.includes("floriday")
94
+ ? "floriday"
95
+ : rawSource === "eigen" || rawSource === "own" || rawSource === "intern"
96
+ ? "eigen"
97
+ : null;
98
+ return {
99
+ status: code && known.includes(code) ? code : null,
100
+ message: str(r["message"]),
101
+ attempts: num(r["attempts"] ?? r["attempt_count"]),
102
+ nextAttemptAt: str(r["nextAttemptAt"] ?? r["next_attempt_at"]),
103
+ source,
104
+ };
105
+ }
106
+ /**
107
+ * Leest de verzendbriefstatus bij een pakbon-printopdracht. Het print_job-id is
108
+ * de sleutel; het kar-id is alleen de terugval.
109
+ */
110
+ export async function readShippingNoteStatus(slipJobId, cartId) {
111
+ const { data, error } = await pickDb.rpc("logistics_shipping_note_status", {
112
+ p_slip_job_id: slipJobId,
113
+ p_cart_id: cartId,
114
+ });
115
+ if (error)
116
+ throw new Error(error.message);
117
+ return parseStatus(data);
118
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowselections/pick-schermen-kwekers",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "flowselections": {
5
5
  "moduleId": "pick-schermen",
6
6
  "pages": [
@@ -64,7 +64,7 @@
64
64
  "devDependencies": {
65
65
  "@cloudflare/vite-plugin": "^1.25.5",
66
66
  "@eslint/js": "^9.32.0",
67
- "@flowselections/core": "1.0.18",
67
+ "@flowselections/core": "1.0.21",
68
68
  "@lovable.dev/vite-tanstack-config": "2.13.1",
69
69
  "@rsbuild/core": "^1.0.0",
70
70
  "@tailwindcss/vite": "^4.2.1",
@@ -1,2 +0,0 @@
1
- export declare function TemplateModulePage(): import("react").JSX.Element;
2
- //# sourceMappingURL=TemplateModulePage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TemplateModulePage.d.ts","sourceRoot":"","sources":["../../src/components/TemplateModulePage.tsx"],"names":[],"mappings":"AAsBA,wBAAgB,kBAAkB,gCAmFjC"}
@@ -1,44 +0,0 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- // ============================================================================
3
- // src/components/TemplateModulePage.tsx — EXAMPLE PAGE COMPONENT
4
- // ============================================================================
5
- // Pagina-componenten horen in src/components/, NIET alleen in src/routes/.
6
- // src/routes/ wordt NIET naar npm gepubliceerd (zie tsconfig.build.json exclude).
7
- //
8
- // GEEN <Header /> hier — die zit in _authenticated.tsx via staticData.title
9
- // ============================================================================
10
- import { useState, useEffect } from "react";
11
- import { useAuth, supabase, Button, Card, CardContent, CardHeader, CardTitle, toast, } from "@flowselections/core";
12
- import { TemplateModuleLogo } from './TemplateModuleLogo';
13
- export function TemplateModulePage() {
14
- // Auth is guaranteed — this user is already logged in
15
- const { user, isAdmin } = useAuth();
16
- // Example state — replace with your own
17
- const [items, setItems] = useState([]);
18
- const [loading, setLoading] = useState(true);
19
- useEffect(() => {
20
- loadData();
21
- }, []);
22
- const loadData = async () => {
23
- setLoading(true);
24
- try {
25
- // Example query — replace "products" with your table
26
- const { data, error } = await supabase
27
- .from("products")
28
- .select("*")
29
- .limit(10);
30
- if (error)
31
- throw error;
32
- // ✅ Altijd Array.isArray bewaken op server-function data
33
- // const safeItems = Array.isArray(data?.items) ? data.items : [];
34
- setItems(Array.isArray(data) ? data : []);
35
- }
36
- catch {
37
- toast.error("Fout bij het laden van gegevens");
38
- }
39
- finally {
40
- setLoading(false);
41
- }
42
- };
43
- return (_jsxs("main", { className: "p-6 space-y-6", children: [isAdmin && (_jsxs("div", { className: "text-sm text-muted-foreground", children: ["Ingelogd als admin: ", user?.email] })), _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Overzicht" }) }), _jsxs(CardContent, { children: [loading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Laden..." })) : items.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Geen gegevens gevonden." })) : (_jsxs("p", { className: "text-sm", children: [items.length, " items geladen."] })), _jsx(Button, { onClick: loadData, className: "mt-4", disabled: loading, children: "Vernieuwen" })] })] }), _jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [_jsx(TemplateModuleLogo, { className: "w-6 h-6 text-primary" }), _jsx("span", { children: "SVG-component (voorkeur voor vector-logo's)" })] })] }));
44
- }