@flowselections/floriday-afhandeling-module 1.0.71 → 1.0.76
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/ControleLijstPrint.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/ControleLijstPrint.js +5 -2
- package/dist-lib/components/afhandeling/ControlePage.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/ControlePage.js +17 -6
- package/dist-lib/components/afhandeling/DagDetailDialog.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/DagDetailDialog.js +50 -24
- package/dist-lib/components/settings/AfhandelingSettingsCard.d.ts.map +1 -1
- package/dist-lib/components/settings/AfhandelingSettingsCard.js +1 -1
- package/dist-lib/integrations/supabase/previewAuthStorage.d.ts +11 -5
- package/dist-lib/integrations/supabase/previewAuthStorage.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/previewAuthStorage.js +38 -21
- package/dist-lib/integrations/supabase/types.d.ts +1445 -15
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/cartAssignments.functions.d.ts.map +1 -1
- package/dist-lib/lib/cartAssignments.functions.js +12 -11
- package/dist-lib/lib/cartControl.functions.d.ts.map +1 -1
- package/dist-lib/lib/cartControl.functions.js +17 -16
- package/dist-lib/lib/cartSeqFout.d.ts +11 -0
- package/dist-lib/lib/cartSeqFout.d.ts.map +1 -0
- package/dist-lib/lib/cartSeqFout.js +18 -0
- package/dist-lib/lib/controleLijst.functions.d.ts +26 -0
- package/dist-lib/lib/controleLijst.functions.d.ts.map +1 -0
- package/dist-lib/lib/controleLijst.functions.js +55 -0
- package/dist-lib/lib/controleLijstPayload.d.ts +32 -0
- package/dist-lib/lib/controleLijstPayload.d.ts.map +1 -0
- package/dist-lib/lib/controleLijstPayload.js +92 -0
- package/dist-lib/lib/controleLijstPayload.test.d.ts +2 -0
- package/dist-lib/lib/controleLijstPayload.test.d.ts.map +1 -0
- package/dist-lib/lib/controleLijstPayload.test.js +34 -0
- package/dist-lib/lib/documentKeuze.d.ts +24 -0
- package/dist-lib/lib/documentKeuze.d.ts.map +1 -0
- package/dist-lib/lib/documentKeuze.functions.d.ts +14 -0
- package/dist-lib/lib/documentKeuze.functions.d.ts.map +1 -0
- package/dist-lib/lib/documentKeuze.functions.js +28 -0
- package/dist-lib/lib/documentKeuze.js +28 -0
- package/dist-lib/lib/documentKeuze.test.d.ts +2 -0
- package/dist-lib/lib/documentKeuze.test.d.ts.map +1 -0
- package/dist-lib/lib/documentKeuze.test.js +23 -0
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
2
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
3
|
+
import { leesDocumentKeuze } from "./documentKeuze.js";
|
|
4
|
+
const SOORTEN = ["pakbon", "productiebon", "verzenddocument", "sticker", "traysticker", "eigen_sticker"];
|
|
5
|
+
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
6
|
+
/** Vraagt bij de Engine welk document (layout) bij deze order hoort. */
|
|
7
|
+
export const getDocumentVoorOrder = createServerFn({ method: "POST" })
|
|
8
|
+
.middleware([requireSupabaseAuth])
|
|
9
|
+
.inputValidator((d) => {
|
|
10
|
+
if (!SOORTEN.includes(d?.documenttype))
|
|
11
|
+
throw new Error("Onbekende documentsoort.");
|
|
12
|
+
return { orderId: String(d.orderId ?? ""), documenttype: d.documenttype };
|
|
13
|
+
})
|
|
14
|
+
.handler(async ({ data, context }) => {
|
|
15
|
+
if (!UUID.test(data.orderId)) {
|
|
16
|
+
return leesDocumentKeuze({ ok: false, reden: "De order is niet gevonden; het document kan niet worden bepaald." }, data.documenttype);
|
|
17
|
+
}
|
|
18
|
+
const sb = context.supabase;
|
|
19
|
+
const { data: res, error } = await sb.rpc("logistics_document_for_order", {
|
|
20
|
+
p_order_id: data.orderId,
|
|
21
|
+
p_documenttype: data.documenttype,
|
|
22
|
+
});
|
|
23
|
+
if (error) {
|
|
24
|
+
console.warn("[documentkeuze]", error.message);
|
|
25
|
+
return leesDocumentKeuze({ ok: false, reden: "Het document kon niet worden bepaald. Probeer het zo opnieuw." }, data.documenttype);
|
|
26
|
+
}
|
|
27
|
+
return leesDocumentKeuze(res, data.documenttype);
|
|
28
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Gedeelde, browser-veilige logica rond de automatische documentkeuze
|
|
2
|
+
// (logistics_document_for_order). Geen eigen layoutkeuze meer.
|
|
3
|
+
export const AUTOMATISCH_DOCUMENT_TEKST = "Het document wordt automatisch bepaald uit de order.";
|
|
4
|
+
/** Zet het antwoord van de functie om; alles wat niet klopt telt als ok=false (fail closed). */
|
|
5
|
+
export function leesDocumentKeuze(raw, soort) {
|
|
6
|
+
const r = raw && typeof raw === "object" ? raw : null;
|
|
7
|
+
if (!r)
|
|
8
|
+
return { ok: false, layoutId: null, bron: null, documenttype: null, reden: `Geen antwoord over het document (${soort}).` };
|
|
9
|
+
const layoutId = typeof r.layout_id === "string" && r.layout_id ? r.layout_id : null;
|
|
10
|
+
const bron = r.bron === "floriday" || r.bron === "eigen" ? r.bron : null;
|
|
11
|
+
const ok = r.ok === true && !!layoutId;
|
|
12
|
+
const reden = typeof r.reden === "string" && r.reden ? r.reden : null;
|
|
13
|
+
return {
|
|
14
|
+
ok,
|
|
15
|
+
layoutId,
|
|
16
|
+
bron,
|
|
17
|
+
documenttype: typeof r.documenttype === "string" ? r.documenttype : null,
|
|
18
|
+
reden: ok ? null : reden ?? `Het document (${soort}) kan niet worden bepaald.`,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Precies één verzenddocument per order: Floriday-order = Floriday-PDF, eigen order = afleverbrief-layout. */
|
|
22
|
+
export function kiesVerzendActie(k) {
|
|
23
|
+
if (!k.ok || !k.layoutId)
|
|
24
|
+
return { soort: "overslaan", reden: k.reden ?? "Het verzenddocument kan niet worden bepaald." };
|
|
25
|
+
if (k.bron === "floriday")
|
|
26
|
+
return { soort: "floriday_pdf" };
|
|
27
|
+
return { soort: "layout", layoutId: k.layoutId, documenttype: k.documenttype ?? "afleverbrief" };
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentKeuze.test.d.ts","sourceRoot":"","sources":["../../src/lib/documentKeuze.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { kiesVerzendActie, leesDocumentKeuze } from "./documentKeuze.js";
|
|
3
|
+
describe("automatische documentkeuze", () => {
|
|
4
|
+
it("ok=false: niet printen, reden doorgeven", () => {
|
|
5
|
+
const k = leesDocumentKeuze({ ok: false, layout_id: null, reden: "Maak een layout" }, "pakbon");
|
|
6
|
+
expect(k.ok).toBe(false);
|
|
7
|
+
expect(kiesVerzendActie(k)).toEqual({ soort: "overslaan", reden: "Maak een layout" });
|
|
8
|
+
});
|
|
9
|
+
it("Floriday-order: wat Floriday levert", () => {
|
|
10
|
+
const k = leesDocumentKeuze({ ok: true, layout_id: "L1", bron: "floriday", documenttype: "afleverbrief" }, "verzenddocument");
|
|
11
|
+
expect(kiesVerzendActie(k)).toEqual({ soort: "floriday_pdf" });
|
|
12
|
+
});
|
|
13
|
+
it("eigen order: afleverbrief-layout", () => {
|
|
14
|
+
const k = leesDocumentKeuze({ ok: true, layout_id: "L2", bron: "eigen", documenttype: "afleverbrief" }, "verzenddocument");
|
|
15
|
+
expect(kiesVerzendActie(k)).toEqual({ soort: "layout", layoutId: "L2", documenttype: "afleverbrief" });
|
|
16
|
+
});
|
|
17
|
+
it("ok=true zonder layout geldt als niet printen", () => {
|
|
18
|
+
expect(leesDocumentKeuze({ ok: true }, "pakbon").ok).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
it("geen antwoord geldt als niet printen", () => {
|
|
21
|
+
expect(leesDocumentKeuze(null, "pakbon").ok).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
});
|