@flowselections/floriday-verkoop-module 1.0.158 → 1.0.160

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
  2. package/dist-lib/components/verkoop/CreateOrderPage.js +5 -1
  3. package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
  4. package/dist-lib/components/verkoop/SalesOrderDetailPage.js +40 -2
  5. package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
  6. package/dist-lib/components/verkoop/VerkoopOrdersPage.js +11 -1
  7. package/dist-lib/components/verkoop/klok/KlokOrderPage.d.ts.map +1 -1
  8. package/dist-lib/components/verkoop/klok/KlokOrderPage.js +3 -1
  9. package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts.map +1 -1
  10. package/dist-lib/components/verkoop/klok/KlokOrdersList.js +2 -2
  11. package/dist-lib/components/verkoop/v3/RowMenu.js +1 -1
  12. package/dist-lib/integrations/supabase/types.d.ts +1329 -0
  13. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  14. package/dist-lib/lib/create-order-form.d.ts +6 -0
  15. package/dist-lib/lib/create-order-form.d.ts.map +1 -1
  16. package/dist-lib/lib/create-order-form.js +8 -0
  17. package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
  18. package/dist-lib/lib/create-order.functions.js +25 -4
  19. package/dist-lib/lib/cron/sync-salesorders.d.ts.map +1 -1
  20. package/dist-lib/lib/cron/sync-salesorders.js +12 -0
  21. package/dist-lib/lib/klok-labels.d.ts +13 -0
  22. package/dist-lib/lib/klok-labels.d.ts.map +1 -1
  23. package/dist-lib/lib/klok-labels.js +8 -0
  24. package/dist-lib/lib/klok-list.d.ts +2 -0
  25. package/dist-lib/lib/klok-list.d.ts.map +1 -1
  26. package/dist-lib/lib/klok-list.js +4 -0
  27. package/dist-lib/lib/order-cancel-view.d.ts +25 -0
  28. package/dist-lib/lib/order-cancel-view.d.ts.map +1 -1
  29. package/dist-lib/lib/order-cancel-view.js +13 -0
  30. package/dist-lib/lib/product-group-lines.server.d.ts +7 -0
  31. package/dist-lib/lib/product-group-lines.server.d.ts.map +1 -0
  32. package/dist-lib/lib/product-group-lines.server.js +26 -0
  33. package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
  34. package/dist-lib/lib/salesorders-list.server.js +4 -4
  35. package/dist-lib/lib/sync-melding.d.ts +8 -0
  36. package/dist-lib/lib/sync-melding.d.ts.map +1 -0
  37. package/dist-lib/lib/sync-melding.functions.d.ts +8 -0
  38. package/dist-lib/lib/sync-melding.functions.d.ts.map +1 -0
  39. package/dist-lib/lib/sync-melding.functions.js +18 -0
  40. package/dist-lib/lib/sync-melding.js +16 -0
  41. package/package.json +26 -1
  42. package/schema/verkoop.sql +529 -1
@@ -1 +1 @@
1
- {"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"AAuGA,wBAAgB,eAAe,gCA6zC9B"}
1
+ {"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"AAuGA,wBAAgB,eAAe,gCAi0C9B"}
@@ -11,7 +11,7 @@ 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
13
  import { isOwnTransportKind, ownPickupLabel, OWN_PICKUP_MISSING_TEXT } from "../../lib/own-transport.js";
14
- import { missingItems, lineTotal, dateWithWeekday, eur, attentionItems, selectionKey, resetOnSelectionChange, applyFirstFeasible, prijsSleutel, PRIJS_FOUT_TEXT, PRIJS_ONBEKEND_TEXT, bekendePrijs, regelMistPrijs, groepLeden } from "../../lib/create-order-form.js";
14
+ import { missingItems, lineTotal, dateWithWeekday, eur, attentionItems, selectionKey, resetOnSelectionChange, applyFirstFeasible, prijsSleutel, PRIJS_FOUT_TEXT, PRIJS_ONBEKEND_TEXT, bekendePrijs, regelMistPrijs, groepLeden, groepZonderLedenTekst } from "../../lib/create-order-form.js";
15
15
  import { useServerFn } from "@tanstack/react-start";
16
16
  import { SearchableSelect } from "./SearchableSelect.js";
17
17
  import { toISODate } from "../../lib/carrier-availability.js";
@@ -812,6 +812,10 @@ export function CreateOrderPage() {
812
812
  const gekozen = v ? products.find((x) => x.id === v) : null;
813
813
  if (gekozen?.source === "group") {
814
814
  // Productgroep: eerst een artikel uit de groep kiezen (een groep heeft geen eigen voorraad).
815
+ if (groepLeden(gekozen, products).length === 0) {
816
+ toast.error(groepZonderLedenTekst(gekozen.product));
817
+ return;
818
+ }
815
819
  setGroepKeuze({ idx, groep: gekozen });
816
820
  return;
817
821
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SalesOrderDetailPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrderDetailPage.tsx"],"names":[],"mappings":"AAyHA,wBAAgB,oBAAoB,gCAoWnC"}
1
+ {"version":3,"file":"SalesOrderDetailPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrderDetailPage.tsx"],"names":[],"mappings":"AA8HA,wBAAgB,oBAAoB,gCAsWnC"}
@@ -33,6 +33,11 @@ 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
35
  import { PickupDeliveryLine } from "./OrderTransportCard.js";
36
+ import { groepZonderGeannuleerd, kanLidAnnuleren } from "../../lib/order-cancel-view.js";
37
+ import { geannuleerdMelding } from "../../lib/order-terugdraaien.js";
38
+ import { cancelLocalOrder } from "../../lib/create-order.functions.js";
39
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, toast } from "@flowselections/core";
40
+ import { Loader2 } from "lucide-react";
36
41
  const eur = new Intl.NumberFormat("nl-NL", { style: "currency", currency: "EUR", minimumFractionDigits: 2, maximumFractionDigits: 2 });
37
42
  function fmtDT(iso) {
38
43
  if (!iso)
@@ -131,7 +136,7 @@ export function SalesOrderDetailPage() {
131
136
  const all = listQuery.data?.orders ?? [];
132
137
  return all.find((o) => o.id === salesOrderId)?.bufferId ?? null;
133
138
  }, [isFloriday, isLocal, detailQuery.data?.bufferId, localDetailQuery.data?.bufferId, primary, listQuery.data?.orders, salesOrderId]);
134
- const bufferOrders = useMemo(() => {
139
+ const bufferOrdersRaw = useMemo(() => {
135
140
  if (!bufferId)
136
141
  return primary ? [primary] : [];
137
142
  const head = primary;
@@ -159,6 +164,8 @@ export function SalesOrderDetailPage() {
159
164
  const localHead = primary ?? siblings.find((o) => o.id === salesOrderId) ?? siblings[0];
160
165
  return [localHead, ...rest];
161
166
  }, [primary, bufferId, isFloriday, isLocal, detailQuery.data?.bufferSiblings, localDetailQuery.data?.bufferSiblings, listQuery.data?.orders, salesOrderId]);
167
+ // Geannuleerde orders zijn nooit lid van een groep (de getoonde order zelf blijft staan).
168
+ const bufferOrders = useMemo(() => groepZonderGeannuleerd(bufferOrdersRaw, primary?.id ?? null), [bufferOrdersRaw, primary?.id]);
162
169
  const inGroup = bufferOrders.length > 1;
163
170
  // Losse order uit een groep (?weergave=order): toon alleen die order.
164
171
  const isBuffer = inGroup && !singleInGroup;
@@ -253,5 +260,36 @@ export function SalesOrderDetailPage() {
253
260
  function BufferOrderRow({ order, member, sellerFallback }) {
254
261
  const [open, setOpen] = useState(false);
255
262
  const bufferInvoiceId = orderUuid(order.orderRowId ?? order.id);
256
- return (_jsxs("div", { className: "overflow-hidden rounded-lg border border-border", children: [_jsxs("div", { className: "flex items-center gap-3 p-3", children: [_jsx("button", { type: "button", onClick: () => setOpen((v) => !v), "aria-expanded": open, "aria-label": open ? "Details verbergen" : "Details tonen", className: "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted", children: open ? _jsx(ChevronDown, { className: "h-4 w-4" }) : _jsx(ChevronRight, { className: "h-4 w-4" }) }), _jsx("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: order.imageUrl ? _jsx("img", { src: order.imageUrl, alt: "", className: "h-full w-full object-cover" }) : _jsx(ImageIcon, { className: "h-5 w-5 text-muted-foreground" }) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "font-semibold tabular-nums text-foreground", children: order.orderNumber || "—" }), _jsx("span", { className: "text-xs text-muted-foreground", children: sourceLabel(order.source ?? (order.isLocal ? "manual" : "floriday")) })] }), _jsx("div", { className: "truncate text-sm text-foreground", children: order.productName }), _jsxs("div", { className: "flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-muted-foreground", children: [_jsxs("span", { children: [formatLoadUnits(order.karCount, order.cartTypeName), " karren", order.karShared ? " (gedeeld)" : ""] }), _jsxs("span", { children: [formatLoadUnits(order.fustCount, order.mixedPacking ? null : order.crateTypeName), " fust"] }), order.mixedPacking && (order.articleCount ?? 0) > 1 && _jsxs("span", { children: ["Gemengd (", order.articleCount, " artikelen)"] }), _jsx("span", { className: "tabular-nums", children: eur.format(order.revenue ?? 0) })] })] }), _jsx(Button, { asChild: true, variant: "outline", size: "sm", className: "shrink-0", children: _jsx(Link, { to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: order.id }, search: { weergave: "order" }, children: "Open order" }) })] }), _jsx("div", { className: "border-t border-border px-3 py-2 text-sm", children: member.invoiceRoute === "floriday" ? (_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx("span", { className: "text-muted-foreground", children: "Factuur via Floriday (Royal FloraHolland)" }), _jsxs("span", { className: "tabular-nums", children: ["Afgemeld: ", member.floridayDone, " van ", member.floridayTotal] })] })) : (bufferInvoiceId && !open && _jsx(OrderInvoiceCard, { orderId: bufferInvoiceId })) }), open && (_jsx("div", { className: "border-t border-border bg-background p-4", children: _jsx(SalesOrderDetailView, { order: order, sellerFallback: sellerFallback ?? null, hideKarindeling: true }) }))] }));
263
+ return (_jsxs("div", { className: "overflow-hidden rounded-lg border border-border", children: [_jsxs("div", { className: "flex items-center gap-3 p-3", children: [_jsx("button", { type: "button", onClick: () => setOpen((v) => !v), "aria-expanded": open, "aria-label": open ? "Details verbergen" : "Details tonen", className: "inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-muted", children: open ? _jsx(ChevronDown, { className: "h-4 w-4" }) : _jsx(ChevronRight, { className: "h-4 w-4" }) }), _jsx("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted", children: order.imageUrl ? _jsx("img", { src: order.imageUrl, alt: "", className: "h-full w-full object-cover" }) : _jsx(ImageIcon, { className: "h-5 w-5 text-muted-foreground" }) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "font-semibold tabular-nums text-foreground", children: order.orderNumber || "—" }), _jsx("span", { className: "text-xs text-muted-foreground", children: sourceLabel(order.source ?? (order.isLocal ? "manual" : "floriday")) })] }), _jsx("div", { className: "truncate text-sm text-foreground", children: order.productName }), _jsxs("div", { className: "flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-muted-foreground", children: [_jsxs("span", { children: [formatLoadUnits(order.karCount, order.cartTypeName), " karren", order.karShared ? " (gedeeld)" : ""] }), _jsxs("span", { children: [formatLoadUnits(order.fustCount, order.mixedPacking ? null : order.crateTypeName), " fust"] }), order.mixedPacking && (order.articleCount ?? 0) > 1 && _jsxs("span", { children: ["Gemengd (", order.articleCount, " artikelen)"] }), _jsx("span", { className: "tabular-nums", children: eur.format(order.revenue ?? 0) })] })] }), kanLidAnnuleren(order) && _jsx(AnnuleerLidKnop, { order: order }), _jsx(Button, { asChild: true, variant: "outline", size: "sm", className: "shrink-0", children: _jsx(Link, { to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: order.id }, search: { weergave: "order" }, children: "Open order" }) })] }), _jsx("div", { className: "border-t border-border px-3 py-2 text-sm", children: member.invoiceRoute === "floriday" ? (_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx("span", { className: "text-muted-foreground", children: "Factuur via Floriday (Royal FloraHolland)" }), _jsxs("span", { className: "tabular-nums", children: ["Afgemeld: ", member.floridayDone, " van ", member.floridayTotal] })] })) : (bufferInvoiceId && !open && _jsx(OrderInvoiceCard, { orderId: bufferInvoiceId })) }), open && (_jsx("div", { className: "border-t border-border bg-background p-4", children: _jsx(SalesOrderDetailView, { order: order, sellerFallback: sellerFallback ?? null, hideKarindeling: true }) }))] }));
264
+ }
265
+ /** Eén order uit een gecombineerde order annuleren (voorraad terug via voorraad_order_terugdraaien op de server). */
266
+ function AnnuleerLidKnop({ order }) {
267
+ const [open, setOpen] = useState(false);
268
+ const [bezig, setBezig] = useState(false);
269
+ const bezigRef = useRef(false);
270
+ const qc = useQueryClient();
271
+ const cancel = useServerFn(cancelLocalOrder);
272
+ const orderId = orderUuid(order.orderRowId ?? order.id);
273
+ const bevestig = async () => {
274
+ if (bezigRef.current || !orderId)
275
+ return;
276
+ bezigRef.current = true;
277
+ setBezig(true);
278
+ try {
279
+ await cancel({ data: { orderId } });
280
+ toast.success(geannuleerdMelding(order.orderNumber));
281
+ setOpen(false);
282
+ await qc.invalidateQueries();
283
+ }
284
+ catch (e) {
285
+ console.error("[AnnuleerLidKnop]", e);
286
+ toast.error(String(e?.message ?? "") || "De order kon niet worden geannuleerd. Probeer het opnieuw of neem contact op met de beheerder.");
287
+ }
288
+ finally {
289
+ bezigRef.current = false;
290
+ setBezig(false);
291
+ }
292
+ };
293
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", className: "shrink-0 text-destructive", onClick: () => setOpen(true), children: "Annuleren" }), _jsx(Dialog, { open: open, onOpenChange: (o) => { if (!bezig)
294
+ setOpen(o); }, children: _jsxs(DialogContent, { className: "sm:max-w-md", children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { children: [order.orderNumber || "Order", " annuleren?"] }), _jsx(DialogDescription, { children: "Alleen deze order wordt geannuleerd; de voorraad komt weer vrij. De andere orders in de groep blijven staan." })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", disabled: bezig, onClick: () => setOpen(false), children: "Terug" }), _jsxs(Button, { variant: "destructive", disabled: bezig, onClick: bevestig, children: [bezig && _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }), "Order annuleren"] })] })] }) })] }));
257
295
  }
@@ -1 +1 @@
1
- {"version":3,"file":"VerkoopOrdersPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/VerkoopOrdersPage.tsx"],"names":[],"mappings":"AAmRA,wBAAgB,iBAAiB,gCA0iChC"}
1
+ {"version":3,"file":"VerkoopOrdersPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/VerkoopOrdersPage.tsx"],"names":[],"mappings":"AAqRA,wBAAgB,iBAAiB,gCAyjChC"}
@@ -13,6 +13,8 @@ import { saveListNav, saveListScroll, takeRestoreScroll } from "../../lib/order-
13
13
  import { useQuery, useQueryClient } from "@tanstack/react-query";
14
14
  import { supabase } from "../../integrations/supabase/client.js";
15
15
  import { getFloridaySyncHealth } from "../../lib/salesorders.functions.js";
16
+ import { getVerkoopSyncMelding } from "../../lib/sync-melding.functions.js";
17
+ import { syncMeldingTekst } from "../../lib/sync-melding.js";
16
18
  import { amsterdamYmd, periodFromSearch, periodRange, periodToSearch, shiftPeriod, ymdString } from "../../lib/period-range.js";
17
19
  import { isSessionError } from "../../lib/session-error.js";
18
20
  import { animateIn, transitionStyle } from "../../lib/motion.js";
@@ -216,6 +218,14 @@ export function VerkoopOrdersPage() {
216
218
  refetchInterval: 120000,
217
219
  retry: 1,
218
220
  });
221
+ const fetchSyncMelding = useServerFn(getVerkoopSyncMelding);
222
+ const { data: syncMelding } = useQuery({
223
+ queryKey: ["verkoop-sync-melding"],
224
+ queryFn: () => fetchSyncMelding(),
225
+ refetchInterval: 120000,
226
+ retry: 1,
227
+ });
228
+ const syncMeldingZin = syncMeldingTekst(syncMelding);
219
229
  const triggerDeleteOrder = useServerFn(deleteLocalOrder);
220
230
  const triggerCancelOrder = useServerFn(cancelLocalOrder);
221
231
  const triggerMarkShipped = useServerFn(markOrdersShipped);
@@ -630,7 +640,7 @@ export function VerkoopOrdersPage() {
630
640
  ? fmtNLDefault(syncHealth.lastSuccessAt)
631
641
  : "nog nooit", syncHealth.lastError ? ` — ${syncHealth.lastError}` : "", syncHealth.failingComponents && syncHealth.failingComponents.length > 0
632
642
  ? ` — onderdelen die stilliggen: ${syncHealth.failingComponents.join(", ")}`
633
- : ""] })] }), _jsx(ChevronDown, { className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform md:hidden " + (syncOpen ? "rotate-180" : ""), "aria-hidden": true }), _jsx("span", { className: (syncOpen ? "block " : "hidden ") + "w-full text-xs text-muted-foreground md:inline md:w-auto", children: "Handmatig ophalen kan via Instellingen \u203A Floriday." })] })), _jsxs("section", { "aria-label": "Kerncijfers", className: KPI_GRID_CLASS, children: [_jsx(KpiTile, { title: "Omzet", loading: isLoading, icon: _jsx(Euro, { className: "h-5 w-5" }), value: _jsx(Crossfade, { value: eur0(totals.revenue) }), sub: `excl. btw · gem. ${eur0(totals.orderCount ? totals.revenue / totals.orderCount : 0)} per order`, trend: tab === "all" && !kpi ? trendOf(totals.revenue, prevData?.totals?.revenue) : null }), _jsx(KpiTile, { title: "Orders", loading: isLoading, icon: _jsx(ShoppingCart, { className: "h-5 w-5" }), value: _jsx(Crossfade, { value: Math.max(0, kpiCounts.all - kpiCounts.cancelled).toLocaleString("nl-NL") }), sub: `${kpiCounts.incoming} inkomend · ${kpiCounts.topick} te picken`, trend: trendOf(Math.max(0, kpiCounts.all - kpiCounts.cancelled), prevData?.statusCounts ? Math.max(0, (prevData.statusCounts.all ?? 0) - (prevData.statusCounts.cancelled ?? 0)) : undefined), onClick: () => setTab("all") }), _jsx(KpiTile, { title: "Fust", loading: isLoading, icon: _jsx(Layers, { className: "h-5 w-5" }), value: _jsx(Crossfade, { value: totals.fustCount.toLocaleString("nl-NL") }), sub: tab === "all" ? "in deze periode" : "in dit tabblad", trend: tab === "all" && !kpi ? trendOf(totals.fustCount, prevData?.totals?.fustCount) : null }), _jsx(KpiTile, { title: "Actie nodig", loading: isLoading, icon: _jsx(AlertTriangle, { className: "h-5 w-5" }), tone: "warning", active: tab === "backlog" || tab === "problem", onClick: () => toggleTab(kpiCounts.backlog > 0 || !features.pickProgress ? "backlog" : "problem"), value: _jsx(Crossfade, { value: (kpiCounts.backlog + kpiCounts.problem).toLocaleString("nl-NL") }), sub: _jsxs("span", { className: "flex flex-wrap items-center gap-x-1", children: [_jsxs("button", { type: "button", "aria-pressed": tab === "backlog", onClick: (e) => {
643
+ : ""] })] }), _jsx(ChevronDown, { className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform md:hidden " + (syncOpen ? "rotate-180" : ""), "aria-hidden": true }), _jsx("span", { className: (syncOpen ? "block " : "hidden ") + "w-full text-xs text-muted-foreground md:inline md:w-auto", children: "Handmatig ophalen kan via Instellingen \u203A Floriday." })] })), syncMeldingZin && !syncHealth?.stale && (_jsxs("div", { role: "alert", className: "shrink-0 flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive", "aria-hidden": true }), _jsx("span", { className: "min-w-0 flex-1 font-semibold", children: syncMeldingZin })] })), _jsxs("section", { "aria-label": "Kerncijfers", className: KPI_GRID_CLASS, children: [_jsx(KpiTile, { title: "Omzet", loading: isLoading, icon: _jsx(Euro, { className: "h-5 w-5" }), value: _jsx(Crossfade, { value: eur0(totals.revenue) }), sub: `excl. btw · gem. ${eur0(totals.orderCount ? totals.revenue / totals.orderCount : 0)} per order`, trend: tab === "all" && !kpi ? trendOf(totals.revenue, prevData?.totals?.revenue) : null }), _jsx(KpiTile, { title: "Orders", loading: isLoading, icon: _jsx(ShoppingCart, { className: "h-5 w-5" }), value: _jsx(Crossfade, { value: Math.max(0, kpiCounts.all - kpiCounts.cancelled).toLocaleString("nl-NL") }), sub: `${kpiCounts.incoming} inkomend · ${kpiCounts.topick} te picken`, trend: trendOf(Math.max(0, kpiCounts.all - kpiCounts.cancelled), prevData?.statusCounts ? Math.max(0, (prevData.statusCounts.all ?? 0) - (prevData.statusCounts.cancelled ?? 0)) : undefined), onClick: () => setTab("all") }), _jsx(KpiTile, { title: "Fust", loading: isLoading, icon: _jsx(Layers, { className: "h-5 w-5" }), value: _jsx(Crossfade, { value: totals.fustCount.toLocaleString("nl-NL") }), sub: tab === "all" ? "in deze periode" : "in dit tabblad", trend: tab === "all" && !kpi ? trendOf(totals.fustCount, prevData?.totals?.fustCount) : null }), _jsx(KpiTile, { title: "Actie nodig", loading: isLoading, icon: _jsx(AlertTriangle, { className: "h-5 w-5" }), tone: "warning", active: tab === "backlog" || tab === "problem", onClick: () => toggleTab(kpiCounts.backlog > 0 || !features.pickProgress ? "backlog" : "problem"), value: _jsx(Crossfade, { value: (kpiCounts.backlog + kpiCounts.problem).toLocaleString("nl-NL") }), sub: _jsxs("span", { className: "flex flex-wrap items-center gap-x-1", children: [_jsxs("button", { type: "button", "aria-pressed": tab === "backlog", onClick: (e) => {
634
644
  e.stopPropagation();
635
645
  toggleTab("backlog");
636
646
  }, className: "rounded-sm font-medium text-destructive underline-offset-2 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [kpiCounts.backlog, " te laat"] }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsx("button", { type: "button", "aria-pressed": tab === "problem", onClick: (e) => {
@@ -1 +1 @@
1
- {"version":3,"file":"KlokOrderPage.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokOrderPage.tsx"],"names":[],"mappings":"AA6EA,wBAAgB,aAAa,gCAwuB5B"}
1
+ {"version":3,"file":"KlokOrderPage.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokOrderPage.tsx"],"names":[],"mappings":"AA8EA,wBAAgB,aAAa,gCA0uB5B"}
@@ -8,7 +8,7 @@ import { ArrowLeft, ChevronDown, Eye, Loader2, Package, Plus, Repeat, RotateCcw,
8
8
  import { listProductsForCreateOrder } from "../../../lib/create-order.functions.js";
9
9
  import { deleteKlokOrder, getKlokArtikelen, getKlokLijsten, getKlokOrder, listKlokSjablonen, repeatKlokOrder, resendKlokOrder, saveKlokConcept, saveKlokSjabloon, sendKlokOrder, refreshKlokStatus, retryKlokAnnuleren, } from "../../../lib/klok.functions.js";
10
10
  import { klokFoutLijst, klokOntbreekt, klokOntbreektVelden, LEGE_KOP, neemPrijsOver, regelMetArtikel, regelNaArtikelwissel } from "../../../lib/klok-form.js";
11
- import { KLOK_LIJST_LEEG_TEXT, KEURCODE_GROEPEN, keurcodeLabel, klokAlleenLezen, klokAnnulerenOpenstaand, klokKanVerwijderen, klokTellers, tellersTekst, volgendeVeildag, klokLijstWeergave, klokLocatieKnoppen, prijsTekst, } from "../../../lib/klok-labels.js";
11
+ import { KLOK_LIJST_LEEG_TEXT, KEURCODE_GROEPEN, keurcodeLabel, klokAlleenLezen, klokAnnulerenOpenstaand, klokKanVerwijderen, klokTellers, tellersTekst, volgendeVeildag, klokLijstWeergave, klokLocatieKnoppen, prijsTekst, klokRegelKwaliteitFout, } from "../../../lib/klok-labels.js";
12
12
  import { fmtNL } from "../../../lib/nl-datetime.js";
13
13
  import { amsterdamYmd, ymdString } from "../../../lib/period-range.js";
14
14
  import { SearchableSelect } from "../SearchableSelect.js";
@@ -398,6 +398,8 @@ export function KlokOrderPage() {
398
398
  const doorStuks = resultaten.filter((r) => r.doorgedraaid).reduce((s, r) => s + Number(r.stuks || 0), 0);
399
399
  return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 pb-40 sm:p-6 sm:pb-32", children: [_jsxs("header", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx(Button, { variant: "ghost", size: "sm", className: "h-9 w-9 p-0", "aria-label": "Terug", onClick: () => navigate({ to: "/floriday-verkoop/klok" }), children: _jsx(ArrowLeft, { className: "h-4 w-4" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "truncate text-xl font-bold tracking-tight sm:text-2xl", children: row ? `Veilbrief ${row.klok_nummer}` : "Klokorder (veilbrief)" }), row && (_jsxs("div", { className: "flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground", children: [_jsx(KlokStatusBadge, { status: status, detail: row.status_detail }), row.status_detail && _jsx("span", { children: row.status_detail }), orderQ.data?.orderNumber && _jsxs("span", { children: ["Order ", orderQ.data.orderNumber] })] }))] })] }), row && (_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: onHerhalen, children: [_jsx(Repeat, { className: "mr-2 h-4 w-4" }), " Herhalen"] }), klokKanVerwijderen(status) && !bewerken && (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setBevestigVerwijder(true), disabled: !!bezig || !!blokkade, title: blokkade ?? undefined, children: [_jsx(Trash2, { className: "mr-2 h-4 w-4" }), " Verwijderen"] })), annulerenOpen && (_jsxs(Button, { size: "sm", variant: "outline", onClick: onOpnieuwAnnuleren, disabled: !!bezig, "aria-busy": bezig === "retry" || undefined, children: [bezig === "retry" ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin", "aria-hidden": true }) : _jsx(RotateCcw, { className: "mr-2 h-4 w-4" }), " Order annuleren opnieuw proberen"] })), klokKanVerwijderen(status) && !bewerken && (_jsx(Button, { size: "sm", onClick: () => setBewerken(true), disabled: !!blokkade, title: blokkade ?? undefined, children: "Wijzigen en opnieuw versturen" }))] }))] }), _jsx(KlokNotice, {}), fout && (_jsxs("div", { role: "alert", className: "flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive-soft px-3 py-2 text-sm text-destructive-soft-foreground", children: [fouten.length > 1 || (fouten.length === 1 && fouten[0].tekst !== fout) ? (_jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("p", { className: "font-medium", children: fouten.length === 1 ? "Er is 1 punt om op te lossen:" : `Er zijn ${fouten.length} punten om op te lossen:` }), _jsx("ul", { className: "mt-1 list-disc space-y-0.5 pl-5", children: fouten.map((f, i) => _jsx("li", { children: f.tekst }, i)) })] })) : (_jsx("span", { className: "min-w-0 flex-1", children: fout })), _jsx("button", { type: "button", "aria-label": "Sluiten", onClick: () => setFout(null), children: _jsx(X, { className: "h-4 w-4" }) })] })), row?.laatste_fout && !fout && (_jsx("div", { className: "rounded-lg border border-border bg-warning-soft px-3 py-2 text-sm text-warning-soft-foreground", children: row.laatste_fout })), _jsx("section", { className: "rounded-xl border border-border bg-card p-4 shadow-sm sm:p-5", children: _jsxs("div", { className: "grid gap-4 [@container(min-width:48rem)]:grid-cols-2 md:grid-cols-2", children: [_jsxs("div", { className: "md:col-span-2 rounded-lg" + (foutVelden.has("veillocatie") ? " p-1 ring-1 ring-destructive" : ""), children: [_jsxs("div", { className: "mb-1.5 text-sm font-medium", children: ["Veillocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), laden ? (_jsxs("div", { className: "flex gap-2", children: [_jsx(Skeleton, { className: "h-9 w-28" }), _jsx(Skeleton, { className: "h-9 w-28" }), _jsx(Skeleton, { className: "h-9 w-28" })] })) : locaties.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: leegTekst ?? lijsten?.locaties?.message ?? lijsten?.locaties?.error ?? (kop.veillocatie_naam || "Geen veillocaties gevonden.") })) : (_jsxs("div", { className: "flex flex-wrap gap-2", children: [toonKnoppen.map((l) => (_jsx(Button, { type: "button", variant: kop.veillocatie_id === l.id ? "default" : "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: alleenLezen, onClick: () => setKop((k) => ({ ...k, ...locFields(l), veilgroep: k.veillocatie_id === l.id ? k.veilgroep : null })), children: l.displayName ?? l.name }, l.id))), toonMeer.length > 0 && !alleenLezen && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "ghost", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", children: ["Meer ", _jsx(ChevronDown, { className: "ml-1 h-4 w-4" })] }) }), _jsx(DropdownMenuContent, { children: toonMeer.map((l) => (_jsx(DropdownMenuItem, { onClick: () => setKop((k) => ({ ...k, ...locFields(l), veilgroep: null })), children: l.displayName ?? l.name }, l.id))) })] }))] }))] }), _jsxs("label", { className: "block", children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Veildatum ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { type: "date", value: kop.veildatum ?? "", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11" + rood("veildatum"), onChange: (e) => setKop((k) => ({ ...k, veildatum: e.target.value || null })) }), kop.veildatum && _jsx("span", { className: "mt-1 block text-xs text-muted-foreground", children: fmtNL(kop.veildatum, { weekday: "long", day: "numeric", month: "long" }) })] }), _jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Veilgroep ", _jsx("span", { className: "text-destructive", children: "*" })] }), laden ? (_jsx(Skeleton, { className: "h-9 w-full" })) : eigenGroep || groepOpties.length === 0 ? (_jsxs("div", { className: "flex gap-2", children: [_jsx(Input, { inputMode: "numeric", placeholder: groepOpties.length === 0 && leegTekst ? leegTekst : "Veilgroep (cijfers)", value: kop.veilgroep ?? "", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11" + rood("veilgroep"), onChange: (e) => setKop((k) => ({ ...k, veilgroep: e.target.value.replace(/\D/g, "") || null })) }), groepOpties.length > 0 && !alleenLezen && _jsx(Button, { variant: "ghost", size: "sm", className: "h-9", onClick: () => setEigenGroep(false), children: "Kies uit lijst" })] })) : (_jsxs("div", { className: "flex gap-2", children: [_jsx(SearchableSelect, { value: kop.veilgroep, options: groepOpties, placeholder: "Zoek veilgroep", allowClear: true, clearLabel: "\u2014 Geen \u2014", disabled: alleenLezen, className: "min-h-9 flex-1 [@media(pointer:coarse)]:min-h-11" + rood("veilgroep"), onChange: (v) => setKop((k) => ({ ...k, veilgroep: v })) }), !alleenLezen && _jsx(Button, { variant: "ghost", size: "sm", className: "h-9", onClick: () => setEigenGroep(true), children: "Zelf invullen" })] }))] }), laden && (_jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Verzendlocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Skeleton, { className: "h-9 w-full" })] })), !laden && verzend.length > 1 && (_jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Verzendlocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(SearchableSelect, { value: kop.verzendlocatie_id, disabled: alleenLezen, allowClear: false, options: verzend.map((v) => ({ value: v.id, label: v.name, badge: v.isDefault ? "Standaard" : v.isExternal ? "Extern" : null })), className: "min-h-9 w-full [@media(pointer:coarse)]:min-h-11" + rood("verzendlocatie"), onChange: (v) => setKop((k) => ({ ...k, verzendlocatie_id: v, verzendlocatie_naam: verzend.find((x) => x.id === v)?.name ?? null })) })] })), !laden && verzend.length === 0 && !kop.verzendlocatie_id && leegTekst && (_jsxs("div", { children: [_jsx("span", { className: "mb-1.5 block text-sm font-medium", children: "Verzendlocatie" }), _jsx("p", { className: "text-sm text-muted-foreground", children: leegTekst })] })), _jsxs("div", { children: [_jsx("span", { className: "mb-1.5 block text-sm font-medium", children: "Vervoer" }), _jsx("div", { className: "flex gap-2", children: VERVOER.map((v) => (_jsx(Button, { type: "button", size: "sm", variant: kop.vervoer === v.id ? "default" : "outline", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setKop((k) => ({ ...k, vervoer: v.id })), children: v.label }, v.id))) })] })] }) }), _jsxs("section", { className: "rounded-xl border border-border bg-card shadow-sm", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3 sm:px-5", children: [_jsx("h2", { className: "text-sm font-semibold", children: "Regels" }), !alleenLezen && (_jsxs("div", { className: "flex flex-wrap gap-2", children: [sjablonen.length > 0 && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", children: ["Kies sjabloon ", _jsx(ChevronDown, { className: "ml-1 h-4 w-4" })] }) }), _jsx(DropdownMenuContent, { children: sjablonen.map((s) => _jsx(DropdownMenuItem, { onClick: () => kiesSjabloon(s), children: s.naam }, s.id)) })] })), _jsx(Button, { variant: "outline", size: "sm", disabled: !kop.veillocatie_id, onClick: () => setSjabloonNaam(""), children: "Opslaan als sjabloon" })] }))] }), _jsx("ul", { className: "divide-y divide-border", children: regels.map((r, i) => {
400
400
  const km = kenmerken[r.key];
401
+ const kwFout = alleenLezen ? null : klokRegelKwaliteitFout(r, km);
402
+ const kwRood = regelRood(r.key, "kwaliteit") || !!kwFout;
401
403
  return (_jsxs("li", { className: "space-y-3 px-4 py-4 sm:px-5", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-2 w-6 shrink-0 text-xs text-muted-foreground tabular-nums", children: i + 1 }), _jsx("div", { className: "min-w-0 flex-1", children: alleenLezen ? (_jsx("div", { className: "py-1.5 text-sm font-medium", children: r.product_name || "Onbekend artikel" })) : (_jsx(SearchableSelect, { value: r.product_id, options: productOpties(false), showImages: true, placeholder: "Kies artikel", allowClear: false, className: "min-h-9 w-full [@media(pointer:coarse)]:min-h-11" + (regelRood(r.key, "artikel") || regelRood(r.key, "fust") ? " border-destructive ring-1 ring-destructive" : ""), onChange: (v) => kiesProduct(r.key, v) })) }), !alleenLezen && (_jsx(Button, { variant: "ghost", size: "sm", className: "h-9 w-9 shrink-0 p-0 [@media(pointer:coarse)]:h-11 [@media(pointer:coarse)]:w-11", "aria-label": "Regel verwijderen", onClick: () => setRegels((rs) => (rs.length > 1 ? rs.filter((x) => x.key !== r.key) : [legeRegel()])), children: _jsx(Trash2, { className: "h-4 w-4" }) }))] }), _jsxs("div", { className: "grid grid-cols-2 gap-3 pl-8 sm:grid-cols-3 lg:grid-cols-6", children: [_jsx(NumField, { label: "Fusten", req: true, fout: regelRood(r.key, "fusten"), value: r.fusten, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { fusten: v }) }), _jsx(NumField, { label: "Stuks/fust", req: true, fout: regelRood(r.key, "stuks"), value: r.stuks_per_fust, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { stuks_per_fust: v }) }), _jsx(NumField, { label: "Fust/laag", value: r.fust_per_laag, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { fust_per_laag: v }) }), _jsx(NumField, { label: "Lagen/kar", value: r.lagen_per_kar, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { lagen_per_kar: v }) }), _jsxs("div", { children: [_jsx(NumField, { label: "Minimumprijs", req: true, fout: regelRood(r.key, "prijs"), value: r.min_prijs, disabled: alleenLezen, inputMode: "decimal", muted: !r.prijs_bevestigd, onChange: (v) => setRegel(r.key, { min_prijs: v, prijs_bevestigd: true, prijs_at: null }) }), !r.prijs_bevestigd && r.min_prijs != null && !alleenLezen && (_jsx("button", { type: "button", className: "mt-1 text-xs font-medium text-primary hover:underline", onClick: () => setRegel(r.key, { prijs_bevestigd: true }), children: "Voorstel bevestigen" }))] }), _jsx(NumField, { label: "Klokvoorverkoop", value: r.voorverkoop_prijs, disabled: alleenLezen, inputMode: "decimal", onChange: (v) => setRegel(r.key, { voorverkoop_prijs: v }) })] }), _jsxs("div", { className: "pl-8", children: [_jsxs("button", { type: "button", className: "text-xs font-medium text-muted-foreground hover:text-foreground", onClick: () => setMeerOpen((m) => ({ ...m, [r.key]: !m[r.key] })), children: [meerOpen[r.key] ? "Minder" : "Meer", ": opmerking, kwaliteit en keurcodes"] }), (meerOpen[r.key] || regelRood(r.key, "kwaliteit")) && (_jsxs("div", { className: "mt-3 grid gap-3 sm:grid-cols-2", children: [_jsxs("label", { className: "block sm:col-span-2", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Opmerking voor de veiling" }), _jsx(Input, { value: r.veil_opmerking ?? "", disabled: alleenLezen, onChange: (e) => setRegel(r.key, { veil_opmerking: e.target.value || null }) })] }), _jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Kwaliteit (S98)" }), _jsxs("select", { className: "h-9 w-full rounded-lg border border-input bg-background px-2 text-sm disabled:cursor-not-allowed disabled:opacity-70 [@media(pointer:coarse)]:h-11" + (regelRood(r.key, "kwaliteit") ? " border-destructive ring-1 ring-destructive" : ""), "aria-invalid": regelRood(r.key, "kwaliteit") || undefined, value: r.kwaliteit ?? "", disabled: alleenLezen, onChange: (e) => setRegel(r.key, { kwaliteit: e.target.value || null }), children: [_jsx("option", { value: "", children: km?.kwaliteit ? `Artikel: ${km.kwaliteit}` : kwaliteitCodes.length ? "Kenmerk van het artikel" : (leegTekst ?? "Kenmerk van het artikel") }), kwaliteitCodes.filter((c) => c?.vbnCode === "S98").map((c) => (_jsxs("option", { value: c.vbnValueCode, children: [c.vbnValueCode, c.description ? ` · ${c.description}` : ""] }, c.vbnValueCode)))] })] }), _jsxs("div", { children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Keurcodes (K01/K02, P01/P02)" }), _jsx(KeurcodeVeld, { codes: kwaliteitCodes.filter((c) => /^(K01|K02|P01|P02)$/.test(String(c?.vbnCode))), waarde: r.keurcodes, voorinvulling: km?.keurcodes ?? [], leegTekst: leegTekst, disabled: alleenLezen, fout: regelRood(r.key, "kwaliteit"), onChange: (v) => setRegel(r.key, { keurcodes: v }) })] })] }))] })] }, r.key));
402
404
  }) }), !alleenLezen && (_jsxs("div", { className: "flex flex-wrap gap-2 border-t border-border px-4 py-3 sm:px-5", children: [_jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setRegels((rs) => [...rs, legeRegel()]), children: [_jsx(Plus, { className: "mr-2 h-4 w-4" }), " Artikel toevoegen"] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", children: [_jsx(Package, { className: "mr-2 h-4 w-4" }), " Uit voorraad"] }) }), _jsxs(DropdownMenuContent, { className: "max-h-80 overflow-y-auto", children: [productOpties(true).length === 0 && _jsx(DropdownMenuItem, { disabled: true, children: "Geen artikelen op voorraad" }), productOpties(true).slice(0, 100).map((o) => (_jsxs(DropdownMenuItem, { onClick: () => { const n = legeRegel(); setRegels((rs) => [...rs.filter((x) => x.product_id || x.product_name), n]); void kiesProduct(n.key, o.value); }, children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: o.label }), _jsx("span", { className: "ml-3 text-xs text-muted-foreground", children: o.hint })] }, o.value)))] })] })] }))] }), resultaten.length > 0 && (_jsxs("section", { className: "rounded-xl border border-border bg-card p-4 shadow-sm sm:p-5", children: [_jsx("h2", { className: "mb-3 text-sm font-semibold", children: "Verkocht" }), _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-left text-[11px] font-semibold uppercase tracking-wider text-muted-foreground", children: [_jsx("th", { className: "py-1", children: "Koper" }), _jsx("th", { className: "py-1", children: "Stuks" }), _jsx("th", { className: "py-1", children: "Prijs" }), _jsx("th", { className: "py-1", children: "Bedrag" })] }) }), _jsx("tbody", { className: "divide-y divide-border", children: resultaten.filter((x) => !x.doorgedraaid).map((x) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2", children: x.koper_naam }), _jsx("td", { className: "py-2 tabular-nums", children: Number(x.stuks || 0).toLocaleString("nl-NL") }), _jsx("td", { className: "py-2 tabular-nums", children: x.prijs != null ? eur(Number(x.prijs)) : "—" }), _jsx("td", { className: "py-2 tabular-nums", children: x.bedrag != null ? eur(Number(x.bedrag)) : "—" })] }, x.id))) })] }), _jsxs("div", { className: "mt-3 flex flex-wrap gap-x-6 gap-y-1 border-t border-border pt-3 text-sm", children: [_jsxs("span", { children: ["Totaal: ", _jsxs("strong", { className: "tabular-nums", children: [verkochtStuks.toLocaleString("nl-NL"), " stuks \u00B7 ", eur(verkochtBedrag)] })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Doorgedraaid: ", _jsxs("span", { className: "tabular-nums", children: [doorStuks.toLocaleString("nl-NL"), " stuks"] })] })] })] })), !alleenLezen && (_jsx("div", { className: "sticky bottom-0 z-20 -mx-4 border-t border-border bg-background/95 px-4 pt-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] backdrop-blur sm:-mx-6 sm:px-6", children: _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "text-sm tabular-nums", children: [_jsx("span", { className: "font-medium", children: tellersTekst(tellers) }), totaal > 0 && _jsxs("span", { className: "ml-2 text-muted-foreground", children: ["\u00B7 min. ", eur(totaal)] }), ontbreekt.length > 0 && _jsxs("span", { className: "ml-2 text-xs text-muted-foreground", title: ontbreekt.join(", "), children: ["\u00B7 ", ontbreekt.length, " ontbreekt nog"] })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs(Button, { variant: "ghost", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setVoorbeeld(true), children: [_jsx(Eye, { className: "mr-2 h-4 w-4" }), " Voorbeeld"] }), bewerken ? (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => { setBewerken(false); geladen.current = null; qc.invalidateQueries({ queryKey: ["klok-order", klokId] }); }, children: "Annuleren" }), _jsxs(Button, { size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => setBevestigWijzig(true), children: [_jsx(Send, { className: "mr-2 h-4 w-4" }), " Opnieuw versturen"] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig, onClick: onOpslaan, children: [_jsx(Save, { className: "mr-2 h-4 w-4" }), " Opslaan als concept"] }), _jsx(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => onVersturen(true), children: "Versturen en nieuwe" }), _jsxs(Button, { size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => onVersturen(false), children: [_jsx(Send, { className: "mr-2 h-4 w-4" }), " ", bezig === "send" ? "Bezig…" : "Versturen naar veiling"] })] }))] })] }) })), voorbeeld && (_jsxs(Dialoog, { titel: "Voorbeeld veilbrief", onClose: () => setVoorbeeld(false), children: [_jsxs("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm", children: [_jsx("dt", { className: "text-muted-foreground", children: "Veillocatie" }), _jsx("dd", { children: kop.veillocatie_naam ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Veildatum" }), _jsx("dd", { children: kop.veildatum ? fmtNL(kop.veildatum, { weekday: "short", day: "numeric", month: "short" }) : "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Veilgroep" }), _jsx("dd", { children: kop.veilgroep ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Verzendlocatie" }), _jsx("dd", { children: kop.verzendlocatie_naam ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Vervoer" }), _jsx("dd", { children: VERVOER.find((v) => v.id === kop.vervoer)?.label })] }), _jsx("ul", { className: "mt-3 divide-y divide-border text-sm", children: regels.filter((r) => r.product_name).map((r) => (_jsxs("li", { className: "flex justify-between gap-3 py-1.5", children: [_jsx("span", { className: "min-w-0 truncate", children: r.product_name }), _jsxs("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: [r.fusten ?? 0, " \u00D7 ", r.stuks_per_fust ?? 0, " \u00B7 min. ", r.min_prijs != null ? eur(r.min_prijs) : "—"] })] }, r.key))) }), _jsx("p", { className: "mt-3 text-sm font-medium tabular-nums", children: tellersTekst(tellers) }), ontbreekt.length > 0 && _jsxs("p", { className: "mt-2 text-sm text-muted-foreground", children: ["Ontbreekt nog: ", ontbreekt.join(", ")] })] })), bevestigWijzig && (_jsxs(Dialoog, { titel: "Wijzigen en opnieuw versturen?", onClose: () => setBevestigWijzig(false), children: [_jsx("p", { className: "text-sm text-muted-foreground", children: "De huidige veilbrief wordt bij de veiling verwijderd en opnieuw verstuurd. Doorgaan?" }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setBevestigWijzig(false), children: "Annuleren" }), _jsx(Button, { onClick: onWijzigEnVerstuur, disabled: !!bezig, children: "Doorgaan" })] })] })), bevestigVerwijder && (_jsxs(Dialoog, { titel: `Veilbrief ${row?.klok_nummer ?? ""} verwijderen?`, onClose: () => !bezig && setBevestigVerwijder(false), children: [_jsx("p", { className: "text-sm text-muted-foreground", children: VERWIJDER_BEVESTIG_TEXT }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setBevestigVerwijder(false), disabled: !!bezig, children: "Annuleren" }), _jsx(Button, { className: "bg-destructive text-destructive-foreground hover:bg-destructive/90", onClick: onVerwijderen, disabled: !!bezig, "aria-busy": bezig === "delete" || undefined, children: bezig === "delete" ? _jsxs(_Fragment, { children: [_jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin", "aria-hidden": true }), " Bezig met verwijderen\u2026"] }) : "Verwijderen" })] })] })), sjabloonNaam != null && (_jsxs(Dialoog, { titel: "Opslaan als sjabloon", onClose: () => setSjabloonNaam(null), children: [_jsxs("label", { className: "block text-sm", children: [_jsxs("span", { className: "mb-1 block", children: ["Naam ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { autoFocus: true, value: sjabloonNaam, maxLength: 80, onChange: (e) => setSjabloonNaam(e.target.value) })] }), _jsxs("p", { className: "mt-2 text-xs text-muted-foreground", children: ["Voor ", kop.veillocatie_naam, ". Prijzen ouder dan 14 dagen worden later als voorstel getoond."] }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setSjabloonNaam(null), children: "Annuleren" }), _jsx(Button, { onClick: bewaarSjabloon, disabled: !sjabloonNaam.trim(), children: "Opslaan" })] })] }))] }));
403
405
  }
@@ -1 +1 @@
1
- {"version":3,"file":"KlokOrdersList.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokOrdersList.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAM/E,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,UAAO;;;;;;;UASpE;AAED,eAAO,MAAM,uBAAuB,sFAAsF,CAAC;AAK3H,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GACpC,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,sEAAsE;IACtE,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,+BAiOA"}
1
+ {"version":3,"file":"KlokOrdersList.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokOrdersList.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAqC,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAMlG,MAAM,WAAW,eAAgB,SAAQ,gBAAgB;IACvD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,UAAO;;;;;;;UASpE;AAED,eAAO,MAAM,uBAAuB,sFAAsF,CAAC;AAK3H,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GACpC,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,sEAAsE;IACtE,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,+BAiOA"}
@@ -7,7 +7,7 @@ import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMe
7
7
  import { FileText, Gavel, Loader2, MoreHorizontal, Printer, Repeat, RotateCcw, Trash2 } from "lucide-react";
8
8
  import { deleteKlokOrder, getKlokAfleverbrief, listKlokOrders, repeatKlokOrder, retryKlokAnnuleren } from "../../../lib/klok.functions.js";
9
9
  import { KLOK_AFLEVERBRIEF_UIT_TEXT, klokAnnulerenOpenstaand, klokKanVerwijderen, klokTellers, volgendeVeildag } from "../../../lib/klok-labels.js";
10
- import { KLOK_PAGE_SIZE } from "../../../lib/klok-list.js";
10
+ import { KLOK_PAGE_SIZE, klokOrderDetailId } from "../../../lib/klok-list.js";
11
11
  import { fmtNL } from "../../../lib/nl-datetime.js";
12
12
  import { amsterdamYmd, ymdString } from "../../../lib/period-range.js";
13
13
  import { EmptyState } from "../v3/EmptyState.js";
@@ -140,7 +140,7 @@ export function KlokOrdersList({ from, to, params, focusedId, onPage, }) {
140
140
  const regels = (o.regels ?? []);
141
141
  const t = klokTellers(regels);
142
142
  const prijzen = regels.map((r) => Number(r.min_prijs)).filter((n) => n > 0);
143
- return (_jsxs("tr", { "data-klok-id": o.id, "aria-selected": focusedId === o.id || undefined, className: "h-[60px] cursor-pointer border-b border-border last:border-0 hover:bg-muted/50 " + (focusedId === o.id ? "bg-muted/60 outline outline-2 -outline-offset-2 outline-ring" : ""), onClick: () => open(o.id), children: [_jsx("td", { className: "px-4 font-medium tabular-nums", children: o.klok_nummer }), _jsx("td", { className: "px-3", children: o.veillocatie_naam ?? "—" }), _jsx("td", { className: "px-3 tabular-nums", children: o.veilgroep ?? "—" }), _jsxs("td", { className: "px-3 tabular-nums", children: [t.fusten, " \u00B7 ", t.stuks] }), _jsx("td", { className: "px-3 tabular-nums", children: prijzen.length ? `€ ${Math.min(...prijzen).toFixed(2).replace(".", ",")}${prijzen.length > 1 && Math.max(...prijzen) !== Math.min(...prijzen) ? ` – ${Math.max(...prijzen).toFixed(2).replace(".", ",")}` : ""}` : "—" }), _jsx("td", { className: "px-3", children: _jsx(KlokStatusBadge, { status: o.status, detail: o.status_detail ?? o.laatste_fout }) }), _jsx("td", { className: "px-3", onClick: (e) => e.stopPropagation(), children: _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", "aria-label": "Acties", disabled: bezig === o.id, children: _jsx(MoreHorizontal, { className: "h-4 w-4" }) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onClick: () => herhaal(o), children: [_jsx(Repeat, { className: "mr-2 h-4 w-4" }), " Herhalen"] }), (o.afleverbrieven ?? []).length ? (_jsxs(DropdownMenuItem, { onClick: () => afleverbrief(o), children: [_jsx(FileText, { className: "mr-2 h-4 w-4" }), " Afleverbrief"] })) : (_jsx("div", { title: KLOK_AFLEVERBRIEF_UIT_TEXT, "aria-label": `Afleverbrief: ${KLOK_AFLEVERBRIEF_UIT_TEXT}`, children: _jsxs(DropdownMenuItem, { disabled: true, children: [_jsx(FileText, { className: "mr-2 h-4 w-4" }), " Afleverbrief"] }) })), _jsxs(DropdownMenuItem, { disabled: !o.order_id, onClick: () => o.order_id && navigate({ to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: o.order_id } }), children: [_jsx(Printer, { className: "mr-2 h-4 w-4" }), " Stickers printen"] }), klokAnnulerenOpenstaand(o) && (_jsxs(DropdownMenuItem, { onClick: () => opnieuwAnnuleren(o), children: [_jsx(RotateCcw, { className: "mr-2 h-4 w-4" }), " Order annuleren opnieuw proberen"] })), klokKanVerwijderen(o.status) && (_jsxs(DropdownMenuItem, { className: "text-destructive", onClick: () => setTeVerwijderen(o), children: [_jsx(Trash2, { className: "mr-2 h-4 w-4" }), " Verwijderen"] }))] })] }) })] }, o.id));
143
+ return (_jsxs("tr", { "data-klok-id": o.id, "aria-selected": focusedId === o.id || undefined, className: "h-[60px] cursor-pointer border-b border-border last:border-0 hover:bg-muted/50 " + (focusedId === o.id ? "bg-muted/60 outline outline-2 -outline-offset-2 outline-ring" : ""), onClick: () => open(o.id), children: [_jsx("td", { className: "px-4 font-medium tabular-nums", children: o.klok_nummer }), _jsx("td", { className: "px-3", children: o.veillocatie_naam ?? "—" }), _jsx("td", { className: "px-3 tabular-nums", children: o.veilgroep ?? "—" }), _jsxs("td", { className: "px-3 tabular-nums", children: [t.fusten, " \u00B7 ", t.stuks] }), _jsx("td", { className: "px-3 tabular-nums", children: prijzen.length ? `€ ${Math.min(...prijzen).toFixed(2).replace(".", ",")}${prijzen.length > 1 && Math.max(...prijzen) !== Math.min(...prijzen) ? ` – ${Math.max(...prijzen).toFixed(2).replace(".", ",")}` : ""}` : "—" }), _jsx("td", { className: "px-3", children: _jsx(KlokStatusBadge, { status: o.status, detail: o.status_detail ?? o.laatste_fout }) }), _jsx("td", { className: "px-3", onClick: (e) => e.stopPropagation(), children: _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "sm", className: "h-8 w-8 p-0", "aria-label": "Acties", disabled: bezig === o.id, children: _jsx(MoreHorizontal, { className: "h-4 w-4" }) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsxs(DropdownMenuItem, { onClick: () => herhaal(o), children: [_jsx(Repeat, { className: "mr-2 h-4 w-4" }), " Herhalen"] }), (o.afleverbrieven ?? []).length ? (_jsxs(DropdownMenuItem, { onClick: () => afleverbrief(o), children: [_jsx(FileText, { className: "mr-2 h-4 w-4" }), " Afleverbrief"] })) : (_jsx("div", { title: KLOK_AFLEVERBRIEF_UIT_TEXT, "aria-label": `Afleverbrief: ${KLOK_AFLEVERBRIEF_UIT_TEXT}`, children: _jsxs(DropdownMenuItem, { disabled: true, children: [_jsx(FileText, { className: "mr-2 h-4 w-4" }), " Afleverbrief"] }) })), _jsxs(DropdownMenuItem, { disabled: !o.order_id, onClick: () => o.order_id && navigate({ to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: klokOrderDetailId(o.order_id) } }), children: [_jsx(Printer, { className: "mr-2 h-4 w-4" }), " Stickers printen"] }), klokAnnulerenOpenstaand(o) && (_jsxs(DropdownMenuItem, { onClick: () => opnieuwAnnuleren(o), children: [_jsx(RotateCcw, { className: "mr-2 h-4 w-4" }), " Order annuleren opnieuw proberen"] })), klokKanVerwijderen(o.status) && (_jsxs(DropdownMenuItem, { className: "text-destructive", onClick: () => setTeVerwijderen(o), children: [_jsx(Trash2, { className: "mr-2 h-4 w-4" }), " Verwijderen"] }))] })] }) })] }, o.id));
144
144
  }) }, dag || "geen"))) })] }), params && pages > 1 && (_jsxs("div", { className: "flex items-center justify-between gap-2 border-t border-border px-4 py-3 text-sm", children: [_jsxs("span", { className: "text-muted-foreground tabular-nums", children: [(page - 1) * KLOK_PAGE_SIZE + 1, "\u2013", Math.min(total, page * KLOK_PAGE_SIZE), " van ", total] }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", disabled: page <= 1, onClick: () => onPage?.(page - 1), children: "Vorige" }), _jsx(Button, { variant: "outline", size: "sm", disabled: page >= pages, onClick: () => onPage?.(page + 1), children: "Volgende" })] })] })), teVerwijderen && (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-foreground/40 p-4", onClick: () => !bezig && setTeVerwijderen(null), children: _jsxs("div", { className: "w-full max-w-md rounded-lg border border-border bg-card p-6 shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsxs("h2", { className: "text-lg font-semibold", children: ["Veilbrief ", teVerwijderen.klok_nummer, " verwijderen?"] }), _jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: VERWIJDER_BEVESTIG_TEXT }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setTeVerwijderen(null), disabled: !!bezig, children: "Annuleren" }), _jsx(Button, { className: "bg-destructive text-destructive-foreground hover:bg-destructive/90", onClick: () => verwijder(teVerwijderen), disabled: !!bezig, "aria-busy": !!bezig || undefined, children: bezig ? _jsxs(_Fragment, { children: [_jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin", "aria-hidden": true }), " Bezig met verwijderen\u2026"] }) : "Verwijderen" })] })] }) }))] }));
145
145
  }
146
146
  function FragmentGroep({ label, count, children }) {
@@ -12,6 +12,6 @@ export function RowMenu({ row, rowId, isBuffer, fulfillingId, onEdit, onDetails,
12
12
  : row.stage === "shipped"
13
13
  ? "Al afgehandeld"
14
14
  : "Afhandelen (verzonden)" }), !isBuffer && row.isLocal ? (_jsx(DropdownMenuItem, { className: "text-destructive focus:text-destructive", onClick: () => onDelete?.(row), children: row.stage === "cancelled" ? "Definitief verwijderen" : "Annuleren" })) : (_jsxs(DropdownMenuItem, { disabled: true, title: isBuffer
15
- ? "Een gecombineerde order kun je niet in één keer annuleren."
15
+ ? "Een gecombineerde order kun je niet in één keer annuleren. Open de order en annuleer per order."
16
16
  : "Floriday-orders annuleer of wijzig je in Floriday.", children: ["Annuleren", isBuffer ? "" : " (FO)"] }))] })] }));
17
17
  }