@flowselections/floriday-verkoop-module 1.0.153 → 1.0.155
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 +56 -30
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts +3 -1
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.js +2 -2
- package/dist-lib/components/verkoop/OrderTransportCard.d.ts +44 -0
- package/dist-lib/components/verkoop/OrderTransportCard.d.ts.map +1 -0
- package/dist-lib/components/verkoop/OrderTransportCard.js +96 -0
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +2 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +3 -3
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +8 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +15 -5
- package/dist-lib/components/verkoop/klok/KlokNotice.d.ts +3 -0
- package/dist-lib/components/verkoop/klok/KlokNotice.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/KlokNotice.js +12 -0
- package/dist-lib/components/verkoop/klok/KlokOrderPage.d.ts +2 -0
- package/dist-lib/components/verkoop/klok/KlokOrderPage.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/KlokOrderPage.js +382 -0
- package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts +10 -0
- package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/KlokOrdersList.js +119 -0
- package/dist-lib/components/verkoop/klok/KlokPage.d.ts +2 -0
- package/dist-lib/components/verkoop/klok/KlokPage.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/KlokPage.js +61 -0
- package/dist-lib/components/verkoop/klok/KlokStatusBadge.d.ts +5 -0
- package/dist-lib/components/verkoop/klok/KlokStatusBadge.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/KlokStatusBadge.js +20 -0
- package/dist-lib/components/verkoop/klok/useKlok.d.ts +17 -0
- package/dist-lib/components/verkoop/klok/useKlok.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/useKlok.js +36 -0
- package/dist-lib/index.d.ts +2 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +8 -1
- package/dist-lib/integrations/supabase/types.d.ts +1168 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/all-rows.d.ts +11 -0
- package/dist-lib/lib/all-rows.d.ts.map +1 -0
- package/dist-lib/lib/all-rows.js +20 -0
- package/dist-lib/lib/belading.server.d.ts.map +1 -1
- package/dist-lib/lib/belading.server.js +20 -9
- package/dist-lib/lib/create-order-form.d.ts +22 -0
- package/dist-lib/lib/create-order-form.d.ts.map +1 -1
- package/dist-lib/lib/create-order-form.js +37 -0
- package/dist-lib/lib/create-order.functions.d.ts +20 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +51 -2
- package/dist-lib/lib/floriday-mirror.server.js +1 -1
- package/dist-lib/lib/klok-form.d.ts +47 -0
- package/dist-lib/lib/klok-form.d.ts.map +1 -0
- package/dist-lib/lib/klok-form.js +51 -0
- package/dist-lib/lib/klok-gateway.server.d.ts +35 -0
- package/dist-lib/lib/klok-gateway.server.d.ts.map +1 -0
- package/dist-lib/lib/klok-gateway.server.js +123 -0
- package/dist-lib/lib/klok-labels.d.ts +63 -0
- package/dist-lib/lib/klok-labels.d.ts.map +1 -0
- package/dist-lib/lib/klok-labels.js +153 -0
- package/dist-lib/lib/klok-sales-row.d.ts +2 -0
- package/dist-lib/lib/klok-sales-row.d.ts.map +1 -0
- package/dist-lib/lib/klok-sales-row.js +5 -0
- package/dist-lib/lib/klok-sales.server.d.ts +5 -0
- package/dist-lib/lib/klok-sales.server.d.ts.map +1 -0
- package/dist-lib/lib/klok-sales.server.js +33 -0
- package/dist-lib/lib/klok.functions.d.ts +265 -0
- package/dist-lib/lib/klok.functions.d.ts.map +1 -0
- package/dist-lib/lib/klok.functions.js +355 -0
- package/dist-lib/lib/klok.server.d.ts +76 -0
- package/dist-lib/lib/klok.server.d.ts.map +1 -0
- package/dist-lib/lib/klok.server.js +401 -0
- package/dist-lib/lib/module-version.d.ts +1 -1
- package/dist-lib/lib/module-version.js +1 -1
- package/dist-lib/lib/order-search.d.ts +16 -0
- package/dist-lib/lib/order-search.d.ts.map +1 -1
- package/dist-lib/lib/order-search.js +16 -1
- package/dist-lib/lib/order-transport.functions.d.ts +49 -0
- package/dist-lib/lib/order-transport.functions.d.ts.map +1 -0
- package/dist-lib/lib/order-transport.functions.js +42 -0
- package/dist-lib/lib/order-transport.server.d.ts +16 -0
- package/dist-lib/lib/order-transport.server.d.ts.map +1 -0
- package/dist-lib/lib/order-transport.server.js +43 -0
- package/dist-lib/lib/own-transport.d.ts +16 -0
- package/dist-lib/lib/own-transport.d.ts.map +1 -1
- package/dist-lib/lib/own-transport.js +28 -0
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +20 -17
- package/dist-lib/lib/salesorders-mapping.d.ts +5 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-mapping.js +1 -0
- package/package.json +20 -3
- package/schema/verkoop.sql +213 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"AAoGA,wBAAgB,eAAe,gCAqwC9B"}
|
|
@@ -10,7 +10,8 @@ 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 {
|
|
13
|
+
import { isOwnTransportKind, ownPickupLabel, OWN_PICKUP_MISSING_TEXT } from "../../lib/own-transport.js";
|
|
14
|
+
import { missingItems, lineTotal, dateWithWeekday, eur, attentionItems, selectionKey, resetOnSelectionChange, applyFirstFeasible, prijsBronLabel, prijsSleutel, PRIJS_FOUT_TEXT } from "../../lib/create-order-form.js";
|
|
14
15
|
import { useServerFn } from "@tanstack/react-start";
|
|
15
16
|
import { SearchableSelect } from "./SearchableSelect.js";
|
|
16
17
|
import { toISODate } from "../../lib/carrier-availability.js";
|
|
@@ -18,7 +19,7 @@ import { getDeparturePreview } from "../../lib/departure-preview.functions.js";
|
|
|
18
19
|
import { getProductPlannability } from "../../lib/product-plannable.functions.js";
|
|
19
20
|
import { decidePreview, momentLabel, firstDateText, LATE_CONFIRM } from "../../lib/departure-preview.js";
|
|
20
21
|
import { ConfirmDialog } from "./ConfirmDialog.js";
|
|
21
|
-
import { listCustomersForCreateOrder, ensureCustomerFromTwinfield, listProductsForCreateOrder, listCustomerStickerProducts, listDeliveryLocationsForCustomerCO, listPickupLocationsCO, getLastPickupLocationCO, listCarriersForCreateOrder, getOrderPickDaysCO, listBeladingOptionsForProducts, createManualOrder,
|
|
22
|
+
import { listCustomersForCreateOrder, ensureCustomerFromTwinfield, listProductsForCreateOrder, listCustomerStickerProducts, listDeliveryLocationsForCustomerCO, listPickupLocationsCO, getLastPickupLocationCO, listCarriersForCreateOrder, getOrderPickDaysCO, listBeladingOptionsForProducts, createManualOrder, getOrderPrices, } from "../../lib/create-order.functions.js";
|
|
22
23
|
import { checkOrderStockAllowed } from "../../lib/logistics-stock.functions.js";
|
|
23
24
|
import { useAllowedLoadCarriers } from "../../lib/useAllowedLoadCarriers.js";
|
|
24
25
|
const beladingKey = (b) => `${b.plants_per_crate}x${b.crates_per_layer}x${b.layers_per_cart}`;
|
|
@@ -44,7 +45,7 @@ export function CreateOrderPage() {
|
|
|
44
45
|
const qc = useQueryClient();
|
|
45
46
|
const fetchCustomers = useServerFn(listCustomersForCreateOrder);
|
|
46
47
|
const fetchProducts = useServerFn(listProductsForCreateOrder);
|
|
47
|
-
const
|
|
48
|
+
const fetchOrderPrices = useServerFn(getOrderPrices);
|
|
48
49
|
const fetchDeliveryLocations = useServerFn(listDeliveryLocationsForCustomerCO);
|
|
49
50
|
const fetchPickupLocations = useServerFn(listPickupLocationsCO);
|
|
50
51
|
const fetchCarriers = useServerFn(listCarriersForCreateOrder);
|
|
@@ -114,10 +115,52 @@ export function CreateOrderPage() {
|
|
|
114
115
|
const [customerReference, setCustomerReference] = useState("");
|
|
115
116
|
// Eigen vervoer / zelf afleveren: bewuste keuze, geen vervoerder.
|
|
116
117
|
const [ownTransport, setOwnTransport] = useState(false);
|
|
118
|
+
// Vertrek-/ophaaltijd bij eigen vervoer of klant haalt op (leeg = nog niet gekozen).
|
|
119
|
+
const [ownPickupTime, setOwnPickupTime] = useState("");
|
|
120
|
+
const ownKindValue = ownTransport
|
|
121
|
+
? "eigen_vervoer"
|
|
122
|
+
: (carriers.find((c) => c.id === carrierId && isOwnTransportKind(c.carrier_kind))?.carrier_kind ?? null);
|
|
123
|
+
const ownPickupKind = !!ownKindValue;
|
|
117
124
|
const [lateConfirmOpen, setLateConfirmOpen] = useState(false);
|
|
118
125
|
const [lines, setLines] = useState([
|
|
119
126
|
{ product_id: null, product_name: "", quantity: null, unit: "stuks", unit_price: null, belading: null },
|
|
120
127
|
]);
|
|
128
|
+
// Automatische prijs per regel via klanten_orderprijs. Opnieuw bij een andere
|
|
129
|
+
// klant, leverdatum, product of aantal; een zelf ingevulde prijs blijft staan.
|
|
130
|
+
const priceWanted = lines
|
|
131
|
+
.map((l, i) => ({ i, key: l.price_mode === "manual" ? null : prijsSleutel(customerId, l.product_id, deliveryDate, l.quantity), l }))
|
|
132
|
+
.filter((x) => x.key && x.key !== x.l.price_key);
|
|
133
|
+
const priceWantedKey = priceWanted.map((x) => `${x.i}:${x.key}`).join(",");
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (!priceWanted.length || !customerId)
|
|
136
|
+
return;
|
|
137
|
+
const todo = priceWanted.map((x) => ({ i: x.i, key: x.key, productId: x.l.product_id, quantity: Number(x.l.quantity ?? 0) || undefined }));
|
|
138
|
+
const t = setTimeout(() => {
|
|
139
|
+
const apply = (res) => {
|
|
140
|
+
setLines((cur) => {
|
|
141
|
+
const copy = [...cur];
|
|
142
|
+
todo.forEach((x, n) => {
|
|
143
|
+
const ln = copy[x.i];
|
|
144
|
+
if (!ln || ln.price_mode === "manual")
|
|
145
|
+
return;
|
|
146
|
+
if (prijsSleutel(customerId, ln.product_id, deliveryDate, ln.quantity) !== x.key)
|
|
147
|
+
return;
|
|
148
|
+
const r = res?.[n];
|
|
149
|
+
if (!r || !r.ok)
|
|
150
|
+
copy[x.i] = { ...ln, price_error: true, price_key: x.key, price_source: null, unit_price: null };
|
|
151
|
+
else
|
|
152
|
+
copy[x.i] = { ...ln, price_error: false, price_key: x.key, price_mode: "auto", unit_price: r.prijs ? r.prijs.net_price : null, price_source: prijsBronLabel(r.prijs) };
|
|
153
|
+
});
|
|
154
|
+
return copy;
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
fetchOrderPrices({ data: { customerId, onDate: deliveryDate || undefined, lines: todo.map(({ productId, quantity }) => ({ productId, quantity })) } })
|
|
158
|
+
.then(apply)
|
|
159
|
+
.catch((e) => { console.error("[orderprijs]", e); apply(null); });
|
|
160
|
+
}, 300);
|
|
161
|
+
return () => clearTimeout(t);
|
|
162
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
163
|
+
}, [priceWantedKey, customerId, deliveryDate]);
|
|
121
164
|
// Standaard stickervinkje: aan als er voor deze klant + dit product een
|
|
122
165
|
// vaste klantsticker bestaat. Een zelf gezet vinkje blijft staan.
|
|
123
166
|
const stickerProductKey = Array.from(new Set(lines.map((l) => l.product_id).filter((v) => !!v))).sort();
|
|
@@ -474,6 +517,7 @@ export function CreateOrderPage() {
|
|
|
474
517
|
carrierId: isReservation || ownTransport ? null : carrierId,
|
|
475
518
|
momentKey: isReservation || ownTransport ? null : momentKey,
|
|
476
519
|
ownTransport: !isReservation && ownTransport,
|
|
520
|
+
ownPickupTime: !isReservation && ownPickupKind && ownPickupTime ? ownPickupTime : null,
|
|
477
521
|
customerReference: customerReference.trim() ? customerReference.trim() : null,
|
|
478
522
|
acceptLateSignup,
|
|
479
523
|
confirmZeroPrice: zeroPriceOkRef.current,
|
|
@@ -617,7 +661,7 @@ export function CreateOrderPage() {
|
|
|
617
661
|
: carrierId ? carrierName(carrierId) ?? "Onbekend"
|
|
618
662
|
: preview?.carrierId ? `Automatisch: ${carrierName(preview.carrierId) ?? "onbekend"}`
|
|
619
663
|
: "Automatisch";
|
|
620
|
-
const momentText = isReservation ? null : ownTransport ? "Eigen vervoer" : decision && (decision.kind === "ok" || decision.kind === "late") ? decision.text ?? null : null;
|
|
664
|
+
const momentText = isReservation ? null : ownPickupKind && ownPickupTime && deliveryDate ? `${ownPickupLabel(ownKindValue)} ${ownPickupTime}` : ownTransport ? "Eigen vervoer" : decision && (decision.kind === "ok" || decision.kind === "late") ? decision.text ?? null : null;
|
|
621
665
|
const missing = missingItems({
|
|
622
666
|
customerId, deliveryLocationId, pickupLocationId, isReservation, deliveryDate,
|
|
623
667
|
validLineCount: validLines.length,
|
|
@@ -626,10 +670,12 @@ export function CreateOrderPage() {
|
|
|
626
670
|
previewPending: canPickDate && !isReservation && !decision,
|
|
627
671
|
previewBlockedReason: decision && (decision.kind === "blocked" || decision.kind === "departed") ? decision.reason : null,
|
|
628
672
|
});
|
|
629
|
-
const
|
|
630
|
-
linesWithoutPrice:
|
|
673
|
+
const attention0 = attentionItems({
|
|
674
|
+
linesWithoutPrice: lines.filter((l) => l.product_id && !l.price_error && !(Number(l.unit_price) > 0)).length,
|
|
675
|
+
linesPriceError: lines.filter((l) => l.product_id && l.price_error).length,
|
|
631
676
|
linesOverStock: lines.filter((l) => l.product_id && shortageByProduct.has(l.product_id)).length,
|
|
632
677
|
});
|
|
678
|
+
const attention = !isReservation && ownPickupKind && !ownPickupTime ? [OWN_PICKUP_MISSING_TEXT, ...attention0] : attention0;
|
|
633
679
|
const canCreate = missing.length === 0 && !createMut.isPending && !stockQ.isFetching;
|
|
634
680
|
const submit = () => {
|
|
635
681
|
if (!canCreate)
|
|
@@ -698,7 +744,7 @@ export function CreateOrderPage() {
|
|
|
698
744
|
setCarrierId(!v || v === "__auto__" ? null : v);
|
|
699
745
|
}
|
|
700
746
|
setMomentKey(null);
|
|
701
|
-
} }))] }), _jsxs("div", { className: "min-w-0 space-y-1.5 @[47.5rem]: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 [@media(pointer:coarse)]:h-11", 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 w-fit cursor-pointer items-center gap-2 text-sm text-muted-foreground [@media(pointer:coarse)]:min-h-11", 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} @container`, 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(220px,1fr)_56px_minmax(120px,0.8fr)_80px_72px_minmax(88px,0.6fr)_92px_88px_44px] gap-2 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground @[60rem]: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 @[60rem]:space-y-0 @[60rem]:divide-y @[60rem]:divide-border", children: lines.map((line, idx) => {
|
|
747
|
+
} })), !isReservation && ownPickupKind && (_jsxs("div", { className: "space-y-1 pt-1", children: [_jsx(Label, { className: fieldLabel, htmlFor: "own-pickup-time", children: ownPickupLabel(ownKindValue) }), _jsx(Input, { id: "own-pickup-time", type: "time", className: "h-9 w-32 tabular-nums [@media(pointer:coarse)]:h-11", value: ownPickupTime, onChange: (e) => setOwnPickupTime(e.target.value) }), !ownPickupTime && _jsx("div", { className: "text-xs text-warning-soft-foreground", children: OWN_PICKUP_MISSING_TEXT })] }))] }), _jsxs("div", { className: "min-w-0 space-y-1.5 @[47.5rem]: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 [@media(pointer:coarse)]:h-11", 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 w-fit cursor-pointer items-center gap-2 text-sm text-muted-foreground [@media(pointer:coarse)]:min-h-11", 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} @container`, 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(220px,1fr)_56px_minmax(120px,0.8fr)_80px_72px_minmax(88px,0.6fr)_92px_88px_44px] gap-2 px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground @[60rem]: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 @[60rem]:space-y-0 @[60rem]:divide-y @[60rem]:divide-border", children: lines.map((line, idx) => {
|
|
702
748
|
const { product, eff: effBelading, ppc, crates } = lineInfo[idx];
|
|
703
749
|
const defaultBelading = completeBelading(product);
|
|
704
750
|
const plants = line.quantity ?? null;
|
|
@@ -722,6 +768,7 @@ export function CreateOrderPage() {
|
|
|
722
768
|
const unit = product?.unit || "stuks";
|
|
723
769
|
const overStock = !!product && (plants ?? 0) > 0 && (shortage || (available != null && (plants ?? 0) > available));
|
|
724
770
|
const noPrice = !!line.product_id && !(Number(line.unit_price) > 0);
|
|
771
|
+
const pricePending = !!line.product_id && line.price_mode !== "manual" && !line.price_error && line.price_key !== prijsSleutel(customerId, line.product_id, deliveryDate, line.quantity);
|
|
725
772
|
const impossible = line.product_id ? impossibleByLine[String(idx)] : undefined;
|
|
726
773
|
const missingLine = line.product_id && !impossible ? (missingByLine[String(idx)] ?? missingByProduct[line.product_id]) : undefined;
|
|
727
774
|
const sizeText = product?.plant_height_cm ? `${product.plant_height_cm} cm` : null;
|
|
@@ -752,32 +799,11 @@ export function CreateOrderPage() {
|
|
|
752
799
|
next[idx] = {
|
|
753
800
|
...next[idx], product_id: v, product_name: p?.product ?? "",
|
|
754
801
|
unit: next[idx].unit ?? p?.unit ?? "stuks", quantity: normalizedQ, belading: b,
|
|
755
|
-
|
|
802
|
+
...(next[idx].price_mode === "manual" ? {} : { unit_price: null, price_source: null, price_error: false, price_key: null }),
|
|
756
803
|
};
|
|
757
804
|
focusNext.current = { kind: "crates", idx };
|
|
758
805
|
}
|
|
759
806
|
setLines(next);
|
|
760
|
-
if (v && customerId && !String(customerId).startsWith("twinfield:")) {
|
|
761
|
-
const lineIdx = idx;
|
|
762
|
-
const hadPrice = next[idx].unit_price;
|
|
763
|
-
fetchEffectivePrices({ data: { customerId, onDate: deliveryDate || undefined, lines: [{ productId: v, quantity: Number(next[idx].quantity ?? 0) || undefined }] } })
|
|
764
|
-
.then((res) => {
|
|
765
|
-
const hit = res?.[v];
|
|
766
|
-
if (!hit)
|
|
767
|
-
return;
|
|
768
|
-
setLines((cur) => {
|
|
769
|
-
const copy = [...cur];
|
|
770
|
-
const ln = copy[lineIdx];
|
|
771
|
-
if (!ln || ln.product_id !== v)
|
|
772
|
-
return cur;
|
|
773
|
-
if (ln.unit_price != null && ln.unit_price !== hadPrice)
|
|
774
|
-
return cur;
|
|
775
|
-
copy[lineIdx] = { ...ln, unit_price: hit.price };
|
|
776
|
-
return copy;
|
|
777
|
-
});
|
|
778
|
-
})
|
|
779
|
-
.catch(() => undefined);
|
|
780
|
-
}
|
|
781
807
|
} }), impossible && _jsxs("div", { className: "mt-1 text-xs text-destructive", children: ["Niet in te delen met deze belading: ", impossible] }), missingLine && _jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: ["Let op: ", missingLine] })] }), _jsxs("label", { className: "order-3 flex h-9 min-w-11 shrink-0 cursor-pointer items-center gap-2 [@media(pointer:coarse)]:h-11 @[60rem]:order-none @[60rem]:justify-center", children: [_jsx("input", { type: "checkbox", className: "h-4 w-4 accent-primary [@media(pointer:coarse)]:h-6 [@media(pointer:coarse)]:w-6", "aria-label": "Sticker nodig", title: "Sticker nodig", checked: line.needs_sticker === true, disabled: !line.product_id, onChange: (e) => { const next = [...lines]; next[idx] = { ...next[idx], needs_sticker: e.target.checked, sticker_manual_for: line.product_id }; setLines(next); } }), _jsx("span", { className: "text-sm @[60rem]:sr-only", children: "Sticker nodig" })] }), _jsxs("div", { className: "order-3 min-w-0 grow basis-[13rem] @[60rem]:order-none @[60rem]:basis-auto", children: [_jsx("div", { className: "mb-1 text-xs text-muted-foreground @[60rem]:sr-only", children: "Belading" }), _jsx(SearchableSelect, { value: effBelading ? beladingKey(effBelading) : null, placeholder: !line.product_id ? "Kies eerst product" : loadingBeladingen ? "Laden…" : noBeladingen ? "Geen belading" : "Kies belading…", disabled: !line.product_id || loadingBeladingen || noBeladingen, allowClear: false, emptyLabel: "Geen belading gekoppeld aan dit product", options: Array.from(optionMap.entries()).map(([key, b]) => ({
|
|
782
808
|
value: key,
|
|
783
809
|
label: beladingLabel(b),
|
|
@@ -807,6 +833,6 @@ export function CreateOrderPage() {
|
|
|
807
833
|
const cr = raw ? Math.max(1, Math.floor(Number(raw))) : null;
|
|
808
834
|
next[idx] = { ...next[idx], quantity: cr === null ? null : cr * ppc };
|
|
809
835
|
setLines(next);
|
|
810
|
-
}, placeholder: ppc === null ? "—" : "Fusten", title: ppc === null ? "Kies eerst een belading" : `${ppc} planten per fust` })] }), _jsxs("div", { className: "grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", children: "Stuks" }), _jsx("div", { className: "flex h-9 items-center text-sm tabular-nums text-foreground @[60rem]:justify-end", children: line.product_id && plants ? plants.toLocaleString("nl-NL") : "—" })] }), _jsxs("div", { className: "min-w-0 grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", 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: "grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", children: "Prijs per stuk" }), _jsx(Input, { type: "number", min: 0, step: "0.01", inputMode: "decimal", className: "h-9 tabular-nums [@media(pointer:coarse)]:h-11", 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: "grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", children: "Totaal" }), _jsx("div", { className: "flex h-9 items-center text-sm font-medium tabular-nums text-foreground @[60rem]:justify-end", children: line.product_id ? eur(lineInfo[idx].total) : "—" })] }), _jsx("div", { className: "order-2 flex shrink-0 justify-end @[60rem]:order-none", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 [@media(pointer:coarse)]:h-11 [@media(pointer:coarse)]:w-11", onClick: () => setLines(lines.filter((_, i) => i !== idx)), "aria-label": "Regel verwijderen", children: _jsx(Trash2, { className: "h-4 w-4" }) }) })] }, idx));
|
|
836
|
+
}, placeholder: ppc === null ? "—" : "Fusten", title: ppc === null ? "Kies eerst een belading" : `${ppc} planten per fust` })] }), _jsxs("div", { className: "grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", children: "Stuks" }), _jsx("div", { className: "flex h-9 items-center text-sm tabular-nums text-foreground @[60rem]:justify-end", children: line.product_id && plants ? plants.toLocaleString("nl-NL") : "—" })] }), _jsxs("div", { className: "min-w-0 grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", 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: "grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", children: "Prijs per stuk" }), _jsx(Input, { type: "number", min: 0, step: "0.01", inputMode: "decimal", className: "h-9 tabular-nums [@media(pointer:coarse)]:h-11", value: line.unit_price ?? "", onChange: (e) => { const next = [...lines]; next[idx] = { ...next[idx], unit_price: e.target.value === "" ? null : Number(e.target.value), price_mode: "manual", price_source: "Handmatig", price_error: false }; setLines(next); }, placeholder: "\u20AC", "aria-invalid": noPrice || line.price_error }), line.price_error ? (_jsx("span", { className: "mt-1 block text-xs text-destructive", children: PRIJS_FOUT_TEXT })) : noPrice && !pricePending ? (_jsx("span", { className: "mt-1 block text-xs text-destructive", children: "Geen prijs gevonden" })) : line.price_source ? (_jsx("span", { className: "mt-1 block truncate text-xs text-muted-foreground", title: line.price_source, children: line.price_source })) : null, line.product_id && (line.price_mode === "manual" || line.price_error) && (_jsx("button", { type: "button", className: "mt-0.5 block text-xs font-medium text-primary hover:underline [@media(pointer:coarse)]:min-h-11", onClick: (e) => { e.preventDefault(); const next = [...lines]; next[idx] = { ...next[idx], price_mode: "auto", price_key: null, price_error: false }; setLines(next); }, children: "Prijs opnieuw ophalen" }))] }), _jsxs("div", { className: "grow basis-[7.5rem] @[60rem]:basis-auto order-3 @[60rem]:order-none", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground @[60rem]:sr-only", children: "Totaal" }), _jsx("div", { className: "flex h-9 items-center text-sm font-medium tabular-nums text-foreground @[60rem]:justify-end", children: line.product_id ? eur(lineInfo[idx].total) : "—" })] }), _jsx("div", { className: "order-2 flex shrink-0 justify-end @[60rem]:order-none", children: _jsx(Button, { variant: "ghost", size: "icon", className: "h-9 w-9 [@media(pointer:coarse)]:h-11 [@media(pointer:coarse)]:w-11", onClick: () => setLines(lines.filter((_, i) => i !== idx)), "aria-label": "Regel verwijderen", children: _jsx(Trash2, { className: "h-4 w-4" }) }) })] }, idx));
|
|
811
837
|
}) }), _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 [@media(pointer:coarse)]:h-11", 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 [@media(pointer:coarse)]:h-11", 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: "min-w-0", children: _jsxs("div", { className: `${cardCls} space-y-4 xl:sticky xl:top-4`, children: [_jsx("h2", { className: h2, children: "Samenvatting" }), summaryRows, missingBlock, attentionBlock, createButton(), _jsx(Button, { variant: "ghost", className: "h-9 w-full [@media(pointer:coarse)]:h-11", onClick: () => navigate({ to: "/floriday-verkoop/verkooporders" }), disabled: createMut.isPending, children: "Annuleren" })] }) })] }), _jsxs("div", { className: "sticky bottom-0 z-30 -mx-4 border-t border-border bg-background/95 px-4 pt-3 backdrop-blur sm:-mx-6 sm:px-6 xl: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 [@media(pointer:coarse)]:min-h-11", 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 }) })] }));
|
|
812
838
|
}
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
* Toont het ophaal- en aanmeldmoment zoals de planning het heeft berekend.
|
|
3
3
|
* Zonder `readOnly` kun je een ander moment van de vervoerder kiezen.
|
|
4
4
|
*/
|
|
5
|
-
export declare function OrderPickupMomentPicker({ orderId, readOnly, compact, }: {
|
|
5
|
+
export declare function OrderPickupMomentPicker({ orderId, readOnly, compact, pickupOnly, }: {
|
|
6
6
|
orderId: string;
|
|
7
7
|
readOnly?: boolean;
|
|
8
8
|
compact?: boolean;
|
|
9
|
+
/** Alleen het ophaalmoment tonen (aanmelden staat dan in een eigen regel). */
|
|
10
|
+
pickupOnly?: boolean;
|
|
9
11
|
}): import("react").JSX.Element;
|
|
10
12
|
//# sourceMappingURL=OrderPickupMomentPicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderPickupMomentPicker.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderPickupMomentPicker.tsx"],"names":[],"mappings":"AAQA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,OAAO,EACP,QAAgB,EAChB,OAAe,
|
|
1
|
+
{"version":3,"file":"OrderPickupMomentPicker.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderPickupMomentPicker.tsx"],"names":[],"mappings":"AAQA;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,OAAO,EACP,QAAgB,EAChB,OAAe,EACf,UAAkB,GACnB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,+BAwEA"}
|
|
@@ -10,7 +10,7 @@ import { formatMoment } from "../../lib/order-departure.js";
|
|
|
10
10
|
* Toont het ophaal- en aanmeldmoment zoals de planning het heeft berekend.
|
|
11
11
|
* Zonder `readOnly` kun je een ander moment van de vervoerder kiezen.
|
|
12
12
|
*/
|
|
13
|
-
export function OrderPickupMomentPicker({ orderId, readOnly = false, compact = false, }) {
|
|
13
|
+
export function OrderPickupMomentPicker({ orderId, readOnly = false, compact = false, pickupOnly = false, }) {
|
|
14
14
|
const qc = useQueryClient();
|
|
15
15
|
const saveMoment = useServerFn(setOrderPickupMoment);
|
|
16
16
|
const [saving, setSaving] = useState(false);
|
|
@@ -37,5 +37,5 @@ export function OrderPickupMomentPicker({ orderId, readOnly = false, compact = f
|
|
|
37
37
|
return _jsx("span", { className: "text-sm text-muted-foreground", children: "Laden\u2026" });
|
|
38
38
|
const view = data?.view;
|
|
39
39
|
const options = data?.options ?? [];
|
|
40
|
-
return (_jsxs("div", { className: compact ? "space-y-1" : "inline-flex flex-col gap-1", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2 text-sm text-foreground", children: [!compact && _jsx(Clock, { className: "h-4 w-4 text-muted-foreground" }), view?.text ? (_jsxs("span", { children: [view.text, data?.deliveryTime ? (_jsxs("span", { className: "text-muted-foreground", children: [" \u00B7 aanlevering ", data.deliveryTime] })) : null] })) : (_jsx("span", { className: "text-muted-foreground", children: view?.reason ?? "Geen ophaalmoment bekend" })), view?.lateSignup && (_jsx("span", { className: "rounded border border-destructive/40 px-1.5 py-0.5 text-xs text-destructive", children: "te laat aangemeld" }))] }), !readOnly && options.length > 1 && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("select", { className: "h-9 min-w-[18rem] rounded-md border border-border bg-background px-2 text-sm text-foreground disabled:opacity-60", value: data?.selectedKey ?? "", disabled: saving, onChange: (e) => onChange(e.target.value), "aria-label": "Ander ophaalmoment kiezen", children: [!data?.selectedKey && _jsx("option", { value: "", children: "Ander ophaalmoment kiezen\u2026" }), options.map((o) => (_jsx("option", { value: o.key, children: o.label }, o.key)))] }), saving && _jsx("span", { className: "text-xs text-muted-foreground", children: "Opslaan\u2026" })] })), data?.lateOverride && (_jsxs("span", { className: "text-xs text-muted-foreground", children: ["Toch aangemaakt na de aanmeldtijd door ", data.lateOverride.by ?? "onbekend", data.lateOverride.at ? ` op ${formatMoment(data.lateOverride.at)}` : ""] })), error && _jsx("span", { className: "text-xs text-destructive", children: error })] }));
|
|
40
|
+
return (_jsxs("div", { className: compact ? "space-y-1" : "inline-flex flex-col gap-1", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2 text-sm text-foreground", children: [!compact && _jsx(Clock, { className: "h-4 w-4 text-muted-foreground" }), view?.text ? (_jsxs("span", { children: [pickupOnly ? view.short ?? view.text : view.text, !pickupOnly && data?.deliveryTime ? (_jsxs("span", { className: "text-muted-foreground", children: [" \u00B7 aanlevering ", data.deliveryTime] })) : null] })) : (_jsx("span", { className: "text-muted-foreground", children: view?.reason ?? "Geen ophaalmoment bekend" })), view?.lateSignup && (_jsx("span", { className: "rounded border border-destructive/40 px-1.5 py-0.5 text-xs text-destructive", children: "te laat aangemeld" }))] }), !readOnly && options.length > 1 && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("select", { className: "h-9 min-w-[18rem] rounded-md border border-border bg-background px-2 text-sm text-foreground disabled:opacity-60", value: data?.selectedKey ?? "", disabled: saving, onChange: (e) => onChange(e.target.value), "aria-label": "Ander ophaalmoment kiezen", children: [!data?.selectedKey && _jsx("option", { value: "", children: "Ander ophaalmoment kiezen\u2026" }), options.map((o) => (_jsx("option", { value: o.key, children: o.label }, o.key)))] }), saving && _jsx("span", { className: "text-xs text-muted-foreground", children: "Opslaan\u2026" })] })), data?.lateOverride && (_jsxs("span", { className: "text-xs text-muted-foreground", children: ["Toch aangemaakt na de aanmeldtijd door ", data.lateOverride.by ?? "onbekend", data.lateOverride.at ? ` op ${formatMoment(data.lateOverride.at)}` : ""] })), error && _jsx("span", { className: "text-xs text-destructive", children: error })] }));
|
|
41
41
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { SalesOrderDTO } from "../../lib/salesorders-mapping.js";
|
|
3
|
+
export declare const orderTransportKey: (orderId: string) => readonly ["order-transport", string];
|
|
4
|
+
export declare function useOrderTransport(orderId: string | null | undefined, enabled?: boolean): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
orderRowId: string;
|
|
6
|
+
deliveryDate: string | null;
|
|
7
|
+
carrier: import("../../lib/carrier-resolve.js").ResolvedCarrier;
|
|
8
|
+
carrierGln: string | null;
|
|
9
|
+
own: boolean;
|
|
10
|
+
ownKind: string | null;
|
|
11
|
+
ownPickup: {
|
|
12
|
+
date: string;
|
|
13
|
+
time: string;
|
|
14
|
+
} | null;
|
|
15
|
+
locked: boolean;
|
|
16
|
+
lockKnown: boolean;
|
|
17
|
+
}, Error>;
|
|
18
|
+
/** "do 29 okt 15:00" uit { date, time }. */
|
|
19
|
+
export declare function ownPickupText(p: {
|
|
20
|
+
date: string;
|
|
21
|
+
time: string;
|
|
22
|
+
} | null | undefined): string | null;
|
|
23
|
+
/** Ophaaltijd invullen/wijzigen bij eigen vervoer of klant haalt op. */
|
|
24
|
+
export declare function OwnPickupEditor({ orderId, kind, current, defaultDate, locked }: {
|
|
25
|
+
orderId: string;
|
|
26
|
+
kind: string | null;
|
|
27
|
+
current: {
|
|
28
|
+
date: string;
|
|
29
|
+
time: string;
|
|
30
|
+
} | null;
|
|
31
|
+
defaultDate: string | null;
|
|
32
|
+
locked: boolean;
|
|
33
|
+
}): import("react").JSX.Element;
|
|
34
|
+
/** Blok "Vervoer" op de orderpagina; ontbrekende velden worden weggelaten. */
|
|
35
|
+
export declare function OrderTransportCard({ order, groupSize, extra }: {
|
|
36
|
+
order: SalesOrderDTO;
|
|
37
|
+
groupSize?: number;
|
|
38
|
+
extra?: ReactNode;
|
|
39
|
+
}): import("react").JSX.Element;
|
|
40
|
+
/** Kopregel van een handmatige order: "Ophalen do 29 okt 15:00 · Levering vr 30 okt 08:00". */
|
|
41
|
+
export declare function PickupDeliveryLine({ order }: {
|
|
42
|
+
order: SalesOrderDTO;
|
|
43
|
+
}): import("react").JSX.Element | null;
|
|
44
|
+
//# sourceMappingURL=OrderTransportCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderTransportCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderTransportCard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAcjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAGnE,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,yCAA0C,CAAC;AAE5F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,UAAO;;;;;;;;;;;;;UAQnF;AAED,4CAA4C;AAC5C,wBAAgB,aAAa,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAIjG;AAED,wEAAwE;AACxE,wBAAgB,eAAe,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC/C,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;CACjB,+BAuCA;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,+BA0E9H;AAED,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,sCAUrE"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
+
import { AlertTriangle, Truck } from "lucide-react";
|
|
6
|
+
import { Badge, Button, Input } from "@flowselections/core";
|
|
7
|
+
import { InfoCard, InfoRow } from "./v3/InfoCard.js";
|
|
8
|
+
import { OrderCarrierPicker } from "./OrderCarrierPicker.js";
|
|
9
|
+
import { OrderPickupMomentPicker } from "./OrderPickupMomentPicker.js";
|
|
10
|
+
import { usePickupMoment } from "../../lib/usePickupMoment.js";
|
|
11
|
+
import { formatMoment } from "../../lib/order-departure.js";
|
|
12
|
+
import { dateWithWeekday } from "../../lib/create-order-form.js";
|
|
13
|
+
import { getOrderTransport, setOrderOwnPickupTime } from "../../lib/order-transport.functions.js";
|
|
14
|
+
import { OWN_PICKUP_LOCKED_TEXT, OWN_PICKUP_MISSING_TEXT, ownPickupLabel } from "../../lib/own-transport.js";
|
|
15
|
+
import { formatLoadUnits } from "../../lib/load-carrier-labels.js";
|
|
16
|
+
import { formatDelivery, deliveryHasTimeFor, deliveryIsWallClockFor } from "../../lib/delivery-format.js";
|
|
17
|
+
export const orderTransportKey = (orderId) => ["order-transport", orderId];
|
|
18
|
+
export function useOrderTransport(orderId, enabled = true) {
|
|
19
|
+
const fetchT = useServerFn(getOrderTransport);
|
|
20
|
+
return useQuery({
|
|
21
|
+
queryKey: orderTransportKey(orderId ?? ""),
|
|
22
|
+
queryFn: () => fetchT({ data: { orderId: orderId } }),
|
|
23
|
+
enabled: !!orderId && enabled,
|
|
24
|
+
staleTime: 30000,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** "do 29 okt 15:00" uit { date, time }. */
|
|
28
|
+
export function ownPickupText(p) {
|
|
29
|
+
if (!p)
|
|
30
|
+
return null;
|
|
31
|
+
const d = dateWithWeekday(p.date);
|
|
32
|
+
return d ? `${d.replace(/ \d{4}$/, "")} ${p.time}` : null;
|
|
33
|
+
}
|
|
34
|
+
/** Ophaaltijd invullen/wijzigen bij eigen vervoer of klant haalt op. */
|
|
35
|
+
export function OwnPickupEditor({ orderId, kind, current, defaultDate, locked }) {
|
|
36
|
+
const qc = useQueryClient();
|
|
37
|
+
const save = useServerFn(setOrderOwnPickupTime);
|
|
38
|
+
const [date, setDate] = useState(current?.date ?? defaultDate ?? "");
|
|
39
|
+
const [time, setTime] = useState(current?.time ?? "");
|
|
40
|
+
const [busy, setBusy] = useState(false);
|
|
41
|
+
const [error, setError] = useState(null);
|
|
42
|
+
const label = ownPickupLabel(kind);
|
|
43
|
+
const onSave = async () => {
|
|
44
|
+
setBusy(true);
|
|
45
|
+
setError(null);
|
|
46
|
+
try {
|
|
47
|
+
const res = await save({ data: { orderId, date, time } });
|
|
48
|
+
if (!res.ok) {
|
|
49
|
+
setError(res.reason);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
await Promise.all([
|
|
53
|
+
qc.invalidateQueries({ queryKey: ["order-transport"] }),
|
|
54
|
+
qc.invalidateQueries({ queryKey: ["order-pickup-moment"] }),
|
|
55
|
+
qc.invalidateQueries({ queryKey: ["sales-orders"] }),
|
|
56
|
+
]);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
console.error("[vervoer] ophaaltijd opslaan", e);
|
|
60
|
+
setError("De ophaaltijd is niet opgeslagen. Probeer het opnieuw of neem contact op met de beheerder.");
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
setBusy(false);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return (_jsxs("div", { className: "space-y-1", title: locked ? OWN_PICKUP_LOCKED_TEXT : undefined, children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Input, { type: "date", "aria-label": `${label}: datum`, className: "h-9 w-40 [@media(pointer:coarse)]:h-11", value: date, disabled: locked || busy, onChange: (e) => setDate(e.target.value) }), _jsx(Input, { type: "time", "aria-label": label, className: "h-9 w-28 [@media(pointer:coarse)]:h-11", value: time, disabled: locked || busy, onChange: (e) => setTime(e.target.value) }), _jsx(Button, { size: "sm", variant: "outline", className: "[@media(pointer:coarse)]:h-11", disabled: locked || busy || !date || !time || (current?.date === date && current?.time === time), onClick: onSave, children: busy ? "Opslaan…" : "Opslaan" })] }), locked && _jsx("div", { className: "text-xs text-muted-foreground", children: OWN_PICKUP_LOCKED_TEXT }), error && _jsx("div", { className: "text-xs text-destructive", children: error })] }));
|
|
67
|
+
}
|
|
68
|
+
/** Blok "Vervoer" op de orderpagina; ontbrekende velden worden weggelaten. */
|
|
69
|
+
export function OrderTransportCard({ order, groupSize, extra }) {
|
|
70
|
+
const orderId = String(order.id);
|
|
71
|
+
const locked = !!order.isReservation;
|
|
72
|
+
const q = useOrderTransport(orderId, !locked);
|
|
73
|
+
const pm = usePickupMoment(orderId);
|
|
74
|
+
const [changing, setChanging] = useState(false);
|
|
75
|
+
const t = q.data;
|
|
76
|
+
const carrier = t?.carrier ?? null;
|
|
77
|
+
const hasCarrier = carrier?.state === "ok" && !!carrier.carrierName;
|
|
78
|
+
const manual = carrier?.source === "handmatig";
|
|
79
|
+
const missingOwnTime = !!t?.own && !t.ownPickup;
|
|
80
|
+
const signup = !t?.own ? formatMoment(pm.data?.departure?.signupDeadline ?? null) : null;
|
|
81
|
+
const karren = Number(order.karCount ?? 0);
|
|
82
|
+
return (_jsxs(InfoCard, { icon: _jsx(Truck, {}), title: "Vervoer", attention: missingOwnTime, action: !locked ? (_jsx(Button, { size: "sm", variant: "ghost", className: "[@media(pointer:coarse)]:h-11", onClick: () => setChanging((v) => !v), "aria-expanded": changing, children: changing ? "Klaar" : "Vervoerder wijzigen" })) : undefined, children: [(groupSize ?? 0) > 1 && (_jsxs("div", { className: "mb-2 rounded-lg border border-warning/40 bg-warning-soft px-3 py-2 text-xs font-medium text-warning-soft-foreground", children: ["Vervoerder en ophaalmoment gelden voor alle ", groupSize, " orders in deze groep."] })), missingOwnTime && (_jsxs("div", { role: "status", className: "mb-2 flex items-start gap-2 rounded-lg border border-warning/40 bg-warning-soft px-3 py-2 text-xs font-medium text-warning-soft-foreground", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-3.5 w-3.5 shrink-0", "aria-hidden": true }), " ", OWN_PICKUP_MISSING_TEXT] })), locked ? (_jsx(InfoRow, { label: "Vervoerder", children: _jsx(OrderCarrierPicker, { orderId: orderId, locked: true, compact: true }) })) : changing ? (_jsx(InfoRow, { label: "Vervoerder", children: _jsx(OrderCarrierPicker, { orderId: orderId, compact: true, groupSize: groupSize }) })) : q.isLoading ? (_jsx(InfoRow, { label: "Vervoerder", children: _jsx("span", { className: "text-sm text-muted-foreground", children: "Laden\u2026" }) })) : q.isError ? (_jsx(InfoRow, { label: "Vervoerder", children: _jsx("span", { className: "text-sm text-destructive", children: "Vervoer kon niet worden geladen. Ververs de pagina." }) })) : hasCarrier ? (_jsx(InfoRow, { label: "Vervoerder", children: _jsxs("span", { className: "inline-flex flex-wrap items-center gap-2", children: [_jsx("span", { children: carrier.carrierName }), _jsx(Badge, { variant: "outline", className: "text-xs", children: manual ? "Handmatig" : "Automatisch" })] }) })) : (_jsx(InfoRow, { label: "Vervoerder", children: _jsx("span", { className: "text-sm text-muted-foreground", children: "Nog geen vervoerder" }) })), !locked && t?.own ? (_jsx(InfoRow, { label: ownPickupLabel(t.ownKind), children: _jsx(OwnPickupEditor, { orderId: orderId, kind: t.ownKind, current: t.ownPickup, defaultDate: t.deliveryDate, locked: t.locked }, `${t.ownPickup?.date ?? ""}|${t.ownPickup?.time ?? ""}`) })) : !locked && t && !t.own ? (_jsx(InfoRow, { label: "Ophaalmoment", children: _jsx(OrderPickupMomentPicker, { orderId: orderId, pickupOnly: true, compact: true }) })) : null, signup && _jsx(InfoRow, { label: "Aanmelden v\u00F3\u00F3r", children: signup }), t?.carrierGln && _jsx(InfoRow, { label: "GLN vervoerder", children: t.carrierGln }), order.cartTypeName && _jsx(InfoRow, { label: "Ladingdrager", children: order.cartTypeName }), karren > 0 && _jsx(InfoRow, { label: "Karren", children: formatLoadUnits(karren, order.cartTypeName ?? null) }), extra] }));
|
|
83
|
+
}
|
|
84
|
+
/** Kopregel van een handmatige order: "Ophalen do 29 okt 15:00 · Levering vr 30 okt 08:00". */
|
|
85
|
+
export function PickupDeliveryLine({ order }) {
|
|
86
|
+
const orderId = String(order.id);
|
|
87
|
+
const t = useOrderTransport(orderId, !order.isReservation);
|
|
88
|
+
const pm = usePickupMoment(orderId);
|
|
89
|
+
const pickup = t.data?.own ? ownPickupText(t.data.ownPickup) : pm.data?.view?.short ?? null;
|
|
90
|
+
const d = order.deliveryAt ? formatDelivery(order.deliveryAt, deliveryHasTimeFor(order), { wallClock: deliveryIsWallClockFor(order) }) : null;
|
|
91
|
+
const levering = d ? [d.date, d.time].filter(Boolean).join(" ") : null;
|
|
92
|
+
const parts = [pickup ? `Ophalen ${pickup}` : null, levering ? `Levering ${levering}` : null].filter(Boolean);
|
|
93
|
+
if (!parts.length)
|
|
94
|
+
return null;
|
|
95
|
+
return _jsx("p", { className: "text-sm font-medium tabular-nums text-foreground", children: parts.join(" · ") });
|
|
96
|
+
}
|
|
@@ -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":"AAyHA,wBAAgB,oBAAoB,gCAoWnC"}
|
|
@@ -32,6 +32,7 @@ import { SourceIcon, sourceLabel } from "./v3/SourceIcon.js";
|
|
|
32
32
|
import { OrderStepper } from "./v3/OrderStepper.js";
|
|
33
33
|
import { NavigationTooltip } from "./v3/NavigationTooltip.js";
|
|
34
34
|
import { FactTile, InfoCard, InfoRow } from "./v3/InfoCard.js";
|
|
35
|
+
import { PickupDeliveryLine } from "./OrderTransportCard.js";
|
|
35
36
|
const eur = new Intl.NumberFormat("nl-NL", { style: "currency", currency: "EUR", minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
36
37
|
function fmtDT(iso) {
|
|
37
38
|
if (!iso)
|
|
@@ -244,7 +245,7 @@ export function SalesOrderDetailPage() {
|
|
|
244
245
|
const fTotal = floridayMembers.reduce((s, m) => s + m.floridayTotal, 0);
|
|
245
246
|
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
|
|
246
247
|
? head.customer.name
|
|
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 && (() => {
|
|
248
|
+
: `${sourceLabel(sources[0])}-order` }), isBuffer && fTotal > 0 && (_jsxs("p", { className: "text-xs font-medium tabular-nums text-foreground", children: ["Afgemeld: ", fDone, " van ", fTotal] })), !isBuffer && isLocal && _jsx(PickupDeliveryLine, { order: head }), !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 && (() => {
|
|
248
249
|
const f = friendlyLoadError(error);
|
|
249
250
|
return (_jsxs("div", { role: "alert", className: "flex items-start gap-3 rounded-xl border border-destructive/30 bg-destructive-soft p-4 text-sm", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0 text-destructive" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "font-medium text-foreground", children: f.text }), _jsxs("details", { className: "mt-1 text-xs text-muted-foreground", children: [_jsx("summary", { className: "cursor-pointer", children: "Technische details" }), f.tech] })] }), _jsx(Button, { size: "sm", variant: "outline", onClick: () => activeQuery.refetch(), children: "Opnieuw" })] }));
|
|
250
251
|
})(), !isLoading && !error && !primary && (_jsx("div", { className: "rounded-xl border border-border bg-card p-8 text-center text-sm text-muted-foreground shadow-sm", children: "Order niet gevonden." })), primary && isBuffer && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-4", children: [_jsx(FactTile, { icon: _jsx(Euro, {}), label: "Totale omzet", value: eur.format(totals.revenue), sub: `${bufferOrders.length} orders` }), _jsx(FactTile, { icon: _jsx(Boxes, {}), label: "Karren", value: engineBuffer ? engineBuffer.karren : totals.karren == null ? "Nog niet bekend" : formatLoadUnits(totals.karren, totals.cartType), sub: engineBuffer && engineBuffer.ladingdragers.length > 0 ? ladingdragerSummary(engineBuffer) : undefined }), _jsx(FactTile, { icon: _jsx(Layers, {}), label: "Fust", value: formatLoadUnits(totals.fusten, totals.crateType) }), _jsx(FactTile, { icon: _jsx(User, {}), label: "Klant", value: primary.customer.name, sub: primary.customer.legalName ?? undefined })] }), _jsxs("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]", children: [_jsxs("div", { className: "min-w-0 space-y-4", children: [_jsx(InfoCard, { icon: _jsx(Layers, {}), title: `Orders in deze groep (${bufferOrders.length})`, children: _jsx("div", { className: "space-y-3", children: bufferOrders.map((o) => (_jsx(BufferOrderRow, { order: o, member: membersFor([o])[0], sellerFallback: sellerFallback }, o.id))) }) }), _jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-semibold text-foreground", children: "Gecombineerde karindeling" }), _jsx(OrderKarindelingCard, { order: primary, pickProgress: bufferPickProgress(engineBuffer, membersFor(bufferOrders).map((m) => m.pickProgress ?? null)) })] })] }), _jsxs("div", { className: "min-w-0 space-y-4", children: [_jsxs(InfoCard, { icon: _jsx(Truck, {}), title: "Vervoer en ophalen", children: [_jsx(InfoRow, { label: "Vervoerder", children: _jsx(OrderCarrierPicker, { orderId: primary.id, applyToBuffer: true, compact: true, groupSize: bufferOrders.length, locked: bufferOrders.every((o) => !!o.isReservation) }) }), _jsxs(InfoRow, { label: "Ophaalmoment", children: [_jsx(OrderPickupMomentPicker, { orderId: primary.id, readOnly: true, compact: true }), _jsxs("div", { className: "mt-1 text-xs font-medium text-warning-soft-foreground", children: ["Geldt voor alle ", bufferOrders.length, " orders in deze groep"] })] }), _jsx(BufferAddresses, { orderId: primary.id })] }), fTotal > 0 && (_jsxs(InfoCard, { icon: _jsx(ReceiptText, {}), title: "Floriday", children: [_jsx(InfoRow, { label: "Floriday-orders", children: _jsx("span", { className: "flex flex-wrap gap-1.5", children: bufferOrders.filter((o) => !o.isLocal && o.orderNumber).map((o) => (_jsx(Badge, { variant: "outline", className: "text-xs", children: o.orderNumber }, o.id))) }) }), _jsxs(InfoRow, { label: "Afgemeld", children: [fDone, " van ", fTotal] })] }))] })] })] })), inGroup && !singleInGroup && rawLocalId && _jsx(EngineBufferCard, { orderId: rawLocalId }), primary && !isBuffer && (_jsx(SalesOrderDetailView, { order: primary, sellerFallback: sellerFallback, members: membersFor([primary]), features: features, groupSize: inGroup ? bufferOrders.length : undefined })), rawLocalId && _jsx(EditLocalOrderDialog, { orderId: rawLocalId, open: editOpen, onOpenChange: setEditOpen })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SalesOrderDetailView.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrderDetailView.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAmC,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAGvH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"SalesOrderDetailView.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrderDetailView.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAmC,KAAK,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAGvH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AA6JnE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,KAAK,EAAE,aAAa,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,+EAA+E;IAC/E,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,0FAA0F;IAC1F,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,+BAkBA"}
|
|
@@ -19,8 +19,7 @@ import { OrderShipmentsCard } from "./OrderShipmentsCard.js";
|
|
|
19
19
|
import { OrderInvoiceCard } from "./OrderInvoiceCard.js";
|
|
20
20
|
import { orderUuid } from "../../lib/order-price-lock.js";
|
|
21
21
|
import { OrderControlStatusCard } from "./OrderControlStatusCard.js";
|
|
22
|
-
import {
|
|
23
|
-
import { OrderPickupMomentPicker } from "./OrderPickupMomentPicker.js";
|
|
22
|
+
import { OrderTransportCard } from "./OrderTransportCard.js";
|
|
24
23
|
import { getFloridayStatusesForRows } from "../../lib/salesorders-list.functions.js";
|
|
25
24
|
function AddressCard({ icon, lines, extra, }) {
|
|
26
25
|
return (_jsxs("div", { className: "inline-flex max-w-xs items-start gap-3 rounded-md border border-border bg-card p-3", children: [_jsx("div", { className: "flex h-9 w-9 items-center justify-center rounded-md bg-primary/10 text-primary", children: icon }), _jsxs("div", { className: "text-sm", children: [lines.length > 0 ? lines.map((l, i) => _jsx("div", { children: l }, i)) : _jsx("div", { children: "\u2014" }), extra && _jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: extra })] })] }));
|
|
@@ -67,6 +66,7 @@ function pickStr(v) {
|
|
|
67
66
|
const TRADE_INSTRUMENT_LABELS = {
|
|
68
67
|
DIRECT_SALES: "Directe verkoop",
|
|
69
68
|
DIRECT_SALE: "Directe verkoop",
|
|
69
|
+
CLOCK_SALES: "Klokverkoop",
|
|
70
70
|
CLOCK_PRESALES: "Klokvoorverkoop",
|
|
71
71
|
CLOCK_PRESALE: "Klokvoorverkoop",
|
|
72
72
|
CONTRACT: "Contract",
|
|
@@ -313,7 +313,7 @@ function SalesOrderDetailViewInner({ floridayLoading, order, sellerFallback, hid
|
|
|
313
313
|
? (order.articleCount ?? 0) > 1 ? `Gemengd (${order.articleCount} artikelen)` : "Gemengd"
|
|
314
314
|
: `Belading ${belading}` })] })] }) }), _jsx("td", { className: "px-2 py-3 font-semibold tabular-nums", children: numberOfPieces > 0 ? numberOfPieces.toLocaleString("nl-NL") : "—" }), _jsx("td", { className: "px-2 py-3 tabular-nums", children: formatLoadUnits(order.fustCount, order.mixedPacking ? null : order.crateTypeName) }), _jsxs("td", { className: "px-2 py-3 tabular-nums", children: [oldProductPrice !== null && _jsx("span", { className: "mr-1 text-destructive line-through", children: eurFlex.format(oldProductPrice) }), eurFlex.format(productUnit)] }), _jsx("td", { className: "px-4 py-3 font-semibold tabular-nums sm:px-5", children: eurFlex.format(totalAmount) })] }) })] }) }), _jsxs("div", { className: "mt-3 space-y-1.5 text-sm", children: [_jsxs("div", { className: "flex justify-between gap-3", children: [_jsx("span", { className: "text-muted-foreground", children: "Transportkosten per stuk" }), _jsx("span", { className: "tabular-nums", children: eurFlex.format(transportPerPiece) })] }), _jsxs("div", { className: "flex justify-between gap-3", children: [_jsx("span", { className: "text-muted-foreground", children: "Inkoopprijs per stuk" }), _jsx("span", { className: "tabular-nums", children: hasPurchase ? eurFlex.format(purchaseUnit) : "—" })] }), hasCorrection && (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-muted-foreground", children: "Prijscorrectie" }), _jsxs("span", { className: "inline-flex items-center gap-1.5", children: [_jsx(CheckCircle2, { className: "h-4 w-4 text-primary" }), " Verwerkt"] })] })), _jsxs("div", { className: "flex items-baseline justify-between gap-3 border-t border-border pt-2 text-base font-semibold", children: [_jsx("span", { children: "Totaal" }), _jsxs("span", { className: "text-right tabular-nums", children: [totalBreakdown && _jsxs("span", { className: "mr-2 block text-xs font-normal text-muted-foreground sm:inline", children: ["(", totalBreakdown, ")"] }), eurFlex.format(totalAmount)] })] }), priceProblem && (_jsxs("div", { className: "rounded-lg border border-destructive/40 bg-destructive-soft px-3 py-2 text-xs text-destructive", children: ["Prijs ontbreekt: ", linesWithoutPrice || "een of meer", " regel(s) zonder prijs. Vul de prijs in voordat de order wordt bevestigd."] }))] })] }), _jsx(InfoCard, { icon: _jsx(MapPin, {}), title: "Aflever- en ophaalgegevens", children: _jsxs("div", { className: "grid grid-cols-1 gap-3 py-1 sm:grid-cols-2", children: [_jsx(AddressBox, { title: "Afleveradres", icon: _jsx(MapPin, {}), lines: deliveryLines }), _jsx(AddressBox, { title: "Ophaaladres", icon: _jsx(Truck, {}), lines: pickupLines })] }) }), _jsx(OrderShipmentsCard, { order: order }), _jsx(OrderLinePackingCard, { orderId: String(order.id) }), !hideKarindeling && _jsx(OrderKarindelingCard, { order: order, pickProgress: member?.pickProgress ?? null })] }), _jsxs("div", { className: "min-w-0 space-y-4", children: [_jsxs(InfoCard, { icon: _jsx(ClipboardList, {}), title: "Orderinformatie", children: [_jsx(InfoRow, { label: "Ordernummer", children: order.orderNumber || "—" }), _jsx(InfoRow, { label: "Status", children: _jsx("span", { className: `rounded-full px-2 py-0.5 text-xs font-medium ${orderStageBadgeClass(order.stage ?? "incoming")}`, children: bestellingLabel }) }), _jsx(InfoRow, { label: "Besteld op", children: fmtDateTime(order.orderedAt) }), _jsx(InfoRow, { label: "Klantreferentie", children: klantReferentie }), isFlorinOrder && _jsx(InfoRow, { label: "Verkoopkanaal", children: verkoopkanaal }), isFlorinOrder && _jsx(InfoRow, { label: "Verkoopwijze", children: verkoopwijze }), isFlorinOrder && _jsx(InfoRow, { label: "Floriday-referentie", children: floridayRef }), _jsx(InfoRow, { label: "Verkoper", children: sellerName ? (_jsxs("span", { className: "inline-flex items-center gap-2", children: [_jsx("span", { className: "inline-flex h-6 w-6 items-center justify-center rounded-full bg-muted text-[10px] font-semibold text-muted-foreground", children: initials(sellerName) }), sellerName] })) : "—" }), hasExternal && (_jsx(InfoRow, { label: "Afhandeling", children: order.floridayExternalFulfilledAt
|
|
315
315
|
? `Afgehandeld in Floriday · ${formatMoment(order.floridayExternalFulfilledAt)}`
|
|
316
|
-
: `${order.floridayExternalFulfilledIds.length} bestelling(en) afgehandeld in Floriday; de rest loopt door` }))] }),
|
|
316
|
+
: `${order.floridayExternalFulfilledIds.length} bestelling(en) afgehandeld in Floriday; de rest loopt door` }))] }), _jsx(OrderTransportCard, { order: order, groupSize: groupSize, extra: showIncoterm ? _jsx(InfoRow, { label: "Leveringsvoorwaarde", children: incoterm }) : undefined }), _jsx(InfoCard, { icon: _jsx(ReceiptText, {}), title: route === "floriday" ? "Factuur via Floriday" : "Factuur", attention: route === "erp" && priceProblem, children: route === "floriday" ? (_jsxs(_Fragment, { children: [_jsx(InfoRow, { label: "Stand", children: invoiceStandText(member, features) }), _jsx(InfoRow, { label: "Gefactureerd door", children: "Royal FloraHolland, via Floriday" }), member && (_jsxs(InfoRow, { label: "Afgemeld", children: [member.floridayDone, " van ", member.floridayTotal] })), member && member.stage === "shipped" && member.floridayDone < member.floridayTotal && (_jsx("div", { className: "mt-2 text-xs text-warning-soft-foreground", children: "De factuur volgt pas na afmelden bij Floriday." })), (() => {
|
|
317
317
|
const line = floridayInvoiceLine(order.floridayRawStatus, member?.floridayDone ?? 0, member?.floridayTotal ?? 0);
|
|
318
318
|
return line ? _jsx(InfoRow, { label: "Floriday", children: line }) : null;
|
|
319
319
|
})(), (order.floridayExternalFulfilledIds?.length ?? 0) > 0 && (_jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: "Al afgehandeld in Floriday" }))] })) : (_jsxs(_Fragment, { children: [_jsxs(InfoRow, { label: "Stand", children: [invoiceStandText(member, features), !member?.erpInvoice && order.invoiceState ? (_jsxs("span", { className: "block text-xs text-muted-foreground", children: [order.invoiceState, order.invoiceNote ? ` · ${order.invoiceNote}` : ""] })) : null] }), order.missingPrice && order.stage !== "cancelled" && !member?.erpInvoice && (_jsx("div", { className: "mt-2 rounded-md bg-warning-soft px-3 py-2 text-xs text-warning-soft-foreground", children: "Prijs ontbreekt: vul de prijs in voordat er gefactureerd kan worden." })), member?.erpInvoice && (_jsxs(_Fragment, { children: [_jsx(InfoRow, { label: "Factuurnummer", children: member.erpInvoice.number ?? "—" }), _jsx(InfoRow, { label: "Status", children: member.erpInvoice.status ?? "—" }), _jsx(InfoRow, { label: "Verstuurd", children: member.erpInvoice.sentAt ? fmtDateTime(member.erpInvoice.sentAt) : "—" })] })), invoiceOrderId && _jsx(OrderInvoiceCard, { orderId: invoiceOrderId })] })) }), o?.salesOrderId ? (_jsxs(_Fragment, { children: [_jsx(OrderControlStatusCard, { floridayId: String(o.salesOrderId), isControlled: order.status.isControlled, controlledAt: order.status.controlledAt }), _jsx(OrderAfleverbrievenCard, { salesOrderId: String(o.salesOrderId), orderNumber: order.orderNumber ?? undefined })] })) : null, _jsxs(InfoCard, { icon: _jsx(User, {}), title: "Klant", children: [_jsxs(InfoRow, { label: "Naam", children: [_jsx("span", { className: "font-medium", children: customerName }), customerLegalName && _jsx("div", { className: "text-xs text-muted-foreground", children: customerLegalName })] }), _jsx(InfoRow, { label: "Telefoon", children: customerPhone }), _jsxs("details", { className: "group pt-2 text-sm", children: [_jsx("summary", { className: "cursor-pointer text-xs font-medium text-muted-foreground hover:text-foreground", children: "Meer klantgegevens" }), _jsx(InfoRow, { label: "GLN", children: customerGln }), _jsx(InfoRow, { label: "Administratienummer", children: customerAdmin }), deliveryGln && _jsx(InfoRow, { label: "GLN afleveradres", children: deliveryGln })] })] })] })] })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SalesOrdersTable.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrdersTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAA8C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAWnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"SalesOrdersTable.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrdersTable.tsx"],"names":[],"mappings":"AACA,OAAO,EAA8C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAWnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,0BAA0B,CAAC;AAwBlC,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAG1D;AAqZD,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,OAAO,EACP,aAAa,EACb,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,QAA2B,EAC3B,SAAmC,EACnC,cAAc,EACd,YAAgB,EAChB,OAAO,EACP,KAAa,EACb,YAAY,EACZ,OAAO,EACP,SAAS,EACT,SAAS,EACT,SAAc,GACf,EAAE;IACD,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC7C,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC5C,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,+DAA+D;IAC/D,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,gDAAgD;IAChD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,+BAmJA"}
|
|
@@ -11,6 +11,7 @@ import { RowMenu } from "./v3/RowMenu.js";
|
|
|
11
11
|
import { CustomerName, useHasCustomerRoute } from "./v3/CustomerName.js";
|
|
12
12
|
import { HoverTip } from "./v3/HoverTip.js";
|
|
13
13
|
import { ArticlesHover } from "./v3/ArticlesHover.js";
|
|
14
|
+
import { articleNamesText } from "../../lib/order-search.js";
|
|
14
15
|
const amount = (n) => (n ?? 0).toLocaleString("nl-NL", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
15
16
|
function fmtOrdered(iso) {
|
|
16
17
|
if (!iso)
|
|
@@ -44,6 +45,12 @@ function Line({ text, className = "" }) {
|
|
|
44
45
|
const t = text || "";
|
|
45
46
|
return (_jsx("div", { className: "truncate " + className, title: t || undefined, children: t || "\u00a0" }));
|
|
46
47
|
}
|
|
48
|
+
/** Alle regelnamen (max. 2 regels, afgekapt) met een ballon "aantal × naam" per regel. */
|
|
49
|
+
function ArticleNames({ row }) {
|
|
50
|
+
const lines = row.articleLines ?? [];
|
|
51
|
+
const text = articleNamesText(lines);
|
|
52
|
+
return (_jsx(HoverTip, { label: `Artikelen: ${text}`, align: "start", className: "!flex w-full max-w-full !justify-start rounded-sm text-left", content: _jsxs("ul", { className: "max-w-72 space-y-1 text-sm", children: [lines.map((l, i) => (_jsxs("li", { className: "flex gap-2", children: [_jsxs("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: [l.quantity.toLocaleString("nl-NL"), " \u00D7"] }), _jsx("span", { className: "min-w-0 text-foreground", children: l.name })] }, i))), _jsxs("li", { className: "border-t border-border pt-1 text-xs text-muted-foreground", children: [row.fustCount, " fust"] })] }), children: _jsx("span", { className: "line-clamp-2 break-words text-sm leading-snug text-foreground", children: text }) }));
|
|
53
|
+
}
|
|
47
54
|
/** "+n"-chip van een buffer met de ordernummers in de tooltip. */
|
|
48
55
|
function BufferChip({ row }) {
|
|
49
56
|
const size = row.bufferSize ?? 1;
|
|
@@ -98,7 +105,7 @@ const DesktopRow = memo(function DesktopRow({ row, rowId, selected, leaving, hig
|
|
|
98
105
|
e.stopPropagation();
|
|
99
106
|
handlers.current.onSelectOrder?.(row);
|
|
100
107
|
}, className: "min-w-0 truncate rounded-sm font-medium tabular-nums focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring " +
|
|
101
|
-
(cancelled ? "line-through" : "text-foreground"), children: row.orderNumber || "—" }), _jsx("span", { className: "shrink-0", children: _jsx(BufferChip, { row: row }) })] }), row.customerReference ? (_jsx(Line, { text: `Ref. ${row.customerReference}`, className: "text-xs text-muted-foreground" })) : null] }), _jsx(TableCell, { className: "min-w-0 py-0", children: _jsxs("div", { className: "flex min-w-0 items-center gap-2.5", children: [_jsx("span", { "aria-hidden": true, className: "hidden h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 text-[11px] font-semibold text-primary lg:inline-flex", children: initials(row.customer.name) }), _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate font-medium", title: row.customer.name || undefined, children: _jsx(CustomerName, { name: row.customer.name, customerId: row.customerId, linkable: linkable }) }), _jsx(Line, { text: place, className: "text-xs text-muted-foreground" })] })] }) }), _jsxs(TableCell, { className: "py-0", children: [_jsx(Line, { text: ordered.date, className: "text-sm text-foreground" }), _jsx(Line, { text: ordered.time, className: "text-xs text-muted-foreground tabular-nums" })] }), _jsxs(TableCell, { className: "py-0 text-left", children: [_jsx(ArticlesHover, { ids: row.bufferOrderIds?.length ? row.bufferOrderIds : [row.id], count: row.articleCount ?? 1, children: _jsx("span", { className: "text-sm text-foreground", children: `${articlesLabel(row.articleCount ?? 1)} · ${row.fustCount} fust` }) }), _jsx("div", { className: "text-xs text-muted-foreground", children: _jsx(Money, { value: row.revenue ?? 0 }) })] }), _jsxs(TableCell, { className: "py-0", children: [_jsx(Line, { text: delivery.date, className: "text-sm text-foreground" }), d2.text ? (_jsxs("div", { className: "flex min-w-0 items-center gap-1 text-xs tabular-nums " + (d2.late ? "font-medium text-destructive" : "text-muted-foreground"), children: [d2.late ? _jsx(AlertCircle, { className: "h-3 w-3 shrink-0", "aria-hidden": true }) : _jsx(Clock, { className: "h-3 w-3 shrink-0", "aria-hidden": true }), _jsx("span", { className: "truncate", children: d2.text })] })) : (_jsx("div", { children: "\u00a0" }))] }), _jsx(TableCell, { className: "py-0", onClick: (e) => e.stopPropagation(), children: _jsx(OrderProgress, { members: members, features: features }) }), _jsx(TableCell, { className: "py-0", onClick: (e) => e.stopPropagation(), children: _jsxs("div", { className: "flex items-center justify-end gap-0.5", children: [_jsx("button", { type: "button", "aria-label": `Open ${row.orderNumber || "order"}`, title: "Openen", onClick: () => handlers.current.onSelectOrder?.(row), className: "inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover:opacity-100 " +
|
|
108
|
+
(cancelled ? "line-through" : "text-foreground"), children: row.orderNumber || "—" }), _jsx("span", { className: "shrink-0", children: _jsx(BufferChip, { row: row }) })] }), row.customerReference ? (_jsx(Line, { text: `Ref. ${row.customerReference}`, className: "text-xs text-muted-foreground" })) : null] }), _jsx(TableCell, { className: "min-w-0 py-0", children: _jsxs("div", { className: "flex min-w-0 items-center gap-2.5", children: [_jsx("span", { "aria-hidden": true, className: "hidden h-8 w-8 shrink-0 items-center justify-center rounded-full bg-primary/10 text-[11px] font-semibold text-primary lg:inline-flex", children: initials(row.customer.name) }), _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "truncate font-medium", title: row.customer.name || undefined, children: _jsx(CustomerName, { name: row.customer.name, customerId: row.customerId, linkable: linkable }) }), _jsx(Line, { text: place, className: "text-xs text-muted-foreground" })] })] }) }), _jsxs(TableCell, { className: "py-0", children: [_jsx(Line, { text: ordered.date, className: "text-sm text-foreground" }), _jsx(Line, { text: ordered.time, className: "text-xs text-muted-foreground tabular-nums" })] }), _jsxs(TableCell, { className: "py-0 text-left", children: [row.articleLines?.length ? (_jsx(ArticleNames, { row: row })) : (_jsx(ArticlesHover, { ids: row.bufferOrderIds?.length ? row.bufferOrderIds : [row.id], count: row.articleCount ?? 1, children: _jsx("span", { className: "text-sm text-foreground", children: `${articlesLabel(row.articleCount ?? 1)} · ${row.fustCount} fust` }) })), _jsx("div", { className: "text-xs text-muted-foreground", children: _jsx(Money, { value: row.revenue ?? 0 }) })] }), _jsxs(TableCell, { className: "py-0", children: [_jsx(Line, { text: delivery.date, className: "text-sm text-foreground" }), d2.text ? (_jsxs("div", { className: "flex min-w-0 items-center gap-1 text-xs tabular-nums " + (d2.late ? "font-medium text-destructive" : "text-muted-foreground"), children: [d2.late ? _jsx(AlertCircle, { className: "h-3 w-3 shrink-0", "aria-hidden": true }) : _jsx(Clock, { className: "h-3 w-3 shrink-0", "aria-hidden": true }), _jsx("span", { className: "truncate", children: d2.text })] })) : (_jsx("div", { children: "\u00a0" }))] }), _jsx(TableCell, { className: "py-0", onClick: (e) => e.stopPropagation(), children: _jsx(OrderProgress, { members: members, features: features }) }), _jsx(TableCell, { className: "py-0", onClick: (e) => e.stopPropagation(), children: _jsxs("div", { className: "flex items-center justify-end gap-0.5", children: [_jsx("button", { type: "button", "aria-label": `Open ${row.orderNumber || "order"}`, title: "Openen", onClick: () => handlers.current.onSelectOrder?.(row), className: "inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-opacity hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring group-hover:opacity-100 " +
|
|
102
109
|
(focused ? "opacity-100" : "opacity-0"), children: _jsx(Eye, { className: "h-4 w-4", "aria-hidden": true }) }), _jsx(RowMenu, { row: row, rowId: rowId, isBuffer: isBuffer, fulfillingId: fulfillingId, onEdit: h.onEditOrder ? (o) => handlers.current.onEditOrder?.(o) : undefined, onDetails: h.onSelectOrder ? (o) => handlers.current.onSelectOrder?.(o) : undefined, onFulfill: h.onFulfillOrder ? (o) => handlers.current.onFulfillOrder?.(o) : undefined, onDelete: h.onDeleteOrder ? (o) => handlers.current.onDeleteOrder?.(o) : undefined })] }) })] }));
|
|
103
110
|
});
|
|
104
111
|
const MobileCard = memo(function MobileCard({ row, rowId, selected, leaving, highlight, features, linkable, fulfillingId, handlers, }) {
|