@flowselections/floriday-verkoop-module 1.0.38 → 1.0.40
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/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +50 -87
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +849 -60
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +849 -60
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +849 -60
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +830 -39
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/cart-lock.functions.d.ts +849 -60
- package/dist-lib/lib/cart-lock.functions.d.ts.map +1 -1
- package/dist-lib/lib/cart-planning-settings.functions.d.ts +8679 -0
- package/dist-lib/lib/cart-planning-settings.functions.d.ts.map +1 -1
- package/dist-lib/lib/cart-replan.functions.d.ts +2565 -198
- package/dist-lib/lib/cart-replan.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.d.ts +11835 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +2565 -198
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-logistic-labels.functions.d.ts +849 -60
- package/dist-lib/lib/floriday-logistic-labels.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.d.ts +849 -60
- package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-public.functions.d.ts +5523 -0
- package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-writes.functions.d.ts +4505 -560
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
- package/dist-lib/lib/load-carriers.functions.d.ts +849 -60
- package/dist-lib/lib/load-carriers.functions.d.ts.map +1 -1
- package/dist-lib/lib/logistics-engine.functions.d.ts +4511 -562
- package/dist-lib/lib/logistics-engine.functions.d.ts.map +1 -1
- package/dist-lib/lib/logistics-stock.functions.d.ts +1578 -0
- package/dist-lib/lib/logistics-stock.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-addresses.functions.d.ts +849 -60
- package/dist-lib/lib/order-addresses.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-buffers.functions.d.ts +2565 -198
- package/dist-lib/lib/order-buffers.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-carrier.functions.d.ts +1578 -0
- package/dist-lib/lib/order-carrier.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-pickup.functions.d.ts +1578 -0
- package/dist-lib/lib/order-pickup.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-shipments.functions.d.ts +3535 -379
- package/dist-lib/lib/order-shipments.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.functions.d.ts +20393 -0
- package/dist-lib/lib/salesorders-list.functions.d.ts.map +1 -0
- package/dist-lib/lib/salesorders-list.functions.js +21 -0
- package/dist-lib/lib/salesorders-list.server.d.ts +28 -0
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -0
- package/dist-lib/lib/salesorders-list.server.js +713 -0
- package/dist-lib/lib/salesorders.functions.d.ts +4505 -560
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/tradeitems.functions.d.ts +849 -60
- package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.d.ts +24 -3
- package/dist-lib/lib/useSalesOrdersQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.js +49 -594
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerkoopOrdersPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/VerkoopOrdersPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VerkoopOrdersPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/VerkoopOrdersPage.tsx"],"names":[],"mappings":"AA8DA,wBAAgB,iBAAiB,gCA+YhC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect,
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
3
|
import { Button, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, toast, } from "@flowselections/core";
|
|
4
4
|
import { Download, Plus, AlertTriangle, RefreshCw, ChevronLeft, ChevronRight, Filter, } from "lucide-react";
|
|
5
5
|
import { useServerFn } from "@tanstack/react-start";
|
|
@@ -9,8 +9,9 @@ import { supabase } from "../../integrations/supabase/client";
|
|
|
9
9
|
import { runSalesOrdersSync } from "../../lib/salesorders.functions";
|
|
10
10
|
import { deleteLocalOrder } from "../../lib/create-order.functions";
|
|
11
11
|
import { runTradeItemsSync } from "../../lib/tradeitems.functions";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { ordersToCsv, } from "../../lib/salesorders-mapping";
|
|
13
|
+
import { listSalesOrders } from "../../lib/salesorders-list.functions";
|
|
14
|
+
import { derivePeriodWindow, useSalesOrdersQuery } from "../../lib/useSalesOrdersQuery";
|
|
14
15
|
import { AnalyticsCards } from "./AnalyticsCards";
|
|
15
16
|
import { SalesOrdersFilters } from "./SalesOrdersFilters";
|
|
16
17
|
import { SalesOrdersFilterPanel, countActiveFilters, } from "./SalesOrdersFilterPanel";
|
|
@@ -23,35 +24,8 @@ const STATUS_TABS = [
|
|
|
23
24
|
{ id: "invoiced", label: "Gefactureerd" },
|
|
24
25
|
{ id: "cancelled", label: "Geannuleerd" },
|
|
25
26
|
];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return true;
|
|
29
|
-
if (tab === "cancelled")
|
|
30
|
-
return o.status.isCancelled;
|
|
31
|
-
if (tab === "shipped")
|
|
32
|
-
return o.status.isShipped;
|
|
33
|
-
if (tab === "invoiced")
|
|
34
|
-
return o.status.isInvoiced;
|
|
35
|
-
if (tab === "open")
|
|
36
|
-
return !o.status.isCancelled && !o.status.isShipped;
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Groepeer orders die tot dezelfde buffer horen tot één "logische" order.
|
|
41
|
-
* Wordt gebruikt voor tellingen en totalen zodat een buffer als 1 order geldt.
|
|
42
|
-
*/
|
|
43
|
-
function collapseBuffers(orders) {
|
|
44
|
-
const seen = new Set();
|
|
45
|
-
const out = [];
|
|
46
|
-
for (const o of orders) {
|
|
47
|
-
const key = o.bufferId && (o.bufferSize ?? 1) > 1 ? `buf:${o.bufferId}` : `one:${o.id}`;
|
|
48
|
-
if (seen.has(key))
|
|
49
|
-
continue;
|
|
50
|
-
seen.add(key);
|
|
51
|
-
out.push(o);
|
|
52
|
-
}
|
|
53
|
-
return out;
|
|
54
|
-
}
|
|
27
|
+
// Statusfiltering, buffer-groepering en totalen gebeuren serverside
|
|
28
|
+
// (zie src/lib/salesorders-list.server.ts).
|
|
55
29
|
export function VerkoopOrdersPage() {
|
|
56
30
|
const [tab, setTab] = useState("all");
|
|
57
31
|
const [filterPanelOpen, setFilterPanelOpen] = useState(false);
|
|
@@ -101,81 +75,70 @@ export function VerkoopOrdersPage() {
|
|
|
101
75
|
setDeleting(false);
|
|
102
76
|
}
|
|
103
77
|
};
|
|
104
|
-
|
|
105
|
-
|
|
78
|
+
// Serverside gefilterd, gesorteerd en gepagineerd: de browser krijgt alleen
|
|
79
|
+
// de zichtbare pagina plus totalen/tellingen.
|
|
80
|
+
const { data, isLoading, error, refetch, isFetching } = useSalesOrdersQuery(filters, {
|
|
81
|
+
tab,
|
|
82
|
+
page,
|
|
83
|
+
pageSize,
|
|
84
|
+
});
|
|
85
|
+
const paged = data?.orders ?? [];
|
|
106
86
|
const activeEnvironment = data?.environment ?? "staging";
|
|
107
|
-
|
|
87
|
+
const totals = data?.totals ?? {
|
|
88
|
+
revenue: 0,
|
|
89
|
+
avgPrice: 0,
|
|
90
|
+
fustCount: 0,
|
|
91
|
+
karCount: 0,
|
|
92
|
+
orderCount: 0,
|
|
93
|
+
};
|
|
94
|
+
const statusCounts = data?.statusCounts ?? {
|
|
95
|
+
all: 0,
|
|
96
|
+
open: 0,
|
|
97
|
+
shipped: 0,
|
|
98
|
+
invoiced: 0,
|
|
99
|
+
cancelled: 0,
|
|
100
|
+
};
|
|
101
|
+
const totalCount = data?.totalCount ?? 0;
|
|
102
|
+
const fetchListForExport = useServerFn(listSalesOrders);
|
|
103
|
+
// Automatisch verversen wanneer de Authenticatie-module de omgeving wijzigt.
|
|
108
104
|
useEffect(() => {
|
|
109
105
|
const channel = supabase
|
|
110
106
|
.channel("floriday-settings-env")
|
|
111
107
|
.on("postgres_changes", { event: "*", schema: "public", table: "floriday_settings" }, () => {
|
|
112
|
-
queryClient.invalidateQueries({ queryKey: ["floriday", "salesorders-
|
|
108
|
+
queryClient.invalidateQueries({ queryKey: ["floriday", "salesorders-list"] });
|
|
113
109
|
})
|
|
114
110
|
.subscribe();
|
|
115
111
|
return () => {
|
|
116
112
|
supabase.removeChannel(channel);
|
|
117
113
|
};
|
|
118
114
|
}, [queryClient]);
|
|
119
|
-
// Realtime — lijst live bijwerken zodra cache-regels binnenkomen/wijzigen.
|
|
120
|
-
useEffect(() => {
|
|
121
|
-
let timer = null;
|
|
122
|
-
const invalidate = () => {
|
|
123
|
-
if (timer)
|
|
124
|
-
clearTimeout(timer);
|
|
125
|
-
timer = setTimeout(() => {
|
|
126
|
-
queryClient.invalidateQueries({ queryKey: ["floriday", "salesorders-cache"] });
|
|
127
|
-
}, 500);
|
|
128
|
-
};
|
|
129
|
-
const channel = supabase
|
|
130
|
-
.channel("floriday-salesorders-cache")
|
|
131
|
-
.on("postgres_changes", { event: "*", schema: "public", table: "floriday_salesorders_cache" }, invalidate)
|
|
132
|
-
.on("postgres_changes", { event: "*", schema: "public", table: "floriday_fulfillment_orders_cache" }, invalidate)
|
|
133
|
-
.subscribe();
|
|
134
|
-
return () => {
|
|
135
|
-
if (timer)
|
|
136
|
-
clearTimeout(timer);
|
|
137
|
-
supabase.removeChannel(channel);
|
|
138
|
-
};
|
|
139
|
-
}, [queryClient]);
|
|
140
|
-
const statusFiltered = useMemo(() => orders.filter((o) => matchesStatus(o, tab)), [orders, tab]);
|
|
141
|
-
const filtered = useMemo(() => applyFilters(statusFiltered, filters), [statusFiltered, filters]);
|
|
142
|
-
const totals = useMemo(() => computeTotals(collapseBuffers(filtered)), [filtered]);
|
|
143
|
-
const statusCounts = useMemo(() => {
|
|
144
|
-
const base = collapseBuffers(applyFilters(orders, filters));
|
|
145
|
-
const counts = {
|
|
146
|
-
all: base.length,
|
|
147
|
-
open: 0,
|
|
148
|
-
shipped: 0,
|
|
149
|
-
invoiced: 0,
|
|
150
|
-
cancelled: 0,
|
|
151
|
-
};
|
|
152
|
-
for (const o of base) {
|
|
153
|
-
if (o.status.isCancelled)
|
|
154
|
-
counts.cancelled++;
|
|
155
|
-
else if (o.status.isShipped)
|
|
156
|
-
counts.shipped++;
|
|
157
|
-
else
|
|
158
|
-
counts.open++;
|
|
159
|
-
if (o.status.isInvoiced)
|
|
160
|
-
counts.invoiced++;
|
|
161
|
-
}
|
|
162
|
-
return counts;
|
|
163
|
-
}, [orders, filters]);
|
|
164
115
|
const activeFilterCount = countActiveFilters(filters);
|
|
165
|
-
const totalCount = filtered.length;
|
|
166
116
|
const totalPages = Math.max(1, Math.ceil(totalCount / pageSize));
|
|
167
117
|
useEffect(() => {
|
|
168
118
|
if (page > totalPages)
|
|
169
119
|
setPage(totalPages);
|
|
170
120
|
}, [page, totalPages]);
|
|
171
|
-
// Reset naar pagina 1 als filters wijzigen
|
|
121
|
+
// Reset naar pagina 1 als filters, tab of paginagrootte wijzigen
|
|
172
122
|
useEffect(() => {
|
|
173
123
|
setPage(1);
|
|
174
|
-
}, [filters, pageSize]);
|
|
175
|
-
const
|
|
176
|
-
const handleExport = () => {
|
|
124
|
+
}, [filters, pageSize, tab]);
|
|
125
|
+
const handleExport = async () => {
|
|
177
126
|
try {
|
|
178
|
-
const
|
|
127
|
+
const win = derivePeriodWindow(filters);
|
|
128
|
+
const res = await fetchListForExport({
|
|
129
|
+
data: {
|
|
130
|
+
since: win.since,
|
|
131
|
+
until: win.until,
|
|
132
|
+
dateField: win.dateField,
|
|
133
|
+
search: filters.search,
|
|
134
|
+
status: filters.status,
|
|
135
|
+
tab,
|
|
136
|
+
page: 1,
|
|
137
|
+
pageSize: 200,
|
|
138
|
+
all: true,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
const { csv, filename } = ordersToCsv(res.rows);
|
|
179
142
|
const blob = new Blob(["\ufeff" + csv], { type: "text/csv;charset=utf-8" });
|
|
180
143
|
const url = URL.createObjectURL(blob);
|
|
181
144
|
const a = document.createElement("a");
|