@flowselections/floriday-verkoop-module 1.0.140 → 1.0.142
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/verkoop/OrderAfleverbrievenCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderAfleverbrievenCard.js +15 -2
- package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts +3 -1
- package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderCarrierPicker.js +6 -2
- package/dist-lib/components/verkoop/OrderControlStatusCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderControlStatusCard.js +2 -2
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +95 -35
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts +6 -0
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +67 -34
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts +3 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.js +77 -8
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts +7 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +39 -26
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +214 -38
- package/dist-lib/components/verkoop/v3/ArticlesHover.d.ts +8 -0
- package/dist-lib/components/verkoop/v3/ArticlesHover.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/ArticlesHover.js +48 -0
- package/dist-lib/components/verkoop/v3/EmptyState.d.ts +9 -0
- package/dist-lib/components/verkoop/v3/EmptyState.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/EmptyState.js +5 -0
- package/dist-lib/components/verkoop/v3/HoverTip.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/HoverTip.js +1 -1
- package/dist-lib/components/verkoop/v3/InfoCard.d.ts +28 -0
- package/dist-lib/components/verkoop/v3/InfoCard.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/InfoCard.js +21 -0
- package/dist-lib/components/verkoop/v3/KpiTile.d.ts +10 -2
- package/dist-lib/components/verkoop/v3/KpiTile.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/KpiTile.js +37 -5
- package/dist-lib/components/verkoop/v3/NoticeBar.d.ts +6 -0
- package/dist-lib/components/verkoop/v3/NoticeBar.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/NoticeBar.js +10 -0
- package/dist-lib/components/verkoop/v3/OrderProgress.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/OrderProgress.js +8 -1
- package/dist-lib/components/verkoop/v3/OrderStepper.d.ts +7 -0
- package/dist-lib/components/verkoop/v3/OrderStepper.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/OrderStepper.js +77 -0
- package/dist-lib/components/verkoop/v3/ShortcutHelp.d.ts +5 -0
- package/dist-lib/components/verkoop/v3/ShortcutHelp.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/ShortcutHelp.js +13 -0
- package/dist-lib/lib/delivery-format.check.d.ts +2 -0
- package/dist-lib/lib/delivery-format.check.d.ts.map +1 -0
- package/dist-lib/lib/delivery-format.check.js +28 -0
- package/dist-lib/lib/delivery-format.d.ts +17 -0
- package/dist-lib/lib/delivery-format.d.ts.map +1 -0
- package/dist-lib/lib/delivery-format.js +42 -0
- package/dist-lib/lib/order-articles.functions.d.ts +11 -0
- package/dist-lib/lib/order-articles.functions.d.ts.map +1 -0
- package/dist-lib/lib/order-articles.functions.js +11 -0
- package/dist-lib/lib/order-articles.server.d.ts +11 -0
- package/dist-lib/lib/order-articles.server.d.ts.map +1 -0
- package/dist-lib/lib/order-articles.server.js +89 -0
- package/dist-lib/lib/order-nav.check.d.ts +2 -0
- package/dist-lib/lib/order-nav.check.d.ts.map +1 -0
- package/dist-lib/lib/order-nav.check.js +16 -0
- package/dist-lib/lib/order-nav.d.ts +24 -0
- package/dist-lib/lib/order-nav.d.ts.map +1 -0
- package/dist-lib/lib/order-nav.js +62 -0
- package/dist-lib/lib/order-progress.server.d.ts +23 -0
- package/dist-lib/lib/order-progress.server.d.ts.map +1 -1
- package/dist-lib/lib/order-progress.server.js +25 -0
- package/dist-lib/lib/order-search.check.d.ts +2 -0
- package/dist-lib/lib/order-search.check.d.ts.map +1 -0
- package/dist-lib/lib/order-search.check.js +16 -0
- package/dist-lib/lib/order-search.d.ts +18 -0
- package/dist-lib/lib/order-search.d.ts.map +1 -0
- package/dist-lib/lib/order-search.js +37 -0
- package/dist-lib/lib/salesorders-list.functions.d.ts +20 -0
- package/dist-lib/lib/salesorders-list.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.functions.js +24 -0
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +4 -3
- package/dist-lib/lib/salesorders-mapping.d.ts +2 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-mapping.js +1 -0
- package/dist-lib/lib/salesorders.functions.d.ts +8 -0
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.js +23 -3
- package/dist-lib/lib/useBufferEvents.js +1 -1
- package/dist-lib/lib/useDetailProgressFallback.d.ts +17 -0
- package/dist-lib/lib/useDetailProgressFallback.d.ts.map +1 -0
- package/dist-lib/lib/useDetailProgressFallback.js +28 -0
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts +1 -0
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.js +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
+
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { orderMatches, searchTokens } from "../../lib/order-search.js";
|
|
3
4
|
import { Button, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, toast, } from "@flowselections/core";
|
|
4
|
-
import { Download, Plus, AlertTriangle, ChevronLeft, ChevronRight,
|
|
5
|
+
import { Download, Plus, AlertTriangle, ChevronLeft, ChevronRight, Euro, Layers, ShoppingCart, X, Inbox, PackageOpen, PackageCheck, Truck, ReceiptText, Ban, List, SlidersHorizontal, ChevronDown, SearchX, Clock, } from "lucide-react";
|
|
5
6
|
import { useServerFn } from "@tanstack/react-start";
|
|
6
7
|
import { useNavigate, useSearch } from "@tanstack/react-router";
|
|
8
|
+
import { saveListNav, saveListScroll, takeRestoreScroll } from "../../lib/order-nav.js";
|
|
7
9
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
8
10
|
import { supabase } from "../../integrations/supabase/client.js";
|
|
9
11
|
import { getFloridaySyncHealth } from "../../lib/salesorders.functions.js";
|
|
10
|
-
import { periodFromSearch, periodToSearch } from "../../lib/period-range.js";
|
|
12
|
+
import { amsterdamYmd, periodFromSearch, periodRange, periodToSearch, shiftPeriod, ymdString } from "../../lib/period-range.js";
|
|
11
13
|
import { isSessionError } from "../../lib/session-error.js";
|
|
12
14
|
import { animateIn, transitionStyle } from "../../lib/motion.js";
|
|
13
15
|
import { cancelLocalOrder, deleteLocalOrder } from "../../lib/create-order.functions.js";
|
|
@@ -22,6 +24,9 @@ import { SalesOrdersTable, salesOrderRowId } from "./SalesOrdersTable.js";
|
|
|
22
24
|
import { EditLocalOrderDialog } from "./EditLocalOrderDialog.js";
|
|
23
25
|
import { StockConsumptionAlertsBanner } from "./StockConsumptionAlertsBanner.js";
|
|
24
26
|
import { KpiTile } from "./v3/KpiTile.js";
|
|
27
|
+
import { EmptyState } from "./v3/EmptyState.js";
|
|
28
|
+
import { NoticeBar } from "./v3/NoticeBar.js";
|
|
29
|
+
import { ShortcutHelp } from "./v3/ShortcutHelp.js";
|
|
25
30
|
// Tabbladen van de orderlijst (v3). Achterstand en "probleem" zijn geen
|
|
26
31
|
// tabblad maar een filterchip / KPI binnen dezelfde lijst.
|
|
27
32
|
const STATUS_TABS = [
|
|
@@ -32,8 +37,58 @@ const STATUS_TABS = [
|
|
|
32
37
|
{ id: "shipped", label: "Aangemeld", hint: "Aangemeld bij vervoerder." },
|
|
33
38
|
{ id: "invoiced", label: "Gefactureerd", hint: "ERP-factuur verstuurd, of afgemeld bij Floriday." },
|
|
34
39
|
{ id: "cancelled", label: "Geannuleerd" },
|
|
35
|
-
{ id: "not_reported", label: "Niet afgemeld bij Floriday", hint: "Afgehandeld, nog niet gemeld bij Floriday." },
|
|
36
40
|
];
|
|
41
|
+
const TAB_ICONS = {
|
|
42
|
+
all: List,
|
|
43
|
+
incoming: Inbox,
|
|
44
|
+
topick: PackageOpen,
|
|
45
|
+
picked: PackageCheck,
|
|
46
|
+
shipped: Truck,
|
|
47
|
+
invoiced: ReceiptText,
|
|
48
|
+
cancelled: Ban,
|
|
49
|
+
};
|
|
50
|
+
/** Procentuele wijziging; null als er geen zinvolle vergelijking is. */
|
|
51
|
+
function pctChange(cur, prev) {
|
|
52
|
+
if (prev == null || prev === 0)
|
|
53
|
+
return null;
|
|
54
|
+
return ((cur - prev) / prev) * 100;
|
|
55
|
+
}
|
|
56
|
+
const fmtShort = (ymd) => new Date(`${ymd}T12:00:00Z`).toLocaleDateString("nl-NL", { day: "numeric", month: "short", timeZone: "UTC" }).replace(".", "");
|
|
57
|
+
/** Leesbare periode: "Week 44 · 26 okt – 1 nov". */
|
|
58
|
+
function periodLabel(f) {
|
|
59
|
+
const r = periodRange(f);
|
|
60
|
+
if (!r)
|
|
61
|
+
return "Alle orders";
|
|
62
|
+
const last = new Date(`${r.endDate}T12:00:00Z`);
|
|
63
|
+
last.setUTCDate(last.getUTCDate() - 1);
|
|
64
|
+
const lastYmd = last.toISOString().slice(0, 10);
|
|
65
|
+
const range = r.startDate === lastYmd ? fmtShort(r.startDate) : `${fmtShort(r.startDate)} – ${fmtShort(lastYmd)}`;
|
|
66
|
+
if (f.period === "day")
|
|
67
|
+
return range;
|
|
68
|
+
if (f.period === "month" && f.month !== undefined) {
|
|
69
|
+
const m = new Date(Date.UTC(f.monthYear ?? 2000, f.month, 15)).toLocaleDateString("nl-NL", { month: "long", year: "numeric", timeZone: "UTC" });
|
|
70
|
+
return m.charAt(0).toUpperCase() + m.slice(1);
|
|
71
|
+
}
|
|
72
|
+
if (f.period === "last7")
|
|
73
|
+
return `Laatste 7 dagen · ${range}`;
|
|
74
|
+
if (f.period === "last30")
|
|
75
|
+
return `Laatste 30 dagen · ${range}`;
|
|
76
|
+
if (f.period === "custom")
|
|
77
|
+
return range;
|
|
78
|
+
return f.week ? `Week ${f.week} · ${range}` : range;
|
|
79
|
+
}
|
|
80
|
+
/** Vergelijkingslabel voor de trend; alleen dag/week/maand hebben een vorige periode. */
|
|
81
|
+
function previousLabel(f) {
|
|
82
|
+
if (f.period === "day")
|
|
83
|
+
return "t.o.v. vorige dag";
|
|
84
|
+
if (f.period === "month")
|
|
85
|
+
return "t.o.v. vorige maand";
|
|
86
|
+
if (f.period === "week" || (!f.period && f.week)) {
|
|
87
|
+
const p = shiftPeriod(f, -1);
|
|
88
|
+
return `t.o.v. week ${p.week}`;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
37
92
|
const clearPeriod = {
|
|
38
93
|
period: undefined,
|
|
39
94
|
week: undefined,
|
|
@@ -57,29 +112,37 @@ function Crossfade({ value }) {
|
|
|
57
112
|
}, [value]);
|
|
58
113
|
return _jsx("span", { ref: ref, className: "inline-block", children: value });
|
|
59
114
|
}
|
|
60
|
-
function FilterChip({ label, onClear }) {
|
|
61
|
-
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: [label, _jsx(X, { className: "h-3.5 w-3.5", "aria-hidden": true })] }));
|
|
115
|
+
function FilterChip({ label, onClear, icon }) {
|
|
116
|
+
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 })] }));
|
|
62
117
|
}
|
|
63
118
|
function StatusTabs({ tab, counts, onChange, }) {
|
|
64
119
|
const listRef = useRef(null);
|
|
65
|
-
const [bar, setBar] = useState(null);
|
|
66
120
|
const activeId = tab === "backlog" ? "topick" : tab === "problem" ? "all" : tab;
|
|
67
121
|
useLayoutEffect(() => {
|
|
68
122
|
const measure = () => {
|
|
69
123
|
const el = listRef.current?.querySelector(`[data-tab="${activeId}"]`);
|
|
70
|
-
|
|
71
|
-
|
|
124
|
+
const list = listRef.current;
|
|
125
|
+
if (el && list && (el.offsetLeft < list.scrollLeft || el.offsetLeft + el.offsetWidth > list.scrollLeft + list.clientWidth)) {
|
|
126
|
+
list.scrollLeft = el.offsetLeft - 8;
|
|
127
|
+
}
|
|
72
128
|
};
|
|
73
129
|
measure();
|
|
74
130
|
window.addEventListener("resize", measure);
|
|
75
131
|
return () => window.removeEventListener("resize", measure);
|
|
76
132
|
}, [activeId, counts]);
|
|
77
|
-
return (_jsx("div", { className: "shrink-0
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
133
|
+
return (_jsx("div", { className: "shrink-0", children: _jsx("div", { ref: listRef, role: "tablist", "aria-label": "Orderstatus", className: "relative -mx-4 flex items-center gap-2 overflow-x-auto px-4 pb-1 [scrollbar-width:none] [mask-image:linear-gradient(to_right,black_85%,transparent)] [&::-webkit-scrollbar]:hidden sm:mx-0 sm:px-0 sm:[mask-image:none]", children: STATUS_TABS.map((t) => {
|
|
134
|
+
const active = activeId === t.id;
|
|
135
|
+
return (_jsxs("button", { "data-tab": t.id, type: "button", role: "tab", "aria-selected": active, onClick: () => onChange(t.id), title: t.hint, style: transitionStyle("color, background-color, border-color", 150), className: "relative flex h-9 items-center gap-2 whitespace-nowrap rounded-lg border px-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring " +
|
|
136
|
+
(active
|
|
137
|
+
? "border-primary/30 bg-primary/10 font-semibold text-foreground"
|
|
138
|
+
: counts[t.id] === 0
|
|
139
|
+
? "border-border bg-card text-muted-foreground/70 hover:text-foreground"
|
|
140
|
+
: "border-border bg-card text-foreground/80 hover:bg-muted hover:text-foreground"), children: [(() => {
|
|
141
|
+
const Icon = TAB_ICONS[t.id];
|
|
142
|
+
return Icon ? _jsx(Icon, { className: "h-4 w-4 shrink-0", "aria-hidden": true }) : null;
|
|
143
|
+
})(), _jsx("span", { children: t.label }), _jsx("span", { className: "inline-flex h-5 min-w-5 items-center justify-center rounded-full px-1.5 text-[11px] font-semibold tabular-nums " +
|
|
144
|
+
(active ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground"), children: _jsx(Crossfade, { value: counts[t.id] }) })] }, t.id));
|
|
145
|
+
}) }) }));
|
|
83
146
|
}
|
|
84
147
|
const eur0 = (n) => `€ ${Math.round(n).toLocaleString("nl-NL")}`;
|
|
85
148
|
// Statusfiltering, buffer-groepering en totalen gebeuren serverside
|
|
@@ -89,11 +152,17 @@ export function VerkoopOrdersPage() {
|
|
|
89
152
|
useBufferEvents();
|
|
90
153
|
const [tab, setTab] = useState("all");
|
|
91
154
|
const [filterPanelOpen, setFilterPanelOpen] = useState(false);
|
|
155
|
+
const [helpOpen, setHelpOpen] = useState(false);
|
|
156
|
+
const [syncOpen, setSyncOpen] = useState(false);
|
|
157
|
+
const [focusedId, setFocusedId] = useState(null);
|
|
92
158
|
// Periode staat in de URL (zoekparameters): terugnavigeren, verversen en
|
|
93
159
|
// een gedeelde link tonen dezelfde periode. Ongeldig → standaard (huidige
|
|
94
160
|
// week op leverdatum), zonder fout.
|
|
95
161
|
const urlSearch = useSearch({ strict: false });
|
|
96
|
-
const [filters, setFiltersState] = useState(() =>
|
|
162
|
+
const [filters, setFiltersState] = useState(() => ({
|
|
163
|
+
...periodFromSearch(urlSearch),
|
|
164
|
+
search: typeof urlSearch.q === "string" ? urlSearch.q.slice(0, 100) : undefined,
|
|
165
|
+
}));
|
|
97
166
|
const periodKey = JSON.stringify(periodToSearch(periodFromSearch(urlSearch)));
|
|
98
167
|
useEffect(() => {
|
|
99
168
|
// URL gewijzigd van buitenaf (terug/vooruit): periode overnemen.
|
|
@@ -107,11 +176,14 @@ export function VerkoopOrdersPage() {
|
|
|
107
176
|
const setFilters = (next) => {
|
|
108
177
|
setFiltersState(next);
|
|
109
178
|
const wanted = periodToSearch(next);
|
|
110
|
-
|
|
179
|
+
const q = next.search?.trim() || undefined;
|
|
180
|
+
const curQ = typeof urlSearch.q === "string" ? urlSearch.q : undefined;
|
|
181
|
+
if (JSON.stringify(wanted) !== periodKey || q !== curQ) {
|
|
111
182
|
void navigateSearch({
|
|
112
183
|
to: ".",
|
|
113
|
-
search: ((prev) => ({ ...prev, ...wanted })),
|
|
114
|
-
|
|
184
|
+
search: ((prev) => ({ ...prev, ...wanted, q })),
|
|
185
|
+
// Typen vervangt de geschiedenis; een periodewissel maakt een nieuwe stap.
|
|
186
|
+
replace: JSON.stringify(wanted) === periodKey,
|
|
115
187
|
});
|
|
116
188
|
}
|
|
117
189
|
};
|
|
@@ -247,16 +319,29 @@ export function VerkoopOrdersPage() {
|
|
|
247
319
|
autoRefreshMs: 60000,
|
|
248
320
|
});
|
|
249
321
|
const { data, isLoading, error, refetch, isFetching, isPlaceholderData, stale, lastSuccessAt } = listQuery;
|
|
322
|
+
// Vorige periode, alleen voor de trend in de KPI-tegels (totalen; faalt stil).
|
|
323
|
+
const prevLabel = previousLabel(filters);
|
|
324
|
+
const prevFilters = useMemo(() => ({ ...filters, ...shiftPeriod(filters, -1), search: undefined }), [filters]);
|
|
325
|
+
const prevQuery = useSalesOrdersQuery(prevFilters, { tab: "all", page: 1, pageSize: 1, enabled: !!prevLabel });
|
|
326
|
+
const prevData = prevLabel && !prevQuery.error && !prevQuery.isPlaceholderData ? prevQuery.data : undefined;
|
|
250
327
|
// Skeleton alleen bij een eigen actie (andere sleutel) of de eerste keer;
|
|
251
328
|
// achtergrondverversing laat de oude rijen staan.
|
|
252
|
-
|
|
253
|
-
|
|
329
|
+
// Alleen de zoekterm gewijzigd → direct op de huidige rijen filteren
|
|
330
|
+
// (geen skeleton); de server bevestigt daarna stil.
|
|
331
|
+
const baseKey = JSON.stringify([{ ...filters, search: undefined }, tab, pageSize]);
|
|
332
|
+
const shownBaseRef = useRef(null);
|
|
333
|
+
const searchPending = isPlaceholderData && !!data && shownBaseRef.current === baseKey;
|
|
334
|
+
const userLoading = isLoading || (isPlaceholderData && !searchPending);
|
|
335
|
+
// Zoekterm telt niet als "nieuwe weergave": geen tabel-fade per toets.
|
|
336
|
+
const viewKey = JSON.stringify([baseKey, page]);
|
|
254
337
|
const shownKeyRef = useRef(null);
|
|
255
|
-
const quiet = !userLoading && shownKeyRef.current === viewKey;
|
|
338
|
+
const quiet = !userLoading && (shownKeyRef.current === viewKey || searchPending);
|
|
256
339
|
useEffect(() => {
|
|
257
|
-
if (!
|
|
340
|
+
if (!isLoading && !isPlaceholderData && data) {
|
|
258
341
|
shownKeyRef.current = viewKey;
|
|
259
|
-
|
|
342
|
+
shownBaseRef.current = baseKey;
|
|
343
|
+
}
|
|
344
|
+
}, [isLoading, isPlaceholderData, data, viewKey, baseKey]);
|
|
260
345
|
// Nieuwe orders tijdens het kijken (stil verversen):
|
|
261
346
|
// - bovenaan pagina 1 → rijen staan er gewoon, kort gemarkeerd;
|
|
262
347
|
// - verder in de lijst / andere pagina → niets verschuiven, knop "n nieuwe orders · Tonen".
|
|
@@ -267,6 +352,7 @@ export function VerkoopOrdersPage() {
|
|
|
267
352
|
const [highlightIds, setHighlightIds] = useState([]);
|
|
268
353
|
const prevRowsRef = useRef([]);
|
|
269
354
|
const prevAllRef = useRef(null);
|
|
355
|
+
const prevSearchRef = useRef(filters.search ?? "");
|
|
270
356
|
useEffect(() => {
|
|
271
357
|
if (!data)
|
|
272
358
|
return;
|
|
@@ -274,7 +360,9 @@ export function VerkoopOrdersPage() {
|
|
|
274
360
|
const prevAll = prevAllRef.current;
|
|
275
361
|
prevRowsRef.current = serverRows;
|
|
276
362
|
prevAllRef.current = data.statusCounts?.all ?? null;
|
|
277
|
-
|
|
363
|
+
const searchChanged = prevSearchRef.current !== (filters.search ?? "");
|
|
364
|
+
prevSearchRef.current = filters.search ?? "";
|
|
365
|
+
if (!quiet || searchChanged || isPlaceholderData) {
|
|
278
366
|
setFrozen(null);
|
|
279
367
|
setPendingNew(0);
|
|
280
368
|
return;
|
|
@@ -308,7 +396,11 @@ export function VerkoopOrdersPage() {
|
|
|
308
396
|
setPage(1);
|
|
309
397
|
tableTopRef.current?.scrollIntoView({ block: "start", behavior: "smooth" });
|
|
310
398
|
};
|
|
311
|
-
const
|
|
399
|
+
const searchToks = useMemo(() => searchTokens(filters.search), [filters.search]);
|
|
400
|
+
const paged = useMemo(() => {
|
|
401
|
+
const rows = frozen ?? serverRows;
|
|
402
|
+
return searchPending ? rows.filter((o) => orderMatches(o, searchToks)) : rows;
|
|
403
|
+
}, [frozen, serverRows, searchPending, searchToks]);
|
|
312
404
|
// Selectie voor bulkacties: alleen rijen die nu zichtbaar zijn.
|
|
313
405
|
const selectedRows = paged.filter((o) => selectedRowIds.includes(salesOrderRowId(o)));
|
|
314
406
|
const selectedPlan = collectDeletePlan(selectedRows);
|
|
@@ -326,8 +418,31 @@ export function VerkoopOrdersPage() {
|
|
|
326
418
|
return next.length === sel.length ? sel : next;
|
|
327
419
|
});
|
|
328
420
|
}, [paged, userLoading]);
|
|
421
|
+
// Navigatie naar het detail: adres, rijvolgorde en scrollpositie bewaren
|
|
422
|
+
// (Terug, Vorige/Volgende). Scroll terugzetten als we via "Terug" komen.
|
|
423
|
+
useEffect(() => {
|
|
424
|
+
if (userLoading)
|
|
425
|
+
return;
|
|
426
|
+
const href = window.location.pathname + window.location.search;
|
|
427
|
+
saveListNav(href, paged.map((r) => ({ id: r.id, memberIds: [r.id, ...(r.bufferOrderIds ?? [])] })));
|
|
428
|
+
const y = takeRestoreScroll(href);
|
|
429
|
+
if (y != null)
|
|
430
|
+
requestAnimationFrame(() => window.scrollTo({ top: y }));
|
|
431
|
+
}, [paged, userLoading]);
|
|
432
|
+
useEffect(() => {
|
|
433
|
+
const onScroll = () => saveListScroll(window.scrollY);
|
|
434
|
+
window.addEventListener("scroll", onScroll, { passive: true });
|
|
435
|
+
return () => window.removeEventListener("scroll", onScroll);
|
|
436
|
+
}, []);
|
|
329
437
|
const activeEnvironment = data?.environment ?? "staging";
|
|
330
|
-
|
|
438
|
+
// KPI-tegels gelden voor de periode + filters, nooit voor de zoekterm:
|
|
439
|
+
// tijdens zoeken blijven de laatst bekende periodecijfers staan.
|
|
440
|
+
const kpiRef = useRef(null);
|
|
441
|
+
if (data && !isPlaceholderData && !filters.search && data.totals && data.statusCounts) {
|
|
442
|
+
kpiRef.current = { key: baseKey, totals: data.totals, counts: data.statusCounts };
|
|
443
|
+
}
|
|
444
|
+
const kpi = filters.search && kpiRef.current?.key === baseKey ? kpiRef.current : null;
|
|
445
|
+
const totals = kpi?.totals ?? data?.totals ?? {
|
|
331
446
|
revenue: 0,
|
|
332
447
|
avgPrice: 0,
|
|
333
448
|
fustCount: 0,
|
|
@@ -346,6 +461,7 @@ export function VerkoopOrdersPage() {
|
|
|
346
461
|
invoiced: 0,
|
|
347
462
|
problem: 0,
|
|
348
463
|
};
|
|
464
|
+
const kpiCounts = kpi?.counts ?? statusCounts;
|
|
349
465
|
const features = data?.features ?? { erpInvoices: false, pickProgress: false };
|
|
350
466
|
const warnings = data?.warnings ?? [];
|
|
351
467
|
const truncated = data?.truncated ?? false;
|
|
@@ -354,7 +470,7 @@ export function VerkoopOrdersPage() {
|
|
|
354
470
|
// Automatisch verversen wanneer de Authenticatie-module de omgeving wijzigt.
|
|
355
471
|
useEffect(() => {
|
|
356
472
|
const channel = supabase
|
|
357
|
-
.channel(
|
|
473
|
+
.channel(`floriday-settings-env-${Math.random().toString(36).slice(2)}`)
|
|
358
474
|
.on("postgres_changes", { event: "*", schema: "public", table: "floriday_settings" }, () => {
|
|
359
475
|
queryClient.invalidateQueries({ queryKey: ["floriday", "salesorders-list"] });
|
|
360
476
|
})
|
|
@@ -421,22 +537,82 @@ export function VerkoopOrdersPage() {
|
|
|
421
537
|
? new Date(lastSuccessAt).toLocaleTimeString("nl-NL", { hour: "2-digit", minute: "2-digit" })
|
|
422
538
|
: null;
|
|
423
539
|
const toggleTab = (t) => setTab(tab === t ? "all" : t);
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
540
|
+
const trendOf = (cur, prev, goodWhenUp = true) => prevLabel && prevData ? { pct: pctChange(cur, prev), label: prevLabel, goodWhenUp } : null;
|
|
541
|
+
// Sneltoetsen: N nieuwe order, J/K door rijen, Enter openen, ? overzicht.
|
|
542
|
+
const keyState = useRef({ paged, focusedId });
|
|
543
|
+
keyState.current = { paged, focusedId };
|
|
544
|
+
useEffect(() => {
|
|
545
|
+
const onKey = (e) => {
|
|
546
|
+
if (e.metaKey || e.ctrlKey || e.altKey)
|
|
547
|
+
return;
|
|
548
|
+
const t = e.target;
|
|
549
|
+
if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)))
|
|
550
|
+
return;
|
|
551
|
+
if (document.querySelector('[role="dialog"]'))
|
|
552
|
+
return;
|
|
553
|
+
const { paged: rows, focusedId: cur } = keyState.current;
|
|
554
|
+
if (e.key === "?") {
|
|
555
|
+
e.preventDefault();
|
|
556
|
+
setHelpOpen(true);
|
|
557
|
+
}
|
|
558
|
+
else if (e.key === "n" || e.key === "N") {
|
|
559
|
+
e.preventDefault();
|
|
560
|
+
void navigate({ to: "/floriday-verkoop/verkooporders/nieuw" });
|
|
561
|
+
}
|
|
562
|
+
else if (e.key === "j" || e.key === "k") {
|
|
563
|
+
if (!rows.length)
|
|
564
|
+
return;
|
|
565
|
+
e.preventDefault();
|
|
566
|
+
const ids = rows.map(salesOrderRowId);
|
|
567
|
+
const i = cur ? ids.indexOf(cur) : -1;
|
|
568
|
+
const next = e.key === "j" ? Math.min(ids.length - 1, i + 1) : Math.max(0, i < 0 ? 0 : i - 1);
|
|
569
|
+
setFocusedId(ids[next]);
|
|
570
|
+
}
|
|
571
|
+
else if (e.key === "Enter" && cur) {
|
|
572
|
+
const row = rows.find((r) => salesOrderRowId(r) === cur);
|
|
573
|
+
if (row) {
|
|
574
|
+
e.preventDefault();
|
|
575
|
+
void navigate({ to: "/floriday-verkoop/verkooporders/$salesOrderId", params: { salesOrderId: row.id } });
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
else if (e.key === "Escape" && cur) {
|
|
579
|
+
setFocusedId(null);
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
window.addEventListener("keydown", onKey);
|
|
583
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
584
|
+
}, [navigate]);
|
|
585
|
+
useEffect(() => setFocusedId(null), [tab, page, filters]);
|
|
586
|
+
const hasFilters = !!filters.search || activeFilterCount > 0 || tab !== "all";
|
|
587
|
+
const notices = [
|
|
588
|
+
...warnings,
|
|
589
|
+
...(truncated ? ["Niet alle orders konden worden meegenomen. Kies een kortere periode voor een volledig overzicht."] : []),
|
|
590
|
+
];
|
|
591
|
+
return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 pb-[calc(7rem+env(safe-area-inset-bottom))] sm:p-6 sm:pb-24", children: [_jsxs("header", { className: "shrink-0 grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 sm:flex sm:flex-wrap sm:justify-between", children: [_jsx("div", { className: "flex min-w-0 items-center gap-3", children: _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "truncate text-xl font-bold leading-tight sm:text-2xl tracking-tight text-foreground", children: "Verkooporders" }), _jsx("p", { className: "flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground", "aria-live": "polite", children: updatedLabel && (_jsxs("span", { className: "inline-flex items-center gap-1 " + (stale ? "text-warning" : ""), children: [_jsx(Clock, { className: "h-3.5 w-3.5", "aria-hidden": true }), stale ? `Niet bijgewerkt sinds ${updatedLabel}` : `Bijgewerkt ${updatedLabel}`] })) })] }) }), _jsxs("div", { className: "contents sm:flex sm:flex-wrap sm:items-center sm:gap-2", children: [_jsx("div", { className: "order-last col-span-2 sm:order-none sm:col-span-1", children: _jsx(SalesOrdersFilters, { value: filters, onChange: setFilters, part: "period" }) }), _jsxs(Button, { variant: "outline", size: "sm", onClick: handleExport, "aria-label": "Exporteren", className: "h-10 w-10 p-0 sm:h-9 sm:w-auto sm:px-3", children: [_jsx(Download, { className: "h-4 w-4 sm:mr-2" }), " ", _jsx("span", { className: "hidden sm:inline", children: "Exporteren" })] }), _jsxs(Button, { size: "sm", className: "hidden sm:inline-flex", onClick: () => navigate({ to: "/floriday-verkoop/verkooporders/nieuw" }), children: [_jsx(Plus, { className: "mr-2 h-4 w-4" }), " Nieuwe order", _jsx("kbd", { "aria-hidden": true, className: "ml-2 hidden rounded border border-primary-foreground/30 bg-primary-foreground/15 px-1.5 font-mono text-[10px] leading-4 text-primary-foreground sm:inline-block", children: "N" })] })] })] }), syncHealth?.stale && (_jsxs("div", { role: "button", tabIndex: 0, "aria-expanded": syncOpen, onClick: () => setSyncOpen((o) => !o), onKeyDown: (e) => { if (e.key === "Enter" || e.key === " ") {
|
|
592
|
+
e.preventDefault();
|
|
593
|
+
setSyncOpen((o) => !o);
|
|
594
|
+
} }, className: "shrink-0 flex flex-wrap items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3 text-sm md:cursor-default", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive" }), _jsxs("div", { className: "min-w-0 flex-1 md:min-w-[16rem]", children: [_jsx("span", { className: "font-semibold", children: syncHealth.credentialProblem
|
|
429
595
|
? "Er komen geen nieuwe Floriday-orders binnen: de toegang tot Floriday werkt niet."
|
|
430
|
-
: "Er komen op dit moment geen nieuwe Floriday-orders binnen." }), " ", _jsxs("span", { className: "text-muted-foreground", children: ["Laatst met succes opgehaald:", " ", syncHealth.lastSuccessAt
|
|
596
|
+
: "Er komen op dit moment geen nieuwe Floriday-orders binnen." }), " ", _jsxs("span", { className: (syncOpen ? "block mt-1 " : "hidden ") + "text-muted-foreground md:inline md:mt-0", children: ["Laatst met succes opgehaald:", " ", syncHealth.lastSuccessAt
|
|
431
597
|
? new Date(syncHealth.lastSuccessAt).toLocaleString("nl-NL")
|
|
432
598
|
: "nog nooit", syncHealth.lastError ? ` — ${syncHealth.lastError}` : "", syncHealth.failingComponents && syncHealth.failingComponents.length > 0
|
|
433
599
|
? ` — onderdelen die stilliggen: ${syncHealth.failingComponents.join(", ")}`
|
|
434
|
-
: ""] })] }), _jsx("span", { className: "text-xs text-muted-foreground", children: "Handmatig ophalen kan via Instellingen \u203A Floriday." })] })), _jsxs("section", { "aria-label": "Kerncijfers", className: "shrink-0 grid grid-cols-2
|
|
600
|
+
: ""] })] }), _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) => {
|
|
601
|
+
e.stopPropagation();
|
|
602
|
+
toggleTab("backlog");
|
|
603
|
+
}, 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) => {
|
|
604
|
+
e.stopPropagation();
|
|
605
|
+
toggleTab("problem");
|
|
606
|
+
}, 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: features.pickProgress ? `${kpiCounts.problem} probleem` : "probleem onbekend" })] }) })] }), _jsx(StatusTabs, { tab: tab, counts: statusCounts, onChange: setTab }), _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: () => {
|
|
607
|
+
const t = amsterdamYmd();
|
|
608
|
+
const from = ymdString({ ...t, y: t.y - 1, d: t.m === 2 && t.d === 29 ? 28 : t.d });
|
|
609
|
+
setFilters({ ...filters, period: "custom", customFrom: from, customTo: ymdString(t) });
|
|
610
|
+
}, children: "Zoek in het laatste jaar" })), (filters.search || activeFilterCount > 0) && (_jsx(Button, { variant: "ghost", size: "sm", onClick: clearAll, children: "Alles wissen" }))] }), _jsx("div", { className: "shrink-0", children: _jsx(StockConsumptionAlertsBanner, {}) }), error && !data && (_jsxs("div", { role: "alert", className: "shrink-0 flex items-start gap-3 rounded-lg border border-destructive/30 bg-destructive-soft p-4 text-sm", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-5 w-5 shrink-0 text-destructive" }), _jsxs("div", { className: "flex-1", children: [_jsx("div", { className: "font-medium text-destructive-soft-foreground", children: isSessionError(error) ? "Je inlogsessie is verlopen" : "Orders konden niet geladen worden" }), _jsx("div", { className: "mt-1 text-muted-foreground", children: isSessionError(error) ? "Log opnieuw in om de orders te zien." : error.message })] }), isSessionError(error) ? (_jsx(Button, { size: "sm", variant: "outline", onClick: () => navigate({ to: "/login" }), children: "Opnieuw inloggen" })) : (_jsx(Button, { size: "sm", variant: "outline", onClick: () => refetch(), disabled: isFetching, children: "Opnieuw proberen" }))] })), _jsx(NoticeBar, { items: notices }), selectedRows.length === 0 && (_jsx("div", { className: "fixed inset-x-0 bottom-0 z-30 border-t border-border bg-background/90 px-4 pt-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] backdrop-blur sm:hidden", children: _jsxs(Button, { className: "h-12 w-full text-base", onClick: () => navigate({ to: "/floriday-verkoop/verkooporders/nieuw" }), children: [_jsx(Plus, { className: "mr-2 h-5 w-5" }), " Nieuwe order"] }) })), selectedRows.length > 0 && (_jsxs("div", { ref: (el) => {
|
|
435
611
|
if (el && !el.dataset.shown) {
|
|
436
612
|
el.dataset.shown = "1";
|
|
437
613
|
animateIn(el, { duration: 180, y: 8 });
|
|
438
614
|
}
|
|
439
|
-
}, role: "region", "aria-label": "Selectie", className: "fixed inset-x-3 bottom-
|
|
615
|
+
}, role: "region", "aria-label": "Selectie", className: "fixed inset-x-3 bottom-[calc(1rem+env(safe-area-inset-bottom))] z-40 mx-auto flex max-w-2xl flex-wrap items-center justify-between gap-3 rounded-lg border border-border bg-popover p-3 text-popover-foreground shadow-lg", children: [_jsxs("div", { className: "text-sm", children: [_jsx("span", { className: "font-medium", children: selectedRows.length }), " geselecteerd", selectedPlan.total !== selectedRows.length && (_jsxs("span", { className: "text-muted-foreground", children: [" \u00B7 ", selectedPlan.total, " onderliggende order(s)"] })), selectedPlan.skipped > 0 && (_jsxs("span", { className: "text-muted-foreground", children: [" \u00B7 ", selectedPlan.skipped, " Floriday-order(s) worden overgeslagen"] }))] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Button, { variant: "ghost", size: "sm", onClick: () => setSelectedRowIds([]), children: "Selectie wissen" }), _jsx(Button, { size: "sm", className: "bg-destructive text-destructive-foreground hover:bg-destructive/90", disabled: selectedPlan.deletable.length === 0, onClick: () => {
|
|
440
616
|
setCancelReason("");
|
|
441
617
|
setPendingAction({
|
|
442
618
|
rows: selectedRows,
|
|
@@ -444,7 +620,7 @@ export function VerkoopOrdersPage() {
|
|
|
444
620
|
});
|
|
445
621
|
}, children: selectedRows.every((r) => r.stage === "cancelled")
|
|
446
622
|
? "Selectie definitief verwijderen"
|
|
447
|
-
: "Selectie annuleren" })] })] })), _jsx("div", { ref: tableTopRef, className: "min-w-0 scroll-mt-4", children: _jsx(SalesOrdersTable, { orders: paged, features: features, quiet: quiet, fadeKey: viewKey, skeletonRows: pageSize, highlightIds: highlightIds, topSlot: pendingNew > 0 ? (_jsx("div", { className: "flex justify-center border-b border-border p-2", children: _jsxs(Button, { size: "sm", variant: "secondary", onClick: showNewOrders, children: [pendingNew, " ", pendingNew === 1 ? "nieuwe order" : "nieuwe orders", " \u00B7 Tonen"] }) })) : null, emptyText: filters.search || activeFilterCount > 0 || tab !== "all"
|
|
623
|
+
: "Selectie annuleren" })] })] })), _jsx("div", { ref: tableTopRef, className: "min-w-0 scroll-mt-4", children: _jsx(SalesOrdersTable, { orders: paged, features: features, quiet: quiet, fadeKey: viewKey, skeletonRows: pageSize, highlightIds: highlightIds, focusedId: focusedId, rowHeight: 60, emptySlot: hasFilters ? (_jsx(EmptyState, { icon: _jsx(SearchX, { className: "h-6 w-6" }), title: "Geen orders gevonden", text: "Geen orders die aan je zoekopdracht of filters voldoen.", action: _jsxs(Button, { variant: "outline", size: "sm", onClick: clearAll, children: [_jsx(X, { className: "mr-2 h-4 w-4" }), " Filters wissen"] }) })) : (_jsx(EmptyState, { icon: _jsx(Inbox, { className: "h-6 w-6" }), title: "Nog geen orders in deze periode", text: "Kies een andere periode of maak zelf een order aan.", action: _jsxs(Button, { size: "sm", onClick: () => navigate({ to: "/floriday-verkoop/verkooporders/nieuw" }), children: [_jsx(Plus, { className: "mr-2 h-4 w-4" }), " Nieuwe order"] }) })), topSlot: pendingNew > 0 ? (_jsx("div", { className: "flex justify-center border-b border-border p-2", children: _jsxs(Button, { size: "sm", variant: "secondary", onClick: showNewOrders, children: [pendingNew, " ", pendingNew === 1 ? "nieuwe order" : "nieuwe orders", " \u00B7 Tonen"] }) })) : null, emptyText: filters.search || activeFilterCount > 0 || tab !== "all"
|
|
448
624
|
? "Geen orders die aan je zoekopdracht of filters voldoen."
|
|
449
625
|
: "Nog geen orders in deze periode.", onClearFilters: filters.search || activeFilterCount > 0 || tab !== "all" ? clearAll : undefined, loading: userLoading, selectedIds: selectedRowIds, onSelectionChange: setSelectedRowIds, onSelectOrder: (o) => navigate({
|
|
450
626
|
to: "/floriday-verkoop/verkooporders/$salesOrderId",
|
|
@@ -514,5 +690,5 @@ export function VerkoopOrdersPage() {
|
|
|
514
690
|
? "Order annuleren"
|
|
515
691
|
: "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
|
|
516
692
|
? "Geen resultaten"
|
|
517
|
-
: `${(page - 1) * pageSize + 1}–${Math.min(page * pageSize, totalCount)} van ${totalCount}` }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsxs("div", { className: "hidden items-center gap-2 sm:flex", children: [_jsx("span", { children: "Per pagina" }), _jsxs(Select, { value: String(pageSize), onValueChange: (v) => setPageSize(Number(v)), children: [_jsx(SelectTrigger, { className: "h-8 w-20", "aria-label": "Resultaten per pagina", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: [10, 20, 50, 100].map((n) => (_jsx(SelectItem, { value: String(n), children: n }, n))) })] })] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { variant: "outline", size: "icon", className: "h-8 w-8", onClick: () => setPage((p) => Math.max(1, p - 1)), disabled: page <= 1, "aria-label": "Vorige pagina", children: _jsx(ChevronLeft, { className: "h-4 w-4" }) }), _jsxs("div", { className: "px-2 text-foreground tabular-nums", "aria-current": "page", children: [page, " / ", totalPages] }), _jsx(Button, { variant: "outline", size: "icon", className: "h-8 w-8", onClick: () => setPage((p) => Math.min(totalPages, p + 1)), disabled: page >= totalPages, "aria-label": "Volgende pagina", children: _jsx(ChevronRight, { className: "h-4 w-4" }) })] })] })] }), _jsx(SalesOrdersFilterPanel, { open: filterPanelOpen, onOpenChange: setFilterPanelOpen, value: filters, onChange: setFilters })] }));
|
|
693
|
+
: `${(page - 1) * pageSize + 1}–${Math.min(page * pageSize, totalCount)} van ${totalCount}` }), _jsxs("div", { className: "flex items-center gap-3", children: [_jsxs("div", { className: "hidden items-center gap-2 sm:flex", children: [_jsx("span", { children: "Per pagina" }), _jsxs(Select, { value: String(pageSize), onValueChange: (v) => setPageSize(Number(v)), children: [_jsx(SelectTrigger, { className: "h-8 w-20", "aria-label": "Resultaten per pagina", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: [10, 20, 50, 100].map((n) => (_jsx(SelectItem, { value: String(n), children: n }, n))) })] })] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { variant: "outline", size: "icon", className: "h-10 w-10 sm:h-8 sm:w-8", onClick: () => setPage((p) => Math.max(1, p - 1)), disabled: page <= 1, "aria-label": "Vorige pagina", children: _jsx(ChevronLeft, { className: "h-4 w-4" }) }), _jsxs("div", { className: "px-2 text-foreground tabular-nums", "aria-current": "page", children: [page, " / ", totalPages] }), _jsx(Button, { variant: "outline", size: "icon", className: "h-10 w-10 sm:h-8 sm:w-8", onClick: () => setPage((p) => Math.min(totalPages, p + 1)), disabled: page >= totalPages, "aria-label": "Volgende pagina", children: _jsx(ChevronRight, { className: "h-4 w-4" }) })] })] })] }), _jsx(ShortcutHelp, { open: helpOpen, onOpenChange: setHelpOpen }), _jsx(SalesOrdersFilterPanel, { open: filterPanelOpen, onOpenChange: setFilterPanelOpen, value: filters, onChange: setFilters })] }));
|
|
518
694
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/** Minimalistische artikelkaart (vaste breedte) bij aanwijzen van "N artikelen". */
|
|
3
|
+
export declare function ArticlesHover({ ids, count, children }: {
|
|
4
|
+
ids: string[];
|
|
5
|
+
count: number;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=ArticlesHover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArticlesHover.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/v3/ArticlesHover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAsBzD,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,+BA+E5G"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger, Skeleton } from "@flowselections/core";
|
|
5
|
+
import { Flower2 } from "lucide-react";
|
|
6
|
+
import { getOrderArticlesPreview } from "../../../lib/order-articles.functions.js";
|
|
7
|
+
// Eén keer per rij ophalen, daarna onthouden (ook tussen hovers).
|
|
8
|
+
const cache = new Map();
|
|
9
|
+
function Thumb({ src }) {
|
|
10
|
+
const [broken, setBroken] = useState(false);
|
|
11
|
+
return (_jsx("span", { className: "inline-flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded-md bg-muted text-muted-foreground", children: src && !broken ? (_jsx("img", { src: src, alt: "", loading: "lazy", className: "h-full w-full object-cover", onError: () => setBroken(true) })) : (_jsx(Flower2, { className: "h-4 w-4", "aria-hidden": true })) }));
|
|
12
|
+
}
|
|
13
|
+
/** Minimalistische artikelkaart (vaste breedte) bij aanwijzen van "N artikelen". */
|
|
14
|
+
export function ArticlesHover({ ids, count, children }) {
|
|
15
|
+
const fetchPreview = useServerFn(getOrderArticlesPreview);
|
|
16
|
+
const [open, setOpen] = useState(false);
|
|
17
|
+
const [data, setData] = useState(null);
|
|
18
|
+
const [failed, setFailed] = useState(false);
|
|
19
|
+
const timer = useRef(null);
|
|
20
|
+
const key = ids.join("|");
|
|
21
|
+
const load = () => {
|
|
22
|
+
let p = cache.get(key);
|
|
23
|
+
if (!p) {
|
|
24
|
+
p = fetchPreview({ data: { ids } });
|
|
25
|
+
cache.set(key, p);
|
|
26
|
+
p.catch(() => cache.delete(key));
|
|
27
|
+
}
|
|
28
|
+
p.then(setData, () => setFailed(true));
|
|
29
|
+
};
|
|
30
|
+
const show = () => {
|
|
31
|
+
if (timer.current)
|
|
32
|
+
clearTimeout(timer.current);
|
|
33
|
+
timer.current = setTimeout(() => {
|
|
34
|
+
setOpen(true);
|
|
35
|
+
if (!data)
|
|
36
|
+
load();
|
|
37
|
+
}, 150);
|
|
38
|
+
};
|
|
39
|
+
const hide = () => {
|
|
40
|
+
if (timer.current)
|
|
41
|
+
clearTimeout(timer.current);
|
|
42
|
+
timer.current = setTimeout(() => setOpen(false), 100);
|
|
43
|
+
};
|
|
44
|
+
const rest = data ? Math.max(0, data.total - data.items.length) : 0;
|
|
45
|
+
const skeletonRows = Math.min(3, Math.max(1, count));
|
|
46
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { type: "button", "aria-label": "Artikelen bekijken", onPointerEnter: show, onPointerLeave: hide, onFocus: show, onBlur: hide, onClick: (e) => e.stopPropagation(), className: "block max-w-full truncate rounded-sm text-left underline-offset-4 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: children }), _jsxs(PopoverContent, { side: "bottom", align: "start", onPointerEnter: show, onPointerLeave: hide, onOpenAutoFocus: (e) => e.preventDefault(), className: "w-72 p-2", children: [_jsxs("ul", { className: "flex flex-col gap-1", children: [!data && !failed &&
|
|
47
|
+
Array.from({ length: skeletonRows }).map((_, i) => (_jsxs("li", { className: "flex items-center gap-3 p-1", children: [_jsx(Skeleton, { className: "h-9 w-9 rounded-md" }), _jsx(Skeleton, { className: "h-3 flex-1" })] }, i))), failed && _jsx("li", { className: "p-2 text-xs text-muted-foreground", children: "Artikelen konden niet geladen worden." }), data?.items.map((it, i) => (_jsxs("li", { className: "flex items-center gap-3 rounded-md p-1", children: [_jsx(Thumb, { src: it.imageUrl }), _jsx("span", { className: "min-w-0 flex-1 truncate text-sm text-foreground", title: it.name, children: it.name }), it.pieces > 0 && (_jsxs("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: [it.pieces.toLocaleString("nl-NL"), " st"] }))] }, i))), data && data.items.length === 0 && _jsx("li", { className: "p-2 text-xs text-muted-foreground", children: "Geen artikelen gevonden." })] }), rest > 0 && (_jsxs("div", { className: "mt-1 border-t border-border px-2 pt-2 text-xs font-medium text-muted-foreground", children: ["+ ", rest, " meer"] }))] })] }));
|
|
48
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/** Lege toestand: groot zacht icoon, korte zin, één actie. */
|
|
3
|
+
export declare function EmptyState({ icon, title, text, action, }: {
|
|
4
|
+
icon: ReactNode;
|
|
5
|
+
title: string;
|
|
6
|
+
text?: string;
|
|
7
|
+
action?: ReactNode;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=EmptyState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmptyState.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/v3/EmptyState.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,8DAA8D;AAC9D,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,MAAM,GACP,EAAE;IACD,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,+BAaA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** Lege toestand: groot zacht icoon, korte zin, één actie. */
|
|
3
|
+
export function EmptyState({ icon, title, text, action, }) {
|
|
4
|
+
return (_jsxs("div", { className: "flex flex-col items-center gap-3 px-4 py-14 text-center", children: [_jsx("span", { className: "inline-flex h-14 w-14 items-center justify-center rounded-full bg-muted text-muted-foreground", "aria-hidden": true, children: icon }), _jsxs("div", { children: [_jsx("div", { className: "text-sm font-semibold text-foreground", children: title }), text && _jsx("div", { className: "mt-1 max-w-sm text-sm text-muted-foreground", children: text })] }), action] }));
|
|
5
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HoverTip.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/v3/HoverTip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,IAAY,EACZ,KAAgB,EAChB,SAAc,GACf,EAAE;IACD,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,+
|
|
1
|
+
{"version":3,"file":"HoverTip.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/v3/HoverTip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGzD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EACP,KAAK,EACL,QAAQ,EACR,IAAY,EACZ,KAAgB,EAChB,SAAc,GACf,EAAE;IACD,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,+BA4CA"}
|
|
@@ -20,5 +20,5 @@ export function HoverTip({ content, label, children, side = "top", align = "cent
|
|
|
20
20
|
timer.current = setTimeout(() => setOpen(false), 80);
|
|
21
21
|
};
|
|
22
22
|
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { type: "button", "aria-label": label, onPointerEnter: show, onPointerLeave: hide, onFocus: show, onBlur: hide, onClick: (e) => e.stopPropagation(), className: "inline-flex shrink-0 items-center justify-center rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring " +
|
|
23
|
-
className, children: children }), _jsx(PopoverContent, { side: side, align: align, avoidCollisions: true, collisionPadding: 8, onOpenAutoFocus: (e) => e.preventDefault(), onPointerEnter: show, onPointerLeave: hide, onClick: (e) => e.stopPropagation(), className: "w-auto max-w-
|
|
23
|
+
className, children: children }), _jsx(PopoverContent, { side: side, align: align, avoidCollisions: true, collisionPadding: 8, onOpenAutoFocus: (e) => e.preventDefault(), onCloseAutoFocus: (e) => e.preventDefault(), onPointerEnter: show, onPointerLeave: hide, onClick: (e) => e.stopPropagation(), className: "w-auto min-w-[14rem] max-w-[20rem] rounded-lg p-3 text-xs leading-snug shadow-lg motion-reduce:animate-none", children: content })] }));
|
|
24
24
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Kaart in de orderdetail-stijl: icoon + titel, optionele actie rechts.
|
|
4
|
+
* Op telefoon in te klappen, behalve als `attention` aan staat (een
|
|
5
|
+
* openstaande actie of probleem wordt nooit verborgen).
|
|
6
|
+
*/
|
|
7
|
+
export declare function InfoCard({ icon, title, action, children, attention, className, bodyClassName, }: {
|
|
8
|
+
icon?: ReactNode;
|
|
9
|
+
title: ReactNode;
|
|
10
|
+
action?: ReactNode;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
attention?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
bodyClassName?: string;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
/** Label-waarde-regel binnen een InfoCard. */
|
|
17
|
+
export declare function InfoRow({ label, children }: {
|
|
18
|
+
label: string;
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
/** Kerntegel boven de kaarten. */
|
|
22
|
+
export declare function FactTile({ icon, label, value, sub }: {
|
|
23
|
+
icon: ReactNode;
|
|
24
|
+
label: string;
|
|
25
|
+
value: ReactNode;
|
|
26
|
+
sub?: ReactNode;
|
|
27
|
+
}): import("react").JSX.Element;
|
|
28
|
+
//# sourceMappingURL=InfoCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoCard.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/v3/InfoCard.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGjD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAiB,EACjB,SAAc,EACd,aAAkB,GACnB,EAAE;IACD,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,+BA4BA;AAED,8CAA8C;AAC9C,wBAAgB,OAAO,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAOlF;AAED,kCAAkC;AAClC,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,GAAG,CAAC,EAAE,SAAS,CAAA;CAAE,+BAa1H"}
|