@flowselections/scan-module 1.0.2 → 1.0.3

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 (29) hide show
  1. package/dist-lib/components/ScanModulePage.d.ts.map +1 -1
  2. package/dist-lib/components/ScanModulePage.js +31 -9
  3. package/dist-lib/components/scanners/KarScannerPage.d.ts +3 -1
  4. package/dist-lib/components/scanners/KarScannerPage.d.ts.map +1 -1
  5. package/dist-lib/components/scanners/KarScannerPage.js +87 -8
  6. package/dist-lib/components/scanners/PublicScannerPage.d.ts +2 -1
  7. package/dist-lib/components/scanners/PublicScannerPage.d.ts.map +1 -1
  8. package/dist-lib/components/scanners/PublicScannerPage.js +2 -2
  9. package/dist-lib/components/scanners/ScannerBySlug.d.ts.map +1 -1
  10. package/dist-lib/components/scanners/ScannerBySlug.js +3 -2
  11. package/dist-lib/hooks/useScanners.d.ts +3 -1
  12. package/dist-lib/hooks/useScanners.d.ts.map +1 -1
  13. package/dist-lib/hooks/useScanners.js +1 -0
  14. package/dist-lib/integrations/supabase/auth-middleware.d.ts +2284 -229
  15. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  16. package/dist-lib/integrations/supabase/client.d.ts +2284 -229
  17. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  18. package/dist-lib/integrations/supabase/client.server.d.ts +2284 -229
  19. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  20. package/dist-lib/integrations/supabase/types.d.ts +2363 -292
  21. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  22. package/dist-lib/integrations/supabase/types.js +15 -1
  23. package/dist-lib/lib/scanI18n.d.ts +1 -1
  24. package/dist-lib/lib/scanI18n.d.ts.map +1 -1
  25. package/dist-lib/lib/scanI18n.js +139 -1
  26. package/dist-lib/lib/veilingbonPrint.d.ts +43 -0
  27. package/dist-lib/lib/veilingbonPrint.d.ts.map +1 -0
  28. package/dist-lib/lib/veilingbonPrint.js +124 -0
  29. package/package.json +105 -103
@@ -8,7 +8,18 @@ export const Constants = {
8
8
  "klaar",
9
9
  "mislukt",
10
10
  ],
11
- app_role: ["admin", "planner", "monteur", "administratie", "ai_admin"],
11
+ app_role: [
12
+ "admin",
13
+ "planner",
14
+ "monteur",
15
+ "administratie",
16
+ "ai_admin",
17
+ "manager",
18
+ "warehouse",
19
+ "sales",
20
+ "developer",
21
+ "receptie",
22
+ ],
12
23
  doc_layout_type: [
13
24
  "pakbon",
14
25
  "factuur",
@@ -24,6 +35,9 @@ export const Constants = {
24
35
  "vrij",
25
36
  "sticker",
26
37
  "productiebon",
38
+ "veilingbon",
39
+ "afleverbrief",
40
+ "veilingbrief",
27
41
  ],
28
42
  doc_orientation: ["portrait", "landscape"],
29
43
  exact_env: ["staging", "live"],
@@ -5,7 +5,7 @@ export interface ScanLanguage {
5
5
  locale: string;
6
6
  }
7
7
  export declare const SCAN_LANGUAGES: ScanLanguage[];
8
- export type ScanTextKey = "chooseLanguage" | "chooseLanguageHint" | "changeLanguage" | "scanner" | "defaultSubtitle" | "loggedInAs" | "otherEmployee" | "whoScans" | "nameHint" | "name" | "namePlaceholder" | "pin" | "startScanning" | "fillName" | "wrongPin" | "restart" | "stepPakbon" | "stepScanning" | "stepReady" | "searchPakbon" | "scanPakbon" | "closeScanZone" | "openPakbonnen" | "loading" | "noPakbonnen" | "noSearchResults" | "order" | "buffer" | "next" | "pakbon" | "pakbonnen" | "products" | "selectAtLeastOne" | "scanZone" | "scanZoneHint" | "startCamera" | "stopCamera" | "codePlaceholder" | "pakbonCodePlaceholder" | "productCodePlaceholder" | "confirmCode" | "inProgressBy" | "finishWithOpen" | "nothingScannedYet" | "cameraUnsupported" | "remaining" | "productsScanned" | "pakbonnenOnCart" | "lastScanned" | "nothingScanned" | "remove" | "fust" | "fustAdded" | "makeVeilingbon" | "veilingbonCreated" | "pakbonStatus" | "allProcessed" | "stillOpen" | "newCart" | "historyNote" | "print" | "pickStation" | "sentToPrinter" | "sentToPick";
8
+ export type ScanTextKey = "chooseLanguage" | "chooseLanguageHint" | "changeLanguage" | "scanner" | "defaultSubtitle" | "loggedInAs" | "otherEmployee" | "whoScans" | "nameHint" | "name" | "namePlaceholder" | "pin" | "startScanning" | "fillName" | "wrongPin" | "restart" | "stepPakbon" | "stepScanning" | "stepReady" | "searchPakbon" | "scanPakbon" | "closeScanZone" | "openPakbonnen" | "loading" | "noPakbonnen" | "noSearchResults" | "order" | "buffer" | "next" | "pakbon" | "pakbonnen" | "products" | "selectAtLeastOne" | "scanZone" | "scanZoneHint" | "startCamera" | "stopCamera" | "codePlaceholder" | "pakbonCodePlaceholder" | "productCodePlaceholder" | "confirmCode" | "inProgressBy" | "finishWithOpen" | "nothingScannedYet" | "cameraUnsupported" | "remaining" | "productsScanned" | "pakbonnenOnCart" | "lastScanned" | "nothingScanned" | "remove" | "fust" | "fustAdded" | "makeVeilingbon" | "veilingbonCreated" | "pakbonStatus" | "allProcessed" | "stillOpen" | "newCart" | "historyNote" | "print" | "pickStation" | "sentToPrinter" | "sentToPick" | "printNoWorkplace" | "printNoPrinter" | "printSending" | "printQueued" | "printBusy" | "printDone" | "printFailed" | "printAlreadyQueued" | "printAgain";
9
9
  export type ScanDict = Record<ScanTextKey, string>;
10
10
  export type ScanT = (key: ScanTextKey, vars?: Record<string, string | number>) => string;
11
11
  export declare function getScanTexts(code?: string | null): ScanDict;
@@ -1 +1 @@
1
- {"version":3,"file":"scanI18n.d.ts","sourceRoot":"","sources":["../../src/lib/scanI18n.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,cAAc,EAAE,YAAY,EAaxC,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,gBAAgB,GAChB,oBAAoB,GACpB,gBAAgB,GAChB,SAAS,GACT,i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AC,GAAG,EAAE,WAAW,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,MAAM,CAAC;AAEzF,wBAAgB,YAAY,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAK3D;AAED,uDAAuD;AACvD,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,KAAK,CAWvD;AAED,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,WAAsC,CAAC"}
@@ -790,6 +790,141 @@ const uk = {
790
790
  sentToPrinter: "Аукціонну накладну надіслано на принтер",
791
791
  sentToPick: "Аукціонну накладну надіслано до Pick Station",
792
792
  };
793
+ // ── Printteksten (centrale print-API) ───────────────────────────────────────
794
+ const PRINT_TEXTS = {
795
+ nl: {
796
+ printNoWorkplace: "Geen werkplek ingesteld voor deze scanner",
797
+ printNoPrinter: "Geen printer gekoppeld aan werkplek {n} — stel dit in bij Layouts & printers",
798
+ printSending: "Bezig met versturen…",
799
+ printQueued: "Staat in de wachtrij",
800
+ printBusy: "Wordt geprint…",
801
+ printDone: "Geprint",
802
+ printFailed: "Printen mislukt: {n}",
803
+ printAlreadyQueued: "Stond al in de wachtrij",
804
+ printAgain: "Opnieuw printen",
805
+ },
806
+ en: {
807
+ printNoWorkplace: "No workplace set for this scanner",
808
+ printNoPrinter: "No printer linked to workplace {n} — set this up in Layouts & printers",
809
+ printSending: "Sending…",
810
+ printQueued: "In the print queue",
811
+ printBusy: "Printing…",
812
+ printDone: "Printed",
813
+ printFailed: "Printing failed: {n}",
814
+ printAlreadyQueued: "Was already in the queue",
815
+ printAgain: "Print again",
816
+ },
817
+ de: {
818
+ printNoWorkplace: "Für diesen Scanner ist kein Arbeitsplatz eingestellt",
819
+ printNoPrinter: "Kein Drucker mit Arbeitsplatz {n} verknüpft — bitte in Layouts & Drucker einstellen",
820
+ printSending: "Wird gesendet…",
821
+ printQueued: "In der Warteschlange",
822
+ printBusy: "Wird gedruckt…",
823
+ printDone: "Gedruckt",
824
+ printFailed: "Drucken fehlgeschlagen: {n}",
825
+ printAlreadyQueued: "Stand bereits in der Warteschlange",
826
+ printAgain: "Erneut drucken",
827
+ },
828
+ fr: {
829
+ printNoWorkplace: "Aucun poste de travail défini pour ce scanner",
830
+ printNoPrinter: "Aucune imprimante liée au poste {n} — configurez-la dans Layouts & imprimantes",
831
+ printSending: "Envoi en cours…",
832
+ printQueued: "Dans la file d'attente",
833
+ printBusy: "Impression en cours…",
834
+ printDone: "Imprimé",
835
+ printFailed: "Échec de l'impression : {n}",
836
+ printAlreadyQueued: "Était déjà dans la file d'attente",
837
+ printAgain: "Imprimer à nouveau",
838
+ },
839
+ it: {
840
+ printNoWorkplace: "Nessuna postazione impostata per questo scanner",
841
+ printNoPrinter: "Nessuna stampante collegata alla postazione {n} — impostala in Layouts e stampanti",
842
+ printSending: "Invio in corso…",
843
+ printQueued: "In coda di stampa",
844
+ printBusy: "Stampa in corso…",
845
+ printDone: "Stampato",
846
+ printFailed: "Stampa non riuscita: {n}",
847
+ printAlreadyQueued: "Era già in coda",
848
+ printAgain: "Stampa di nuovo",
849
+ },
850
+ es: {
851
+ printNoWorkplace: "No hay puesto de trabajo configurado para este escáner",
852
+ printNoPrinter: "Ninguna impresora vinculada al puesto {n} — configúrelo en Layouts e impresoras",
853
+ printSending: "Enviando…",
854
+ printQueued: "En la cola de impresión",
855
+ printBusy: "Imprimiendo…",
856
+ printDone: "Impreso",
857
+ printFailed: "Error al imprimir: {n}",
858
+ printAlreadyQueued: "Ya estaba en la cola",
859
+ printAgain: "Imprimir de nuevo",
860
+ },
861
+ da: {
862
+ printNoWorkplace: "Ingen arbejdsplads angivet for denne scanner",
863
+ printNoPrinter: "Ingen printer knyttet til arbejdspladsen {n} — indstil det under Layouts og printere",
864
+ printSending: "Sender…",
865
+ printQueued: "I printkøen",
866
+ printBusy: "Udskriver…",
867
+ printDone: "Udskrevet",
868
+ printFailed: "Udskrivning mislykkedes: {n}",
869
+ printAlreadyQueued: "Stod allerede i køen",
870
+ printAgain: "Udskriv igen",
871
+ },
872
+ sv: {
873
+ printNoWorkplace: "Ingen arbetsplats inställd för denna skanner",
874
+ printNoPrinter: "Ingen skrivare kopplad till arbetsplatsen {n} — ställ in det under Layouts och skrivare",
875
+ printSending: "Skickar…",
876
+ printQueued: "I utskriftskön",
877
+ printBusy: "Skriver ut…",
878
+ printDone: "Utskriven",
879
+ printFailed: "Utskriften misslyckades: {n}",
880
+ printAlreadyQueued: "Fanns redan i kön",
881
+ printAgain: "Skriv ut igen",
882
+ },
883
+ pl: {
884
+ printNoWorkplace: "Nie ustawiono stanowiska dla tego skanera",
885
+ printNoPrinter: "Brak drukarki przypisanej do stanowiska {n} — ustaw to w Layouts i drukarki",
886
+ printSending: "Wysyłanie…",
887
+ printQueued: "W kolejce wydruku",
888
+ printBusy: "Drukowanie…",
889
+ printDone: "Wydrukowano",
890
+ printFailed: "Drukowanie nie powiodło się: {n}",
891
+ printAlreadyQueued: "Było już w kolejce",
892
+ printAgain: "Drukuj ponownie",
893
+ },
894
+ ro: {
895
+ printNoWorkplace: "Nicio stație de lucru setată pentru acest scaner",
896
+ printNoPrinter: "Nicio imprimantă asociată stației {n} — configurați în Layouts și imprimante",
897
+ printSending: "Se trimite…",
898
+ printQueued: "În coada de printare",
899
+ printBusy: "Se printează…",
900
+ printDone: "Printat",
901
+ printFailed: "Printarea a eșuat: {n}",
902
+ printAlreadyQueued: "Era deja în coadă",
903
+ printAgain: "Printează din nou",
904
+ },
905
+ bg: {
906
+ printNoWorkplace: "Няма зададено работно място за този скенер",
907
+ printNoPrinter: "Няма принтер, свързан с работно място {n} — настройте го в Layouts и принтери",
908
+ printSending: "Изпраща се…",
909
+ printQueued: "В опашката за печат",
910
+ printBusy: "Печата се…",
911
+ printDone: "Отпечатано",
912
+ printFailed: "Печатът е неуспешен: {n}",
913
+ printAlreadyQueued: "Вече беше в опашката",
914
+ printAgain: "Печат отново",
915
+ },
916
+ uk: {
917
+ printNoWorkplace: "Для цього сканера не задано робоче місце",
918
+ printNoPrinter: "Немає принтера, прив'язаного до робочого місця {n} — налаштуйте у Layouts і принтери",
919
+ printSending: "Надсилання…",
920
+ printQueued: "У черзі друку",
921
+ printBusy: "Друкується…",
922
+ printDone: "Надруковано",
923
+ printFailed: "Не вдалося надрукувати: {n}",
924
+ printAlreadyQueued: "Уже було в черзі",
925
+ printAgain: "Надрукувати ще раз",
926
+ },
927
+ };
793
928
  const DICTS = {
794
929
  nl,
795
930
  en,
@@ -805,7 +940,10 @@ const DICTS = {
805
940
  uk,
806
941
  };
807
942
  export function getScanTexts(code) {
808
- return DICTS[code ?? "nl"] ?? nl;
943
+ const taal = code ?? "nl";
944
+ const basis = DICTS[taal] ?? nl;
945
+ const print = PRINT_TEXTS[taal] ?? PRINT_TEXTS["en"];
946
+ return { ...basis, ...PRINT_TEXTS["nl"], ...print };
809
947
  }
810
948
  /** Vertaalfunctie met eenvoudige {naam}-vervanging. */
811
949
  export function createScanT(code) {
@@ -0,0 +1,43 @@
1
+ export declare const VEILINGBON_PAPIERFORMAAT = "A4";
2
+ export type PrintJobStatus = "wachtend" | "bezig" | "voltooid" | "mislukt" | "geannuleerd";
3
+ export interface VeilingbonRegel {
4
+ product_code: string;
5
+ product_naam: string | null;
6
+ aantal: number;
7
+ }
8
+ export interface VeilingbonPayload {
9
+ karnummer: string;
10
+ ordernummer: string;
11
+ buffer: string;
12
+ klanten: string[];
13
+ medewerker: string;
14
+ regels: VeilingbonRegel[];
15
+ }
16
+ /** Dezelfde bon stond al in de wachtrij (dubbelbeveiliging van de print-API). */
17
+ export declare function isDubbeleAanvraag(fout: unknown): boolean;
18
+ /**
19
+ * Printer die bij een werkplek hoort. De werkplek moet gelijk zijn aan de
20
+ * locatie- of systeemnaam van de printer in Layouts & printers.
21
+ */
22
+ export declare function printerVoorWerkplek(werkplek: string | null | undefined, papierformaat?: string): Promise<string | null>;
23
+ export interface VeilingbonPrintResultaat {
24
+ jobId: string;
25
+ printerId: string | null;
26
+ }
27
+ /**
28
+ * Zet de veilingbon in de centrale printwachtrij.
29
+ * Eerst altijd printDocument (mét printerId). Alleen als daar geen layout voor
30
+ * bestaat volgt printHtml met de bestaande veilingbon-HTML. Nooit allebei.
31
+ */
32
+ export declare function printVeilingbon(opties: {
33
+ printerId: string;
34
+ documentnaam: string;
35
+ payload: VeilingbonPayload;
36
+ html: string;
37
+ isHerprint?: boolean;
38
+ }): Promise<VeilingbonPrintResultaat>;
39
+ /** Volgt de status van een printopdracht. Geeft een opzegfunctie terug. */
40
+ export declare function volgJobStatus(jobId: string, callback: (status: PrintJobStatus, foutmelding?: string | null) => void): () => void;
41
+ /** HTML-variant van de veilingbon (alleen gebruikt als er geen layout is). */
42
+ export declare function veilingbonHtml(payload: VeilingbonPayload): string;
43
+ //# sourceMappingURL=veilingbonPrint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"veilingbonPrint.d.ts","sourceRoot":"","sources":["../../src/lib/veilingbonPrint.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,GAAG,aAAa,CAAC;AAE3F,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAQD,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAKxD;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,aAAa,GAAE,MAAiC,GAC/C,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqBxB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAgBpC;AAED,2EAA2E;AAC3E,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GACtE,MAAM,IAAI,CA0BZ;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CA6BjE"}
@@ -0,0 +1,124 @@
1
+ // ============================================================================
2
+ // src/lib/veilingbonPrint.ts — VEILINGBON VIA DE CENTRALE PRINT-API
3
+ // ============================================================================
4
+ // De scanner-module schrijft NOOIT zelf in print_jobs en beheert geen printers.
5
+ // Alles loopt via @flowselections/layout-maker. Zolang een helper daar nog niet
6
+ // in zit, wordt een read-only vervanger gebruikt (printerlijst / statuslezen).
7
+ // ============================================================================
8
+ import * as layoutMaker from "@flowselections/layout-maker";
9
+ import { supabase } from "@flowselections/core";
10
+ /* eslint-disable @typescript-eslint/no-explicit-any */
11
+ const lm = layoutMaker;
12
+ const db = supabase;
13
+ export const VEILINGBON_PAPIERFORMAAT = "A4";
14
+ /** Fout die aangeeft dat er geen layout bestaat voor het documenttype. */
15
+ function isGeenLayoutFout(fout) {
16
+ const bericht = fout instanceof Error ? fout.message : String(fout ?? "");
17
+ return /geen layout gevonden/i.test(bericht);
18
+ }
19
+ /** Dezelfde bon stond al in de wachtrij (dubbelbeveiliging van de print-API). */
20
+ export function isDubbeleAanvraag(fout) {
21
+ const Dubbel = lm.DubbeleAanvraagFout;
22
+ if (typeof Dubbel === "function" && fout instanceof Dubbel)
23
+ return true;
24
+ const bericht = fout instanceof Error ? fout.message : String(fout ?? "");
25
+ return /dubbele aanvraag|al in de wachtrij|reeds aangevraagd/i.test(bericht);
26
+ }
27
+ /**
28
+ * Printer die bij een werkplek hoort. De werkplek moet gelijk zijn aan de
29
+ * locatie- of systeemnaam van de printer in Layouts & printers.
30
+ */
31
+ export async function printerVoorWerkplek(werkplek, papierformaat = VEILINGBON_PAPIERFORMAAT) {
32
+ const plek = (werkplek ?? "").trim();
33
+ if (!plek)
34
+ return null;
35
+ if (typeof lm.printerVoorWerkplek === "function") {
36
+ const gevonden = await lm.printerVoorWerkplek(plek, papierformaat);
37
+ if (!gevonden)
38
+ return null;
39
+ return typeof gevonden === "string" ? gevonden : (gevonden.id ?? null);
40
+ }
41
+ // Terugval: read-only printerlijst uit de centrale module.
42
+ if (typeof lm.beschikbarePrinters !== "function")
43
+ return null;
44
+ const printers = await lm.beschikbarePrinters();
45
+ const lijst = Array.isArray(printers) ? printers : [];
46
+ const past = (p) => [p?.locatie, p?.naam].some((waarde) => typeof waarde === "string" && waarde.trim().toLowerCase() === plek.toLowerCase()) && p?.actief !== false;
47
+ const opFormaat = lijst.filter((p) => past(p) && (!p?.papierformaat || p.papierformaat === papierformaat));
48
+ const gekozen = opFormaat[0] ?? lijst.filter(past)[0];
49
+ return gekozen?.id ?? null;
50
+ }
51
+ /**
52
+ * Zet de veilingbon in de centrale printwachtrij.
53
+ * Eerst altijd printDocument (mét printerId). Alleen als daar geen layout voor
54
+ * bestaat volgt printHtml met de bestaande veilingbon-HTML. Nooit allebei.
55
+ */
56
+ export async function printVeilingbon(opties) {
57
+ const basis = {
58
+ documenttype: "veilingbon",
59
+ documentnaam: opties.documentnaam,
60
+ printerId: opties.printerId,
61
+ isHerprint: opties.isHerprint === true,
62
+ };
63
+ try {
64
+ const res = await lm.printDocument({ ...basis, payload: opties.payload });
65
+ return { jobId: res?.jobId, printerId: res?.printerId ?? opties.printerId };
66
+ }
67
+ catch (fout) {
68
+ if (!isGeenLayoutFout(fout) || typeof lm.printHtml !== "function")
69
+ throw fout;
70
+ const res = await lm.printHtml({ ...basis, html: opties.html });
71
+ return { jobId: res?.jobId, printerId: res?.printerId ?? opties.printerId };
72
+ }
73
+ }
74
+ /** Volgt de status van een printopdracht. Geeft een opzegfunctie terug. */
75
+ export function volgJobStatus(jobId, callback) {
76
+ if (typeof lm.volgJobStatus === "function") {
77
+ const stop = lm.volgJobStatus(jobId, (job) => {
78
+ const status = (typeof job === "string" ? job : job?.status);
79
+ callback(status, typeof job === "object" ? (job?.foutmelding ?? null) : null);
80
+ });
81
+ return typeof stop === "function" ? stop : () => { };
82
+ }
83
+ // Terugval: read-only status uitlezen tot de opdracht klaar is.
84
+ let actief = true;
85
+ const lees = async () => {
86
+ const { data } = await db.from("print_jobs").select("status, foutmelding").eq("id", jobId).maybeSingle();
87
+ if (!actief || !data)
88
+ return;
89
+ callback(data.status, data.foutmelding ?? null);
90
+ if (data.status === "voltooid" || data.status === "mislukt" || data.status === "geannuleerd") {
91
+ actief = false;
92
+ clearInterval(timer);
93
+ }
94
+ };
95
+ const timer = setInterval(() => void lees(), 2000);
96
+ void lees();
97
+ return () => {
98
+ actief = false;
99
+ clearInterval(timer);
100
+ };
101
+ }
102
+ /** HTML-variant van de veilingbon (alleen gebruikt als er geen layout is). */
103
+ export function veilingbonHtml(payload) {
104
+ const esc = (waarde) => String(waarde ?? "")
105
+ .split("&").join("&amp;")
106
+ .split("<").join("&lt;")
107
+ .split(">").join("&gt;");
108
+ const regels = payload.regels
109
+ .map((r) => `<tr><td>${esc(r.product_code)}</td><td>${esc(r.product_naam ?? "")}</td><td style="text-align:right">${esc(r.aantal)}</td></tr>`)
110
+ .join("");
111
+ return `<!doctype html><html lang="nl"><head><meta charset="utf-8"><title>Veilingbon ${esc(payload.karnummer)}</title><style>
112
+ body{font-family:Arial,Helvetica,sans-serif;font-size:12pt;margin:16mm}
113
+ h1{font-size:20pt;margin:0 0 4mm}
114
+ table{width:100%;border-collapse:collapse;margin-top:6mm}
115
+ th,td{border-bottom:1px solid #999;padding:2mm 1mm;text-align:left}
116
+ </style></head><body>
117
+ <h1>Veilingbon ${esc(payload.karnummer)}</h1>
118
+ <p>Order: ${esc(payload.ordernummer)} · Buffer: ${esc(payload.buffer)}</p>
119
+ <p>Klanten: ${esc(payload.klanten.join(", "))}</p>
120
+ <p>Medewerker: ${esc(payload.medewerker)}</p>
121
+ <table><thead><tr><th>Code</th><th>Product</th><th style="text-align:right">Aantal</th></tr></thead>
122
+ <tbody>${regels}</tbody></table>
123
+ </body></html>`;
124
+ }
package/package.json CHANGED
@@ -1,103 +1,105 @@
1
- {
2
- "name": "@flowselections/scan-module",
3
- "version": "1.0.2",
4
- "flowselections": {
5
- "moduleId": "scan-module",
6
- "pages": [
7
- {
8
- "export": "ScanModulePage",
9
- "route": "scannen",
10
- "title": "Scanners"
11
- },
12
- {
13
- "export": "PublicScannerPage",
14
- "route": "scanner",
15
- "title": "Scanner — pakbonnen scannen en veilingbon maken",
16
- "nav": false,
17
- "public": true
18
- },
19
- {
20
- "export": "ScannerBySlug",
21
- "route": "scanner/$slug",
22
- "title": "Scanner — pakbonnen scannen en veilingbon maken",
23
- "nav": false,
24
- "public": true
25
- }
26
- ]
27
- },
28
- "private": false,
29
- "sideEffects": false,
30
- "type": "module",
31
- "main": "./dist-lib/index.js",
32
- "types": "./dist-lib/index.d.ts",
33
- "exports": {
34
- ".": {
35
- "types": "./dist-lib/index.d.ts",
36
- "default": "./dist-lib/index.js"
37
- },
38
- "./styles": "./dist-lib/styles.css"
39
- },
40
- "files": [
41
- "dist-lib",
42
- "public"
43
- ],
44
- "publishConfig": {
45
- "access": "public"
46
- },
47
- "scripts": {
48
- "dev": "vite dev",
49
- "build": "vite build",
50
- "build:lib": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node -e \"require('fs').writeFileSync('dist-lib/styles.css', '@source \\\"./\\\";\\n')\"",
51
- "build:lib:watch": "tsc -p tsconfig.build.json --watch",
52
- "build:dev": "vite build --mode development",
53
- "preview": "vite preview",
54
- "lint": "eslint ."
55
- },
56
- "peerDependencies": {
57
- "@flowselections/core": "*",
58
- "@tanstack/react-query": "^5.0.0",
59
- "@tanstack/react-router": "^1.0.0",
60
- "@tanstack/react-start": "^1.0.0",
61
- "lucide-react": "^0.400.0",
62
- "react": "^18 || ^19",
63
- "react-dom": "^18 || ^19",
64
- "sonner": "^2.0.0"
65
- },
66
- "dependencies": {
67
- "@supabase/supabase-js": "^2.110.0",
68
- "@zxing/browser": "^0.2.1",
69
- "@zxing/library": "^0.23.0"
70
- },
71
- "devDependencies": {
72
- "@cloudflare/vite-plugin": "^1.25.5",
73
- "@eslint/js": "^9.32.0",
74
- "@lovable.dev/vite-tanstack-config": "2.9.1",
75
- "@rsbuild/core": "^1.0.0",
76
- "@tailwindcss/vite": "^4.2.1",
77
- "@tanstack/react-query": "^5.83.0",
78
- "@tanstack/react-router": "^1.168.0",
79
- "@tanstack/react-start": "^1.167.14",
80
- "@tanstack/router-plugin": "^1.167.10",
81
- "@types/node": "^22.16.5",
82
- "@types/react": "^19.2.0",
83
- "@types/react-dom": "^19.2.0",
84
- "@vitejs/plugin-react": "^5.0.4",
85
- "eslint": "^9.32.0",
86
- "eslint-plugin-react-hooks": "^5.2.0",
87
- "eslint-plugin-react-refresh": "^0.4.20",
88
- "globals": "^15.15.0",
89
- "lucide-react": "^0.575.0",
90
- "react": "^19.2.0",
91
- "react-dom": "^19.2.0",
92
- "sonner": "^2.0.7",
93
- "tailwindcss": "^4.2.1",
94
- "tw-animate-css": "^1.3.4",
95
- "typescript": "^5.8.3",
96
- "tsc-alias": "^1.8.10",
97
- "typescript-eslint": "^8.56.1",
98
- "vite": "^7.3.1",
99
- "vite-tsconfig-paths": "^6.1.1",
100
- "nitro": "3.0.260603-beta",
101
- "@flowselections/core": "1.0.16"
102
- }
103
- }
1
+ {
2
+ "name": "@flowselections/scan-module",
3
+ "version": "1.0.3",
4
+ "flowselections": {
5
+ "moduleId": "scan-module",
6
+ "pages": [
7
+ {
8
+ "export": "ScanModulePage",
9
+ "route": "scannen",
10
+ "title": "Scanners"
11
+ },
12
+ {
13
+ "export": "PublicScannerPage",
14
+ "route": "scanner",
15
+ "title": "Scanner — pakbonnen scannen en veilingbon maken",
16
+ "nav": false,
17
+ "public": true
18
+ },
19
+ {
20
+ "export": "ScannerBySlug",
21
+ "route": "scanner/$slug",
22
+ "title": "Scanner — pakbonnen scannen en veilingbon maken",
23
+ "nav": false,
24
+ "public": true
25
+ }
26
+ ]
27
+ },
28
+ "private": false,
29
+ "sideEffects": false,
30
+ "type": "module",
31
+ "main": "./dist-lib/index.js",
32
+ "types": "./dist-lib/index.d.ts",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist-lib/index.d.ts",
36
+ "default": "./dist-lib/index.js"
37
+ },
38
+ "./styles": "./dist-lib/styles.css"
39
+ },
40
+ "files": [
41
+ "dist-lib",
42
+ "public"
43
+ ],
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "scripts": {
48
+ "dev": "vite dev",
49
+ "build": "vite build",
50
+ "build:lib": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && node -e \"require('fs').writeFileSync('dist-lib/styles.css', '@source \\\"./\\\";\\n')\"",
51
+ "build:lib:watch": "tsc -p tsconfig.build.json --watch",
52
+ "build:dev": "vite build --mode development",
53
+ "preview": "vite preview",
54
+ "lint": "eslint ."
55
+ },
56
+ "peerDependencies": {
57
+ "@flowselections/core": "*",
58
+ "@tanstack/react-query": "^5.0.0",
59
+ "@tanstack/react-router": "^1.0.0",
60
+ "@tanstack/react-start": "^1.0.0",
61
+ "lucide-react": "^0.400.0",
62
+ "react": "^18 || ^19",
63
+ "react-dom": "^18 || ^19",
64
+ "sonner": "^2.0.0",
65
+ "@flowselections/layout-maker": "*"
66
+ },
67
+ "dependencies": {
68
+ "@flowselections/layout-maker": "^1.7.3",
69
+ "@supabase/supabase-js": "^2.110.0",
70
+ "@zxing/browser": "^0.2.1",
71
+ "@zxing/library": "^0.23.0"
72
+ },
73
+ "devDependencies": {
74
+ "@cloudflare/vite-plugin": "^1.25.5",
75
+ "@eslint/js": "^9.32.0",
76
+ "@lovable.dev/vite-tanstack-config": "2.13.1",
77
+ "@rsbuild/core": "^1.0.0",
78
+ "@tailwindcss/vite": "^4.2.1",
79
+ "@tanstack/react-query": "^5.83.0",
80
+ "@tanstack/react-router": "^1.168.0",
81
+ "@tanstack/react-start": "^1.167.14",
82
+ "@tanstack/router-plugin": "^1.167.10",
83
+ "@types/node": "^22.16.5",
84
+ "@types/react": "^19.2.0",
85
+ "@types/react-dom": "^19.2.0",
86
+ "@vitejs/plugin-react": "^5.0.4",
87
+ "eslint": "^9.32.0",
88
+ "eslint-plugin-react-hooks": "^5.2.0",
89
+ "eslint-plugin-react-refresh": "^0.4.20",
90
+ "globals": "^15.15.0",
91
+ "lucide-react": "^0.575.0",
92
+ "react": "^19.2.0",
93
+ "react-dom": "^19.2.0",
94
+ "sonner": "^2.0.7",
95
+ "tailwindcss": "^4.2.1",
96
+ "tw-animate-css": "^1.3.4",
97
+ "typescript": "^5.8.3",
98
+ "tsc-alias": "^1.8.10",
99
+ "typescript-eslint": "^8.56.1",
100
+ "vite": "^7.3.1",
101
+ "vite-tsconfig-paths": "^6.1.1",
102
+ "nitro": "3.0.260603-beta",
103
+ "@flowselections/core": "1.0.16"
104
+ }
105
+ }