@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
|
@@ -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;
|
|
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":"
|
|
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
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DagDetailDialog.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/DagDetailDialog.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"DagDetailDialog.d.ts","sourceRoot":"","sources":["../../../src/components/afhandeling/DagDetailDialog.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAiMjE,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,uFAAuF;IACvF,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,4DAA4D;IAC5D,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,sCAG1D"}
|
|
@@ -53,7 +53,8 @@ import { toDayKey } from "../../lib/logisticsEngine/capacity.js";
|
|
|
53
53
|
import { VerzetOrderDialog } from "./VerzetOrderDialog.js";
|
|
54
54
|
import { markOrderShipped } from "../../lib/orderFulfilment.functions.js";
|
|
55
55
|
import { getDeliveryNotePdf } from "../../lib/deliveryNote.functions.js";
|
|
56
|
-
import {
|
|
56
|
+
import { getDocumentVoorOrder } from "../../lib/documentKeuze.functions.js";
|
|
57
|
+
import { kiesVerzendActie, AUTOMATISCH_DOCUMENT_TEKST } from "../../lib/documentKeuze.js";
|
|
57
58
|
import { setPickDay } from "../../lib/logisticsEngine/reschedule.js";
|
|
58
59
|
import { clearDayStaffPlan, computeCapacity, getDayStaffPlan, getEngineStaffDefaults, setDayStaffPlan, toDateKey, } from "../../lib/logisticsEngine/staffPlanning.js";
|
|
59
60
|
function voortgang(status) {
|
|
@@ -439,7 +440,18 @@ async function printDocumentenVoorOrder(p, fetchLines, fetchCarts, fetchDelivery
|
|
|
439
440
|
let printed = 0;
|
|
440
441
|
let failed = 0;
|
|
441
442
|
const skipped = [];
|
|
442
|
-
|
|
443
|
+
let pakbonKeuze;
|
|
444
|
+
try {
|
|
445
|
+
pakbonKeuze = await fetchShippingNoteLayout({ data: { orderId: p.order.id, documenttype: "pakbon" } });
|
|
446
|
+
}
|
|
447
|
+
catch (err) {
|
|
448
|
+
pakbonKeuze = { ok: false, layoutId: null, bron: null, documenttype: null, reden: err instanceof Error ? err.message : "Het document kon niet worden bepaald." };
|
|
449
|
+
}
|
|
450
|
+
if (!pakbonKeuze.ok) {
|
|
451
|
+
failed += engineCarts.length;
|
|
452
|
+
reasons.push(`Pakbon ${p.order.orderNumber} niet geprint: ${pakbonKeuze.reden}`);
|
|
453
|
+
}
|
|
454
|
+
await Promise.all((pakbonKeuze.ok ? engineCarts : []).map(async (engineCart, idx) => {
|
|
443
455
|
const nr = String(engineCart.cartNumber).padStart(2, "0");
|
|
444
456
|
const cartNumber = `${p.order.orderNumber}-${nr}`;
|
|
445
457
|
const ci = infoById.get(engineCart.cartId);
|
|
@@ -451,6 +463,7 @@ async function printDocumentenVoorOrder(p, fetchLines, fetchCarts, fetchDelivery
|
|
|
451
463
|
const opdracht = (isHerprint) => printLayoutDocument({
|
|
452
464
|
documenttype: "pakbon",
|
|
453
465
|
documentnaam: `PAK-${p.order.orderNumber}-${nr}`,
|
|
466
|
+
layoutId: pakbonKeuze.layoutId ?? undefined,
|
|
454
467
|
isHerprint,
|
|
455
468
|
volgStatus: false,
|
|
456
469
|
payload: pakbonPayload({ cartId: ci.cartId, barcode: ci.barcode, cartNumber, cartIndex: idx + 1, cartTotal, order: orderInfo, pickDate, lines: pakbonLines }),
|
|
@@ -474,16 +487,19 @@ async function printDocumentenVoorOrder(p, fetchLines, fetchCarts, fetchDelivery
|
|
|
474
487
|
console.warn("[print-all] pakbon mislukt", cartNumber, err);
|
|
475
488
|
}
|
|
476
489
|
}));
|
|
477
|
-
//
|
|
490
|
+
// Verzenddocument op de achtergrond: precies één per order, automatisch bepaald uit de order.
|
|
478
491
|
const achtergrond = (async () => {
|
|
479
492
|
try {
|
|
480
|
-
const
|
|
493
|
+
const actie = kiesVerzendActie(await fetchShippingNoteLayout({ data: { orderId: p.order.id, documenttype: "verzenddocument" } }));
|
|
481
494
|
let jobId = null;
|
|
482
|
-
if (
|
|
495
|
+
if (actie.soort === "overslaan") {
|
|
496
|
+
return { printed: 0, failed: 1, reasons: [`Verzenddocument ${p.order.orderNumber} niet geprint: ${actie.reden}`] };
|
|
497
|
+
}
|
|
498
|
+
else if (actie.soort === "layout") {
|
|
483
499
|
jobId = await printLayoutDocument({
|
|
484
|
-
documenttype:
|
|
500
|
+
documenttype: actie.documenttype,
|
|
485
501
|
documentnaam: `AFL-${p.order.orderNumber}`,
|
|
486
|
-
layoutId:
|
|
502
|
+
layoutId: actie.layoutId,
|
|
487
503
|
volgStatus: false,
|
|
488
504
|
payload: { order: { ...orderInfo, cartIndex: 1, cartTotal, cartNumber: p.order.orderNumber } },
|
|
489
505
|
});
|
|
@@ -491,7 +507,7 @@ async function printDocumentenVoorOrder(p, fetchLines, fetchCarts, fetchDelivery
|
|
|
491
507
|
else {
|
|
492
508
|
const { pdf } = await fetchDeliveryNote({ data: { orderRef: p.order.orderNumber } });
|
|
493
509
|
if (!pdf)
|
|
494
|
-
return { printed: 0, failed: 1, reasons: [`
|
|
510
|
+
return { printed: 0, failed: 1, reasons: [`Verzenddocument ${p.order.orderNumber} niet geprint: Floriday heeft de verzendbrief nog niet geleverd.`] };
|
|
495
511
|
jobId = await printPdfDocument({ documenttype: "afleverbrief", documentnaam: `AFL-${p.order.orderNumber}`, pdfBase64: pdf.base64, volgStatus: false });
|
|
496
512
|
}
|
|
497
513
|
return jobId ? { printed: 1, failed: 0, reasons: [] } : { printed: 0, failed: 1, reasons: ["de Printwachtrij gaf geen opdracht-id terug."] };
|
|
@@ -524,7 +540,7 @@ function BufferGroup({ bufferId, orders: dayOrders }) {
|
|
|
524
540
|
const fetchLines = useServerFn(getOrderLines);
|
|
525
541
|
const fetchCarts = useServerFn(getOrderCartIds);
|
|
526
542
|
const fetchDeliveryNote = useServerFn(getDeliveryNotePdf);
|
|
527
|
-
const fetchShippingNoteLayout = useServerFn(
|
|
543
|
+
const fetchShippingNoteLayout = useServerFn(getDocumentVoorOrder);
|
|
528
544
|
const fetchPakbonInfo = useServerFn(getPakbonCartInfo);
|
|
529
545
|
const shipState = useContext(ShipStateCtx);
|
|
530
546
|
// Tel op unieke kar-id: een gedeelde bufferkar telt één keer.
|
|
@@ -670,7 +686,7 @@ function OrderRow({ planned: p, cartsToday, engineStatus, }) {
|
|
|
670
686
|
const fetchLines = useServerFn(getOrderLines);
|
|
671
687
|
const fetchCarts = useServerFn(getOrderCartIds);
|
|
672
688
|
const fetchDeliveryNote = useServerFn(getDeliveryNotePdf);
|
|
673
|
-
const fetchShippingNoteLayout = useServerFn(
|
|
689
|
+
const fetchShippingNoteLayout = useServerFn(getDocumentVoorOrder);
|
|
674
690
|
const archivedQ = useOrderArchived(p.order.id);
|
|
675
691
|
const shipStateRow = useContext(ShipStateCtx).get(refKey(p.order.orderNumber));
|
|
676
692
|
const fetchPakbonInfo = useServerFn(getPakbonCartInfo);
|
|
@@ -785,7 +801,7 @@ function KarRow({ cart: c, cartTotal, selected, onToggle, }) {
|
|
|
785
801
|
const [bezig, setBezig] = useState(null);
|
|
786
802
|
const fetchLines = useServerFn(getOrderLines);
|
|
787
803
|
const fetchDeliveryNote = useServerFn(getDeliveryNotePdf);
|
|
788
|
-
const fetchShippingNoteLayout = useServerFn(
|
|
804
|
+
const fetchShippingNoteLayout = useServerFn(getDocumentVoorOrder);
|
|
789
805
|
const fetchPakbonInfo = useServerFn(getPakbonCartInfo);
|
|
790
806
|
const printPakbon = async () => {
|
|
791
807
|
if (bezig)
|
|
@@ -815,8 +831,14 @@ function KarRow({ cart: c, cartTotal, selected, onToggle, }) {
|
|
|
815
831
|
if (!ci)
|
|
816
832
|
throw new Error(`Pakbon ${c.cartNumber} kan nog niet worden geprint: de kar is nog niet ingedeeld. Probeer het over een minuut opnieuw.`);
|
|
817
833
|
const nr = String(c.cartIndex + 1).padStart(2, "0");
|
|
834
|
+
if (!p?.order.id)
|
|
835
|
+
throw new Error(`Pakbon ${c.cartNumber} niet geprint: de order is niet gevonden.`);
|
|
836
|
+
const keuze = await fetchShippingNoteLayout({ data: { orderId: p.order.id, documenttype: "pakbon" } });
|
|
837
|
+
if (!keuze.ok)
|
|
838
|
+
throw new Error(`Pakbon ${c.cartNumber} niet geprint: ${keuze.reden}`);
|
|
818
839
|
await printLayoutDocument({
|
|
819
840
|
documenttype: "pakbon",
|
|
841
|
+
layoutId: keuze.layoutId ?? undefined,
|
|
820
842
|
documentnaam: `PAK-${c.orderRef}-${nr}`,
|
|
821
843
|
isHerprint: true,
|
|
822
844
|
volgStatus: false,
|
|
@@ -851,35 +873,39 @@ function KarRow({ cart: c, cartTotal, selected, onToggle, }) {
|
|
|
851
873
|
return;
|
|
852
874
|
setBezig("brief");
|
|
853
875
|
try {
|
|
854
|
-
// 1) De layout die de Engine koppelt aan "Verzendbrief voor BVO orders".
|
|
855
876
|
const p = c.order;
|
|
856
|
-
|
|
857
|
-
|
|
877
|
+
if (!p?.order.id)
|
|
878
|
+
throw new Error(`Verzenddocument ${c.orderRef} niet geprint: de order is niet gevonden.`);
|
|
879
|
+
const actie = kiesVerzendActie(await fetchShippingNoteLayout({ data: { orderId: p.order.id, documenttype: "verzenddocument" } }));
|
|
880
|
+
if (actie.soort === "overslaan") {
|
|
881
|
+
toast.error(`Verzenddocument ${c.orderRef} niet geprint: ${actie.reden}`);
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
if (actie.soort === "layout") {
|
|
858
885
|
await printLayoutDocument({
|
|
859
|
-
documenttype:
|
|
886
|
+
documenttype: actie.documenttype,
|
|
860
887
|
documentnaam: `AFL-${c.orderRef}`,
|
|
861
|
-
layoutId:
|
|
888
|
+
layoutId: actie.layoutId,
|
|
862
889
|
isHerprint: true,
|
|
863
890
|
payload: {
|
|
864
891
|
order: {
|
|
865
|
-
id: p
|
|
892
|
+
id: p.order.id,
|
|
866
893
|
orderNumber: c.orderRef,
|
|
867
894
|
customerName: c.customerName,
|
|
868
|
-
country: p
|
|
869
|
-
deliveryDate: p
|
|
895
|
+
country: p.order.country ?? null,
|
|
896
|
+
deliveryDate: p.order.deliveryDate ?? null,
|
|
870
897
|
cartIndex: c.cartIndex,
|
|
871
898
|
cartTotal,
|
|
872
899
|
cartNumber: c.cartNumber,
|
|
873
900
|
},
|
|
874
901
|
},
|
|
875
902
|
});
|
|
876
|
-
toast.success(`
|
|
903
|
+
toast.success(`Verzenddocument ${c.orderRef} is naar de printer gestuurd.`);
|
|
877
904
|
return;
|
|
878
905
|
}
|
|
879
|
-
// 2) Geen eigen layout ingesteld: dan de Floriday-brief, als die er is.
|
|
880
906
|
const { pdf } = await fetchDeliveryNote({ data: { orderRef: c.orderRef } });
|
|
881
907
|
if (!pdf) {
|
|
882
|
-
toast.error(
|
|
908
|
+
toast.error(`Verzenddocument ${c.orderRef} niet geprint: Floriday heeft de verzendbrief nog niet geleverd.`);
|
|
883
909
|
return;
|
|
884
910
|
}
|
|
885
911
|
await printPdfDocument({
|
|
@@ -888,7 +914,7 @@ function KarRow({ cart: c, cartTotal, selected, onToggle, }) {
|
|
|
888
914
|
isHerprint: true,
|
|
889
915
|
pdfBase64: pdf.base64,
|
|
890
916
|
});
|
|
891
|
-
toast.success(`
|
|
917
|
+
toast.success(`Verzenddocument ${c.orderRef} is naar de printer gestuurd.`);
|
|
892
918
|
}
|
|
893
919
|
catch (err) {
|
|
894
920
|
toast.error(printFoutMelding(err));
|
|
@@ -899,7 +925,7 @@ function KarRow({ cart: c, cartTotal, selected, onToggle, }) {
|
|
|
899
925
|
};
|
|
900
926
|
return (_jsxs("div", { className: `rounded-md border p-3 ${selected ? "border-primary bg-primary/5" : ""}`, children: [_jsxs("div", { className: "flex items-start gap-3", children: [_jsx(Checkbox, { checked: selected, onCheckedChange: onToggle, className: "mt-1" }), _jsxs("div", { className: "grid flex-1 gap-3 lg:grid-cols-[1fr_1.4fr_1fr_auto] lg:items-center", children: [_jsx(Field, { label: "Karnummer", value: c.cartNumber }), _jsx(Field, { label: "Klant", value: c.customerName }), _jsx(Field, { label: "Bestelling", value: c.orderRef }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Badge, { variant: voortgang(c.status).variant, children: voortgang(c.status).label }), c.coverageLabel && _jsx(Badge, { variant: "secondary", children: c.coverageLabel }), c.hasContent ? (_jsxs(_Fragment, { children: [c.shared && _jsx(Badge, { variant: "outline", children: "Gedeelde bufferkar" }), _jsxs(Badge, { variant: "outline", children: [c.occupancy ?? "—", "%", c.layerUtilization != null
|
|
901
927
|
? ` · ${Number(c.layerUtilization.toFixed(1)).toLocaleString("nl-NL")}% van de kar`
|
|
902
|
-
: ""] }), _jsxs(Badge, { variant: "outline", children: [c.layers ?? "—", c.maxLayers != null ? ` / ${c.maxLayers}` : "", " lagen"] }), _jsxs(Badge, { variant: "outline", children: [c.crates ?? "—", " fusten"] }), _jsxs(Badge, { variant: "outline", children: [c.plants ?? "—", " planten"] })] })) : (_jsx(Badge, { variant: "outline", className: "text-muted-foreground", children: c.contentLoading ? "Karinhoud laden…" : c.coverageLabel ? "Geen kar in deze indeling" : "Nog geen karindeling" })), _jsxs(Button, { size: "sm", variant: "outline", disabled: bezig !== null, onClick: printPakbon, title:
|
|
928
|
+
: ""] }), _jsxs(Badge, { variant: "outline", children: [c.layers ?? "—", c.maxLayers != null ? ` / ${c.maxLayers}` : "", " lagen"] }), _jsxs(Badge, { variant: "outline", children: [c.crates ?? "—", " fusten"] }), _jsxs(Badge, { variant: "outline", children: [c.plants ?? "—", " planten"] })] })) : (_jsx(Badge, { variant: "outline", className: "text-muted-foreground", children: c.contentLoading ? "Karinhoud laden…" : c.coverageLabel ? "Geen kar in deze indeling" : "Nog geen karindeling" })), _jsxs(Button, { size: "sm", variant: "outline", disabled: bezig !== null, onClick: printPakbon, title: `Pakbon van deze kar opnieuw printen. ${AUTOMATISCH_DOCUMENT_TEKST}`, children: [_jsx(Printer, { className: "mr-1 h-3.5 w-3.5" }), bezig === "pakbon" ? "Bezig…" : "Pakbon"] }), _jsxs(Button, { size: "sm", variant: "outline", disabled: bezig !== null, onClick: printVerzendbrief, title: `Verzenddocument van deze bestelling printen. ${AUTOMATISCH_DOCUMENT_TEKST}`, children: [_jsx(Printer, { className: "mr-1 h-3.5 w-3.5" }), bezig === "brief" ? "Bezig…" : "Verzendbrief"] }), _jsxs(Button, { size: "sm", variant: "outline", onClick: () => setVerzetOpen(true), title: "Ophaaldag of ophaaltijd van de bestelling van deze kar wijzigen", children: [_jsx(CalendarClock, { className: "mr-1 h-3.5 w-3.5" }), "Verzetten"] })] })] })] }), _jsx(VerzetOrderDialog, { open: verzetOpen, orderRef: c.orderRef, carrierTarget: {
|
|
903
929
|
carrierId: c.order?.order.carrierId ?? null,
|
|
904
930
|
country: c.order?.order.country ?? null,
|
|
905
931
|
province: c.order?.order.province ?? null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AfhandelingSettingsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/AfhandelingSettingsCard.tsx"],"names":[],"mappings":"AAuBA,wBAAgB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"AfhandelingSettingsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/AfhandelingSettingsCard.tsx"],"names":[],"mappings":"AAuBA,wBAAgB,uBAAuB,gCAkKtC"}
|
|
@@ -79,7 +79,7 @@ export function AfhandelingSettingsCard() {
|
|
|
79
79
|
toast.error(e instanceof Error ? e.message : "Opslaan mislukt");
|
|
80
80
|
},
|
|
81
81
|
});
|
|
82
|
-
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CalendarClock, { className: "h-5 w-5 text-primary" }), _jsx(CardTitle, { children: "Afhandeling \u2014 Planning" })] }), _jsx(CardDescription, { children: "De pickplanning (pickdagen, picktijd en verdeling over de week) wordt volledig bepaald door de planning. Hieronder staan alleen de instellingen van deze module zelf." })] }), _jsxs(CardContent, { className: "space-y-5", children: [_jsxs("div", { className: "rounded-md border p-4 space-y-4", children: [_jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Mail, { className: "h-4 w-4 text-primary" }), _jsx(Label, { htmlFor: "mailEnabled", className: "font-semibold", children: "Aanmeldmail vervoerders" })] }), _jsx("p", { className: "text-xs text-muted-foreground max-w-prose", children: "Verstuurt automatisch een mail met de te verwachten karren naar de vervoerder v\u00F3\u00F3r de aanmelddeadline van het ophaalmoment. E\u00E9n mail per ophaaldag/-moment per vervoerder." })] }), _jsx(Switch, { id: "mailEnabled", checked: mailEnabled, onCheckedChange: setMailEnabled })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "mailLead", children: "Minuten v\u00F3\u00F3r aanmelddeadline versturen" }), _jsx(Input, { id: "mailLead", type: "number", min: 0, max: 1440, value: mailLead, disabled: !mailEnabled, onChange: (e) => setMailLead(Math.max(0, Math.min(1440, Math.floor(Number(e.target.value)) || 0))) })] }), _jsx("div", { className: "space-y-1 text-sm", children: _jsxs("div", { children: [_jsx("strong", { children: "Verzendadres:" }), " ", cron.data?.senderEmail ? cron.data.senderEmail : _jsx("span", { className: "text-muted-foreground", children: "nog geen verbonden adres" }), " ", _jsx("span", { className: "text-xs text-muted-foreground", children: "(instellen bij E-mailkoppeling)" })] }) }), _jsxs("details", { className: "text-xs text-muted-foreground", children: [_jsx("summary", { className: "cursor-pointer", children: "Details voor beheer" }), _jsxs("div", { className: "mt-2 space-y-2", children: [_jsx(Label, { htmlFor: "mailPurpose", children: "Doeleinde in E-mailkoppeling" }), _jsx(Input, { id: "mailPurpose", value: mailPurpose, disabled: !mailEnabled, onChange: (e) => setMailPurpose(e.target.value) }), _jsxs("p", { children: ["Standaard: ", _jsx("code", { children: "afhandeling_carrier_signup" }), "."] })] })] })] }), _jsx(SignupStatusBlock, { status: cron.data ?? null, loading: cron.isLoading, failed: cron.isError }), _jsxs("div", { className: "rounded-md bg-muted/50 p-3 text-xs text-muted-foreground", children: [_jsx("strong", { children: "Ophaaltijd" }), " en ", _jsx("strong", { children: "Aanmeldtijd" }), " stel je per vervoerder in (werkdagen v\u00F3\u00F3r bezorgdag). De vervoerder die als ", _jsx("strong", { children: "standaard" }), " is gemarkeerd, wordt gebruikt voor orders zonder eigen vervoerder."] }), _jsx(Button, { onClick: () => mutation.mutate(), disabled: mutation.isPending, children: mutation.isPending ? "Opslaan…" : "Opslaan" })] })] }));
|
|
82
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CalendarClock, { className: "h-5 w-5 text-primary" }), _jsx(CardTitle, { children: "Afhandeling \u2014 Planning" })] }), _jsx(CardDescription, { children: "De pickplanning (pickdagen, picktijd en verdeling over de week) wordt volledig bepaald door de planning. Hieronder staan alleen de instellingen van deze module zelf. Printen: het document wordt automatisch bepaald uit de order." })] }), _jsxs(CardContent, { className: "space-y-5", children: [_jsxs("div", { className: "rounded-md border p-4 space-y-4", children: [_jsxs("div", { className: "flex items-start justify-between gap-4", children: [_jsxs("div", { className: "space-y-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Mail, { className: "h-4 w-4 text-primary" }), _jsx(Label, { htmlFor: "mailEnabled", className: "font-semibold", children: "Aanmeldmail vervoerders" })] }), _jsx("p", { className: "text-xs text-muted-foreground max-w-prose", children: "Verstuurt automatisch een mail met de te verwachten karren naar de vervoerder v\u00F3\u00F3r de aanmelddeadline van het ophaalmoment. E\u00E9n mail per ophaaldag/-moment per vervoerder." })] }), _jsx(Switch, { id: "mailEnabled", checked: mailEnabled, onCheckedChange: setMailEnabled })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "mailLead", children: "Minuten v\u00F3\u00F3r aanmelddeadline versturen" }), _jsx(Input, { id: "mailLead", type: "number", min: 0, max: 1440, value: mailLead, disabled: !mailEnabled, onChange: (e) => setMailLead(Math.max(0, Math.min(1440, Math.floor(Number(e.target.value)) || 0))) })] }), _jsx("div", { className: "space-y-1 text-sm", children: _jsxs("div", { children: [_jsx("strong", { children: "Verzendadres:" }), " ", cron.data?.senderEmail ? cron.data.senderEmail : _jsx("span", { className: "text-muted-foreground", children: "nog geen verbonden adres" }), " ", _jsx("span", { className: "text-xs text-muted-foreground", children: "(instellen bij E-mailkoppeling)" })] }) }), _jsxs("details", { className: "text-xs text-muted-foreground", children: [_jsx("summary", { className: "cursor-pointer", children: "Details voor beheer" }), _jsxs("div", { className: "mt-2 space-y-2", children: [_jsx(Label, { htmlFor: "mailPurpose", children: "Doeleinde in E-mailkoppeling" }), _jsx(Input, { id: "mailPurpose", value: mailPurpose, disabled: !mailEnabled, onChange: (e) => setMailPurpose(e.target.value) }), _jsxs("p", { children: ["Standaard: ", _jsx("code", { children: "afhandeling_carrier_signup" }), "."] })] })] })] }), _jsx(SignupStatusBlock, { status: cron.data ?? null, loading: cron.isLoading, failed: cron.isError }), _jsxs("div", { className: "rounded-md bg-muted/50 p-3 text-xs text-muted-foreground", children: [_jsx("strong", { children: "Ophaaltijd" }), " en ", _jsx("strong", { children: "Aanmeldtijd" }), " stel je per vervoerder in (werkdagen v\u00F3\u00F3r bezorgdag). De vervoerder die als ", _jsx("strong", { children: "standaard" }), " is gemarkeerd, wordt gebruikt voor orders zonder eigen vervoerder."] }), _jsx(Button, { onClick: () => mutation.mutate(), disabled: mutation.isPending, children: mutation.isPending ? "Opslaan…" : "Opslaan" })] })] }));
|
|
83
83
|
}
|
|
84
84
|
function SignupStatusBlock({ status, loading, failed, }) {
|
|
85
85
|
if (loading)
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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":"
|
|
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
|
-
|
|
3
|
-
|
|
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
|
-
? (
|
|
15
|
-
??
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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(
|
|
60
|
+
resolve(reply);
|
|
44
61
|
};
|
|
45
62
|
const onMessage = (e) => {
|
|
46
|
-
if (editorOrigins.
|
|
63
|
+
if (!editorOrigins.includes(e.origin))
|
|
47
64
|
return;
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
finish(
|
|
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
|
|
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((
|
|
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
|
|
83
|
-
if (res
|
|
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
|
|
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(() =>
|
|
131
|
+
return request('lovable-preview-auth:remove', key, local ?? undefined).then(() => { });
|
|
115
132
|
},
|
|
116
133
|
};
|
|
117
134
|
}
|