@flowselections/baan-pick-schermen 1.0.7 → 1.0.9
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/BaanApiPage.d.ts +2 -0
- package/dist-lib/components/BaanApiPage.d.ts.map +1 -0
- package/dist-lib/components/BaanApiPage.js +122 -0
- package/dist-lib/components/BaanBatchAfronden.d.ts +7 -0
- package/dist-lib/components/BaanBatchAfronden.d.ts.map +1 -0
- package/dist-lib/components/BaanBatchAfronden.js +33 -0
- package/dist-lib/components/BaanBatchesPage.d.ts.map +1 -1
- package/dist-lib/components/BaanBatchesPage.js +17 -6
- package/dist-lib/components/BaanPickSchermenPage.d.ts.map +1 -1
- package/dist-lib/components/BaanPickSchermenPage.js +2 -2
- package/dist-lib/hooks/useBaanPickSchermenData.js +3 -3
- package/dist-lib/index.d.ts +1 -2
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +3 -5
- package/dist-lib/integrations/supabase/types.d.ts +1036 -767
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/baan/opzetTypes.d.ts +2 -1
- package/dist-lib/lib/baan/opzetTypes.d.ts.map +1 -1
- package/dist-lib/lib/grijpApi.d.ts +14 -0
- package/dist-lib/lib/grijpApi.d.ts.map +1 -0
- package/dist-lib/lib/grijpApi.js +72 -0
- package/dist-lib/lib/plattegrondBestand.js +1 -1
- package/dist-lib/lib/server/grijpApi.d.ts +11 -0
- package/dist-lib/lib/server/grijpApi.d.ts.map +1 -0
- package/dist-lib/lib/server/grijpApi.js +104 -0
- package/dist-lib/lib/server/index.d.ts +1 -0
- package/dist-lib/lib/server/index.d.ts.map +1 -1
- package/dist-lib/lib/server/index.js +1 -0
- package/package.json +31 -26
- package/dist-lib/components/TemplateModuleLogo.d.ts +0 -6
- package/dist-lib/components/TemplateModuleLogo.d.ts.map +0 -1
- package/dist-lib/components/TemplateModuleLogo.js +0 -4
- package/dist-lib/components/TemplateModulePage.d.ts +0 -2
- package/dist-lib/components/TemplateModulePage.d.ts.map +0 -1
- package/dist-lib/components/TemplateModulePage.js +0 -44
- package/dist-lib/components/TemplatePage.d.ts +0 -2
- package/dist-lib/components/TemplatePage.d.ts.map +0 -1
- package/dist-lib/components/TemplatePage.js +0 -4
- package/dist-lib/components/settings/MijnModuleSettingsCard.d.ts +0 -2
- package/dist-lib/components/settings/MijnModuleSettingsCard.d.ts.map +0 -1
- package/dist-lib/components/settings/MijnModuleSettingsCard.js +0 -42
- package/dist-lib/hooks/useMijnModuleData.d.ts +0 -13
- package/dist-lib/hooks/useMijnModuleData.d.ts.map +0 -1
- package/dist-lib/hooks/useMijnModuleData.js +0 -49
|
@@ -69,7 +69,8 @@ export interface OpzetTekort {
|
|
|
69
69
|
naam: string | null;
|
|
70
70
|
fusten: number;
|
|
71
71
|
reden: string;
|
|
72
|
-
uitleg: string;
|
|
72
|
+
uitleg: string; /** BP-12: batch die de kar nog gebruikt (reden kar_bezet_andere_batch). */
|
|
73
|
+
andere_batch?: string | null;
|
|
73
74
|
}
|
|
74
75
|
export interface OpzetData {
|
|
75
76
|
gevonden: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opzetTypes.d.ts","sourceRoot":"","sources":["../../../src/lib/baan/opzetTypes.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACxG,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,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AAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const GRIJP_API_MAX_BYTES: number;
|
|
2
|
+
export declare const GRIJP_API_MAX_PLANTEN = 1000;
|
|
3
|
+
export declare const GRIJP_API_PAD_BATCHES = "/api/public/baan/v1/batches";
|
|
4
|
+
export declare const GRIJP_API_PAD_TEST = "/api/public/baan/v1/test";
|
|
5
|
+
export declare const GRIJP_API_PAD_TRAYS = "/api/public/baan/v1/trays";
|
|
6
|
+
/** MES-melding "tray op de baan": { scan_id, batch_id, id, aantal }. Reden in gewone taal of null. */
|
|
7
|
+
export declare function controleerTrayBody(body: unknown): string | null;
|
|
8
|
+
/** Geeft een reden in gewone taal terug als de body niet volgens de documentatie is, anders null. */
|
|
9
|
+
export declare function controleerGrijpApiBody(body: unknown): string | null;
|
|
10
|
+
export declare function sha256Hex(tekst: string): Promise<string>;
|
|
11
|
+
export declare function leesBearer(request: Request): string | null;
|
|
12
|
+
/** Nieuwe sleutel: 32 willekeurige bytes als hex met herkenbaar voorvoegsel. */
|
|
13
|
+
export declare function nieuweApiSleutel(): string;
|
|
14
|
+
//# sourceMappingURL=grijpApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grijpApi.d.ts","sourceRoot":"","sources":["../../src/lib/grijpApi.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,QAAa,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,qBAAqB,gCAAgC,CAAC;AACnE,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAC7D,eAAO,MAAM,mBAAmB,8BAA8B,CAAC;AAE/D,sGAAsG;AACtG,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAU/D;AAED,qGAAqG;AACrG,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAuBnE;AAED,wBAAsB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG9D;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAI1D;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,IAAI,MAAM,CAIzC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Grijpvoorraad-API v1 — vormcontrole en hulpfuncties (zonder servercode; ook in de browser bruikbaar).
|
|
2
|
+
// De database (baan_api_batch_ontvangen) beslist; deze controle zorgt alleen voor een leesbare reden.
|
|
3
|
+
export const GRIJP_API_MAX_BYTES = 256 * 1024;
|
|
4
|
+
export const GRIJP_API_MAX_PLANTEN = 1000;
|
|
5
|
+
export const GRIJP_API_PAD_BATCHES = "/api/public/baan/v1/batches";
|
|
6
|
+
export const GRIJP_API_PAD_TEST = "/api/public/baan/v1/test";
|
|
7
|
+
export const GRIJP_API_PAD_TRAYS = "/api/public/baan/v1/trays";
|
|
8
|
+
/** MES-melding "tray op de baan": { scan_id, batch_id, id, aantal }. Reden in gewone taal of null. */
|
|
9
|
+
export function controleerTrayBody(body) {
|
|
10
|
+
if (!body || typeof body !== "object" || Array.isArray(body))
|
|
11
|
+
return "bericht is geen JSON-object";
|
|
12
|
+
const b = body;
|
|
13
|
+
for (const k of ["scan_id", "batch_id", "id"]) {
|
|
14
|
+
const v = b[k];
|
|
15
|
+
if (typeof v !== "string" || !v.trim() || v.length > 200)
|
|
16
|
+
return `${k} ontbreekt of is ongeldig`;
|
|
17
|
+
}
|
|
18
|
+
const a = b["aantal"];
|
|
19
|
+
if (typeof a !== "number" || !Number.isInteger(a) || a < 1 || a > 1000)
|
|
20
|
+
return "aantal moet een geheel getal van 1 t/m 1000 zijn";
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
/** Geeft een reden in gewone taal terug als de body niet volgens de documentatie is, anders null. */
|
|
24
|
+
export function controleerGrijpApiBody(body) {
|
|
25
|
+
if (!body || typeof body !== "object" || Array.isArray(body))
|
|
26
|
+
return "bericht is geen JSON-object";
|
|
27
|
+
const b = body;
|
|
28
|
+
const bid = b["batch_id"];
|
|
29
|
+
if (typeof bid !== "string" || !bid.trim() || bid.length > 200)
|
|
30
|
+
return "batch_id ontbreekt of is ongeldig";
|
|
31
|
+
const datum = b["datum"];
|
|
32
|
+
if (typeof datum !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(datum) || Number.isNaN(Date.parse(`${datum}T00:00:00Z`))
|
|
33
|
+
|| new Date(`${datum}T00:00:00Z`).toISOString().slice(0, 10) !== datum)
|
|
34
|
+
return "datum moet JJJJ-MM-DD zijn";
|
|
35
|
+
const volg = b["volgnummer"];
|
|
36
|
+
if (typeof volg !== "number" || !Number.isInteger(volg) || volg < 1 || volg > 2147483647)
|
|
37
|
+
return "volgnummer moet een geheel getal vanaf 1 zijn";
|
|
38
|
+
const ids = b["ids"];
|
|
39
|
+
const aantallen = b["aantallen"];
|
|
40
|
+
if (!Array.isArray(ids) || ids.length === 0)
|
|
41
|
+
return "ids ontbreekt of is leeg";
|
|
42
|
+
if (!Array.isArray(aantallen))
|
|
43
|
+
return "aantallen ontbreekt";
|
|
44
|
+
if (ids.length !== aantallen.length)
|
|
45
|
+
return "ids en aantallen zijn niet even lang";
|
|
46
|
+
if (ids.length > GRIJP_API_MAX_PLANTEN)
|
|
47
|
+
return `maximaal ${GRIJP_API_MAX_PLANTEN} planten per batch`;
|
|
48
|
+
for (let i = 0; i < ids.length; i++) {
|
|
49
|
+
const id = ids[i];
|
|
50
|
+
if (typeof id !== "string" || !id.trim())
|
|
51
|
+
return `ids positie ${i + 1} is geen tekst`;
|
|
52
|
+
const q = aantallen[i];
|
|
53
|
+
if (typeof q !== "number" || !Number.isInteger(q) || q <= 0)
|
|
54
|
+
return `aantallen positie ${i + 1} moet een geheel getal groter dan 0 zijn`;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
export async function sha256Hex(tekst) {
|
|
59
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(tekst));
|
|
60
|
+
return Array.from(new Uint8Array(digest), (x) => x.toString(16).padStart(2, "0")).join("");
|
|
61
|
+
}
|
|
62
|
+
export function leesBearer(request) {
|
|
63
|
+
const m = /^Bearer\s+(.+)$/i.exec((request.headers.get("authorization") ?? "").trim());
|
|
64
|
+
const t = m?.[1]?.trim() ?? "";
|
|
65
|
+
return t ? t : null;
|
|
66
|
+
}
|
|
67
|
+
/** Nieuwe sleutel: 32 willekeurige bytes als hex met herkenbaar voorvoegsel. */
|
|
68
|
+
export function nieuweApiSleutel() {
|
|
69
|
+
const b = new Uint8Array(32);
|
|
70
|
+
crypto.getRandomValues(b);
|
|
71
|
+
return "baan_" + Array.from(b, (x) => x.toString(16).padStart(2, "0")).join("");
|
|
72
|
+
}
|
|
@@ -120,7 +120,7 @@ export async function maakSjabloon() {
|
|
|
120
120
|
const XLSX = await import("xlsx");
|
|
121
121
|
const boek = XLSX.utils.book_new();
|
|
122
122
|
XLSX.utils.book_append_sheet(boek, XLSX.utils.aoa_to_sheet([
|
|
123
|
-
[...KOLOMMEN_VAKKEN], ["Z1-
|
|
123
|
+
[...KOLOMMEN_VAKKEN], ["Z1-A01", 4.25, 2], ["Z1-A02", 4.25, 3],
|
|
124
124
|
]), "vakken");
|
|
125
125
|
XLSX.utils.book_append_sheet(boek, XLSX.utils.aoa_to_sheet([
|
|
126
126
|
[...KOLOMMEN_PUNTEN], ["baan", "Baan 1", 1, 5, 0.5, null, null], ["blokkade", "Stelling Z1", null, 3, 15, 7, 19],
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function grijpApiBatchesHandler({ request }: {
|
|
2
|
+
request: Request;
|
|
3
|
+
}): Promise<Response>;
|
|
4
|
+
export declare function grijpApiTestHandler({ request }: {
|
|
5
|
+
request: Request;
|
|
6
|
+
}): Promise<Response>;
|
|
7
|
+
/** MES meldt een tray die op de baan is gezet: POST /api/public/baan/v1/trays. Altijd 200 zonder body. */
|
|
8
|
+
export declare function grijpApiTraysHandler({ request }: {
|
|
9
|
+
request: Request;
|
|
10
|
+
}): Promise<Response>;
|
|
11
|
+
//# sourceMappingURL=grijpApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grijpApi.d.ts","sourceRoot":"","sources":["../../../src/lib/server/grijpApi.ts"],"names":[],"mappings":"AAuCA,wBAAsB,sBAAsB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEjG;AAED,wBAAsB,mBAAmB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE9F;AAED,0GAA0G;AAC1G,wBAAsB,oBAAoB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAsB/F"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Grijpvoorraad-API v1: POST /api/public/baan/v1/batches (en /test voor testberichten).
|
|
2
|
+
// Antwoord altijd 200 zonder body (documentatie). Fouten staan in baan_inbox en op de pagina API.
|
|
3
|
+
import { createClient } from "@supabase/supabase-js";
|
|
4
|
+
import { controleerGrijpApiBody, controleerTrayBody, GRIJP_API_MAX_BYTES, leesBearer, sha256Hex } from "../grijpApi.js";
|
|
5
|
+
const leeg = () => new Response(null, { status: 200, headers: { "Cache-Control": "no-store" } });
|
|
6
|
+
async function ontvang(request, test) {
|
|
7
|
+
const url = process.env["SUPABASE_URL"];
|
|
8
|
+
const key = process.env["SUPABASE_SERVICE_ROLE_KEY"] || process.env["SB_SERVICE_ROLE_KEY"];
|
|
9
|
+
if (!url || !key) {
|
|
10
|
+
console.error("[baan grijp-api] SUPABASE_URL of service-sleutel ontbreekt; bericht niet verwerkt");
|
|
11
|
+
return leeg();
|
|
12
|
+
}
|
|
13
|
+
const token = leesBearer(request);
|
|
14
|
+
const hash = token ? await sha256Hex(token) : "";
|
|
15
|
+
let body = {};
|
|
16
|
+
let vormfout = null;
|
|
17
|
+
const lengte = Number(request.headers.get("content-length") ?? "0");
|
|
18
|
+
if (lengte > GRIJP_API_MAX_BYTES) {
|
|
19
|
+
vormfout = "bericht is groter dan 256 kB";
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const tekst = await request.text();
|
|
23
|
+
if (tekst.length > GRIJP_API_MAX_BYTES)
|
|
24
|
+
vormfout = "bericht is groter dan 256 kB";
|
|
25
|
+
else {
|
|
26
|
+
try {
|
|
27
|
+
body = JSON.parse(tekst);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
body = { ruw: tekst.slice(0, 2000) };
|
|
31
|
+
vormfout = "bericht is geen geldige JSON";
|
|
32
|
+
}
|
|
33
|
+
if (!vormfout)
|
|
34
|
+
vormfout = controleerGrijpApiBody(body);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const bewaar = body && typeof body === "object" && !Array.isArray(body) ? body : { ruw: body };
|
|
38
|
+
const db = createClient(url, key, { auth: { persistSession: false, autoRefreshToken: false } });
|
|
39
|
+
const { data, error } = await db.rpc("baan_api_batch_ontvangen", { _sleutel_hash: hash, _body: bewaar, _test: test, _vormfout: vormfout });
|
|
40
|
+
if (error)
|
|
41
|
+
console.error("[baan grijp-api] verwerken mislukt", error.message);
|
|
42
|
+
else if (data?.resultaat !== "verwerkt")
|
|
43
|
+
console.warn("[baan grijp-api]", JSON.stringify(data));
|
|
44
|
+
return leeg();
|
|
45
|
+
}
|
|
46
|
+
export async function grijpApiBatchesHandler({ request }) {
|
|
47
|
+
try {
|
|
48
|
+
return await ontvang(request, false);
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
console.error("[baan grijp-api] onverwachte fout", e);
|
|
52
|
+
return leeg();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export async function grijpApiTestHandler({ request }) {
|
|
56
|
+
try {
|
|
57
|
+
return await ontvang(request, true);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
console.error("[baan grijp-api test] onverwachte fout", e);
|
|
61
|
+
return leeg();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** MES meldt een tray die op de baan is gezet: POST /api/public/baan/v1/trays. Altijd 200 zonder body. */
|
|
65
|
+
export async function grijpApiTraysHandler({ request }) {
|
|
66
|
+
try {
|
|
67
|
+
const url = process.env["SUPABASE_URL"];
|
|
68
|
+
const key = process.env["SUPABASE_SERVICE_ROLE_KEY"] || process.env["SB_SERVICE_ROLE_KEY"];
|
|
69
|
+
if (!url || !key) {
|
|
70
|
+
console.error("[baan grijp-api trays] SUPABASE_URL of service-sleutel ontbreekt; melding niet verwerkt");
|
|
71
|
+
return leeg();
|
|
72
|
+
}
|
|
73
|
+
const token = leesBearer(request);
|
|
74
|
+
const hash = token ? await sha256Hex(token) : "";
|
|
75
|
+
let body = {};
|
|
76
|
+
let vormfout = null;
|
|
77
|
+
const tekst = Number(request.headers.get("content-length") ?? "0") > GRIJP_API_MAX_BYTES ? null : await request.text();
|
|
78
|
+
if (tekst === null || tekst.length > GRIJP_API_MAX_BYTES)
|
|
79
|
+
vormfout = "bericht is groter dan 256 kB";
|
|
80
|
+
else {
|
|
81
|
+
try {
|
|
82
|
+
body = JSON.parse(tekst);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
body = {};
|
|
86
|
+
vormfout = "bericht is geen geldige JSON";
|
|
87
|
+
}
|
|
88
|
+
if (!vormfout)
|
|
89
|
+
vormfout = controleerTrayBody(body);
|
|
90
|
+
}
|
|
91
|
+
const bewaar = body && typeof body === "object" && !Array.isArray(body) ? body : {};
|
|
92
|
+
const db = createClient(url, key, { auth: { persistSession: false, autoRefreshToken: false } });
|
|
93
|
+
const { data, error } = await db.rpc("baan_api_scan_ontvangen", { _sleutel_hash: hash, _body: bewaar, _vormfout: vormfout });
|
|
94
|
+
if (error)
|
|
95
|
+
console.error("[baan grijp-api trays] verwerken mislukt", error.message);
|
|
96
|
+
else if (data?.status !== "verwerkt")
|
|
97
|
+
console.warn("[baan grijp-api trays]", JSON.stringify(data));
|
|
98
|
+
return leeg();
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.error("[baan grijp-api trays] onverwachte fout", e);
|
|
102
|
+
return leeg();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { apsEventsHandler, controleerApsEnvelop } from "./apsEvents.js";
|
|
2
2
|
export { mesEventsHandler } from "./mesEvents.js";
|
|
3
3
|
export { controleerMesEnvelop } from "../mesEnvelop.js";
|
|
4
|
+
export { grijpApiBatchesHandler, grijpApiTestHandler, grijpApiTraysHandler } from "./grijpApi.js";
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { apsEventsHandler, controleerApsEnvelop } from "./apsEvents.js";
|
|
2
2
|
export { mesEventsHandler } from "./mesEvents.js";
|
|
3
3
|
export { controleerMesEnvelop } from "../mesEnvelop.js";
|
|
4
|
+
export { grijpApiBatchesHandler, grijpApiTestHandler, grijpApiTraysHandler } from "./grijpApi.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowselections/baan-pick-schermen",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"flowselections": {
|
|
5
5
|
"moduleId": "baan-pick-schermen",
|
|
6
6
|
"pages": [
|
|
@@ -9,11 +9,6 @@
|
|
|
9
9
|
"route": "baan-pick-schermen",
|
|
10
10
|
"title": "Baan Pick Schermen"
|
|
11
11
|
},
|
|
12
|
-
{
|
|
13
|
-
"export": "BaanPlattegrondPage",
|
|
14
|
-
"route": "baan-pick-schermen/plattegrond",
|
|
15
|
-
"title": "Plattegrond"
|
|
16
|
-
},
|
|
17
12
|
{
|
|
18
13
|
"export": "BaanBatchesPage",
|
|
19
14
|
"route": "baan-pick-schermen/batches",
|
|
@@ -25,24 +20,6 @@
|
|
|
25
20
|
"title": "Nep-APS",
|
|
26
21
|
"nav": false
|
|
27
22
|
},
|
|
28
|
-
{
|
|
29
|
-
"export": "Baan1Page",
|
|
30
|
-
"route": "baan-pick-schermen/baan/1",
|
|
31
|
-
"title": "Baan 1",
|
|
32
|
-
"nav": false
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"export": "Baan2Page",
|
|
36
|
-
"route": "baan-pick-schermen/baan/2",
|
|
37
|
-
"title": "Baan 2",
|
|
38
|
-
"nav": false
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"export": "Baan3Page",
|
|
42
|
-
"route": "baan-pick-schermen/baan/3",
|
|
43
|
-
"title": "Baan 3",
|
|
44
|
-
"nav": false
|
|
45
|
-
},
|
|
46
23
|
{
|
|
47
24
|
"export": "BaanSchermenPage",
|
|
48
25
|
"route": "baan-pick-schermen/schermen",
|
|
@@ -59,6 +36,11 @@
|
|
|
59
36
|
"route": "baan-pick-schermen/demo",
|
|
60
37
|
"title": "Demobaan",
|
|
61
38
|
"nav": false
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"export": "BaanApiPage",
|
|
42
|
+
"route": "baan-pick-schermen/api",
|
|
43
|
+
"title": "API"
|
|
62
44
|
}
|
|
63
45
|
],
|
|
64
46
|
"productlijn": "mes-select",
|
|
@@ -107,6 +89,30 @@
|
|
|
107
89
|
"methods": [
|
|
108
90
|
"POST"
|
|
109
91
|
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"routePath": "/api/public/baan/v1/batches",
|
|
95
|
+
"import": "@flowselections/baan-pick-schermen/server",
|
|
96
|
+
"handler": "grijpApiBatchesHandler",
|
|
97
|
+
"methods": [
|
|
98
|
+
"POST"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"routePath": "/api/public/baan/v1/test",
|
|
103
|
+
"import": "@flowselections/baan-pick-schermen/server",
|
|
104
|
+
"handler": "grijpApiTestHandler",
|
|
105
|
+
"methods": [
|
|
106
|
+
"POST"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"routePath": "/api/public/baan/v1/trays",
|
|
111
|
+
"import": "@flowselections/baan-pick-schermen/server",
|
|
112
|
+
"handler": "grijpApiTraysHandler",
|
|
113
|
+
"methods": [
|
|
114
|
+
"POST"
|
|
115
|
+
]
|
|
110
116
|
}
|
|
111
117
|
]
|
|
112
118
|
},
|
|
@@ -153,8 +159,7 @@
|
|
|
153
159
|
"sonner": "^2.0.0"
|
|
154
160
|
},
|
|
155
161
|
"dependencies": {
|
|
156
|
-
"@supabase/supabase-js": "^2.105.3"
|
|
157
|
-
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz"
|
|
162
|
+
"@supabase/supabase-js": "^2.105.3"
|
|
158
163
|
},
|
|
159
164
|
"devDependencies": {
|
|
160
165
|
"@cloudflare/vite-plugin": "^1.25.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateModuleLogo.d.ts","sourceRoot":"","sources":["../../src/components/TemplateModuleLogo.tsx"],"names":[],"mappings":"AAQA,UAAU,uBAAuB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,SAAS,EAAE,EAAE,uBAAuB,+BAwBxE"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
export function TemplateModuleLogo({ className }) {
|
|
3
|
-
return (_jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, "aria-hidden": "true", children: [_jsx("rect", { width: "40", height: "40", rx: "8", fill: "currentColor", opacity: "0.1" }), _jsx("text", { x: "50%", y: "50%", dominantBaseline: "middle", textAnchor: "middle", fontSize: "18", fontWeight: "600", fill: "currentColor", children: "M" })] }));
|
|
4
|
-
}
|
|
@@ -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.js';
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TemplatePage.d.ts","sourceRoot":"","sources":["../../src/components/TemplatePage.tsx"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,gCAS3B"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
export function TemplatePage() {
|
|
3
|
-
return (_jsxs("div", { className: "p-6", children: [_jsx("h1", { className: "text-2xl font-semibold", children: "Module pagina" }), _jsx("p", { className: "text-muted-foreground mt-2", children: "Vervang dit component met de pagina's van jouw module." })] }));
|
|
4
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MijnModuleSettingsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/MijnModuleSettingsCard.tsx"],"names":[],"mappings":"AAiCA,wBAAgB,sBAAsB,gCA+CrC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// ============================================================================
|
|
3
|
-
// src/components/settings/MijnModuleSettingsCard.tsx — EXAMPLE SETTINGS CARD
|
|
4
|
-
// ============================================================================
|
|
5
|
-
// This is an example of a settings card for your module.
|
|
6
|
-
// It appears on the main settings page when registered in src/index.ts.
|
|
7
|
-
//
|
|
8
|
-
// RULES:
|
|
9
|
-
// - Must return a <Card> as its root element
|
|
10
|
-
// - Handles its own data fetching — no props are passed by the core
|
|
11
|
-
// - Use the same Card primitives from @flowselections/core
|
|
12
|
-
//
|
|
13
|
-
// WHAT TO DO:
|
|
14
|
-
// - Rename this file to match your card's purpose
|
|
15
|
-
// - Add your real settings UI
|
|
16
|
-
// - Register it in src/index.ts under settingsCards
|
|
17
|
-
// - Delete this file entirely if your module has no settings
|
|
18
|
-
// ============================================================================
|
|
19
|
-
import { useState } from "react";
|
|
20
|
-
import { Card, CardContent, CardDescription, CardHeader, CardTitle, Button, Input, Label, toast, } from "@flowselections/core";
|
|
21
|
-
import { Settings2 } from "lucide-react";
|
|
22
|
-
export function MijnModuleSettingsCard() {
|
|
23
|
-
// Replace with your real settings state
|
|
24
|
-
const [setting, setSetting] = useState("");
|
|
25
|
-
const [saving, setSaving] = useState(false);
|
|
26
|
-
const handleSave = async () => {
|
|
27
|
-
setSaving(true);
|
|
28
|
-
try {
|
|
29
|
-
// Example: save to a table — replace with your real query
|
|
30
|
-
// const { error } = await supabase.from("my_settings").upsert({ ... });
|
|
31
|
-
// if (error) throw error;
|
|
32
|
-
toast.success("Instellingen opgeslagen");
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
toast.error("Fout bij het opslaan");
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
setSaving(false);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Settings2, { className: "h-5 w-5 text-primary" }), _jsx(CardTitle, { children: "Module Instellingen" }), " "] }), _jsx(CardDescription, { children: "Beheer de instellingen voor deze module " })] }), _jsxs(CardContent, { className: "space-y-4", children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "setting", children: "Instelling" }), _jsx(Input, { id: "setting", value: setting, onChange: (e) => setSetting(e.target.value), placeholder: "Waarde..." })] }), _jsx(Button, { onClick: handleSave, disabled: saving, children: saving ? "Opslaan..." : "Opslaan" })] })] }));
|
|
42
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
interface MijnItem {
|
|
2
|
-
id: string;
|
|
3
|
-
created_at: string;
|
|
4
|
-
[key: string]: unknown;
|
|
5
|
-
}
|
|
6
|
-
export declare function useMijnModuleData(): {
|
|
7
|
-
items: MijnItem[];
|
|
8
|
-
loading: boolean;
|
|
9
|
-
error: string | null;
|
|
10
|
-
reload: () => Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
13
|
-
//# sourceMappingURL=useMijnModuleData.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMijnModuleData.d.ts","sourceRoot":"","sources":["../../src/hooks/useMijnModuleData.ts"],"names":[],"mappings":"AAkBA,UAAU,QAAQ;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,iBAAiB;;;;;EAkChC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// src/hooks/useMijnModuleData.ts — EXAMPLE DATA HOOK
|
|
3
|
-
// ============================================================================
|
|
4
|
-
// Put your data fetching logic in hooks like this, not directly in components.
|
|
5
|
-
// This keeps your pages clean and makes it easy to reuse data across pages.
|
|
6
|
-
//
|
|
7
|
-
// WHAT TO DO:
|
|
8
|
-
// - Rename to match your data (e.g. useProducts, useOrders, useSuppliers)
|
|
9
|
-
// - Replace the example query with your real Supabase query
|
|
10
|
-
// - Replace MijnItem with your actual table's row type
|
|
11
|
-
// - Import and use in your page components
|
|
12
|
-
// - Delete this file if you prefer a different pattern
|
|
13
|
-
// ============================================================================
|
|
14
|
-
import { useState, useEffect, useCallback } from "react";
|
|
15
|
-
import { supabase, toast } from "@flowselections/core";
|
|
16
|
-
export function useMijnModuleData() {
|
|
17
|
-
const [items, setItems] = useState([]);
|
|
18
|
-
const [loading, setLoading] = useState(true);
|
|
19
|
-
const [error, setError] = useState(null);
|
|
20
|
-
const load = useCallback(async () => {
|
|
21
|
-
setLoading(true);
|
|
22
|
-
setError(null);
|
|
23
|
-
try {
|
|
24
|
-
const { data, error } = await supabase
|
|
25
|
-
.from("products") // ← CHANGE THIS to your table
|
|
26
|
-
.select("*")
|
|
27
|
-
.order("created_at", { ascending: false });
|
|
28
|
-
if (error)
|
|
29
|
-
throw error;
|
|
30
|
-
setItems(data ?? []);
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
setError("Fout bij het laden van gegevens");
|
|
34
|
-
toast.error("Fout bij het laden van gegevens");
|
|
35
|
-
}
|
|
36
|
-
finally {
|
|
37
|
-
setLoading(false);
|
|
38
|
-
}
|
|
39
|
-
}, []);
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
load();
|
|
42
|
-
}, [load]);
|
|
43
|
-
return {
|
|
44
|
-
items,
|
|
45
|
-
loading,
|
|
46
|
-
error,
|
|
47
|
-
reload: load,
|
|
48
|
-
};
|
|
49
|
-
}
|