@flowselections/floriday-verkoop-module 1.0.8 → 1.0.9
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/floriday/FlorydaySyncHealthBanner.d.ts +9 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts.map +1 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.js +26 -0
- package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.js +6 -9
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +2 -1
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +2667 -169
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +2667 -169
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +2667 -169
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +2736 -155
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.js +2 -0
- package/dist-lib/lib/floriday-gateway.server.d.ts +42 -0
- package/dist-lib/lib/floriday-gateway.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-gateway.server.js +222 -0
- package/dist-lib/lib/floriday-public.functions.d.ts +63971 -0
- package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-public.functions.js +210 -0
- package/dist-lib/lib/floriday-sync.d.ts.map +1 -1
- package/dist-lib/lib/floriday-sync.js +18 -79
- package/dist-lib/lib/floriday-writes.functions.d.ts +45678 -0
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-writes.functions.js +110 -0
- package/dist-lib/lib/salesorders.functions.d.ts +17178 -9683
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.js +44 -86
- package/dist-lib/lib/tradeitems.functions.d.ts +2667 -169
- package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.js +11 -25
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
environment: "staging" | "live";
|
|
3
|
+
resources: string[];
|
|
4
|
+
/** Max minuten dat een sync mag achterlopen voordat de banner verschijnt. */
|
|
5
|
+
staleAfterMinutes?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function FlorydaySyncHealthBanner({ environment, resources, staleAfterMinutes, }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=FlorydaySyncHealthBanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlorydaySyncHealthBanner.d.ts","sourceRoot":"","sources":["../../../src/components/floriday/FlorydaySyncHealthBanner.tsx"],"names":[],"mappings":"AAKA,UAAU,KAAK;IACb,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,6EAA6E;IAC7E,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,wBAAwB,CAAC,EACvC,WAAW,EACX,SAAS,EACT,iBAAsB,GACvB,EAAE,KAAK,kDAmCP"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
4
|
+
import { AlertTriangle } from "lucide-react";
|
|
5
|
+
import { getFlorydaySyncHealth } from "../../lib/floriday-public.functions";
|
|
6
|
+
export function FlorydaySyncHealthBanner({ environment, resources, staleAfterMinutes = 30, }) {
|
|
7
|
+
const fetchHealth = useServerFn(getFlorydaySyncHealth);
|
|
8
|
+
const { data } = useQuery({
|
|
9
|
+
queryKey: ["floriday", "sync-health", environment, resources.join(",")],
|
|
10
|
+
queryFn: () => fetchHealth({ data: { environment, resources } }),
|
|
11
|
+
staleTime: 60000,
|
|
12
|
+
refetchInterval: 120000,
|
|
13
|
+
});
|
|
14
|
+
if (!data || !data.resources)
|
|
15
|
+
return null;
|
|
16
|
+
const now = Date.now();
|
|
17
|
+
const stale = data.resources.filter((r) => {
|
|
18
|
+
if (!r.lastSyncedAt)
|
|
19
|
+
return true;
|
|
20
|
+
const age = (now - new Date(r.lastSyncedAt).getTime()) / 60000;
|
|
21
|
+
return age > staleAfterMinutes || Boolean(r.lastError);
|
|
22
|
+
});
|
|
23
|
+
if (stale.length === 0)
|
|
24
|
+
return null;
|
|
25
|
+
return (_jsxs("div", { className: "flex items-start gap-3 rounded-md border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-900", children: [_jsx(AlertTriangle, { className: "mt-0.5 h-4 w-4 shrink-0" }), _jsxs("div", { className: "space-y-1", children: [_jsx("div", { className: "font-medium", children: "Floriday-data is mogelijk verouderd" }), _jsx("ul", { className: "space-y-0.5 text-xs", children: stale.map((r) => (_jsxs("li", { children: [_jsx("strong", { children: r.resource }), ":", " ", r.lastSyncedAt ? `laatste sync ${new Date(r.lastSyncedAt).toLocaleString("nl-NL")}` : "nooit gesynchroniseerd", r.lastError ? ` — ${r.lastError}` : ""] }, r.resource))) })] })] }));
|
|
26
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CreateOrderPage.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/CreateOrderPage.tsx"],"names":[],"mappings":"AA4IA,wBAAgB,eAAe,4CAoX9B"}
|
|
@@ -5,6 +5,8 @@ import { Link, useNavigate } from "@tanstack/react-router";
|
|
|
5
5
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
6
6
|
import { ArrowLeft, ChevronDown, Plus, Search, Trash2, Truck, MapPin, } from "lucide-react";
|
|
7
7
|
import { supabase } from "../../integrations/supabase/client";
|
|
8
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
9
|
+
import { getFlorydayCachedList } from "../../lib/floriday-public.functions";
|
|
8
10
|
const eur = new Intl.NumberFormat("nl-NL", {
|
|
9
11
|
style: "currency",
|
|
10
12
|
currency: "EUR",
|
|
@@ -49,25 +51,20 @@ function useCustomersForOrder() {
|
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
function useProductsForOrder() {
|
|
54
|
+
const fetchCachedList = useServerFn(getFlorydayCachedList);
|
|
52
55
|
return useQuery({
|
|
53
56
|
queryKey: ["create-order", "products"],
|
|
54
57
|
queryFn: async () => {
|
|
55
|
-
const [localRes,
|
|
58
|
+
const [localRes, floridayList] = await Promise.all([
|
|
56
59
|
supabase
|
|
57
60
|
.from("products")
|
|
58
61
|
.select("id, product, sale_price, unit")
|
|
59
62
|
.order("product", { ascending: true })
|
|
60
63
|
.limit(2000),
|
|
61
|
-
|
|
62
|
-
.from("floriday_trade_items_cache")
|
|
63
|
-
.select("floriday_id, data")
|
|
64
|
-
.eq("is_deleted", false)
|
|
65
|
-
.limit(5000),
|
|
64
|
+
fetchCachedList({ data: { environment: "staging", entity: "trade-items", limit: 5000 } }),
|
|
66
65
|
]);
|
|
67
66
|
if (localRes.error)
|
|
68
67
|
throw localRes.error;
|
|
69
|
-
if (floridayRes.error)
|
|
70
|
-
throw floridayRes.error;
|
|
71
68
|
const out = [];
|
|
72
69
|
for (const r of localRes.data ?? []) {
|
|
73
70
|
out.push({
|
|
@@ -78,7 +75,7 @@ function useProductsForOrder() {
|
|
|
78
75
|
unit: r.unit ?? null,
|
|
79
76
|
});
|
|
80
77
|
}
|
|
81
|
-
for (const r of
|
|
78
|
+
for (const r of floridayList.rows ?? []) {
|
|
82
79
|
const d = r.data ?? {};
|
|
83
80
|
const name = pickStr(d.name) ??
|
|
84
81
|
pickStr(d.productName) ??
|
|
@@ -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":"AA6DA,wBAAgB,iBAAiB,4CA6RhC"}
|
|
@@ -12,6 +12,7 @@ import { AnalyticsCards } from "./AnalyticsCards";
|
|
|
12
12
|
import { SalesOrdersFilters } from "./SalesOrdersFilters";
|
|
13
13
|
import { SalesOrdersFilterPanel, countActiveFilters, } from "./SalesOrdersFilterPanel";
|
|
14
14
|
import { SalesOrdersTable } from "./SalesOrdersTable";
|
|
15
|
+
import { FlorydaySyncHealthBanner } from "../../components/floriday/FlorydaySyncHealthBanner";
|
|
15
16
|
const STATUS_TABS = [
|
|
16
17
|
{ id: "all", label: "Alle" },
|
|
17
18
|
{ id: "open", label: "Open" },
|
|
@@ -127,7 +128,7 @@ export function VerkoopOrdersPage() {
|
|
|
127
128
|
setSyncing(false);
|
|
128
129
|
}
|
|
129
130
|
};
|
|
130
|
-
return (_jsxs("main", { className: "space-y-5 p-6", children: [_jsx("div", { className: "flex items-center justify-between border-b border-border", children: _jsx("div", { className: "flex items-center gap-6 overflow-x-auto", children: STATUS_TABS.map((t) => {
|
|
131
|
+
return (_jsxs("main", { className: "space-y-5 p-6", children: [_jsx(FlorydaySyncHealthBanner, { environment: "staging", resources: ["sales-orders", "trade-items", "customer-organizations"] }), _jsx("div", { className: "flex items-center justify-between border-b border-border", children: _jsx("div", { className: "flex items-center gap-6 overflow-x-auto", children: STATUS_TABS.map((t) => {
|
|
131
132
|
const active = tab === t.id;
|
|
132
133
|
const count = statusCounts[t.id];
|
|
133
134
|
return (_jsxs("button", { type: "button", onClick: () => setTab(t.id), className: "relative -mb-px flex items-center gap-2 whitespace-nowrap border-b-2 px-1 pb-3 pt-1 text-sm transition-colors " +
|