@flowselections/floriday-afhandeling-module 1.0.73 → 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.
Files changed (26) hide show
  1. package/dist-lib/components/afhandeling/ControleLijstPrint.d.ts.map +1 -1
  2. package/dist-lib/components/afhandeling/ControleLijstPrint.js +5 -2
  3. package/dist-lib/components/afhandeling/ControlePage.d.ts.map +1 -1
  4. package/dist-lib/components/afhandeling/ControlePage.js +17 -6
  5. package/dist-lib/integrations/supabase/previewAuthStorage.d.ts +11 -5
  6. package/dist-lib/integrations/supabase/previewAuthStorage.d.ts.map +1 -1
  7. package/dist-lib/integrations/supabase/previewAuthStorage.js +38 -21
  8. package/dist-lib/integrations/supabase/types.d.ts +1445 -15
  9. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  10. package/dist-lib/lib/cartAssignments.functions.d.ts.map +1 -1
  11. package/dist-lib/lib/cartAssignments.functions.js +12 -11
  12. package/dist-lib/lib/cartControl.functions.d.ts.map +1 -1
  13. package/dist-lib/lib/cartControl.functions.js +17 -16
  14. package/dist-lib/lib/cartSeqFout.d.ts +11 -0
  15. package/dist-lib/lib/cartSeqFout.d.ts.map +1 -0
  16. package/dist-lib/lib/cartSeqFout.js +18 -0
  17. package/dist-lib/lib/controleLijst.functions.d.ts +26 -0
  18. package/dist-lib/lib/controleLijst.functions.d.ts.map +1 -0
  19. package/dist-lib/lib/controleLijst.functions.js +55 -0
  20. package/dist-lib/lib/controleLijstPayload.d.ts +32 -0
  21. package/dist-lib/lib/controleLijstPayload.d.ts.map +1 -0
  22. package/dist-lib/lib/controleLijstPayload.js +92 -0
  23. package/dist-lib/lib/controleLijstPayload.test.d.ts +2 -0
  24. package/dist-lib/lib/controleLijstPayload.test.d.ts.map +1 -0
  25. package/dist-lib/lib/controleLijstPayload.test.js +34 -0
  26. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ControleLijstPrint.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/ControleLijstPrint.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,2BAA2B,CAAC;AAuCnC;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,WAAW,EAAE,EACpB,IAAI,GAAE,eAAsB,GAC3B,MAAM,CAoGR"}
1
+ {"version":3,"file":"ControleLijstPrint.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/ControleLijstPrint.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAInE,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,2BAA2B,CAAC;AAuCnC;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,WAAW,EAAE,EACpB,IAAI,GAAE,eAAsB,GAC3B,MAAM,CAqGR"}
@@ -1,4 +1,6 @@
1
1
  import { countryCode } from "../../lib/countries.js";
2
+ import { amsterdamDay } from "../../lib/timezone.js";
3
+ import { controleStatusTekst } from "../../lib/controleLijstPayload.js";
2
4
  import { getPrintDict, PICKSTATION_LOCALE, } from "../../lib/pickstationI18n.js";
3
5
  const DAY_ABBR_BY_LANG = {
4
6
  nl: ["ZO", "MA", "DI", "WO", "DO", "VR", "ZA"],
@@ -45,10 +47,11 @@ export function renderControleLijstHtml(carts, lang = "nl") {
45
47
  case "ready": return t.statusReady;
46
48
  case "shipped": return t.statusShipped;
47
49
  case "delivered": return t.statusDelivered;
48
- default: return String(status);
50
+ default: return controleStatusTekst(String(status), printedCount);
49
51
  }
50
52
  };
51
- const today = new Date().toLocaleDateString(locale, {
53
+ const today = new Date(`${amsterdamDay(new Date())}T12:00:00Z`).toLocaleDateString(locale, {
54
+ timeZone: "UTC",
52
55
  weekday: "long",
53
56
  day: "2-digit",
54
57
  month: "long",
@@ -1 +1 @@
1
- {"version":3,"file":"ControlePage.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/ControlePage.tsx"],"names":[],"mappings":"AAkJA,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CAAO,+BAo+BpE"}
1
+ {"version":3,"file":"ControlePage.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/ControlePage.tsx"],"names":[],"mappings":"AAoJA,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CAAO,+BA++BpE"}
@@ -10,6 +10,8 @@ import { ScanControleView } from "./ScanControleView.js";
10
10
  import { renderControleLijstHtml } from "./ControleLijstPrint.js";
11
11
  import { printHtmlDocument, printFoutMelding } from "../../lib/printing.js";
12
12
  import { callServerFn } from "../../lib/serverFnError.js";
13
+ import { printControleLijstViaLayout } from "../../lib/controleLijst.functions.js";
14
+ import { bouwControleLijstPayload } from "../../lib/controleLijstPayload.js";
13
15
  function dayDiffFromToday(iso) {
14
16
  const d = new Date(iso);
15
17
  if (Number.isNaN(d.getTime()))
@@ -94,6 +96,7 @@ export function ControlePage({ onExit } = {}) {
94
96
  const [confirmApproval, setConfirmApproval] = useState(null);
95
97
  const fetchToday = useServerFn(getTodaysControlCarts);
96
98
  const fetchHistory = useServerFn(listControlHistory);
99
+ const printControleLijstFn = useServerFn(printControleLijstViaLayout);
97
100
  const fetchProposals = useServerFn(getControlRescheduleProposals);
98
101
  const submit = useServerFn(submitControlSession);
99
102
  const fetchDraft = useServerFn(getControlDraft);
@@ -516,12 +519,20 @@ export function ControlePage({ onExit } = {}) {
516
519
  return (_jsxs("main", { className: "h-full overflow-y-auto p-6 space-y-6", children: [_jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-semibold", children: "Controle karren" }), _jsxs("p", { className: "text-sm text-muted-foreground", children: ["Dagelijkse eindcontrole \u2014 vandaag ", new Date().toLocaleDateString("nl-NL")] })] }), _jsxs("div", { className: "flex gap-2", children: [_jsxs(Button, { variant: "outline", disabled: printBezig || carts.length === 0, onClick: async () => {
517
520
  setPrintBezig(true);
518
521
  try {
519
- await printHtmlDocument({
520
- documenttype: "controlelijst",
521
- documentnaam: `CTRL-${new Date().toISOString().slice(0, 10)}`,
522
- html: renderControleLijstHtml(carts, "nl"),
523
- papierformaat: "A4",
524
- });
522
+ const documentnaam = `CTRL-${new Date().toISOString().slice(0, 10)}`;
523
+ const res = await callServerFn(() => printControleLijstFn({
524
+ data: { payload: bouwControleLijstPayload(carts), documentnaam },
525
+ }), "printControleLijstViaLayout");
526
+ if (res.route === "fout")
527
+ throw new Error(res.melding);
528
+ if (res.route === "terugval") {
529
+ await printHtmlDocument({
530
+ documenttype: "controlelijst",
531
+ documentnaam,
532
+ html: renderControleLijstHtml(carts, "nl"),
533
+ papierformaat: "A4",
534
+ });
535
+ }
525
536
  toast.success("Controlelijst naar de printer gestuurd.");
526
537
  }
527
538
  catch (err) {
@@ -1,6 +1,12 @@
1
- export declare function brokeredPreviewStorage(): Storage | {
2
- getItem: (key: string) => Promise<string | null>;
3
- setItem: (key: string, value: string) => Promise<void>;
4
- removeItem: (key: string) => Promise<undefined>;
5
- } | undefined;
1
+ /** Storage accepted by Supabase's `auth.storage` option; `localStorage` and the editor broker both satisfy it. */
2
+ export interface PreviewAuthStorage {
3
+ getItem: (key: string) => string | null | Promise<string | null>;
4
+ setItem: (key: string, value: string) => void | Promise<void>;
5
+ removeItem: (key: string) => void | Promise<void>;
6
+ }
7
+ /**
8
+ * On a Lovable preview surface, broker the auth session to the editor over
9
+ * postMessage so the project's preview surfaces share one login; else localStorage.
10
+ */
11
+ export declare function brokeredPreviewStorage(): PreviewAuthStorage | undefined;
6
12
  //# sourceMappingURL=previewAuthStorage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"previewAuthStorage.d.ts","sourceRoot":"","sources":["../../../src/integrations/supabase/previewAuthStorage.ts"],"names":[],"mappings":"AAIA,wBAAgB,sBAAsB;mBA6Db,MAAM;mBAwBZ,MAAM,SAAS,MAAM;sBASlB,MAAM;cAM3B"}
1
+ {"version":3,"file":"previewAuthStorage.d.ts","sourceRoot":"","sources":["../../../src/integrations/supabase/previewAuthStorage.ts"],"names":[],"mappings":"AAEA,kHAAkH;AAClH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACjE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD;AA6BD;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,kBAAkB,GAAG,SAAS,CAsGvE"}
@@ -1,6 +1,21 @@
1
1
  // This file is automatically generated. Do not edit it directly.
2
- // On a Lovable preview surface, broker the auth session to the editor over
3
- // postMessage so the project's preview surfaces share one login; else localStorage.
2
+ const RESULT = 'lovable-preview-auth:result';
3
+ function readBrokerReply(data, requestId) {
4
+ if (typeof data !== 'object' || data === null)
5
+ return null;
6
+ if (!('type' in data) || data.type !== RESULT)
7
+ return null;
8
+ if (!('requestId' in data) || data.requestId !== requestId)
9
+ return null;
10
+ return {
11
+ ok: 'ok' in data && Boolean(data.ok),
12
+ value: 'value' in data && typeof data.value === 'string' ? data.value : null,
13
+ };
14
+ }
15
+ /**
16
+ * On a Lovable preview surface, broker the auth session to the editor over
17
+ * postMessage so the project's preview surfaces share one login; else localStorage.
18
+ */
4
19
  export function brokeredPreviewStorage() {
5
20
  if (typeof window === 'undefined')
6
21
  return undefined;
@@ -11,10 +26,13 @@ export function brokeredPreviewStorage() {
11
26
  // preview--<name> host can't smuggle another project's id.
12
27
  const UUID = '[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}';
13
28
  const projectId = onPreviewZone
14
- ? (host.match(new RegExp('^(?:id-preview(?:-[a-z0-9]+)?|project)--(' + UUID + ')(?:-dev)?(?=\\.|$)', 'i'))?.[1]
15
- ?? host.match(new RegExp('^(' + UUID + ')(?=[.-])', 'i'))?.[1])
29
+ ? (new RegExp('^(?:id-preview(?:-[a-z0-9]+)?|project)--(' + UUID + ')(?:-dev)?(?=\\.|$)', 'i').exec(host)?.[1]
30
+ ?? new RegExp('^(' + UUID + ')(?=[.-])', 'i').exec(host)?.[1])
16
31
  : undefined;
17
- const framed = window.parent && window.parent !== window;
32
+ // lib.dom types window.parent and location.ancestorOrigins as always set, but a
33
+ // detached frame has no parent and not every browser implements ancestorOrigins.
34
+ const parentWindow = window.parent;
35
+ const framed = parentWindow !== null && parentWindow !== window;
18
36
  if (!projectId || !framed)
19
37
  return localStorage;
20
38
  // Post only to the real editor ancestor, validated as a Lovable origin, so the
@@ -23,40 +41,39 @@ export function brokeredPreviewStorage() {
23
41
  const EDITOR = dev
24
42
  ? /^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$|^http:\/\/localhost:3000$/
25
43
  : /^https:\/\/([a-z0-9-]+\.)*(lovable\.dev|gptengineer\.app)$/;
26
- const ancestor = (location.ancestorOrigins && location.ancestorOrigins[0]) || (document.referrer ? new URL(document.referrer).origin : '');
44
+ const ancestorOrigins = location.ancestorOrigins;
45
+ const ancestor = ancestorOrigins?.[0] ?? (document.referrer ? new URL(document.referrer).origin : '');
27
46
  const editorOrigins = ancestor && EDITOR.test(ancestor)
28
47
  ? [ancestor]
29
48
  : (dev ? ['https://lovable.dev', 'http://localhost:3000'] : ['https://lovable.dev']);
30
- const RESULT = 'lovable-preview-auth:result';
31
49
  const TIMEOUT = 2000;
32
50
  const newId = () => Math.random().toString(36).slice(2) + Date.now().toString(36);
33
51
  const request = (type, key, value) => new Promise((resolve) => {
34
52
  const requestId = newId();
35
53
  let done = false;
36
- let timer;
37
- const finish = (r) => {
54
+ const finish = (reply) => {
38
55
  if (done)
39
56
  return;
40
57
  done = true;
41
58
  clearTimeout(timer);
42
59
  window.removeEventListener('message', onMessage);
43
- resolve(r);
60
+ resolve(reply);
44
61
  };
45
62
  const onMessage = (e) => {
46
- if (editorOrigins.indexOf(e.origin) < 0)
63
+ if (!editorOrigins.includes(e.origin))
47
64
  return;
48
- const d = e.data;
49
- if (d && d.type === RESULT && d.requestId === requestId)
50
- finish(d);
65
+ const reply = readBrokerReply(e.data, requestId);
66
+ if (reply)
67
+ finish(reply);
51
68
  };
52
69
  window.addEventListener('message', onMessage);
70
+ const timer = setTimeout(() => { finish(null); }, TIMEOUT);
53
71
  const msg = { type, requestId, projectId, key };
54
72
  if (value !== undefined)
55
- msg['value'] = value;
73
+ msg.value = value;
56
74
  // targetOrigin per trusted editor origin, so a session token never reaches an arbitrary embedder.
57
75
  for (const origin of editorOrigins)
58
76
  window.parent.postMessage(msg, origin);
59
- timer = setTimeout(() => finish(null), TIMEOUT);
60
77
  });
61
78
  // The editor may not be listening yet at the first getItem, so retry once.
62
79
  let firstGet = true;
@@ -74,13 +91,13 @@ export function brokeredPreviewStorage() {
74
91
  const local = readLocal(key);
75
92
  let res = await request('lovable-preview-auth:get', key, local ?? undefined);
76
93
  if (!res && firstGet) {
77
- await new Promise((r) => setTimeout(r, RETRY_DELAY));
94
+ await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));
78
95
  res = await request('lovable-preview-auth:get', key, local ?? undefined);
79
96
  }
80
97
  firstGet = false;
81
98
  // '' is the logout tombstone: clear the local copy too so it can't resurrect if
82
- // the broker later goes silent. A null reply means never-synced -> keep local.
83
- if (res && res.ok && typeof res.value === 'string') {
99
+ // the broker later goes silent. A null value means never-synced -> keep local.
100
+ if (res?.ok && res.value !== null) {
84
101
  if (res.value === '') {
85
102
  if (local !== undefined && readLocal(key) === local)
86
103
  localStorage.removeItem(key);
@@ -100,7 +117,7 @@ export function brokeredPreviewStorage() {
100
117
  setItem: (key, value) => {
101
118
  localStorage.setItem(key, value);
102
119
  return request('lovable-preview-auth:set', key, value).then((res) => {
103
- if (res && res.ok && typeof res.value === 'string' && localStorage.getItem(key) === value) {
120
+ if (res?.ok && res.value !== null && localStorage.getItem(key) === value) {
104
121
  if (res.value === '')
105
122
  localStorage.removeItem(key);
106
123
  else
@@ -111,7 +128,7 @@ export function brokeredPreviewStorage() {
111
128
  removeItem: (key) => {
112
129
  const local = readLocal(key);
113
130
  localStorage.removeItem(key);
114
- return request('lovable-preview-auth:remove', key, local ?? undefined).then(() => undefined);
131
+ return request('lovable-preview-auth:remove', key, local ?? undefined).then(() => { });
115
132
  },
116
133
  };
117
134
  }