@flowselections/floriday-verkoop-module 1.0.157 → 1.0.158

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 (69) hide show
  1. package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
  2. package/dist-lib/components/verkoop/CreateOrderPage.js +34 -19
  3. package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts +13 -0
  4. package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts.map +1 -1
  5. package/dist-lib/components/verkoop/SalesOrdersFilterPanel.js +23 -15
  6. package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts +3 -1
  7. package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
  8. package/dist-lib/components/verkoop/SalesOrdersFilters.js +8 -4
  9. package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
  10. package/dist-lib/components/verkoop/VerkoopOrdersPage.js +41 -26
  11. package/dist-lib/components/verkoop/klok/KlokOrderPage.d.ts.map +1 -1
  12. package/dist-lib/components/verkoop/klok/KlokOrderPage.js +81 -43
  13. package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts +22 -6
  14. package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts.map +1 -1
  15. package/dist-lib/components/verkoop/klok/KlokOrdersList.js +42 -14
  16. package/dist-lib/components/verkoop/klok/KlokPage.d.ts.map +1 -1
  17. package/dist-lib/components/verkoop/klok/KlokPage.js +101 -25
  18. package/dist-lib/components/verkoop/v3/FilterChip.d.ts +8 -0
  19. package/dist-lib/components/verkoop/v3/FilterChip.d.ts.map +1 -0
  20. package/dist-lib/components/verkoop/v3/FilterChip.js +6 -0
  21. package/dist-lib/components/verkoop/v3/KpiTile.d.ts +2 -0
  22. package/dist-lib/components/verkoop/v3/KpiTile.d.ts.map +1 -1
  23. package/dist-lib/components/verkoop/v3/KpiTile.js +2 -0
  24. package/dist-lib/components/verkoop/v3/ShortcutHelp.d.ts +4 -1
  25. package/dist-lib/components/verkoop/v3/ShortcutHelp.d.ts.map +1 -1
  26. package/dist-lib/components/verkoop/v3/ShortcutHelp.js +3 -3
  27. package/dist-lib/components/verkoop/v3/SourceIcon.d.ts +1 -1
  28. package/dist-lib/components/verkoop/v3/SourceIcon.d.ts.map +1 -1
  29. package/dist-lib/components/verkoop/v3/SourceIcon.js +4 -1
  30. package/dist-lib/integrations/supabase/types.d.ts +629 -0
  31. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  32. package/dist-lib/lib/create-order-form.d.ts +15 -0
  33. package/dist-lib/lib/create-order-form.d.ts.map +1 -1
  34. package/dist-lib/lib/create-order-form.js +21 -0
  35. package/dist-lib/lib/create-order.functions.d.ts +5 -3
  36. package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
  37. package/dist-lib/lib/create-order.functions.js +21 -70
  38. package/dist-lib/lib/klok-form.d.ts +22 -1
  39. package/dist-lib/lib/klok-form.d.ts.map +1 -1
  40. package/dist-lib/lib/klok-form.js +50 -6
  41. package/dist-lib/lib/klok-labels.d.ts +43 -0
  42. package/dist-lib/lib/klok-labels.d.ts.map +1 -1
  43. package/dist-lib/lib/klok-labels.js +65 -3
  44. package/dist-lib/lib/klok-list.d.ts +35 -0
  45. package/dist-lib/lib/klok-list.d.ts.map +1 -0
  46. package/dist-lib/lib/klok-list.js +60 -0
  47. package/dist-lib/lib/klok.functions.d.ts +27 -2
  48. package/dist-lib/lib/klok.functions.d.ts.map +1 -1
  49. package/dist-lib/lib/klok.functions.js +107 -15
  50. package/dist-lib/lib/klok.server.d.ts +6 -0
  51. package/dist-lib/lib/klok.server.d.ts.map +1 -1
  52. package/dist-lib/lib/klok.server.js +61 -11
  53. package/dist-lib/lib/order-cancel-view.d.ts +8 -0
  54. package/dist-lib/lib/order-cancel-view.d.ts.map +1 -0
  55. package/dist-lib/lib/order-cancel-view.js +22 -0
  56. package/dist-lib/lib/order-cancel.server.d.ts +9 -11
  57. package/dist-lib/lib/order-cancel.server.d.ts.map +1 -1
  58. package/dist-lib/lib/order-cancel.server.js +20 -78
  59. package/dist-lib/lib/order-progress.d.ts +3 -1
  60. package/dist-lib/lib/order-progress.d.ts.map +1 -1
  61. package/dist-lib/lib/order-progress.js +2 -0
  62. package/dist-lib/lib/order-terugdraaien.d.ts +21 -0
  63. package/dist-lib/lib/order-terugdraaien.d.ts.map +1 -0
  64. package/dist-lib/lib/order-terugdraaien.js +32 -0
  65. package/dist-lib/lib/salesorders-list.server.d.ts +4 -0
  66. package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
  67. package/dist-lib/lib/salesorders-list.server.js +9 -2
  68. package/package.json +4 -1
  69. package/schema/verkoop.sql +16 -0
@@ -1 +1 @@
1
- {"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"AAsGA,wBAAgB,eAAe,gCAkxC9B"}
1
+ {"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"AAuGA,wBAAgB,eAAe,gCA6zC9B"}
@@ -6,12 +6,12 @@ import { fmtNL } from "../../lib/nl-datetime.js";
6
6
  // afhaallocaties, vervoerders). Ophaalmoment en haalbare leverdatum komen
7
7
  // van de Logistiek Engine (logistics_departure_preview).
8
8
  import { useEffect, useMemo, useRef, useState } from "react";
9
- import { Button, Input, Label, Textarea, toast, } from "@flowselections/core";
9
+ import { Button, Input, Label, Textarea, toast, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } 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
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 } 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 } 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";
@@ -125,6 +125,26 @@ export function CreateOrderPage() {
125
125
  const [lines, setLines] = useState([
126
126
  { product_id: null, product_name: "", quantity: null, unit: "stuks", unit_price: null, belading: null },
127
127
  ]);
128
+ function kiesRegelProduct(idx, v) {
129
+ const next = [...lines];
130
+ if (v === null)
131
+ next[idx] = { ...next[idx], product_id: null, belading: null };
132
+ else {
133
+ const p = products.find((x) => x.id === v);
134
+ const b = completeBelading(p);
135
+ const newPpc = b?.plants_per_crate ?? null;
136
+ const currentQ = Number(next[idx].quantity ?? 0);
137
+ const normalizedQ = newPpc === null ? (currentQ > 0 ? currentQ : null) : currentQ > 0 ? Math.ceil(currentQ / newPpc) * newPpc : newPpc;
138
+ next[idx] = {
139
+ ...next[idx], product_id: v, product_name: p?.product ?? "",
140
+ unit: next[idx].unit ?? p?.unit ?? "stuks", quantity: normalizedQ, belading: b,
141
+ ...(next[idx].price_mode === "manual" ? {} : { unit_price: null, price_source: null, price_error: false, price_key: null }),
142
+ };
143
+ focusNext.current = { kind: "crates", idx };
144
+ }
145
+ setLines(next);
146
+ }
147
+ const [groepKeuze, setGroepKeuze] = useState(null);
128
148
  // Automatische prijs per regel via klanten_orderprijs. Opnieuw bij een andere
129
149
  // klant, leverdatum, product of aantal; een zelf ingevulde prijs blijft staan.
130
150
  const priceWanted = lines
@@ -789,23 +809,13 @@ export function CreateOrderPage() {
789
809
  muted: !p.in_stock,
790
810
  };
791
811
  }), onChange: (v) => {
792
- const next = [...lines];
793
- if (v === null)
794
- next[idx] = { ...next[idx], product_id: null, belading: null };
795
- else {
796
- const p = products.find((x) => x.id === v);
797
- const b = completeBelading(p);
798
- const newPpc = b?.plants_per_crate ?? null;
799
- const currentQ = Number(next[idx].quantity ?? 0);
800
- const normalizedQ = newPpc === null ? (currentQ > 0 ? currentQ : null) : currentQ > 0 ? Math.ceil(currentQ / newPpc) * newPpc : newPpc;
801
- next[idx] = {
802
- ...next[idx], product_id: v, product_name: p?.product ?? "",
803
- unit: next[idx].unit ?? p?.unit ?? "stuks", quantity: normalizedQ, belading: b,
804
- ...(next[idx].price_mode === "manual" ? {} : { unit_price: null, price_source: null, price_error: false, price_key: null }),
805
- };
806
- focusNext.current = { kind: "crates", idx };
812
+ const gekozen = v ? products.find((x) => x.id === v) : null;
813
+ if (gekozen?.source === "group") {
814
+ // Productgroep: eerst een artikel uit de groep kiezen (een groep heeft geen eigen voorraad).
815
+ setGroepKeuze({ idx, groep: gekozen });
816
+ return;
807
817
  }
808
- setLines(next);
818
+ kiesRegelProduct(idx, v);
809
819
  } }), 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]) => ({
810
820
  value: key,
811
821
  label: beladingLabel(b),
@@ -836,5 +846,10 @@ export function CreateOrderPage() {
836
846
  next[idx] = { ...next[idx], quantity: cr === null ? null : cr * ppc };
837
847
  setLines(next);
838
848
  }, 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, price_zero_ok: 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 ? (_jsxs("span", { className: "mt-1 block text-xs text-destructive", children: [PRIJS_ONBEKEND_TEXT, line.unit_price != null && Number(line.unit_price) === 0 && (_jsxs("span", { className: "mt-1 flex items-center gap-1.5 text-foreground [@media(pointer:coarse)]:min-h-11", children: [_jsx("input", { type: "checkbox", className: "h-4 w-4", checked: !!line.price_zero_ok, onChange: (e) => { const next = [...lines]; next[idx] = { ...next[idx], price_zero_ok: e.target.checked }; setLines(next); } }), "Prijs 0 is juist"] }))] })) : line.price_zero_ok && Number(line.unit_price) === 0 ? (_jsx("span", { className: "mt-1 block text-xs text-muted-foreground", children: "Prijs 0 bevestigd" })) : 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));
839
- }) }), _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 }) })] }));
849
+ }) }), _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")] }), groepKeuze && (() => {
850
+ const leden = groepLeden(groepKeuze.groep, products);
851
+ const groepNaam = String(groepKeuze.groep.product ?? "").replace(/^\s*\[Groep\]\s*/i, "");
852
+ return (_jsx(Dialog, { open: true, onOpenChange: (o) => { if (!o)
853
+ setGroepKeuze(null); }, children: _jsxs(DialogContent, { className: "sm:max-w-lg", children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { children: ["Kies een artikel uit ", groepNaam] }), _jsx(DialogDescription, { children: "Een productgroep heeft geen eigen voorraad. Kies het artikel dat je wilt verkopen." })] }), leden.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Deze groep heeft geen artikelen die je kunt bestellen." })) : (_jsx("ul", { className: "max-h-[60vh] divide-y divide-border overflow-y-auto", children: leden.map((l) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "flex min-h-11 w-full items-center justify-between gap-3 px-2 py-2 text-left text-sm hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", onClick: () => { kiesRegelProduct(groepKeuze.idx, l.id); setGroepKeuze(null); }, children: [_jsx("span", { className: "min-w-0 truncate font-medium", children: l.product }), _jsx("span", { className: "shrink-0 text-xs " + (l.in_stock ? "text-muted-foreground" : "text-destructive"), children: l.in_stock ? `Beschikbaar: ${l.available_stock ?? 0} ${l.unit || "stuks"}` : "Niet op voorraad" })] }) }, l.id))) }))] }) }));
854
+ })(), _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 }) })] }));
840
855
  }
@@ -1,3 +1,4 @@
1
+ import { type ReactNode } from "react";
1
2
  import type { Filters } from "./SalesOrdersFilters.js";
2
3
  export declare function countActiveFilters(f: Filters): number;
3
4
  export declare function SalesOrdersFilterPanel({ open, onOpenChange, value, onChange, }: {
@@ -6,4 +7,16 @@ export declare function SalesOrdersFilterPanel({ open, onOpenChange, value, onCh
6
7
  value: Filters;
7
8
  onChange: (next: Filters) => void;
8
9
  }): import("react").JSX.Element;
10
+ /**
11
+ * Het filterpaneel zelf (rechts inschuivend, Esc sluit, "Wis alle filters",
12
+ * "Toepassen"). Verkooporders en Klok gebruiken hetzelfde paneel; alleen de
13
+ * velden verschillen.
14
+ */
15
+ export declare function FilterPanelShell({ open, onOpenChange, activeCount, onClearAll, children, }: {
16
+ open: boolean;
17
+ onOpenChange: (open: boolean) => void;
18
+ activeCount: number;
19
+ onClearAll: () => void;
20
+ children: ReactNode;
21
+ }): import("react").JSX.Element;
9
22
  //# sourceMappingURL=SalesOrdersFilterPanel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SalesOrdersFilterPanel.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrdersFilterPanel.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAYrD;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACnC,+BA6OA"}
1
+ {"version":3,"file":"SalesOrdersFilterPanel.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrdersFilterPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAalD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAYrD;AAED,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACnC,+BA6KA;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,UAAU,EACV,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,EAAE,SAAS,CAAC;CACrB,+BAmEA"}
@@ -25,16 +25,6 @@ export function countActiveFilters(f) {
25
25
  return n;
26
26
  }
27
27
  export function SalesOrdersFilterPanel({ open, onOpenChange, value, onChange, }) {
28
- useEffect(() => {
29
- if (!open)
30
- return;
31
- const onKey = (e) => {
32
- if (e.key === "Escape")
33
- onOpenChange(false);
34
- };
35
- window.addEventListener("keydown", onKey);
36
- return () => window.removeEventListener("keydown", onKey);
37
- }, [open, onOpenChange]);
38
28
  const clearAll = () => {
39
29
  onChange({
40
30
  ...value,
@@ -50,13 +40,31 @@ export function SalesOrdersFilterPanel({ open, onOpenChange, value, onChange, })
50
40
  });
51
41
  };
52
42
  const activeCount = countActiveFilters(value);
43
+ return (_jsx(FilterPanelShell, { open: open, onOpenChange: onOpenChange, activeCount: activeCount, onClearAll: clearAll, children: _jsxs("div", { className: "space-y-5", children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Klant" }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx("span", { className: "inline-flex h-7 items-center rounded-full border border-border bg-background px-3 text-xs text-muted-foreground", children: "Connecties" }), _jsx("span", { className: "inline-flex h-7 items-center rounded-full border border-primary/40 bg-primary/10 px-3 text-xs font-medium text-primary", children: "Alle klanten" })] }), _jsxs(Select, { value: value.klant ?? "all", onValueChange: (v) => onChange({ ...value, klant: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "Kies een klant" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "Kies een klant" }) })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Handelsvorm" }), _jsxs(Select, { value: value.handelsvorm ?? "all", onValueChange: (v) => onChange({ ...value, handelsvorm: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alles -" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "all", children: "- Alles -" }), _jsx(SelectItem, { value: "klok", children: "Klok" }), _jsx(SelectItem, { value: "direct", children: "Direct" })] })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Voorraadlocatie" }), _jsxs(Select, { value: value.voorraadlocatie ?? "all", onValueChange: (v) => onChange({ ...value, voorraadlocatie: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alle voorraadlocaties -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Alle voorraadlocaties -" }) })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Kanaal" }), _jsxs(Select, { value: value.kanaal ?? "all", onValueChange: (v) => onChange({ ...value, kanaal: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alle verkoopkanalen -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Alle verkoopkanalen -" }) })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Financi\u00EBle afhandeling" }), _jsxs(Select, { value: value.financieleAfhandeling ?? "all", onValueChange: (v) => onChange({ ...value, financieleAfhandeling: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Financi\u00EBle afhandeling -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Financi\u00EBle afhandeling -" }) })] }), _jsxs("label", { className: "flex items-center gap-2 pt-1 text-sm text-foreground", children: [_jsx(Checkbox, { checked: !!value.onvolledigVerrekend, onCheckedChange: (c) => onChange({ ...value, onvolledigVerrekend: c === true ? true : undefined }) }), _jsx("span", { children: "Onvolledig verrekend" })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Artikel" }), _jsxs(Select, { value: value.artikel ?? "all", onValueChange: (v) => onChange({ ...value, artikel: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alle artikelen -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Alle artikelen -" }) })] }), _jsxs("label", { className: "flex items-center gap-2 pt-1 text-sm text-foreground", children: [_jsx(Checkbox, { checked: !!value.daytrade, onCheckedChange: (c) => onChange({ ...value, daytrade: c === true ? true : undefined }) }), _jsx("span", { children: "Daytrade transacties" })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Order-referentie" }), _jsx(Input, { placeholder: "Order-referentie", value: value.orderReferentie ?? "", onChange: (e) => onChange({
44
+ ...value,
45
+ orderReferentie: e.target.value ? e.target.value : undefined,
46
+ }), className: "h-10" })] })] }) }));
47
+ }
48
+ /**
49
+ * Het filterpaneel zelf (rechts inschuivend, Esc sluit, "Wis alle filters",
50
+ * "Toepassen"). Verkooporders en Klok gebruiken hetzelfde paneel; alleen de
51
+ * velden verschillen.
52
+ */
53
+ export function FilterPanelShell({ open, onOpenChange, activeCount, onClearAll, children, }) {
54
+ useEffect(() => {
55
+ if (!open)
56
+ return;
57
+ const onKey = (e) => {
58
+ if (e.key === "Escape")
59
+ onOpenChange(false);
60
+ };
61
+ window.addEventListener("keydown", onKey);
62
+ return () => window.removeEventListener("keydown", onKey);
63
+ }, [open, onOpenChange]);
53
64
  return (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40 bg-black/30 transition-opacity " +
54
65
  (open ? "opacity-100" : "pointer-events-none opacity-0"), onClick: () => onOpenChange(false), "aria-hidden": true }), _jsxs("aside", { className: "fixed right-0 top-0 z-50 flex h-full w-full max-w-sm flex-col border-l border-border bg-card shadow-xl transition-transform " +
55
- (open ? "translate-x-0" : "translate-x-full"), role: "dialog", "aria-hidden": !open, inert: !open, "aria-label": "Filters", children: [_jsxs("div", { className: "flex items-center justify-between border-b border-border px-5 py-4", children: [_jsx("h2", { className: "text-base font-semibold text-foreground", children: "Filters" }), _jsx("button", { type: "button", onClick: () => onOpenChange(false), className: "inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", "aria-label": "Sluiten", children: _jsx(X, { className: "h-4 w-4" }) })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-5 py-4", children: [_jsx("button", { type: "button", onClick: clearAll, disabled: activeCount === 0, className: "mb-4 text-sm " +
66
+ (open ? "translate-x-0" : "translate-x-full"), role: "dialog", "aria-hidden": !open, inert: !open, "aria-label": "Filters", children: [_jsxs("div", { className: "flex items-center justify-between border-b border-border px-5 py-4", children: [_jsx("h2", { className: "text-base font-semibold text-foreground", children: "Filters" }), _jsx("button", { type: "button", onClick: () => onOpenChange(false), className: "inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", "aria-label": "Sluiten", children: _jsx(X, { className: "h-4 w-4" }) })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-5 py-4", children: [_jsx("button", { type: "button", onClick: onClearAll, disabled: activeCount === 0, className: "mb-4 text-sm " +
56
67
  (activeCount === 0
57
68
  ? "cursor-not-allowed text-muted-foreground/60"
58
- : "text-primary hover:underline"), children: "Wis alle filters" }), _jsxs("div", { className: "space-y-5", children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Klant" }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx("span", { className: "inline-flex h-7 items-center rounded-full border border-border bg-background px-3 text-xs text-muted-foreground", children: "Connecties" }), _jsx("span", { className: "inline-flex h-7 items-center rounded-full border border-primary/40 bg-primary/10 px-3 text-xs font-medium text-primary", children: "Alle klanten" })] }), _jsxs(Select, { value: value.klant ?? "all", onValueChange: (v) => onChange({ ...value, klant: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "Kies een klant" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "Kies een klant" }) })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Handelsvorm" }), _jsxs(Select, { value: value.handelsvorm ?? "all", onValueChange: (v) => onChange({ ...value, handelsvorm: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alles -" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "all", children: "- Alles -" }), _jsx(SelectItem, { value: "klok", children: "Klok" }), _jsx(SelectItem, { value: "direct", children: "Direct" })] })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Voorraadlocatie" }), _jsxs(Select, { value: value.voorraadlocatie ?? "all", onValueChange: (v) => onChange({ ...value, voorraadlocatie: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alle voorraadlocaties -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Alle voorraadlocaties -" }) })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Kanaal" }), _jsxs(Select, { value: value.kanaal ?? "all", onValueChange: (v) => onChange({ ...value, kanaal: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alle verkoopkanalen -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Alle verkoopkanalen -" }) })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Financi\u00EBle afhandeling" }), _jsxs(Select, { value: value.financieleAfhandeling ?? "all", onValueChange: (v) => onChange({ ...value, financieleAfhandeling: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Financi\u00EBle afhandeling -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Financi\u00EBle afhandeling -" }) })] }), _jsxs("label", { className: "flex items-center gap-2 pt-1 text-sm text-foreground", children: [_jsx(Checkbox, { checked: !!value.onvolledigVerrekend, onCheckedChange: (c) => onChange({ ...value, onvolledigVerrekend: c === true ? true : undefined }) }), _jsx("span", { children: "Onvolledig verrekend" })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Artikel" }), _jsxs(Select, { value: value.artikel ?? "all", onValueChange: (v) => onChange({ ...value, artikel: v === "all" ? undefined : v }), children: [_jsx(SelectTrigger, { className: "h-10 w-full", children: _jsx(SelectValue, { placeholder: "- Alle artikelen -" }) }), _jsx(SelectContent, { children: _jsx(SelectItem, { value: "all", children: "- Alle artikelen -" }) })] }), _jsxs("label", { className: "flex items-center gap-2 pt-1 text-sm text-foreground", children: [_jsx(Checkbox, { checked: !!value.daytrade, onCheckedChange: (c) => onChange({ ...value, daytrade: c === true ? true : undefined }) }), _jsx("span", { children: "Daytrade transacties" })] })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { className: "text-sm font-semibold", children: "Order-referentie" }), _jsx(Input, { placeholder: "Order-referentie", value: value.orderReferentie ?? "", onChange: (e) => onChange({
59
- ...value,
60
- orderReferentie: e.target.value ? e.target.value : undefined,
61
- }), className: "h-10" })] })] })] }), _jsx("div", { className: "border-t border-border px-5 py-3", children: _jsx(Button, { className: "w-full", onClick: () => onOpenChange(false), children: "Toepassen" }) })] })] }));
69
+ : "text-primary hover:underline"), children: "Wis alle filters" }), children] }), _jsx("div", { className: "border-t border-border px-5 py-3", children: _jsx(Button, { className: "w-full", onClick: () => onOpenChange(false), children: "Toepassen" }) })] })] }));
62
70
  }
@@ -22,7 +22,7 @@ export interface Filters {
22
22
  dateField?: "ordered" | "delivery";
23
23
  period?: "week" | "month" | "day" | "last7" | "last30" | "custom";
24
24
  }
25
- export declare function SalesOrdersFilters({ value, onChange, part, busy, alle, }: {
25
+ export declare function SalesOrdersFilters({ value, onChange, part, busy, alle, searchPlaceholder, }: {
26
26
  value: Filters;
27
27
  onChange: (next: Filters) => void;
28
28
  /** Alleen de periodekeuze, alleen het zoekveld, of beide (standaard). */
@@ -34,5 +34,7 @@ export declare function SalesOrdersFilters({ value, onChange, part, busy, alle,
34
34
  active: boolean;
35
35
  onChange: (active: boolean) => void;
36
36
  };
37
+ /** Eigen tekst in het zoekveld (bv. op de pagina Klok). */
38
+ searchPlaceholder?: string;
37
39
  }): import("react").JSX.Element;
38
40
  //# sourceMappingURL=SalesOrdersFilters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SalesOrdersFilters.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrdersFilters.tsx"],"names":[],"mappings":"AA8BA,MAAM,WAAW,OAAO;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACnE;AA6BD,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,IAAa,EACb,IAAY,EACZ,IAAI,GACL,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACpC,6DAA6D;IAC7D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sFAAsF;IACtF,IAAI,CAAC,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;KAAE,CAAC;CACjE,+BAwUA"}
1
+ {"version":3,"file":"SalesOrdersFilters.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrdersFilters.tsx"],"names":[],"mappings":"AA8BA,MAAM,WAAW,OAAO;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACnE;AA6BD,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAQ,EACR,IAAa,EACb,IAAY,EACZ,IAAI,EACJ,iBAAiB,GAClB,EAAE;IACD,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACpC,6DAA6D;IAC7D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sFAAsF;IACtF,IAAI,CAAC,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAA;KAAE,CAAC;IAChE,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,+BA4UA"}
@@ -27,7 +27,8 @@ function generateMonthOptions() {
27
27
  }
28
28
  return options;
29
29
  }
30
- export function SalesOrdersFilters({ value, onChange, part = "both", busy = false, alle, }) {
30
+ export function SalesOrdersFilters({ value, onChange, part = "both", busy = false, alle, searchPlaceholder, }) {
31
+ const [weekOpen, setWeekOpen] = useState(false);
31
32
  const currentWeek = getCurrentWeek();
32
33
  const week = value.week ?? currentWeek.week;
33
34
  const year = value.year ?? currentWeek.year;
@@ -146,10 +147,13 @@ export function SalesOrdersFilters({ value, onChange, part = "both", busy = fals
146
147
  };
147
148
  const alleActief = !!alle?.active;
148
149
  const showArrows = !alleActief && (period === "week" || period === "month" || period === "day");
149
- return (_jsxs("div", { className: "flex w-full flex-wrap items-center gap-2 sm:w-auto", children: [part !== "search" && (_jsxs("div", { className: "flex h-10 w-full items-center justify-between gap-1 rounded-md border border-border bg-card px-1 sm:h-9 sm:w-auto sm:justify-start", children: [showArrows && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: () => shiftPeriod(-1), className: "inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground", "aria-label": "Vorige", children: _jsx(ChevronLeft, { className: "h-4 w-4" }) }), _jsx("button", { type: "button", onClick: () => shiftPeriod(1), className: "inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground", "aria-label": "Volgende", children: _jsx(ChevronRight, { className: "h-4 w-4" }) })] })), alleActief ? (_jsx("span", { className: "px-2 text-sm font-medium text-foreground whitespace-nowrap", children: "Alle" })) : period === "month" ? (_jsxs(Select, { value: `${monthYear}-${month}`, onValueChange: (v) => {
150
+ return (_jsxs("div", { className: "flex w-full flex-wrap items-center gap-2 sm:w-auto", children: [part !== "search" && (_jsxs("div", { className: "flex h-10 w-full items-center justify-between gap-1 rounded-md border border-border bg-card px-1 sm:h-9 sm:w-auto sm:justify-start", children: [showArrows && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", onClick: (e) => { e.stopPropagation(); setWeekOpen(false); shiftPeriod(-1); }, className: "inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground", "aria-label": "Vorige", children: _jsx(ChevronLeft, { className: "h-4 w-4" }) }), _jsx("button", { type: "button", onClick: (e) => { e.stopPropagation(); setWeekOpen(false); shiftPeriod(1); }, className: "inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground", "aria-label": "Volgende", children: _jsx(ChevronRight, { className: "h-4 w-4" }) })] })), alleActief ? (_jsx("span", { className: "px-2 text-sm font-medium text-foreground whitespace-nowrap", children: "Alle" })) : period === "month" ? (_jsxs(Select, { value: `${monthYear}-${month}`, onValueChange: (v) => {
150
151
  const [y, m] = v.split("-").map(Number);
151
152
  onChange({ ...value, month: m, monthYear: y });
152
- }, children: [_jsx(SelectTrigger, { className: "h-7 w-36 border-0 bg-transparent px-2 text-sm font-medium text-foreground shadow-none focus:ring-0", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: monthOptions.map((opt) => (_jsx(SelectItem, { value: opt.value, children: opt.label }, opt.value))) })] })) : period === "day" ? (_jsx(Input, { type: "date", value: day, onChange: (e) => onChange({ ...value, day: e.target.value }), className: "h-7 w-40 border-0 bg-transparent px-2 text-sm font-medium text-foreground shadow-none focus-visible:ring-0" })) : period === "custom" ? (_jsxs("div", { className: "flex items-center gap-1 px-2", children: [_jsx(Input, { type: "date", value: value.customFrom ?? todayYmd, onChange: (e) => onChange({ ...value, customFrom: e.target.value }), className: "h-7 w-36 border-0 bg-transparent px-1 text-sm font-medium text-foreground shadow-none focus-visible:ring-0" }), _jsx("span", { className: "text-muted-foreground", children: "\u2013" }), _jsx(Input, { type: "date", value: value.customTo ?? todayYmd, onChange: (e) => onChange({ ...value, customTo: e.target.value }), className: "h-7 w-36 border-0 bg-transparent px-1 text-sm font-medium text-foreground shadow-none focus-visible:ring-0" })] })) : period === "last7" || period === "last30" ? (_jsx("span", { className: "px-2 text-sm font-medium text-foreground whitespace-nowrap", children: period === "last7" ? "Afgelopen 7 dagen" : "Afgelopen 30 dagen" })) : (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", className: "px-2 text-sm font-medium text-foreground whitespace-nowrap rounded hover:bg-accent h-7", "aria-label": "Kies week", children: ["Week ", week, " - ", year] }) }), _jsx(PopoverContent, { className: "w-auto p-0 pointer-events-auto", align: "start", children: _jsx(WeekCalendar, { week: week, year: year, onSelect: (w, y) => onChange({ ...value, week: w, year: y }) }) })] })), (value.dateField ?? "delivery") === "ordered" && (_jsx("span", { className: "pr-1 text-sm text-muted-foreground whitespace-nowrap", "aria-label": "Periode op besteldatum", children: "\u00B7 besteldatum" })), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground", "aria-label": "Periode-opties", children: _jsx(MoreVertical, { className: "h-4 w-4" }) }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-56", children: [_jsxs(DropdownMenuRadioGroup, { value: alleActief ? "__alle" : period, onValueChange: (v) => {
153
+ }, children: [_jsx(SelectTrigger, { className: "h-7 w-36 border-0 bg-transparent px-2 text-sm font-medium text-foreground shadow-none focus:ring-0", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: monthOptions.map((opt) => (_jsx(SelectItem, { value: opt.value, children: opt.label }, opt.value))) })] })) : period === "day" ? (_jsx(Input, { type: "date", value: day, onChange: (e) => onChange({ ...value, day: e.target.value }), className: "h-7 w-40 border-0 bg-transparent px-2 text-sm font-medium text-foreground shadow-none focus-visible:ring-0" })) : period === "custom" ? (_jsxs("div", { className: "flex items-center gap-1 px-2", children: [_jsx(Input, { type: "date", value: value.customFrom ?? todayYmd, onChange: (e) => onChange({ ...value, customFrom: e.target.value }), className: "h-7 w-36 border-0 bg-transparent px-1 text-sm font-medium text-foreground shadow-none focus-visible:ring-0" }), _jsx("span", { className: "text-muted-foreground", children: "\u2013" }), _jsx(Input, { type: "date", value: value.customTo ?? todayYmd, onChange: (e) => onChange({ ...value, customTo: e.target.value }), className: "h-7 w-36 border-0 bg-transparent px-1 text-sm font-medium text-foreground shadow-none focus-visible:ring-0" })] })) : period === "last7" || period === "last30" ? (_jsx("span", { className: "px-2 text-sm font-medium text-foreground whitespace-nowrap", children: period === "last7" ? "Afgelopen 7 dagen" : "Afgelopen 30 dagen" })) : (_jsxs(Popover, { open: weekOpen, onOpenChange: setWeekOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { type: "button", className: "px-2 text-sm font-medium text-foreground whitespace-nowrap rounded hover:bg-accent h-7", "aria-label": "Kies week", children: ["Week ", week, " - ", year] }) }), _jsx(PopoverContent, { className: "w-auto p-0 pointer-events-auto", align: "start", children: _jsx(WeekCalendar, { week: week, year: year, onSelect: (w, y) => {
154
+ onChange({ ...value, week: w, year: y });
155
+ setWeekOpen(false);
156
+ } }) })] })), (value.dateField ?? "delivery") === "ordered" && (_jsx("span", { className: "pr-1 text-sm text-muted-foreground whitespace-nowrap", "aria-label": "Periode op besteldatum", children: "\u00B7 besteldatum" })), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "inline-flex h-7 w-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground", "aria-label": "Periode-opties", children: _jsx(MoreVertical, { className: "h-4 w-4" }) }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-56", children: [_jsxs(DropdownMenuRadioGroup, { value: alleActief ? "__alle" : period, onValueChange: (v) => {
153
157
  if (v === "__alle")
154
158
  return alle?.onChange(true);
155
159
  alle?.onChange(false);
@@ -157,7 +161,7 @@ export function SalesOrdersFilters({ value, onChange, part = "both", busy = fals
157
161
  }, children: [alle && _jsx(DropdownMenuRadioItem, { value: "__alle", children: "Alle" }), _jsx(DropdownMenuRadioItem, { value: "day", children: "Dag" }), _jsx(DropdownMenuRadioItem, { value: "week", children: "Week" }), _jsx(DropdownMenuRadioItem, { value: "month", children: "Maand" }), _jsx(DropdownMenuRadioItem, { value: "last7", children: "Afgelopen 7 dagen" }), _jsx(DropdownMenuRadioItem, { value: "last30", children: "Afgelopen 30 dagen" }), _jsx(DropdownMenuRadioItem, { value: "custom", children: "Aangepast tijdsbestek" })] }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuRadioGroup, { value: value.dateField ?? "delivery", onValueChange: (v) => onChange({ ...value, dateField: v === "ordered" ? "ordered" : "delivery" }), children: [_jsx(DropdownMenuRadioItem, { value: "delivery", children: "Op leverdatum" }), _jsx(DropdownMenuRadioItem, { value: "ordered", children: "Op besteldatum" })] }), _jsx(DropdownMenuSeparator, {}), _jsxs("div", { className: "px-2 py-1.5 text-sm text-muted-foreground inline-flex items-center gap-1", children: [alleActief ? "Alle" : periodLabel(), (value.dateField ?? "delivery") === "ordered" ? " · besteldatum" : "", _jsx(ChevronDown, { className: "h-3.5 w-3.5" })] })] })] })] })), part !== "period" && (_jsxs("div", { className: "group relative flex h-10 sm:h-9 w-full items-center overflow-hidden rounded-md border border-border bg-card " +
158
162
  "transition-[box-shadow,border-color,width] duration-[180ms] ease-out motion-reduce:transition-none " +
159
163
  "focus-within:border-primary focus-within:ring-[3px] focus-within:ring-ring/20 " +
160
- (part === "search" ? "sm:w-80 sm:focus-within:w-[400px]" : ""), children: [_jsx(Search, { className: "ml-3 h-4 w-4 shrink-0 text-muted-foreground transition-colors duration-[120ms] group-focus-within:text-primary", "aria-hidden": true }), _jsx("input", { ref: inputRef, type: "search", placeholder: part === "search" ? "Zoek op ordernummer, klant, artikel of referentie" : "Op briefnummer zoeken", "aria-label": "Zoeken", value: search, maxLength: 100, autoComplete: "off", spellCheck: false, onChange: (e) => setSearch(e.target.value), onKeyDown: (e) => {
164
+ (part === "search" ? "sm:w-80 sm:focus-within:w-[400px]" : ""), children: [_jsx(Search, { className: "ml-3 h-4 w-4 shrink-0 text-muted-foreground transition-colors duration-[120ms] group-focus-within:text-primary", "aria-hidden": true }), _jsx("input", { ref: inputRef, type: "search", placeholder: searchPlaceholder ?? (part === "search" ? "Zoek op ordernummer, klant, artikel of referentie" : "Op briefnummer zoeken"), "aria-label": "Zoeken", value: search, maxLength: 100, autoComplete: "off", spellCheck: false, onChange: (e) => setSearch(e.target.value), onKeyDown: (e) => {
161
165
  if (e.key === "Escape" && search) {
162
166
  e.preventDefault();
163
167
  clearSearch();
@@ -1 +1 @@
1
- {"version":3,"file":"VerkoopOrdersPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/VerkoopOrdersPage.tsx"],"names":[],"mappings":"AA8RA,wBAAgB,iBAAiB,gCAwhChC"}
1
+ {"version":3,"file":"VerkoopOrdersPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/VerkoopOrdersPage.tsx"],"names":[],"mappings":"AAmRA,wBAAgB,iBAAiB,gCA0iChC"}
@@ -3,10 +3,10 @@ import { fmtNL, fmtNLDefault } from "../../lib/nl-datetime.js";
3
3
  import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { orderMatches, searchTokens } from "../../lib/order-search.js";
5
5
  import { Button, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, toast, } from "@flowselections/core";
6
- import { Download, Plus, AlertTriangle, ChevronLeft, ChevronRight, Euro, Layers, ShoppingCart, X, Inbox, PackageOpen, PackageCheck, Truck, ReceiptText, Ban, List, SlidersHorizontal, ChevronDown, SearchX, Clock, Gavel, } from "lucide-react";
6
+ import { Download, Plus, AlertTriangle, ChevronLeft, ChevronRight, Euro, Layers, ShoppingCart, X, Inbox, PackageOpen, PackageCheck, Truck, ReceiptText, Ban, List, SlidersHorizontal, ChevronDown, SearchX, Clock, Gavel, Loader2, } from "lucide-react";
7
7
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@flowselections/core";
8
8
  import { useKlokZichtbaar } from "./klok/useKlok.js";
9
- import { KlokOrdersList, useKlokOrders } from "./klok/KlokOrdersList.js";
9
+ import { KlokOrdersList } from "./klok/KlokOrdersList.js";
10
10
  import { useServerFn } from "@tanstack/react-start";
11
11
  import { useNavigate, useSearch } from "@tanstack/react-router";
12
12
  import { saveListNav, saveListScroll, takeRestoreScroll } from "../../lib/order-nav.js";
@@ -27,7 +27,10 @@ import { SalesOrdersFilterPanel, countActiveFilters, } from "./SalesOrdersFilter
27
27
  import { SalesOrdersTable, salesOrderRowId } from "./SalesOrdersTable.js";
28
28
  import { EditLocalOrderDialog } from "./EditLocalOrderDialog.js";
29
29
  import { StockConsumptionAlertsBanner } from "./StockConsumptionAlertsBanner.js";
30
- import { KpiTile } from "./v3/KpiTile.js";
30
+ import { KPI_GRID_CLASS, KpiTile } from "./v3/KpiTile.js";
31
+ import { FilterChip } from "./v3/FilterChip.js";
32
+ import { markeerGeannuleerd } from "../../lib/order-cancel-view.js";
33
+ import { geannuleerdMelding, TERUGGEDRAAID_TEXT } from "../../lib/order-terugdraaien.js";
31
34
  import { EmptyState } from "./v3/EmptyState.js";
32
35
  import { NoticeBar } from "./v3/NoticeBar.js";
33
36
  import { ShortcutHelp } from "./v3/ShortcutHelp.js";
@@ -116,9 +119,6 @@ function Crossfade({ value }) {
116
119
  }, [value]);
117
120
  return _jsx("span", { ref: ref, className: "inline-block", children: value });
118
121
  }
119
- function FilterChip({ label, onClear, icon }) {
120
- return (_jsxs("button", { type: "button", onClick: onClear, "aria-label": `Filter ${label} wissen`, className: "inline-flex h-8 items-center gap-1.5 rounded-full border border-border bg-muted px-3 text-xs font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [icon, label, _jsx(X, { className: "h-3.5 w-3.5", "aria-hidden": true })] }));
121
- }
122
122
  function StatusTabs({ tab, counts, onChange, extra, }) {
123
123
  const listRef = useRef(null);
124
124
  const activeId = tab === "backlog" ? "topick" : tab === "problem" ? "all" : tab;
@@ -176,9 +176,6 @@ export function VerkoopOrdersPage() {
176
176
  ...periodFromSearch(urlSearch),
177
177
  search: typeof urlSearch.q === "string" ? urlSearch.q.slice(0, 100) : undefined,
178
178
  }));
179
- const klokRange = periodRange(filters);
180
- // Teller op de Klok-tab: zelfde lijst (en cache) als het Klok-tabblad zelf.
181
- const klokQ = useKlokOrders(klokRange?.startDate ?? null, klokRange?.endDate ?? null, klokZichtbaar);
182
179
  const periodKey = JSON.stringify(periodToSearch(periodFromSearch(urlSearch)));
183
180
  useEffect(() => {
184
181
  // URL gewijzigd van buitenaf (terug/vooruit): periode overnemen.
@@ -264,7 +261,19 @@ export function VerkoopOrdersPage() {
264
261
  return mode === "cancel" ? "Annuleren mislukt" : "Verwijderen mislukt";
265
262
  return msg;
266
263
  };
264
+ const confirmLock = useRef(false);
267
265
  const handleConfirmAction = async () => {
266
+ if (!pendingAction || confirmLock.current)
267
+ return;
268
+ confirmLock.current = true;
269
+ try {
270
+ await runConfirmAction();
271
+ }
272
+ finally {
273
+ confirmLock.current = false;
274
+ }
275
+ };
276
+ const runConfirmAction = async () => {
268
277
  if (!pendingAction)
269
278
  return;
270
279
  const mode = pendingAction.mode;
@@ -279,18 +288,18 @@ export function VerkoopOrdersPage() {
279
288
  setDeleting(true);
280
289
  setDeleteProgress(0);
281
290
  let done = 0;
282
- let reversals = 0;
283
291
  const failed = [];
292
+ const geannuleerd = [];
284
293
  for (const target of deletable) {
285
294
  try {
286
295
  if (mode === "cancel") {
287
- await triggerCancelOrder({
296
+ const res = await triggerCancelOrder({
288
297
  data: { orderId: target.id, reason: cancelReason.trim() || undefined },
289
298
  });
299
+ geannuleerd.push({ id: target.id, nummer: res.orderNumber ?? null });
290
300
  }
291
301
  else {
292
- const res = await triggerDeleteOrder({ data: { orderId: target.id } });
293
- reversals += res.reversalEntries;
302
+ await triggerDeleteOrder({ data: { orderId: target.id } });
294
303
  }
295
304
  done += 1;
296
305
  }
@@ -301,20 +310,26 @@ export function VerkoopOrdersPage() {
301
310
  }
302
311
  setDeleting(false);
303
312
  setDeleteProgress(0);
313
+ if (geannuleerd.length > 0) {
314
+ // Rij direct op geannuleerd; daarna de lijst opnieuw ophalen.
315
+ const ids = geannuleerd.map((g) => g.id);
316
+ queryClient.setQueriesData({ queryKey: ["floriday", "salesorders-list"] }, (old) => markeerGeannuleerd(old, ids));
317
+ }
304
318
  if (done > 0) {
305
319
  const extra = [];
306
- if (mode === "cancel")
307
- extra.push("voorraad teruggeboekt");
308
- else
309
- extra.push(`${reversals} voorraadmutatie(s) teruggedraaid`);
310
320
  if (skipped > 0)
311
321
  extra.push(`${skipped} overgeslagen`);
312
322
  if (failed.length > 0)
313
323
  extra.push(`${failed.length} mislukt`);
314
- const verb = mode === "cancel" ? "geannuleerd" : "verwijderd";
315
- toast.success(deletable.length > 1
316
- ? `${done} van ${deletable.length} bestelling(en) ${verb} — ${extra.join(", ")}`
317
- : `Bestelling ${verb} — ${extra.join(", ")}`);
324
+ const suffix = extra.length ? ` (${extra.join(", ")})` : "";
325
+ if (mode === "cancel") {
326
+ toast.success(geannuleerd.length === 1
327
+ ? `${geannuleerdMelding(geannuleerd[0].nummer)}${suffix}`
328
+ : `${geannuleerd.length} orders geannuleerd; de voorraad is weer vrij.${suffix}`);
329
+ }
330
+ else {
331
+ toast.success(`${done > 1 ? `${done} orders verwijderd. ` : "Order verwijderd. "}${TERUGGEDRAAID_TEXT}${suffix}`);
332
+ }
318
333
  }
319
334
  if (failed.length > 0) {
320
335
  toast.error(Array.from(new Set(failed)).join(" · "));
@@ -324,7 +339,7 @@ export function VerkoopOrdersPage() {
324
339
  setCancelReason("");
325
340
  setSelectedRowIds([]);
326
341
  }
327
- await refetch();
342
+ await queryClient.invalidateQueries({ queryKey: ["floriday", "salesorders-list"] });
328
343
  };
329
344
  // Serverside gefilterd, gesorteerd en gepagineerd: de browser krijgt alleen
330
345
  // de zichtbare pagina plus totalen/tellingen.
@@ -615,7 +630,7 @@ export function VerkoopOrdersPage() {
615
630
  ? fmtNLDefault(syncHealth.lastSuccessAt)
616
631
  : "nog nooit", syncHealth.lastError ? ` — ${syncHealth.lastError}` : "", syncHealth.failingComponents && syncHealth.failingComponents.length > 0
617
632
  ? ` — onderdelen die stilliggen: ${syncHealth.failingComponents.join(", ")}`
618
- : ""] })] }), _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: "-mx-4 flex shrink-0 snap-x snap-mandatory scroll-px-4 gap-3 overflow-x-auto px-4 pb-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden sm:mx-0 sm:grid sm:grid-cols-2 sm:overflow-visible sm:px-0 sm:pb-0 lg:grid-cols-4 [&>*]:w-[78%] [&>*]:max-w-[280px] [&>*]:shrink-0 [&>*]:snap-start sm:[&>*]:w-auto sm:[&>*]:max-w-none", 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: kpiCounts.all.toLocaleString("nl-NL") }), sub: `${kpiCounts.incoming} inkomend · ${kpiCounts.topick} te picken`, trend: trendOf(kpiCounts.all, prevData?.statusCounts?.all), 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) => {
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) => {
619
634
  e.stopPropagation();
620
635
  toggleTab("backlog");
621
636
  }, 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) => {
@@ -626,7 +641,7 @@ export function VerkoopOrdersPage() {
626
641
  setTab(t);
627
642
  }, extra: klokZichtbaar ? {
628
643
  id: "__klok", label: "Klok", icon: Gavel, active: showKlok,
629
- count: klokQ.data ? (klokQ.data.orders ?? []).filter((o) => o.status !== "verwijderd").length : null,
644
+ count: typeof data?.klokCount === "number" ? data.klokCount : null,
630
645
  onClick: () => setShowKlok((v) => !v),
631
646
  } : undefined }), _jsxs("div", { className: "shrink-0 flex flex-wrap items-center gap-2", children: [_jsx("div", { className: "min-w-0 flex-1 sm:flex-none", children: _jsx(SalesOrdersFilters, { value: filters, onChange: setFilters, part: "search", busy: searchPending }) }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => setFilterPanelOpen(true), "aria-label": "Filters", className: "relative h-10 px-3 sm:h-9", children: [_jsx(SlidersHorizontal, { className: "h-4 w-4 sm:mr-2" }), _jsx("span", { className: "hidden sm:inline", children: "Filters" }), activeFilterCount > 0 && (_jsx("span", { className: "ml-2 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1.5 text-[11px] font-semibold text-primary-foreground", children: activeFilterCount }))] }), tab === "backlog" && (_jsx(FilterChip, { label: "Te laat", icon: _jsx(Clock, { className: "h-3.5 w-3.5 text-destructive", "aria-hidden": true }), onClear: () => setTab("topick") })), tab === "problem" && (_jsx(FilterChip, { label: "Probleem", icon: _jsx(AlertTriangle, { className: "h-3.5 w-3.5 text-warning", "aria-hidden": true }), onClear: () => setTab("all") })), filters.search && !userLoading && !searchPending && totalCount === 0 && filters.period !== "custom" && (_jsx(Button, { variant: "outline", size: "sm", onClick: () => {
632
647
  const t = amsterdamYmd();
@@ -709,8 +724,8 @@ export function VerkoopOrdersPage() {
709
724
  : single?.orderNumber || single?.id }), " ", "wilt ", verb, "?"] })), isCancel
710
725
  ? " De bestelling blijft bewaard onder Geannuleerd, gaat uit de planning en facturatie, en de voorraad wordt teruggeboekt."
711
726
  : " De bestelling wordt definitief gewist; resterende voorraadmutaties worden teruggedraaid."] }), isCancel && (_jsxs("label", { className: "mt-4 block text-sm text-foreground", children: ["Reden (optioneel)", _jsx("textarea", { value: cancelReason, onChange: (e) => setCancelReason(e.target.value), rows: 2, maxLength: 500, placeholder: "Bijv. klant heeft geannuleerd", className: "mt-1 w-full rounded-md border border-input bg-background p-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring" })] })), plan.skipped > 0 && (_jsxs("p", { className: "mt-2 text-sm text-warning", children: [plan.skipped, " van de ", plan.total, " zijn Floriday-orders en worden overgeslagen."] })), plan.deletable.length === 0 && (_jsxs("p", { className: "mt-2 text-sm text-destructive", children: ["Geen van deze regels kan hier ", verb, "."] }))] }));
712
- })(), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", onClick: () => setPendingAction(null), disabled: deleting, children: "Sluiten" }), _jsx(Button, { size: "sm", onClick: handleConfirmAction, disabled: deleting || collectDeletePlan(pendingAction.rows).deletable.length === 0, className: "bg-destructive text-destructive-foreground hover:bg-destructive/90", children: deleting
713
- ? `Bezig… ${deleteProgress}/${collectDeletePlan(pendingAction.rows).deletable.length}`
727
+ })(), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "outline", size: "sm", onClick: () => setPendingAction(null), disabled: deleting, children: "Sluiten" }), _jsx(Button, { size: "sm", onClick: handleConfirmAction, disabled: deleting || collectDeletePlan(pendingAction.rows).deletable.length === 0, "aria-busy": deleting || undefined, className: "bg-destructive text-destructive-foreground hover:bg-destructive/90", children: deleting
728
+ ? _jsxs(_Fragment, { children: [_jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin", "aria-hidden": true }), " Bezig\u2026 ", deleteProgress, "/", collectDeletePlan(pendingAction.rows).deletable.length] })
714
729
  : pendingAction.mode === "cancel"
715
730
  ? "Order annuleren"
716
731
  : "Definitief verwijderen" })] })] }) })), editOrderId && (_jsx(EditLocalOrderDialog, { orderId: editOrderId, open: !!editOrderId, onOpenChange: (o) => !o && setEditOrderId(null) })), _jsxs("nav", { "aria-label": "Paginering", className: "shrink-0 flex flex-wrap items-center justify-between gap-3 text-sm text-muted-foreground", children: [_jsx("div", { children: totalCount === 0
@@ -1 +1 @@
1
- {"version":3,"file":"KlokOrderPage.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokOrderPage.tsx"],"names":[],"mappings":"AAwEA,wBAAgB,aAAa,gCAgsB5B"}
1
+ {"version":3,"file":"KlokOrderPage.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokOrderPage.tsx"],"names":[],"mappings":"AA6EA,wBAAgB,aAAa,gCAwuB5B"}