@flowselections/floriday-verkoop-module 1.0.143 → 1.0.145
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/verkoop/CreateOrderPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.js +50 -14
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +27 -2
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.js +1 -1
- package/dist-lib/components/verkoop/SearchableSelect.js +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +4 -2
- package/dist-lib/components/verkoop/order-detail-shortcuts.check.d.ts +2 -0
- package/dist-lib/components/verkoop/order-detail-shortcuts.check.d.ts.map +1 -0
- package/dist-lib/components/verkoop/order-detail-shortcuts.check.js +38 -0
- package/dist-lib/components/verkoop/order-shortcuts.check.d.ts +2 -0
- package/dist-lib/components/verkoop/order-shortcuts.check.d.ts.map +1 -0
- package/dist-lib/components/verkoop/order-shortcuts.check.js +34 -0
- package/dist-lib/components/verkoop/v3/NavigationTooltip.d.ts +7 -0
- package/dist-lib/components/verkoop/v3/NavigationTooltip.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/NavigationTooltip.js +6 -0
- package/dist-lib/integrations/supabase/types.d.ts +167 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/create-order-form.check.js +8 -1
- package/dist-lib/lib/create-order-form.d.ts +27 -0
- package/dist-lib/lib/create-order-form.d.ts.map +1 -1
- package/dist-lib/lib/create-order-form.js +27 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"AA2FA,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"AA2FA,wBAAgB,eAAe,gCAusC9B"}
|
|
@@ -10,7 +10,7 @@ import { Button, Input, Label, Textarea, toast, } from "@flowselections/core";
|
|
|
10
10
|
import { Link, useBlocker, useNavigate } from "@tanstack/react-router";
|
|
11
11
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
12
12
|
import { AlertTriangle, ArrowLeft, CheckCircle2, ChevronUp, Loader2, Plus, Trash2 } from "lucide-react";
|
|
13
|
-
import { missingItems, lineTotal, dateWithWeekday, eur } from "../../lib/create-order-form.js";
|
|
13
|
+
import { missingItems, lineTotal, dateWithWeekday, eur, attentionItems, selectionKey, resetOnSelectionChange, applyFirstFeasible } from "../../lib/create-order-form.js";
|
|
14
14
|
import { useServerFn } from "@tanstack/react-start";
|
|
15
15
|
import { SearchableSelect } from "./SearchableSelect.js";
|
|
16
16
|
import { toISODate } from "../../lib/carrier-availability.js";
|
|
@@ -290,6 +290,24 @@ export function CreateOrderPage() {
|
|
|
290
290
|
}, [loadCarriersEngine.allowed.join(","), loadCarriersEngine.default]);
|
|
291
291
|
const canPickDate = !!customerId && !!deliveryLocationId && !!pickupLocationId;
|
|
292
292
|
const [momentKey, setMomentKey] = useState(null);
|
|
293
|
+
// Leverdatum: automatisch (Engine-voorstel) of zelf gekozen.
|
|
294
|
+
const [dateSource, setDateSource] = useState("auto");
|
|
295
|
+
const [dateNotice, setDateNotice] = useState(null);
|
|
296
|
+
// Elk voorstel hoort bij deze keuze; antwoorden voor een vorige keuze worden genegeerd.
|
|
297
|
+
const selKey = selectionKey(customerId, deliveryLocationId, pickupLocationId);
|
|
298
|
+
const lastSelKey = useRef(selKey);
|
|
299
|
+
useEffect(() => {
|
|
300
|
+
if (lastSelKey.current === selKey)
|
|
301
|
+
return;
|
|
302
|
+
lastSelKey.current = selKey;
|
|
303
|
+
const r = resetOnSelectionChange({ deliveryDate, dateSource });
|
|
304
|
+
setDeliveryDate(r.deliveryDate);
|
|
305
|
+
setDateSource(r.dateSource);
|
|
306
|
+
setCarrierId(null);
|
|
307
|
+
setMomentKey(null);
|
|
308
|
+
setDateNotice(null);
|
|
309
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
310
|
+
}, [selKey]);
|
|
293
311
|
// ---- Ophaalmoment (Logistiek Engine) ----------------------------------
|
|
294
312
|
// Bij elke wijziging van vervoerder, afleverlocatie, leverdatum of moment
|
|
295
313
|
// vraagt het scherm de Engine om een voorbeeld. Kort wachten zodat niet
|
|
@@ -302,8 +320,9 @@ export function CreateOrderPage() {
|
|
|
302
320
|
deliveryDate: deliveryDate || toISODate(new Date()),
|
|
303
321
|
momentKey: ownTransport ? null : momentKey,
|
|
304
322
|
ownTransport,
|
|
323
|
+
selKey,
|
|
305
324
|
}
|
|
306
|
-
: null, [canPickDate, isReservation, carrierId, deliveryLocationId, deliveryDate, momentKey, ownTransport]);
|
|
325
|
+
: null, [canPickDate, isReservation, carrierId, deliveryLocationId, deliveryDate, momentKey, ownTransport, selKey]);
|
|
307
326
|
const [debouncedInput, setDebouncedInput] = useState(previewInput);
|
|
308
327
|
useEffect(() => {
|
|
309
328
|
const t = setTimeout(() => setDebouncedInput(previewInput), 300);
|
|
@@ -314,22 +333,33 @@ export function CreateOrderPage() {
|
|
|
314
333
|
enabled: !!debouncedInput,
|
|
315
334
|
staleTime: 15000,
|
|
316
335
|
queryFn: async () => {
|
|
336
|
+
const { selKey: _k, ...input } = debouncedInput;
|
|
317
337
|
try {
|
|
318
|
-
return (await fetchPreview({ data:
|
|
338
|
+
return (await fetchPreview({ data: input })).preview;
|
|
319
339
|
}
|
|
320
340
|
catch {
|
|
321
341
|
return null;
|
|
322
342
|
}
|
|
323
343
|
},
|
|
324
344
|
});
|
|
325
|
-
const
|
|
326
|
-
const
|
|
327
|
-
|
|
345
|
+
const previewCurrent = !!previewInput && debouncedInput?.selKey === selKey && previewQ.isSuccess;
|
|
346
|
+
const preview = previewCurrent ? previewQ.data ?? null : null;
|
|
347
|
+
const decision = previewCurrent ? decidePreview(preview) : null;
|
|
348
|
+
// Leverdatum uit het voorstel voor de huidige keuze: automatisch overnemen;
|
|
349
|
+
// een zelf gekozen datum alleen wissen als hij niet meer haalbaar is.
|
|
350
|
+
const firstFeasible = preview?.firstFeasibleDeliveryDate ?? null;
|
|
328
351
|
useEffect(() => {
|
|
329
|
-
if (!
|
|
330
|
-
|
|
352
|
+
if (!firstFeasible)
|
|
353
|
+
return;
|
|
354
|
+
const r = applyFirstFeasible({ deliveryDate, dateSource, firstFeasible });
|
|
355
|
+
if (r.deliveryDate !== deliveryDate)
|
|
356
|
+
setDeliveryDate(r.deliveryDate);
|
|
357
|
+
if (r.dateSource !== dateSource)
|
|
358
|
+
setDateSource(r.dateSource);
|
|
359
|
+
if (r.cleared)
|
|
360
|
+
setDateNotice("Gekozen leverdatum past niet meer, kies opnieuw");
|
|
331
361
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
332
|
-
}, [
|
|
362
|
+
}, [firstFeasible, selKey]);
|
|
333
363
|
// Geen vervoerder gekozen = "Automatisch": de Engine kiest; niets overnemen.
|
|
334
364
|
// Andere vervoerder/locatie/datum: eigen momentkeuze vervalt als hij er niet meer is.
|
|
335
365
|
useEffect(() => {
|
|
@@ -554,7 +584,8 @@ export function CreateOrderPage() {
|
|
|
554
584
|
return;
|
|
555
585
|
focusNext.current = null;
|
|
556
586
|
const el = f.kind === "product" ? productRefs.current[f.idx] : crateRefs.current[f.idx];
|
|
557
|
-
setTimeout(() => el?.focus()
|
|
587
|
+
setTimeout(() => { el?.focus(); if (el instanceof HTMLInputElement)
|
|
588
|
+
el.select(); }, 30);
|
|
558
589
|
});
|
|
559
590
|
const emptyLine = () => ({ product_id: null, product_name: "", quantity: null, unit: "stuks", unit_price: null, belading: null });
|
|
560
591
|
const addLine = () => {
|
|
@@ -590,6 +621,10 @@ export function CreateOrderPage() {
|
|
|
590
621
|
previewPending: canPickDate && !isReservation && !decision,
|
|
591
622
|
previewBlockedReason: decision && (decision.kind === "blocked" || decision.kind === "departed") ? decision.reason : null,
|
|
592
623
|
});
|
|
624
|
+
const attention = attentionItems({
|
|
625
|
+
linesWithoutPrice: zeroPriceCount,
|
|
626
|
+
linesOverStock: lines.filter((l) => l.product_id && shortageByProduct.has(l.product_id)).length,
|
|
627
|
+
});
|
|
593
628
|
const canCreate = missing.length === 0 && !createMut.isPending && !stockQ.isFetching;
|
|
594
629
|
const submit = () => {
|
|
595
630
|
if (!canCreate)
|
|
@@ -620,14 +655,15 @@ export function CreateOrderPage() {
|
|
|
620
655
|
const summaryRows = (_jsxs("dl", { className: "space-y-3 text-sm", children: [_jsxs("div", { children: [_jsx("dt", { className: "text-xs text-muted-foreground", children: "Klant" }), _jsx("dd", { className: "font-medium text-foreground", children: selectedCustomer ? customerLabel(selectedCustomer) : "—" }), selectedCustomer && customerSub(selectedCustomer) && _jsx("dd", { className: "text-xs text-muted-foreground", children: customerSub(selectedCustomer) })] }), _jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_auto] gap-2", children: [_jsx("dt", { className: "text-muted-foreground", children: "Leverdatum" }), _jsx("dd", { className: "text-right tabular-nums text-foreground", children: isReservation ? "Reservering" : dateWithWeekday(deliveryDate) ?? "—" })] }), _jsxs("div", { className: "space-y-1", children: [_jsx("dt", { className: "text-muted-foreground", children: "Ophaalmoment" }), !isReservation && !ownTransport && preview && preview.moments.length > 1 && decision && (decision.kind === "ok" || decision.kind === "late") ? (_jsx("select", { className: "h-9 w-full rounded-md border border-input bg-background px-2 text-sm text-foreground", value: momentKey ?? decision.momentKey ?? "", onChange: (e) => setMomentKey(e.target.value || null), "aria-label": "Ophaalmoment kiezen", children: preview.moments.map((m) => (_jsxs("option", { value: m.momentKey, disabled: !m.feasible, children: [momentLabel(m), m.feasible ? "" : " (niet haalbaar)"] }, m.momentKey))) })) : (_jsx("dd", { className: "text-foreground", children: momentText ?? (canPickDate && !isReservation && !decision
|
|
621
656
|
? _jsx("span", { className: "inline-block h-4 w-40 animate-pulse rounded bg-muted align-middle", "aria-label": "Ophaalmoment laden" })
|
|
622
657
|
: "—") }))] }), _jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)_auto] gap-2", children: [_jsx("dt", { className: "text-muted-foreground", children: "Vervoerder" }), _jsx("dd", { className: "truncate text-right text-foreground", children: carrierText })] }), _jsxs("div", { className: "border-t border-border pt-3 grid grid-cols-[minmax(0,1fr)_auto] gap-y-1.5 gap-x-2 tabular-nums", children: [_jsx("dt", { className: "text-muted-foreground", children: "Regels" }), _jsx("dd", { className: "text-right", children: validLines.length }), _jsx("dt", { className: "text-muted-foreground", children: "Fusten" }), _jsx("dd", { className: "text-right", children: totals.crates }), _jsx("dt", { className: "text-muted-foreground", children: "Stuks" }), _jsx("dd", { className: "text-right", children: totals.stuks.toLocaleString("nl-NL") })] }), _jsxs("div", { className: "border-t border-border pt-3 grid grid-cols-[minmax(0,1fr)_auto] gap-2", children: [_jsx("dt", { className: "font-semibold text-foreground", children: "Totaal" }), _jsx("dd", { className: "text-right text-lg font-semibold tabular-nums text-foreground", children: eur(totals.amount) })] })] }));
|
|
623
|
-
const missingBlock = missing.length > 0 ? (_jsxs("div", { className: "rounded-lg border border-border bg-muted/40 p-3 text-sm", children: [_jsx("div", { className: "mb-1 font-medium text-foreground", children: "Ontbreekt nog" }), _jsx("ul", { className: "space-y-1 text-muted-foreground", children: missing.map((m) => (_jsxs("li", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-2 h-1 w-1 shrink-0 rounded-full bg-muted-foreground" }), m] }, m))) })] })) : (_jsxs("div", { className: "flex items-center gap-2 rounded-lg bg-primary/10 p-3 text-sm font-medium text-primary", children: [_jsx(CheckCircle2, { className: "h-4 w-4 shrink-0" }), " Alles is compleet"] }));
|
|
658
|
+
const missingBlock = missing.length > 0 ? (_jsxs("div", { className: "rounded-lg border border-border bg-muted/40 p-3 text-sm", children: [_jsx("div", { className: "mb-1 font-medium text-foreground", children: "Ontbreekt nog" }), _jsx("ul", { className: "space-y-1 text-muted-foreground", children: missing.map((m) => (_jsxs("li", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-2 h-1 w-1 shrink-0 rounded-full bg-muted-foreground" }), m] }, m))) })] })) : attention.length > 0 ? null : (_jsxs("div", { className: "flex items-center gap-2 rounded-lg bg-primary/10 p-3 text-sm font-medium text-primary", children: [_jsx(CheckCircle2, { className: "h-4 w-4 shrink-0" }), " Alles is compleet"] }));
|
|
659
|
+
const attentionBlock = attention.length > 0 ? (_jsxs("div", { className: "rounded-lg border border-warning/40 bg-warning-soft p-3 text-sm", children: [_jsxs("div", { className: "mb-1 flex items-center gap-2 font-medium text-foreground", children: [_jsx(AlertTriangle, { className: "h-4 w-4 shrink-0 text-warning-soft-foreground" }), "Aandachtspunten"] }), _jsx("ul", { className: "space-y-1 text-muted-foreground", children: attention.map((m) => (_jsxs("li", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-2 h-1 w-1 shrink-0 rounded-full bg-muted-foreground" }), m] }, m))) })] })) : null;
|
|
624
660
|
const createButton = (cls = "") => (_jsx(Button, { className: `h-10 w-full ${cls}`, onClick: submit, disabled: !canCreate, title: stockBlocked ? "Onvoldoende voorraad; pas de aantallen aan." : undefined, children: createMut.isPending ? _jsxs(_Fragment, { children: [_jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), "Bezig\u2026"] })
|
|
625
661
|
: stockQ.isFetching ? "Voorraad controleren…" : "Bestelling aanmaken" }));
|
|
626
662
|
const deliveryAddr = (l) => [
|
|
627
663
|
l.address_line || [l.street, l.house_number].filter(Boolean).join(" "),
|
|
628
664
|
l.postal_code, l.city, l.country,
|
|
629
665
|
].filter(Boolean).join(", ");
|
|
630
|
-
return (_jsxs("main", { className: "mx-auto max-w-[1280px] space-y-4 p-4 pb-40 sm:p-6 md:pb-6", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-3", children: [_jsx(Button, { asChild: true, variant: "ghost", size: "icon", className: "h-9 w-9 shrink-0", "aria-label": "Terug naar verkooporders", children: _jsx(Link, { to: "/floriday-verkoop/verkooporders", children: _jsx(ArrowLeft, { className: "h-4 w-4" }) }) }), _jsx("h1", { className: "truncate text-xl font-bold text-foreground sm:text-2xl", children: "Nieuwe bestelling" })] }), loadErrors.length > 0 && (_jsx("div", { className: "rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive", children: loadErrors.map((m) => _jsx("div", { children: m }, m)) })), _jsxs("div", { className: "grid gap-4 md:grid-cols-[minmax(0,1fr)_300px] lg:grid-cols-[minmax(0,1fr)_340px]", children: [_jsxs("div", { className: "min-w-0 space-y-4", children: [_jsxs("section", { className: cardCls, children: [_jsx("h2", { className: h2, children: "Ordergegevens" }), _jsxs("div", { className: "mt-4 grid gap-4 lg:grid-cols-2", children: [_jsxs("div", { className: "space-y-1.5 lg:col-span-2", children: [_jsxs(Label, { className: fieldLabel, children: ["Klant ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(SearchableSelect, { value: customerId, placeholder: customersQ.isLoading ? "Laden…" : "Zoek op naam, plaats of debiteurnummer", options: customers.map((c) => ({
|
|
666
|
+
return (_jsxs("main", { className: "mx-auto max-w-[1280px] space-y-4 p-4 pb-40 sm:p-6 md:pb-6", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-3", children: [_jsx(Button, { asChild: true, variant: "ghost", size: "icon", className: "h-9 w-9 shrink-0", "aria-label": "Terug naar verkooporders", children: _jsx(Link, { to: "/floriday-verkoop/verkooporders", children: _jsx(ArrowLeft, { className: "h-4 w-4" }) }) }), _jsx("h1", { className: "truncate text-xl font-bold text-foreground sm:text-2xl", children: "Nieuwe bestelling" })] }), loadErrors.length > 0 && (_jsx("div", { className: "rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive", children: loadErrors.map((m) => _jsx("div", { children: m }, m)) })), _jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)] gap-4 md:grid-cols-[minmax(0,1fr)_300px] lg:grid-cols-[minmax(0,1fr)_340px]", children: [_jsxs("div", { className: "min-w-0 space-y-4", children: [_jsxs("section", { className: cardCls, children: [_jsx("h2", { className: h2, children: "Ordergegevens" }), _jsxs("div", { className: "mt-4 grid grid-cols-[minmax(0,1fr)] gap-4 lg:grid-cols-2", children: [_jsxs("div", { className: "space-y-1.5 lg:col-span-2", children: [_jsxs(Label, { className: fieldLabel, children: ["Klant ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(SearchableSelect, { value: customerId, placeholder: customersQ.isLoading ? "Laden…" : "Zoek op naam, plaats of debiteurnummer", options: customers.map((c) => ({
|
|
631
667
|
value: c.id,
|
|
632
668
|
label: customerLabel(c),
|
|
633
669
|
hint: customerSub(c) || (c.commercial_name && c.company_name !== c.commercial_name ? c.company_name : null),
|
|
@@ -655,7 +691,7 @@ export function CreateOrderPage() {
|
|
|
655
691
|
setCarrierId(!v || v === "__auto__" ? null : v);
|
|
656
692
|
}
|
|
657
693
|
setMomentKey(null);
|
|
658
|
-
} }))] }), _jsxs("div", { className: "space-y-1.5 lg:col-span-2", children: [_jsxs(Label, { className: fieldLabel, children: ["Leverdatum ", !isReservation && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsxs("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-center", children: [_jsx(Input, { type: "date", className: "h-9 sm:w-48", value: !isReservation && canPickDate ? deliveryDate : "", disabled: isReservation || !canPickDate, onChange: (e) => { setDeliveryDate(e.target.value || ""); setMomentKey(null); } }), !isReservation && deliveryDate && canPickDate && (_jsx("span", { className: "text-sm font-medium text-foreground", children: dateWithWeekday(deliveryDate) }))] }), _jsxs("label", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [_jsx("input", { type: "checkbox", checked: isReservation, onChange: (e) => setIsReservation(e.target.checked), className: "h-4 w-4 rounded border-input accent-primary" }), "Reservering (nog geen vaste leverdatum)"] }), !isReservation && !canPickDate && (_jsx("div", { className: "text-xs text-muted-foreground", children: "Kies eerst klant, afleverlocatie en afhaallocatie." })), !isReservation && momentText && (_jsxs("div", { className: "text-xs text-muted-foreground md:hidden", children: ["Ophaalmoment: ", momentText] })), !isReservation && decision?.kind === "blocked" && (_jsx("div", { className: "text-xs text-destructive", children: decision.reason })), !isReservation && decision?.kind === "departed" && (_jsxs("div", { className: "space-y-2 rounded-lg border border-destructive/40 p-2.5 text-xs", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setOwnTransport(true); setCarrierId(null); setMomentKey(null); }, children: "Eigen vervoer / zelf afleveren" })] })] })), !isReservation && decision?.kind === "late" && (_jsxs("div", { className: "space-y-2 rounded-lg border border-destructive/40 p-2.5 text-xs", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), (firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: createMut.isPending, onClick: () => setLateConfirmOpen(true), children: ["Toch aanmaken voor ", deliveryDate ? fmtDate(deliveryDate) : "de gekozen datum"] })] })] }))] })] })] }), _jsxs("section", { className: cardCls, children: [_jsx("div", { className: "flex items-center justify-between gap-3", children: _jsx("h2", { className: h2, children: "Bestelregels" }) }), _jsxs("div", { className: "mt-4 hidden grid-cols-[minmax(0,2.4fr)_56px_minmax(0,1.6fr)_80px_72px_minmax(0,1fr)_92px_88px_36px] gap-2 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground lg:grid", children: [_jsx("div", { children: "Product" }), _jsx("div", { className: "text-center", children: "Sticker" }), _jsx("div", { children: "Belading" }), _jsx("div", { children: "Fusten" }), _jsx("div", { className: "text-right", children: "Stuks" }), _jsx("div", { children: "Beschikbaar" }), _jsx("div", { children: "Prijs/st" }), _jsx("div", { className: "text-right", children: "Totaal" }), _jsx("div", {})] }), _jsx("div", { className: "mt-2 space-y-2 lg:space-y-0 lg:divide-y lg:divide-border", children: lines.map((line, idx) => {
|
|
694
|
+
} }))] }), _jsxs("div", { className: "space-y-1.5 lg:col-span-2", children: [_jsxs(Label, { className: fieldLabel, children: ["Leverdatum ", !isReservation && _jsx("span", { className: "text-destructive", children: "*" })] }), _jsxs("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-center", children: [_jsx(Input, { type: "date", className: "h-9 sm:w-48", value: !isReservation && canPickDate ? deliveryDate : "", disabled: isReservation || !canPickDate, onChange: (e) => { setDeliveryDate(e.target.value || ""); setDateSource(e.target.value ? "user" : "auto"); setDateNotice(null); setMomentKey(null); } }), dateNotice && !deliveryDate && _jsx("span", { className: "text-sm text-warning-soft-foreground", children: dateNotice }), !isReservation && deliveryDate && canPickDate && (_jsx("span", { className: "text-sm font-medium text-foreground", children: dateWithWeekday(deliveryDate) }))] }), _jsxs("label", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [_jsx("input", { type: "checkbox", checked: isReservation, onChange: (e) => setIsReservation(e.target.checked), className: "h-4 w-4 rounded border-input accent-primary" }), "Reservering (nog geen vaste leverdatum)"] }), !isReservation && !canPickDate && (_jsx("div", { className: "text-xs text-muted-foreground", children: "Kies eerst klant, afleverlocatie en afhaallocatie." })), !isReservation && momentText && (_jsxs("div", { className: "text-xs text-muted-foreground md:hidden", children: ["Ophaalmoment: ", momentText] })), !isReservation && decision?.kind === "blocked" && (_jsx("div", { className: "text-xs text-destructive", children: decision.reason })), !isReservation && decision?.kind === "departed" && (_jsxs("div", { className: "space-y-2 rounded-lg border border-destructive/40 p-2.5 text-xs", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, decision.next?.signupDeadline ?? null) })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setDateSource("user"); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsx(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setOwnTransport(true); setCarrierId(null); setMomentKey(null); }, children: "Eigen vervoer / zelf afleveren" })] })] })), !isReservation && decision?.kind === "late" && (_jsxs("div", { className: "space-y-2 rounded-lg border border-destructive/40 p-2.5 text-xs", children: [_jsx("div", { className: "text-destructive", children: decision.reason }), (firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason) && (_jsx("div", { className: "text-muted-foreground", children: firstDateText(decision.firstDate, preview?.nextFeasibleMoment?.signupDeadline ?? null) ?? decision.firstReason })), _jsxs("div", { className: "flex flex-wrap gap-2", children: [decision.firstDate && (_jsxs(Button, { type: "button", size: "sm", variant: "outline", onClick: () => { setDeliveryDate(decision.firstDate); setDateSource("user"); setMomentKey(null); }, children: ["Gebruik ", fmtDate(decision.firstDate)] })), _jsxs(Button, { type: "button", size: "sm", variant: "outline", disabled: createMut.isPending, onClick: () => setLateConfirmOpen(true), children: ["Toch aanmaken voor ", deliveryDate ? fmtDate(deliveryDate) : "de gekozen datum"] })] })] }))] })] })] }), _jsxs("section", { className: cardCls, children: [_jsx("div", { className: "flex items-center justify-between gap-3", children: _jsx("h2", { className: h2, children: "Bestelregels" }) }), _jsxs("div", { className: "mt-4 hidden grid-cols-[minmax(0,2.4fr)_56px_minmax(0,1.6fr)_80px_72px_minmax(0,1fr)_92px_88px_36px] gap-2 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground lg:grid", children: [_jsx("div", { children: "Product" }), _jsx("div", { className: "text-center", children: "Sticker" }), _jsx("div", { children: "Belading" }), _jsx("div", { children: "Fusten" }), _jsx("div", { className: "text-right", children: "Stuks" }), _jsx("div", { children: "Beschikbaar" }), _jsx("div", { children: "Prijs/st" }), _jsx("div", { className: "text-right", children: "Totaal" }), _jsx("div", {})] }), _jsx("div", { className: "mt-2 space-y-2 lg:space-y-0 lg:divide-y lg:divide-border", children: lines.map((line, idx) => {
|
|
659
695
|
const { product, eff: effBelading, ppc, crates } = lineInfo[idx];
|
|
660
696
|
const defaultBelading = completeBelading(product);
|
|
661
697
|
const plants = line.quantity ?? null;
|
|
@@ -765,5 +801,5 @@ export function CreateOrderPage() {
|
|
|
765
801
|
next[idx] = { ...next[idx], quantity: cr === null ? null : cr * ppc };
|
|
766
802
|
setLines(next);
|
|
767
803
|
}, placeholder: ppc === null ? "—" : "Fusten", title: ppc === null ? "Kies eerst een belading" : `${ppc} planten per fust` })] }), _jsxs("div", { className: "col-span-1 lg:col-span-1", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground lg:hidden", children: "Stuks" }), _jsx("div", { className: "flex h-9 items-center text-sm tabular-nums text-foreground lg:justify-end", children: line.product_id && plants ? plants.toLocaleString("nl-NL") : "—" })] }), _jsxs("div", { className: "col-span-1 min-w-0 lg:col-span-1", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground lg:hidden", children: "Beschikbaar" }), product ? (_jsxs("div", { className: `flex min-h-9 items-center gap-1 text-sm tabular-nums ${overStock ? (stockBlocked ? "text-destructive" : "text-warning-soft-foreground") : "text-foreground"}`, children: [overStock && _jsx(AlertTriangle, { className: "h-3.5 w-3.5 shrink-0" }), _jsxs("span", { className: "truncate", children: [(available ?? 0).toLocaleString("nl-NL"), " ", unit] })] })) : _jsx("div", { className: "flex h-9 items-center text-sm text-muted-foreground", children: "\u2014" }), overStock && (_jsx("div", { className: `text-xs ${stockBlocked ? "text-destructive" : "text-warning-soft-foreground"}`, children: shortage ? `Tekort ${shortage.missing.toLocaleString("nl-NL")}` : "Meer dan beschikbaar" }))] }), _jsxs("label", { className: "col-span-1 lg:col-span-1", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground lg:hidden", children: "Prijs per stuk" }), _jsx(Input, { type: "number", min: 0, step: "0.01", className: "h-9 tabular-nums", value: line.unit_price ?? "", onChange: (e) => { const next = [...lines]; next[idx] = { ...next[idx], unit_price: e.target.value === "" ? null : Number(e.target.value) }; setLines(next); }, placeholder: "\u20AC", "aria-invalid": noPrice }), noPrice && _jsx("span", { className: "mt-1 block text-xs text-destructive", children: "Geen prijs gevonden" })] }), _jsxs("div", { className: "col-span-1 lg:col-span-1", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground lg:hidden", children: "Totaal" }), _jsx("div", { className: "flex h-9 items-center text-sm font-medium tabular-nums text-foreground lg:justify-end", children: line.product_id ? eur(lineInfo[idx].total) : "—" })] }), _jsx("div", { className: "col-span-2 flex justify-end lg:col-span-1", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9", onClick: () => setLines(lines.filter((_, i) => i !== idx)), "aria-label": "Regel verwijderen", children: _jsx(Trash2, { className: "h-4 w-4" }) }) })] }, idx));
|
|
768
|
-
}) }), _jsxs("div", { className: "mt-3 flex flex-col gap-3 border-t border-border pt-3 sm:flex-row sm:items-center sm:justify-between", children: [_jsxs(Button, { variant: "outline", className: "h-9 w-full sm:w-auto", onClick: addLine, children: [_jsx(Plus, { className: "mr-1 h-4 w-4" }), " Regel toevoegen"] }), _jsxs("div", { className: "flex flex-wrap items-center gap-x-5 gap-y-1 text-sm tabular-nums", children: [_jsxs("span", { className: "text-muted-foreground", children: ["Fusten ", _jsx("span", { className: "font-medium text-foreground", children: totals.crates })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Stuks ", _jsx("span", { className: "font-medium text-foreground", children: totals.stuks.toLocaleString("nl-NL") })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Totaal ", _jsx("span", { className: "font-semibold text-foreground", children: eur(totals.amount) })] })] })] }), stockCheck && stockCheck.shortages.length > 0 && !stockBlocked && (_jsx("div", { className: "mt-3 rounded-lg bg-warning-soft p-2.5 text-xs text-warning-soft-foreground", children: "Uitleveren zonder voorraad staat aan: de bestelling kan met tekort worden aangemaakt." }))] }), _jsxs("section", { className: cardCls, children: [_jsx("h2", { className: h2, children: "Aanvullend" }), _jsxs("div", { className: "mt-4 grid gap-4", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: fieldLabel, children: "Referentie klant" }), _jsx(Input, { value: customerReference, maxLength: 100, className: "h-9", onChange: (e) => setCustomerReference(e.target.value), placeholder: "Optioneel, bijvoorbeeld het bestelnummer van je klant" })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: fieldLabel, children: "Opmerkingen" }), _jsx(Textarea, { value: notes, onChange: (e) => setNotes(e.target.value), placeholder: "Optionele notities bij deze bestelling", rows: 3 })] })] })] })] }), _jsx("aside", { className: "hidden md:block", children: _jsxs("div", { className: `${cardCls} sticky top-4 space-y-4`, children: [_jsx("h2", { className: h2, children: "Samenvatting" }), summaryRows, missingBlock, createButton(), _jsx(Button, { variant: "ghost", className: "h-9 w-full", onClick: () => navigate({ to: "/floriday-verkoop/verkooporders" }), disabled: createMut.isPending, children: "Annuleren" })] }) })] }), _jsxs("div", { className: "fixed inset-x-0 bottom-0 z-30 border-t border-border bg-background/95 px-4 pt-3 backdrop-blur md:hidden", style: { paddingBottom: "max(12px, env(safe-area-inset-bottom))" }, children: [mobileSummaryOpen && (_jsxs("div", { className: "mb-3 max-h-[50vh] space-y-3 overflow-y-auto", children: [summaryRows, missingBlock] })), _jsxs("button", { type: "button", className: "mb-2 flex w-full items-center justify-between gap-3 text-left", onClick: () => setMobileSummaryOpen((o) => !o), "aria-expanded": mobileSummaryOpen, children: [_jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block truncate text-xs text-muted-foreground", children: momentText ? `Ophalen: ${momentText.replace(/^ophalen /, "")}` : missing.length > 0 ? `${missing.length} ontbreekt nog` : "Alles is compleet" }), _jsx("span", { className: "block text-base font-semibold tabular-nums text-foreground", children: eur(totals.amount) })] }), _jsx(ChevronUp, { className: `h-5 w-5 shrink-0 text-muted-foreground transition-transform ${mobileSummaryOpen ? "" : "rotate-180"}` })] }), createButton("h-12")] }), _jsx(ConfirmDialog, { open: zeroConfirmOpen, onOpenChange: setZeroConfirmOpen, title: "Prijs \u20AC 0 bevestigen?", description: `${zeroPriceCount} regel(s) hebben prijs € 0. Deze regels worden zo gefactureerd. Weet je zeker dat dat klopt?`, confirmLabel: "Ja, prijs \u20AC 0 klopt", onConfirm: () => { zeroPriceOkRef.current = true; createMut.mutate(undefined); } }), _jsx(ConfirmDialog, { open: lateConfirmOpen, onOpenChange: setLateConfirmOpen, title: "Toch aanmaken na de aanmeldtijd?", description: LATE_CONFIRM, confirmLabel: "Toch aanmaken", onConfirm: () => createMut.mutate({ lateConfirmed: true }) })] }));
|
|
804
|
+
}) }), _jsxs("div", { className: "mt-3 flex flex-col gap-3 border-t border-border pt-3 sm:flex-row sm:items-center sm:justify-between", children: [_jsxs(Button, { variant: "outline", className: "h-9 w-full sm:w-auto", onClick: addLine, children: [_jsx(Plus, { className: "mr-1 h-4 w-4" }), " Regel toevoegen"] }), _jsxs("div", { className: "flex flex-wrap items-center gap-x-5 gap-y-1 text-sm tabular-nums", children: [_jsxs("span", { className: "text-muted-foreground", children: ["Fusten ", _jsx("span", { className: "font-medium text-foreground", children: totals.crates })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Stuks ", _jsx("span", { className: "font-medium text-foreground", children: totals.stuks.toLocaleString("nl-NL") })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Totaal ", _jsx("span", { className: "font-semibold text-foreground", children: eur(totals.amount) })] })] })] }), stockCheck && stockCheck.shortages.length > 0 && !stockBlocked && (_jsx("div", { className: "mt-3 rounded-lg bg-warning-soft p-2.5 text-xs text-warning-soft-foreground", children: "Uitleveren zonder voorraad staat aan: de bestelling kan met tekort worden aangemaakt." }))] }), _jsxs("section", { className: cardCls, children: [_jsx("h2", { className: h2, children: "Aanvullend" }), _jsxs("div", { className: "mt-4 grid gap-4", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: fieldLabel, children: "Referentie klant" }), _jsx(Input, { value: customerReference, maxLength: 100, className: "h-9", onChange: (e) => setCustomerReference(e.target.value), placeholder: "Optioneel, bijvoorbeeld het bestelnummer van je klant" })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: fieldLabel, children: "Opmerkingen" }), _jsx(Textarea, { value: notes, onChange: (e) => setNotes(e.target.value), placeholder: "Optionele notities bij deze bestelling", rows: 3 })] })] })] })] }), _jsx("aside", { className: "hidden md:block", children: _jsxs("div", { className: `${cardCls} sticky top-4 space-y-4`, children: [_jsx("h2", { className: h2, children: "Samenvatting" }), summaryRows, missingBlock, attentionBlock, createButton(), _jsx(Button, { variant: "ghost", className: "h-9 w-full", onClick: () => navigate({ to: "/floriday-verkoop/verkooporders" }), disabled: createMut.isPending, children: "Annuleren" })] }) })] }), _jsxs("div", { className: "fixed inset-x-0 bottom-0 z-30 border-t border-border bg-background/95 px-4 pt-3 backdrop-blur md:hidden", style: { paddingBottom: "max(12px, env(safe-area-inset-bottom))" }, children: [mobileSummaryOpen && (_jsxs("div", { className: "mb-3 max-h-[50vh] space-y-3 overflow-y-auto", children: [summaryRows, missingBlock, attentionBlock] })), _jsxs("button", { type: "button", className: "mb-2 flex w-full items-center justify-between gap-3 text-left", onClick: () => setMobileSummaryOpen((o) => !o), "aria-expanded": mobileSummaryOpen, children: [_jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "block truncate text-xs text-muted-foreground", children: momentText ? `Ophalen: ${momentText.replace(/^ophalen /, "")}` : missing.length > 0 ? `${missing.length} ontbreekt nog` : attention.length > 0 ? `${attention.length} aandachtspunt${attention.length === 1 ? "" : "en"}` : "Alles is compleet" }), _jsx("span", { className: "block text-base font-semibold tabular-nums text-foreground", children: eur(totals.amount) })] }), _jsx(ChevronUp, { className: `h-5 w-5 shrink-0 text-muted-foreground transition-transform ${mobileSummaryOpen ? "" : "rotate-180"}` })] }), createButton("h-12")] }), _jsx(ConfirmDialog, { open: zeroConfirmOpen, onOpenChange: setZeroConfirmOpen, title: "Prijs \u20AC 0 bevestigen?", description: `${zeroPriceCount} regel(s) hebben prijs € 0. Deze regels worden zo gefactureerd. Weet je zeker dat dat klopt?`, confirmLabel: "Ja, prijs \u20AC 0 klopt", onConfirm: () => { zeroPriceOkRef.current = true; createMut.mutate(undefined); } }), _jsx(ConfirmDialog, { open: lateConfirmOpen, onOpenChange: setLateConfirmOpen, title: "Toch aanmaken na de aanmeldtijd?", description: LATE_CONFIRM, confirmLabel: "Toch aanmaken", onConfirm: () => createMut.mutate({ lateConfirmed: true }) })] }));
|
|
769
805
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SalesOrderDetailPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrderDetailPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SalesOrderDetailPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrderDetailPage.tsx"],"names":[],"mappings":"AAwHA,wBAAgB,oBAAoB,gCAmWnC"}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { fmtNL } from "../../lib/nl-datetime.js";
|
|
3
3
|
import { seedPickupMoment } from "../../lib/usePickupMoment.js";
|
|
4
4
|
import { bufferPickProgress } from "../../lib/buffer-carts.js";
|
|
5
|
-
import { useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { Link, useParams, useSearch } from "@tanstack/react-router";
|
|
7
7
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
8
8
|
import { useServerFn } from "@tanstack/react-start";
|
|
@@ -30,6 +30,7 @@ import { toProgressMember } from "../../lib/order-progress.js";
|
|
|
30
30
|
import { listHref, markRestore, neighbours } from "../../lib/order-nav.js";
|
|
31
31
|
import { SourceIcon, sourceLabel } from "./v3/SourceIcon.js";
|
|
32
32
|
import { OrderStepper } from "./v3/OrderStepper.js";
|
|
33
|
+
import { NavigationTooltip } from "./v3/NavigationTooltip.js";
|
|
33
34
|
import { FactTile, InfoCard, InfoRow } from "./v3/InfoCard.js";
|
|
34
35
|
const eur = new Intl.NumberFormat("nl-NL", { style: "currency", currency: "EUR", minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
35
36
|
function fmtDT(iso) {
|
|
@@ -212,12 +213,36 @@ export function SalesOrderDetailPage() {
|
|
|
212
213
|
: fallback.state;
|
|
213
214
|
const nav = neighbours(salesOrderId);
|
|
214
215
|
const backHref = listHref();
|
|
216
|
+
const backLink = useRef(null);
|
|
217
|
+
const previousLink = useRef(null);
|
|
218
|
+
const nextLink = useRef(null);
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
const onDetailKey = (e) => {
|
|
221
|
+
if (e.defaultPrevented || e.repeat || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey)
|
|
222
|
+
return;
|
|
223
|
+
const target = e.target;
|
|
224
|
+
if (target?.isContentEditable || target?.closest('input, textarea, select, [role="combobox"], [contenteditable="true"]'))
|
|
225
|
+
return;
|
|
226
|
+
if (document.querySelector('[role="dialog"]:not([aria-hidden="true"]):not([data-state="closed"]), [role="alertdialog"]:not([aria-hidden="true"]):not([data-state="closed"]), [role="menu"]:not([aria-hidden="true"]):not([data-state="closed"]), [role="listbox"]:not([aria-hidden="true"]):not([data-state="closed"])'))
|
|
227
|
+
return;
|
|
228
|
+
const link = e.key === "ArrowLeft" ? previousLink.current
|
|
229
|
+
: e.key === "ArrowRight" ? nextLink.current
|
|
230
|
+
: e.key === "Escape" ? backLink.current : null;
|
|
231
|
+
if (!link?.isConnected)
|
|
232
|
+
return;
|
|
233
|
+
e.preventDefault();
|
|
234
|
+
// Use the existing links: list order, buffer routes and scroll restoration stay identical.
|
|
235
|
+
link.click();
|
|
236
|
+
};
|
|
237
|
+
window.addEventListener("keydown", onDetailKey);
|
|
238
|
+
return () => window.removeEventListener("keydown", onDetailKey);
|
|
239
|
+
}, []);
|
|
215
240
|
const head = primary ?? (cached.row && !(cached.row.bufferSize && cached.row.bufferSize > 1) ? cached.row : null);
|
|
216
241
|
const sources = (isBuffer ? bufferOrders : head ? [head] : []).map((o) => o.source ?? (o.isLocal ? "manual" : "floriday"));
|
|
217
242
|
const floridayMembers = membersFor(bufferOrders).filter((m) => m.invoiceRoute === "floriday" && !m.cancelled);
|
|
218
243
|
const fDone = floridayMembers.reduce((s, m) => s + m.floridayDone, 0);
|
|
219
244
|
const fTotal = floridayMembers.reduce((s, m) => s + m.floridayTotal, 0);
|
|
220
|
-
return (_jsxs("main", { className: "mx-auto w-full max-w-[1200px] space-y-4 p-4 pb-24 sm:p-6", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx(Button, { asChild: true, variant: "ghost", size: "sm", className: "-ml-2", children: backHref ? (_jsxs("a", { href: backHref, onClick: () => markRestore(), children: [_jsx(ArrowLeft, { className: "mr-2 h-4 w-4" }), " Terug naar verkooporders"] })) : (_jsxs(Link, { to: "/floriday-verkoop/verkooporders", children: [_jsx(ArrowLeft, { className: "mr-2 h-4 w-4" }), " Terug naar verkooporders"] })) }), nav && (nav.prev || nav.next) && (_jsxs("div", { className: "flex items-center gap-2", children: [nav.prev ? (_jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsxs(Link, { to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: nav.prev }, children: [_jsx(ChevronLeft, { className: "mr-1 h-4 w-4" }), " Vorige"] }) })) : null, nav.next ? (_jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsxs(Link, { to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: nav.next }, children: ["Volgende ", _jsx(ChevronRight, { className: "ml-1 h-4 w-4" })] }) })) : null] }))] }), head && (_jsxs("header", { className: "flex flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-sm sm:flex-row sm:items-center sm:justify-between sm:p-5", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-3", children: [_jsx("span", { className: "inline-flex h-14 w-14 shrink-0 items-center justify-center rounded-xl bg-primary/10", children: _jsx(SourceIcon, { sources: sources }) }), _jsxs("div", { className: "min-w-0 space-y-0.5", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("h1", { className: "truncate text-xl font-bold tracking-tight text-foreground sm:text-2xl", children: isBuffer ? `Samengevoegde order · ${bufferOrders.length} orders` : head.orderNumber || "Order" }), !isBuffer && (_jsx("span", { className: `rounded-full px-2 py-0.5 text-xs font-medium ${orderStageBadgeClass(head.stage ?? "incoming")}`, children: orderStageLabel(head.stage ?? (head.status?.isCancelled ? "cancelled" : "incoming")) }))] }), _jsx("p", { className: "text-sm text-muted-foreground", children: isBuffer
|
|
245
|
+
return (_jsxs("main", { className: "mx-auto w-full max-w-[1200px] space-y-4 p-4 pb-24 sm:p-6", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx(NavigationTooltip, { label: "Terug naar verkooporders", shortcut: "Esc", children: _jsx(Button, { asChild: true, variant: "ghost", size: "sm", className: "-ml-2", children: backHref ? (_jsxs("a", { ref: backLink, href: backHref, onClick: () => markRestore(), "aria-keyshortcuts": "Escape", children: [_jsx(ArrowLeft, { className: "mr-2 h-4 w-4" }), " Terug naar verkooporders"] })) : (_jsxs(Link, { ref: backLink, to: "/floriday-verkoop/verkooporders", "aria-keyshortcuts": "Escape", children: [_jsx(ArrowLeft, { className: "mr-2 h-4 w-4" }), " Terug naar verkooporders"] })) }) }), nav && (nav.prev || nav.next) && (_jsxs("div", { className: "flex items-center gap-2", children: [nav.prev ? (_jsx(NavigationTooltip, { label: "Vorige order", shortcut: "\u2190", children: _jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsxs(Link, { ref: previousLink, to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: nav.prev }, "aria-keyshortcuts": "ArrowLeft", children: [_jsx(ChevronLeft, { className: "mr-1 h-4 w-4" }), " Vorige"] }) }) })) : null, nav.next ? (_jsx(NavigationTooltip, { label: "Volgende order", shortcut: "\u2192", children: _jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsxs(Link, { ref: nextLink, to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: nav.next }, "aria-keyshortcuts": "ArrowRight", children: ["Volgende ", _jsx(ChevronRight, { className: "ml-1 h-4 w-4" })] }) }) })) : null] }))] }), head && (_jsxs("header", { className: "flex flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-sm sm:flex-row sm:items-center sm:justify-between sm:p-5", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-3", children: [_jsx("span", { className: "inline-flex h-14 w-14 shrink-0 items-center justify-center rounded-xl bg-primary/10", children: _jsx(SourceIcon, { sources: sources }) }), _jsxs("div", { className: "min-w-0 space-y-0.5", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("h1", { className: "truncate text-xl font-bold tracking-tight text-foreground sm:text-2xl", children: isBuffer ? `Samengevoegde order · ${bufferOrders.length} orders` : head.orderNumber || "Order" }), !isBuffer && (_jsx("span", { className: `rounded-full px-2 py-0.5 text-xs font-medium ${orderStageBadgeClass(head.stage ?? "incoming")}`, children: orderStageLabel(head.stage ?? (head.status?.isCancelled ? "cancelled" : "incoming")) }))] }), _jsx("p", { className: "text-sm text-muted-foreground", children: isBuffer
|
|
221
246
|
? head.customer.name
|
|
222
247
|
: `${sourceLabel(sources[0])}-order` }), isBuffer && fTotal > 0 && (_jsxs("p", { className: "text-xs font-medium tabular-nums text-foreground", children: ["Afgemeld: ", fDone, " van ", fTotal] })), !isBuffer && fmtDT(head.orderedAt) && (_jsxs("p", { className: "text-xs text-muted-foreground", children: ["Ontvangen op ", fmtDT(head.orderedAt)] }))] })] }), rawLocalId && !isBuffer && (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setEditOpen(true), disabled: !primary, className: "w-full sm:w-auto", children: [_jsx(Pencil, { className: "mr-2 h-4 w-4" }), " Bestelling bewerken"] }))] })), singleInGroup && inGroup && primary && (_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 rounded-xl border border-primary/30 bg-primary/5 px-4 py-3 text-sm", children: [_jsxs("span", { className: "inline-flex items-center gap-2 text-foreground", children: [_jsx(Layers, { className: "h-4 w-4 text-primary" }), " Onderdeel van een samengevoegde order met ", bufferOrders.length, " orders"] }), _jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsx(Link, { to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId }, children: "Naar samengevoegde weergave" }) })] })), primary && _jsx(OrderStepper, { members: membersFor(isBuffer ? bufferOrders : [primary]), features: features, invoiceLoad: invoiceLoad }), isLoading && !primary && _jsx(DetailSkeleton, {}), error && !primary && (() => {
|
|
223
248
|
const f = friendlyLoadError(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SalesOrdersFilterPanel.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrdersFilterPanel.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAYrD;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACnC,+
|
|
1
|
+
{"version":3,"file":"SalesOrdersFilterPanel.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrdersFilterPanel.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAYrD;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACnC,+BA6OA"}
|
|
@@ -52,7 +52,7 @@ export function SalesOrdersFilterPanel({ open, onOpenChange, value, onChange, })
|
|
|
52
52
|
const activeCount = countActiveFilters(value);
|
|
53
53
|
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40 bg-black/30 transition-opacity " +
|
|
54
54
|
(open ? "opacity-100" : "pointer-events-none opacity-0"), onClick: () => onOpenChange(false), "aria-hidden": true }), _jsxs("aside", { className: "fixed right-0 top-0 z-50 flex h-full w-full max-w-sm flex-col border-l border-border bg-card shadow-xl transition-transform " +
|
|
55
|
-
(open ? "translate-x-0" : "translate-x-full"), role: "dialog", "aria-label": "Filters", children: [_jsxs("div", { className: "flex items-center justify-between border-b border-border px-5 py-4", children: [_jsx("h2", { className: "text-base font-semibold text-foreground", children: "Filters" }), _jsx("button", { type: "button", onClick: () => onOpenChange(false), className: "inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", "aria-label": "Sluiten", children: _jsx(X, { className: "h-4 w-4" }) })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-5 py-4", children: [_jsx("button", { type: "button", onClick: clearAll, disabled: activeCount === 0, className: "mb-4 text-sm " +
|
|
55
|
+
(open ? "translate-x-0" : "translate-x-full"), role: "dialog", "aria-hidden": !open, inert: !open, "aria-label": "Filters", children: [_jsxs("div", { className: "flex items-center justify-between border-b border-border px-5 py-4", children: [_jsx("h2", { className: "text-base font-semibold text-foreground", children: "Filters" }), _jsx("button", { type: "button", onClick: () => onOpenChange(false), className: "inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", "aria-label": "Sluiten", children: _jsx(X, { className: "h-4 w-4" }) })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-5 py-4", children: [_jsx("button", { type: "button", onClick: clearAll, disabled: activeCount === 0, className: "mb-4 text-sm " +
|
|
56
56
|
(activeCount === 0
|
|
57
57
|
? "cursor-not-allowed text-muted-foreground/60"
|
|
58
58
|
: "text-primary hover:underline"), children: "Wis alle filters" }), _jsxs("div", { className: "space-y-5", children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Klant" }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx("span", { className: "inline-flex h-7 items-center rounded-full border border-border bg-background px-3 text-xs text-muted-foreground", children: "Connecties" }), _jsx("span", { className: "inline-flex h-7 items-center rounded-full border border-primary/40 bg-primary/10 px-3 text-xs font-medium text-primary", children: "Alle klanten" })] }), _jsxs(Select, { value: value.klant ?? "all", onValueChange: (v) => onChange({ ...value, klant: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "Kies een klant" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "Kies een klant" }) })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Handelsvorm" }), _jsxs(Select, { value: value.handelsvorm ?? "all", onValueChange: (v) => onChange({ ...value, handelsvorm: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alles -" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "all", children: "- Alles -" }), _jsx(SelectItem, { value: "klok", children: "Klok" }), _jsx(SelectItem, { value: "direct", children: "Direct" })] })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Voorraadlocatie" }), _jsxs(Select, { value: value.voorraadlocatie ?? "all", onValueChange: (v) => onChange({ ...value, voorraadlocatie: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alle voorraadlocaties -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Alle voorraadlocaties -" }) })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Kanaal" }), _jsxs(Select, { value: value.kanaal ?? "all", onValueChange: (v) => onChange({ ...value, kanaal: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alle verkoopkanalen -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Alle verkoopkanalen -" }) })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Financi\u00EBle afhandeling" }), _jsxs(Select, { value: value.financieleAfhandeling ?? "all", onValueChange: (v) => onChange({ ...value, financieleAfhandeling: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Financi\u00EBle afhandeling -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Financi\u00EBle afhandeling -" }) })] }), _jsxs("label", { className: "flex items-center gap-2 pt-1 text-sm text-foreground", children: [_jsx(Checkbox, { checked: !!value.onvolledigVerrekend, onCheckedChange: (c) => onChange({ ...value, onvolledigVerrekend: c === true ? true : undefined }) }), _jsx("span", { children: "Onvolledig verrekend" })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Artikel" }), _jsxs(Select, { value: value.artikel ?? "all", onValueChange: (v) => onChange({ ...value, artikel: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alle artikelen -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Alle artikelen -" }) })] }), _jsxs("label", { className: "flex items-center gap-2 pt-1 text-sm text-foreground", children: [_jsx(Checkbox, { checked: !!value.daytrade, onCheckedChange: (c) => onChange({ ...value, daytrade: c === true ? true : undefined }) }), _jsx("span", { children: "Daytrade transacties" })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Order-referentie" }), _jsx(Input, { placeholder: "Order-referentie", value: value.orderReferentie ?? "", onChange: (e) => onChange({
|
|
@@ -20,7 +20,7 @@ export const SearchableSelect = forwardRef(function SearchableSelect({ value, op
|
|
|
20
20
|
}, [options, q]);
|
|
21
21
|
return (_jsxs(Popover, { open: open, onOpenChange: (o) => { if (disabled)
|
|
22
22
|
return; setOpen(o); if (!o)
|
|
23
|
-
setQ(""); }, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "outline", role: "combobox", "aria-expanded": open, disabled: disabled, ref: ref, id: id, className: `w-full justify-between font-normal ${className ?? ""}`, children: [renderValue && selected ? (_jsx("span", { className: "flex min-w-0 flex-1 items-center gap-2 text-left", children: renderValue(selected) })) : (_jsx("span", { className: `truncate ${selected ? "" : "text-muted-foreground"}`, children: selected?.label ?? placeholder })), _jsx(ChevronsUpDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })] }) }), _jsxs(PopoverContent, { className: "w-[--radix-popover-trigger-width] p-0", align: "start", children: [_jsx("div", { className: "p-2 border-b", children: _jsxs("div", { className: "relative", children: [_jsx(Search, { className: "absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" }), _jsx(Input, { autoFocus: true, value: q, onChange: (e) => setQ(e.target.value), onKeyDown: (e) => {
|
|
23
|
+
setQ(""); }, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "outline", role: "combobox", "aria-expanded": open, disabled: disabled, ref: ref, id: id, className: `w-full min-w-0 max-w-full justify-between overflow-hidden font-normal ${className ?? ""}`, children: [renderValue && selected ? (_jsx("span", { className: "flex min-w-0 flex-1 items-center gap-2 text-left", children: renderValue(selected) })) : (_jsx("span", { className: `truncate ${selected ? "" : "text-muted-foreground"}`, children: selected?.label ?? placeholder })), _jsx(ChevronsUpDown, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })] }) }), _jsxs(PopoverContent, { className: "w-[--radix-popover-trigger-width] p-0", align: "start", children: [_jsx("div", { className: "p-2 border-b", children: _jsxs("div", { className: "relative", children: [_jsx(Search, { className: "absolute left-2 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" }), _jsx(Input, { autoFocus: true, value: q, onChange: (e) => setQ(e.target.value), onKeyDown: (e) => {
|
|
24
24
|
if (e.key === "Enter" && filtered.length > 0) {
|
|
25
25
|
e.preventDefault();
|
|
26
26
|
onChange(filtered[0].value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerkoopOrdersPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/VerkoopOrdersPage.tsx"],"names":[],"mappings":"AAyPA,wBAAgB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"VerkoopOrdersPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/VerkoopOrdersPage.tsx"],"names":[],"mappings":"AAyPA,wBAAgB,iBAAiB,gCAy+BhC"}
|
|
@@ -549,7 +549,9 @@ export function VerkoopOrdersPage() {
|
|
|
549
549
|
const t = e.target;
|
|
550
550
|
if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)))
|
|
551
551
|
return;
|
|
552
|
-
if (
|
|
552
|
+
if (helpOpen || filterPanelOpen || pendingAction || editOrderId)
|
|
553
|
+
return;
|
|
554
|
+
if (document.querySelector('[role="dialog"]:not([aria-hidden="true"]):not([data-state="closed"]), [role="alertdialog"]:not([aria-hidden="true"]):not([data-state="closed"])'))
|
|
553
555
|
return;
|
|
554
556
|
const { paged: rows, focusedId: cur } = keyState.current;
|
|
555
557
|
if (e.key === "?") {
|
|
@@ -582,7 +584,7 @@ export function VerkoopOrdersPage() {
|
|
|
582
584
|
};
|
|
583
585
|
window.addEventListener("keydown", onKey);
|
|
584
586
|
return () => window.removeEventListener("keydown", onKey);
|
|
585
|
-
}, [navigate]);
|
|
587
|
+
}, [navigate, helpOpen, filterPanelOpen, pendingAction, editOrderId]);
|
|
586
588
|
useEffect(() => setFocusedId(null), [tab, page, filters]);
|
|
587
589
|
const hasFilters = !!filters.search || activeFilterCount > 0 || tab !== "all";
|
|
588
590
|
const notices = [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-detail-shortcuts.check.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/order-detail-shortcuts.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
const source = readFileSync(new URL("./SalesOrderDetailPage.tsx", import.meta.url), "utf8");
|
|
5
|
+
const match = source.match(/const onDetailKey = (\(e: KeyboardEvent\) => \{[\s\S]*?)\n };\n window.addEventListener/);
|
|
6
|
+
assert.ok(match, "Detail keyboard handler must exist");
|
|
7
|
+
const code = ts.transpileModule(`const handler = ${match[1]}\n};`, {
|
|
8
|
+
compilerOptions: { target: ts.ScriptTarget.ES2022 },
|
|
9
|
+
}).outputText;
|
|
10
|
+
const clicked = [];
|
|
11
|
+
const makeLink = (name) => ({ current: { isConnected: true, click: () => clicked.push(name) } });
|
|
12
|
+
const back = makeLink("back");
|
|
13
|
+
const prev = makeLink("previous");
|
|
14
|
+
const next = makeLink("next");
|
|
15
|
+
let overlay = false;
|
|
16
|
+
const handler = new Function("document", "backLink", "previousLink", "nextLink", `${code}; return handler;`)({ querySelector: () => overlay ? {} : null }, back, prev, next);
|
|
17
|
+
const press = (key, extra = {}) => handler({ key, target: { closest: () => null }, preventDefault() { }, ...extra });
|
|
18
|
+
press("ArrowLeft");
|
|
19
|
+
assert.deepEqual(clicked.splice(0), ["previous"]);
|
|
20
|
+
press("ArrowRight");
|
|
21
|
+
assert.deepEqual(clicked.splice(0), ["next"]);
|
|
22
|
+
press("Escape");
|
|
23
|
+
assert.deepEqual(clicked.splice(0), ["back"]);
|
|
24
|
+
prev.current = null;
|
|
25
|
+
next.current = null;
|
|
26
|
+
press("ArrowLeft");
|
|
27
|
+
press("ArrowRight");
|
|
28
|
+
assert.equal(clicked.length, 0, "Absent neighbours must never navigate");
|
|
29
|
+
for (const flag of ["ctrlKey", "metaKey", "altKey", "shiftKey", "repeat", "defaultPrevented"])
|
|
30
|
+
press("Escape", { [flag]: true });
|
|
31
|
+
assert.equal(clicked.length, 0, "Modified, repeated and handled keys must be ignored");
|
|
32
|
+
press("Escape", { target: { closest: () => ({}) } });
|
|
33
|
+
press("Escape", { target: { isContentEditable: true } });
|
|
34
|
+
assert.equal(clicked.length, 0, "Editing must not navigate");
|
|
35
|
+
overlay = true;
|
|
36
|
+
press("Escape");
|
|
37
|
+
assert.equal(clicked.length, 0, "Open dialogs and menus must not navigate");
|
|
38
|
+
console.log("Detail shortcuts: previous/next/back and navigation safeguards passed.");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-shortcuts.check.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/order-shortcuts.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import ts from "typescript";
|
|
4
|
+
// Exercise the actual page handler without requiring a signed-in session.
|
|
5
|
+
const source = readFileSync(new URL("./VerkoopOrdersPage.tsx", import.meta.url), "utf8");
|
|
6
|
+
const match = source.match(/const onKey = (\(e: KeyboardEvent\) => \{[\s\S]*?)\n };\n window.addEventListener/);
|
|
7
|
+
assert.ok(match, "Order keyboard handler must exist");
|
|
8
|
+
const code = ts.transpileModule(`const handler = ${match[1]}\n};`, {
|
|
9
|
+
compilerOptions: { target: ts.ScriptTarget.ES2022 },
|
|
10
|
+
}).outputText;
|
|
11
|
+
const destinations = [];
|
|
12
|
+
let dialog = null;
|
|
13
|
+
const createHandler = new Function("document", "navigate", "keyState", "helpOpen", "filterPanelOpen", "pendingAction", "editOrderId", `${code}; return handler;`);
|
|
14
|
+
const makeHandler = (filterOpen = false) => createHandler({ querySelector: () => dialog }, (destination) => destinations.push(destination), { current: { paged: [], focusedId: null } }, false, filterOpen, null, null);
|
|
15
|
+
const press = (handler, key, tagName = "BODY", ctrlKey = false) => {
|
|
16
|
+
handler({ key, target: { tagName }, ctrlKey, preventDefault() { } });
|
|
17
|
+
};
|
|
18
|
+
for (const key of ["n", "N"]) {
|
|
19
|
+
destinations.length = 0;
|
|
20
|
+
press(makeHandler(), key);
|
|
21
|
+
assert.deepEqual(destinations, [{ to: "/floriday-verkoop/verkooporders/nieuw" }]);
|
|
22
|
+
}
|
|
23
|
+
destinations.length = 0;
|
|
24
|
+
press(makeHandler(true), "n");
|
|
25
|
+
assert.equal(destinations.length, 0, "Open filters must block navigation");
|
|
26
|
+
dialog = {};
|
|
27
|
+
press(makeHandler(), "n");
|
|
28
|
+
assert.equal(destinations.length, 0, "Open dialogs must block navigation");
|
|
29
|
+
dialog = null;
|
|
30
|
+
for (const tagName of ["INPUT", "TEXTAREA", "SELECT"])
|
|
31
|
+
press(makeHandler(), "n", tagName);
|
|
32
|
+
press(makeHandler(), "n", "BODY", true);
|
|
33
|
+
assert.equal(destinations.length, 0, "Typing and browser shortcuts must not open an order");
|
|
34
|
+
console.log("Order shortcuts: n/N navigate; open dialogs, typing and modifiers remain protected.");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationTooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/v3/NavigationTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE9C,wBAAgB,iBAAiB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACrB,+BAWA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
export function NavigationTooltip({ label, shortcut, children }) {
|
|
4
|
+
const id = useId();
|
|
5
|
+
return (_jsxs("span", { className: "group relative inline-flex", children: [children, _jsxs("span", { id: id, role: "tooltip", className: "pointer-events-none absolute left-1/2 top-full z-50 mt-2 flex -translate-x-1/2 items-center gap-3 whitespace-nowrap rounded-md border border-border bg-popover px-3 py-2 text-xs text-popover-foreground shadow-md invisible opacity-0 group-hover:visible group-hover:opacity-100 group-focus-within:visible group-focus-within:opacity-100", children: [label, _jsx("kbd", { className: "rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-xs text-muted-foreground", children: shortcut })] })] }));
|
|
6
|
+
}
|