@flowselections/dashboard-planner-installatie-techniek 1.0.42 → 1.1.1
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/README.md +24 -0
- package/dist-lib/components/DashboardDagNotities.d.ts +4 -1
- package/dist-lib/components/DashboardDagNotities.d.ts.map +1 -1
- package/dist-lib/components/DashboardDagNotities.js +99 -22
- package/dist-lib/components/DashboardPlannerInstallatieTechniekPage.d.ts.map +1 -1
- package/dist-lib/components/DashboardPlannerInstallatieTechniekPage.js +2 -2
- package/dist-lib/components/DashboardStatistieken.d.ts +3 -1
- package/dist-lib/components/DashboardStatistieken.d.ts.map +1 -1
- package/dist-lib/components/DashboardStatistieken.js +2 -2
- package/dist-lib/components/WerkurenGrafiek.d.ts +5 -3
- package/dist-lib/components/WerkurenGrafiek.d.ts.map +1 -1
- package/dist-lib/components/WerkurenGrafiek.js +11 -10
- package/dist-lib/components/settings/DashboardInstellingenCard.d.ts +2 -0
- package/dist-lib/components/settings/DashboardInstellingenCard.d.ts.map +1 -0
- package/dist-lib/components/settings/DashboardInstellingenCard.js +74 -0
- package/dist-lib/components/ui/sankey-chart.d.ts.map +1 -1
- package/dist-lib/components/ui/sankey-chart.js +32 -4
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +3 -1
- package/dist-lib/integrations/supabase/types.d.ts +3485 -1
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/dashboard-constanten.d.ts +1 -1
- package/dist-lib/lib/dashboard-constanten.d.ts.map +1 -1
- package/dist-lib/lib/dashboard-constanten.js +3 -4
- package/dist-lib/lib/dashboard-dagnotities.d.ts +15 -0
- package/dist-lib/lib/dashboard-dagnotities.d.ts.map +1 -1
- package/dist-lib/lib/dashboard-dagnotities.js +26 -3
- package/dist-lib/lib/dashboard-instellingen.d.ts +18 -0
- package/dist-lib/lib/dashboard-instellingen.d.ts.map +1 -0
- package/dist-lib/lib/dashboard-instellingen.js +83 -0
- package/dist-lib/lib/dashboard-planner-installatie-techniek.functions.js +3 -3
- package/dist-lib/lib/dashboard-planner-installatie-techniek.server.d.ts.map +1 -1
- package/dist-lib/lib/dashboard-planner-installatie-techniek.server.js +5 -1
- package/dist-lib/lib/dashboard-planner-installatie-techniek.stats.server.d.ts +44 -7
- package/dist-lib/lib/dashboard-planner-installatie-techniek.stats.server.d.ts.map +1 -1
- package/dist-lib/lib/dashboard-planner-installatie-techniek.stats.server.js +206 -76
- package/dist-lib/lib/dashboard-planner-installatie-techniek.types.d.ts +7 -0
- package/dist-lib/lib/dashboard-planner-installatie-techniek.types.d.ts.map +1 -1
- package/dist-lib/lib/rekenregels.d.ts +52 -0
- package/dist-lib/lib/rekenregels.d.ts.map +1 -0
- package/dist-lib/lib/rekenregels.js +129 -0
- package/package.json +47 -15
package/README.md
CHANGED
|
@@ -21,3 +21,27 @@ cd <repository-name>
|
|
|
21
21
|
npm i
|
|
22
22
|
npm run dev
|
|
23
23
|
```
|
|
24
|
+
|
|
25
|
+
## Instellingen (tabel `dashboard_pit_instellingen`)
|
|
26
|
+
Beheer via de instellingenkaart "Dashboard installatietechniek". Ontbreekt een waarde, dan geldt de standaard (= huidig gedrag).
|
|
27
|
+
|
|
28
|
+
| Sleutel | Standaard | Betekenis |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| tijdzone | Europe/Amsterdam | Dag-, week- en maandgrenzen |
|
|
31
|
+
| betaal_periode_dagen | 28 | Periode van het betaalpercentage |
|
|
32
|
+
| week_start | 1 (maandag) | Eerste dag van de urengrafiek |
|
|
33
|
+
| max_weken_terug | 6 | Weeknavigatie in de urengrafiek |
|
|
34
|
+
| ftf_periode_dagen | 365 | Alleen met `ftf_met_periode` |
|
|
35
|
+
| tellen_in_database | false | Statistieken via RPC's (geen 1000-rijengrens) |
|
|
36
|
+
| lokale_maandgrens | false | "Afgerond deze maand" in lokale tijdzone |
|
|
37
|
+
| uren_uit_duur_minuten | false | Uren uit `werkbon_time_logs.duur_minuten` |
|
|
38
|
+
| ftf_met_periode | false | First-time-fix alleen over de periode |
|
|
39
|
+
| notitie_vergrendeling | false | Dagnotities met optimistische vergrendeling |
|
|
40
|
+
|
|
41
|
+
Gedeelde rekenregels staan in `src/lib/rekenregels.ts`.
|
|
42
|
+
|
|
43
|
+
## Changelog
|
|
44
|
+
### 1.1.0
|
|
45
|
+
- Migratie: tabel `dashboard_pit_instellingen` en RPC's `dashboard_pit_omzet_open`, `dashboard_pit_offertes`, `dashboard_pit_werkuren`, `dashboard_pit_ftf`, `dashboard_pit_facturen_betaald`, `dashboard_dagnotitie_bewaar` (security invoker).
|
|
46
|
+
- Nieuwe instellingen en schakelaars (alle schakelaars standaard uit = huidig gedrag).
|
|
47
|
+
- Dagnotities: direct opslaan bij dag-/zichtwissel (altijd aan).
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/** `vergrendeling`: optimistische vergrendeling (instelling notitie_vergrendeling, standaard uit). */
|
|
2
|
+
export declare function DashboardDagNotities({ vergrendeling }?: {
|
|
3
|
+
vergrendeling?: boolean;
|
|
4
|
+
}): import("react").JSX.Element;
|
|
2
5
|
//# sourceMappingURL=DashboardDagNotities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardDagNotities.d.ts","sourceRoot":"","sources":["../../src/components/DashboardDagNotities.tsx"],"names":[],"mappings":"AAYA,wBAAgB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"DashboardDagNotities.d.ts","sourceRoot":"","sources":["../../src/components/DashboardDagNotities.tsx"],"names":[],"mappings":"AAYA,sGAAsG;AACtG,wBAAgB,oBAAoB,CAAC,EAAE,aAAqB,EAAE,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,+BAmI/F"}
|
|
@@ -1,52 +1,129 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
import { ChevronLeft, ChevronRight, StickyNote } from "lucide-react";
|
|
5
|
-
import { supabase, toast } from "@flowselections/core";
|
|
4
|
+
import { ChevronLeft, ChevronRight, Lock, StickyNote, Users } from "lucide-react";
|
|
5
|
+
import { supabase, toast, useAuth } from "@flowselections/core";
|
|
6
6
|
import { dashboardDatum } from "../lib/dashboard-constanten";
|
|
7
|
-
import { dagNaam, knipNotitie, verschuifDag, metPunten, PUNT, MAX_NOTITIE_LENGTE } from "../lib/dashboard-dagnotities";
|
|
7
|
+
import { dagNaam, knipNotitie, verschuifDag, metPunten, PUNT, MAX_NOTITIE_LENGTE, notitieEigenaar, bewaarWijze, moetFlushen, leesBewaarUitkomst, CONFLICT_MELDING } from "../lib/dashboard-dagnotities";
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
9
|
const db = supabase;
|
|
10
|
-
|
|
10
|
+
/** `vergrendeling`: optimistische vergrendeling (instelling notitie_vergrendeling, standaard uit). */
|
|
11
|
+
export function DashboardDagNotities({ vergrendeling = false } = {}) {
|
|
11
12
|
const [datum, setDatum] = useState(null);
|
|
12
13
|
const [tekst, setTekst] = useState("");
|
|
13
14
|
const [bewaren, setBewaren] = useState("");
|
|
14
15
|
const vuil = useRef(false);
|
|
16
|
+
const timer = useRef(null);
|
|
17
|
+
const geladen = useRef(null);
|
|
15
18
|
const queryClient = useQueryClient();
|
|
16
|
-
|
|
19
|
+
const { user } = useAuth();
|
|
20
|
+
const [zicht, setZicht] = useState("iedereen");
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setDatum(dashboardDatum());
|
|
23
|
+
if (window.localStorage.getItem("dashboard-notitie-zicht") === "mij")
|
|
24
|
+
setZicht("mij");
|
|
25
|
+
}, []);
|
|
26
|
+
const eigenaar = notitieEigenaar(zicht, user?.id);
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
const filter2 = (q, eig) => (eig === null ? q.is("eigenaar", null) : q.eq("eigenaar", eig));
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
|
+
const filter = (q) => (eigenaar === null ? q.is("eigenaar", null) : q.eq("eigenaar", eigenaar));
|
|
17
31
|
const { data, isLoading } = useQuery({
|
|
18
|
-
queryKey: ["dashboard-dagnotitie", datum],
|
|
19
|
-
enabled: !!datum,
|
|
32
|
+
queryKey: ["dashboard-dagnotitie", datum, zicht, user?.id],
|
|
33
|
+
enabled: !!datum && eigenaar !== undefined,
|
|
20
34
|
queryFn: async () => {
|
|
21
|
-
const { data, error } = await db.from("dashboard_dagnotities").select("tekst, updated_at").eq("datum", datum).maybeSingle();
|
|
35
|
+
const { data, error } = await filter(db.from("dashboard_dagnotities").select("tekst, updated_at").eq("datum", datum)).maybeSingle();
|
|
22
36
|
if (error)
|
|
23
37
|
throw error;
|
|
24
38
|
return { tekst: typeof data?.tekst === "string" ? data.tekst : "", updated_at: data?.updated_at ?? null };
|
|
25
39
|
},
|
|
26
40
|
});
|
|
27
41
|
useEffect(() => {
|
|
28
|
-
if (data && !vuil.current)
|
|
42
|
+
if (data && !vuil.current) {
|
|
29
43
|
setTekst(metPunten(data.tekst));
|
|
44
|
+
geladen.current = data.updated_at;
|
|
45
|
+
}
|
|
30
46
|
}, [data]);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const d = datum;
|
|
35
|
-
const t = window.setTimeout(async () => {
|
|
47
|
+
/** Slaat één notitie op; met vergrendeling via de RPC (conflict = niet overschrijven). */
|
|
48
|
+
const bewaar = async (d, z, eig, t, opDezePagina) => {
|
|
49
|
+
if (opDezePagina)
|
|
36
50
|
setBewaren("bezig");
|
|
37
|
-
|
|
51
|
+
const sleutel = ["dashboard-dagnotitie", d, z, user?.id];
|
|
52
|
+
let updatedAt = new Date().toISOString();
|
|
53
|
+
if (bewaarWijze(vergrendeling) === "vergrendeld") {
|
|
54
|
+
const { data: r, error } = await db.rpc("dashboard_dagnotitie_bewaar", { _datum: d, _eigenaar: eig, _tekst: t, _verwacht: opDezePagina ? geladen.current : queryClient.getQueryData(sleutel)?.updated_at ?? null });
|
|
55
|
+
const u = error ? null : leesBewaarUitkomst(r);
|
|
56
|
+
if (!u) {
|
|
57
|
+
console.error("[dagnotities] bewaren mislukt:", error ?? r);
|
|
58
|
+
if (opDezePagina)
|
|
59
|
+
setBewaren("");
|
|
60
|
+
toast.error("Notitie kon niet worden bewaard");
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (u.status === "conflict") {
|
|
64
|
+
if (opDezePagina) {
|
|
65
|
+
setBewaren("");
|
|
66
|
+
vuil.current = false;
|
|
67
|
+
}
|
|
68
|
+
toast.error(CONFLICT_MELDING);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
updatedAt = u.updated_at;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const upd = await filter2(db.from("dashboard_dagnotities").update({ tekst: t }).eq("datum", d), eig).select("id, updated_at");
|
|
75
|
+
let error = upd.error;
|
|
76
|
+
if (!error && Array.isArray(upd.data) && upd.data[0]?.updated_at)
|
|
77
|
+
updatedAt = upd.data[0].updated_at;
|
|
78
|
+
if (!error && (!Array.isArray(upd.data) || upd.data.length === 0)) {
|
|
79
|
+
const ins = await db.from("dashboard_dagnotities").insert({ datum: d, tekst: t, eigenaar: eig }).select("updated_at").maybeSingle();
|
|
80
|
+
error = ins.error;
|
|
81
|
+
if (ins.data?.updated_at)
|
|
82
|
+
updatedAt = ins.data.updated_at;
|
|
83
|
+
}
|
|
38
84
|
if (error) {
|
|
39
|
-
|
|
85
|
+
console.error("[dagnotities] bewaren mislukt:", error);
|
|
86
|
+
if (opDezePagina)
|
|
87
|
+
setBewaren("");
|
|
40
88
|
toast.error("Notitie kon niet worden bewaard");
|
|
41
89
|
return;
|
|
42
90
|
}
|
|
91
|
+
}
|
|
92
|
+
if (opDezePagina) {
|
|
43
93
|
vuil.current = false;
|
|
44
94
|
setBewaren("bewaard");
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
95
|
+
geladen.current = updatedAt;
|
|
96
|
+
}
|
|
97
|
+
queryClient.setQueryData(sleutel, { tekst: t, updated_at: updatedAt });
|
|
98
|
+
};
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
if (!vuil.current || !datum || eigenaar === undefined)
|
|
101
|
+
return;
|
|
102
|
+
const d = datum, z = zicht, eig = eigenaar, t = tekst;
|
|
103
|
+
timer.current = window.setTimeout(() => { timer.current = null; void bewaar(d, z, eig, t, true); }, 800);
|
|
104
|
+
return () => { if (timer.current !== null)
|
|
105
|
+
window.clearTimeout(timer.current); timer.current = null; };
|
|
106
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
107
|
+
}, [tekst, datum, zicht, eigenaar, queryClient]);
|
|
108
|
+
/** Openstaande wijziging direct opslaan vóór een wissel (niets kwijt). */
|
|
109
|
+
const flush = () => {
|
|
110
|
+
if (timer.current !== null) {
|
|
111
|
+
window.clearTimeout(timer.current);
|
|
112
|
+
timer.current = null;
|
|
113
|
+
}
|
|
114
|
+
if (moetFlushen(vuil.current, datum, eigenaar))
|
|
115
|
+
void bewaar(datum, zicht, eigenaar, tekst, false);
|
|
116
|
+
vuil.current = false;
|
|
117
|
+
geladen.current = null;
|
|
118
|
+
};
|
|
119
|
+
const wissel = (n) => { flush(); setBewaren(""); setTekst(""); setDatum(n); };
|
|
120
|
+
const kiesZicht = (z) => {
|
|
121
|
+
flush();
|
|
122
|
+
setBewaren("");
|
|
123
|
+
setTekst("");
|
|
124
|
+
setZicht(z);
|
|
125
|
+
window.localStorage.setItem("dashboard-notitie-zicht", z);
|
|
126
|
+
};
|
|
50
127
|
const naam = datum ? dagNaam(datum) : "vandaag";
|
|
51
128
|
const vandaag = datum ? dashboardDatum() : "";
|
|
52
129
|
const knop = "inline-flex h-6 w-6 items-center justify-center rounded-md border border-border text-muted-foreground hover:bg-accent hover:text-foreground";
|
|
@@ -61,5 +138,5 @@ export function DashboardDagNotities() {
|
|
|
61
138
|
setTekst(nieuw);
|
|
62
139
|
requestAnimationFrame(() => { const c = Math.min(nieuw.length, pos + (nieuw === "" ? -pos : extra)); el.setSelectionRange(c, c); });
|
|
63
140
|
}, onFocus: () => { if (tekst === "")
|
|
64
|
-
setTekst(PUNT); }, placeholder: isLoading ? "Laden…" : `Schrijf een notitie voor ${naam}…`, className: "h-[
|
|
141
|
+
setTekst(PUNT); }, placeholder: isLoading ? "Laden…" : `Schrijf een notitie voor ${naam}…`, className: "h-[100px] w-full resize-none overflow-auto rounded-md border border-input bg-background px-2 py-1 text-xs focus:outline-none focus-visible:ring-1 focus-visible:ring-ring" }), _jsxs("div", { className: "flex h-5 items-center justify-between gap-2", children: [_jsxs("label", { className: "relative inline-flex items-center", children: [_jsx("span", { className: "sr-only", children: "Wie ziet deze notitie" }), zicht === "mij" ? _jsx(Lock, { className: "pointer-events-none absolute left-1.5 h-3 w-3 text-muted-foreground" }) : _jsx(Users, { className: "pointer-events-none absolute left-1.5 h-3 w-3 text-muted-foreground" }), _jsxs("select", { value: zicht, onChange: (e) => kiesZicht(e.target.value), className: "h-5 cursor-pointer rounded-md border border-input bg-background pl-6 pr-1 text-[11px] text-foreground hover:bg-accent focus:outline-none focus-visible:ring-1 focus-visible:ring-ring", children: [_jsx("option", { value: "iedereen", children: "Voor iedereen" }), _jsx("option", { value: "mij", disabled: !user?.id, children: "Alleen voor mij" })] })] }), _jsx("span", { className: "text-[10px] text-muted-foreground", children: bewaren === "bezig" ? "Bewaren…" : bewaren === "bewaard" ? "Bewaard" : "" })] })] }));
|
|
65
142
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardPlannerInstallatieTechniekPage.d.ts","sourceRoot":"","sources":["../../src/components/DashboardPlannerInstallatieTechniekPage.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAC;AAKzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AA0FvD,8FAA8F;AAC9F,wBAAgB,uCAAuC,CAAC,EAAE,OAAO,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;CAAO,+
|
|
1
|
+
{"version":3,"file":"DashboardPlannerInstallatieTechniekPage.d.ts","sourceRoot":"","sources":["../../src/components/DashboardPlannerInstallatieTechniekPage.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qDAAqD,CAAC;AAKzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AA0FvD,8FAA8F;AAC9F,wBAAgB,uCAAuC,CAAC,EAAE,OAAO,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,UAAU,EAAE,CAAA;CAAO,+BA4GnG;AAED,wBAAgB,wBAAwB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IAAE,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,+BAqF5G"}
|
|
@@ -159,9 +159,9 @@ export function DashboardPlannerInstallatieTechniekPage({ modules } = {}) {
|
|
|
159
159
|
refetch();
|
|
160
160
|
toast.success("Dashboard ververst");
|
|
161
161
|
};
|
|
162
|
-
return (_jsxs("main", { ref: mainRef, className: "planner-dashboard px-4 pb-6 pt-2 space-y-4 lg:px-6", children: [_jsx("style", { children: dashboardViewportStyles }), _jsxs("div", { className: "dashboard-toolbar flex flex-wrap items-center justify-between gap-3", children: [_jsxs("p", { className: "min-w-0 text-sm text-muted-foreground", children: ["Welkom terug", profile?.display_name || user?.email ? `, ${profile?.display_name ?? user?.email}` : "", ". Kies een module."] }), _jsx(DashboardSnelkoppelingen, { modules: modules }), _jsxs(Button, { onClick: handleVernieuwen, variant: "outline", size: "sm", className: "h-8 shrink-0 gap-2", children: [_jsx(RefreshCw, { className: `w-4 h-4 ${isFetching ? "animate-spin" : ""}` }), "Vernieuwen"] }), _jsx(DashboardDagNotities, {})] }), isError && (_jsxs("div", { className: "flex items-center gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm", children: [_jsx(AlertTriangle, { className: "h-4 w-4 text-destructive" }), _jsx("span", { className: "text-muted-foreground", children: error instanceof Error && error.message.includes('unauthorized')
|
|
162
|
+
return (_jsxs("main", { ref: mainRef, className: "planner-dashboard px-4 pb-6 pt-2 space-y-4 lg:px-6", children: [_jsx("style", { children: dashboardViewportStyles }), _jsxs("div", { className: "dashboard-toolbar flex flex-wrap items-center justify-between gap-3", children: [_jsxs("p", { className: "min-w-0 text-sm text-muted-foreground", children: ["Welkom terug", profile?.display_name || user?.email ? `, ${profile?.display_name ?? user?.email}` : "", ". Kies een module."] }), _jsx(DashboardSnelkoppelingen, { modules: modules }), _jsxs(Button, { onClick: handleVernieuwen, variant: "outline", size: "sm", className: "h-8 shrink-0 gap-2", children: [_jsx(RefreshCw, { className: `w-4 h-4 ${isFetching ? "animate-spin" : ""}` }), "Vernieuwen"] }), _jsx(DashboardDagNotities, { vergrendeling: data?.instellingen?.notitie_vergrendeling === true })] }), isError && (_jsxs("div", { className: "flex items-center gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm", children: [_jsx(AlertTriangle, { className: "h-4 w-4 text-destructive" }), _jsx("span", { className: "text-muted-foreground", children: error instanceof Error && error.message.includes('unauthorized')
|
|
163
163
|
? 'Je sessie is verlopen — log opnieuw in.'
|
|
164
|
-
: 'Kon de aantallen niet laden — probeer het opnieuw met Vernieuwen.' })] })), _jsx(DashboardModuleNavigatie, { kpis: dashboard.kpis, loading: isLoading }), _jsx(DashboardStatistieken, { stats: normaliseerStats(data?.stats), wekenTerug: wekenTerug, onWeek: setWekenTerug, loading: isLoading })] }));
|
|
164
|
+
: 'Kon de aantallen niet laden — probeer het opnieuw met Vernieuwen.' })] })), _jsx(DashboardModuleNavigatie, { kpis: dashboard.kpis, loading: isLoading }), _jsx(DashboardStatistieken, { stats: normaliseerStats(data?.stats), wekenTerug: wekenTerug, onWeek: setWekenTerug, maxWekenTerug: data?.instellingen?.max_weken_terug, weekStart: data?.instellingen?.week_start, loading: isLoading })] }));
|
|
165
165
|
}
|
|
166
166
|
export function DashboardModuleNavigatie({ kpis, loading }) {
|
|
167
167
|
const router = useRouter();
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { DashboardStats } from "../lib/dashboard-planner-installatie-techniek.types";
|
|
2
2
|
export declare function normaliseerStats(raw: unknown): DashboardStats;
|
|
3
|
-
export declare function DashboardStatistieken({ stats, loading, wekenTerug, onWeek }: {
|
|
3
|
+
export declare function DashboardStatistieken({ stats, loading, wekenTerug, onWeek, maxWekenTerug, weekStart }: {
|
|
4
4
|
stats: DashboardStats;
|
|
5
5
|
loading: boolean;
|
|
6
|
+
maxWekenTerug?: number;
|
|
7
|
+
weekStart?: number;
|
|
6
8
|
wekenTerug?: number;
|
|
7
9
|
onWeek?: (wekenTerug: number) => void;
|
|
8
10
|
}): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardStatistieken.d.ts","sourceRoot":"","sources":["../../src/components/DashboardStatistieken.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;AAY1F,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAgD7D;AAmCD,wBAAgB,qBAAqB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,UAAc,EAAE,MAAM,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"DashboardStatistieken.d.ts","sourceRoot":"","sources":["../../src/components/DashboardStatistieken.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;AAY1F,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAgD7D;AAmCD,wBAAgB,qBAAqB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,UAAc,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,EAAE;IAC1G,KAAK,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IACpF,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5D,+BA2EA"}
|
|
@@ -64,7 +64,7 @@ export function normaliseerStats(raw) {
|
|
|
64
64
|
function StatKaart({ titel, icon: Icon, children, regels, loading }) {
|
|
65
65
|
return (_jsx(Card, { className: "h-full", children: _jsxs(CardContent, { className: "dashboard-stat-content dashboard-hours-content p-4 space-y-3", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: titel }), _jsx("div", { className: "flex items-center justify-center w-8 h-8 rounded-full text-primary bg-primary/10", children: _jsx(Icon, { className: "w-4 h-4" }) })] }), loading ? (_jsx(Skeleton, { className: "h-24 w-full" })) : (_jsxs(_Fragment, { children: [children, _jsx("dl", { className: "grid grid-cols-2 gap-x-4 gap-y-2 border-t pt-3", children: regels.map((r) => (_jsxs("div", { children: [_jsx("dt", { className: "text-xs text-muted-foreground", children: r.k }), _jsx("dd", { className: "text-sm font-medium", children: r.v })] }, r.k))) })] }))] }) }));
|
|
66
66
|
}
|
|
67
|
-
export function DashboardStatistieken({ stats, loading, wekenTerug = 0, onWeek }) {
|
|
67
|
+
export function DashboardStatistieken({ stats, loading, wekenTerug = 0, onWeek, maxWekenTerug, weekStart }) {
|
|
68
68
|
const { omzetOpen: o, offertePijplijn: p, werkUren: w } = stats;
|
|
69
69
|
const fb = stats.facturenBetaald;
|
|
70
70
|
const betaaldPct = fb.verzondenAantal !== null && fb.verzondenAantal > 0 && fb.betaaldAantal !== null
|
|
@@ -76,5 +76,5 @@ export function DashboardStatistieken({ stats, loading, wekenTerug = 0, onWeek }
|
|
|
76
76
|
k: "In één keer opgelost",
|
|
77
77
|
v: w.firstTimeFixPct === null ? "–" : `${w.firstTimeFixPct}% (van ${w.firstTimeFixBasis})`,
|
|
78
78
|
},
|
|
79
|
-
], children: _jsx(WerkurenGrafiek, { dagen: w.urenPerDag, beschikbaar: w.urenDezeWeek !== null, wekenTerug: wekenTerug, onWeek: onWeek }) })] })] }));
|
|
79
|
+
], children: _jsx(WerkurenGrafiek, { dagen: w.urenPerDag, beschikbaar: w.urenDezeWeek !== null, wekenTerug: wekenTerug, onWeek: onWeek, maxWekenTerug: maxWekenTerug, weekStart: weekStart }) })] })] }));
|
|
80
80
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const MAX_WEKEN_TERUG = 6;
|
|
2
2
|
/** Maandag (NL) van de week waarin `nu` valt, als YYYY-MM-DD. */
|
|
3
|
-
export declare function maandagVanWeek(nu: Date): string;
|
|
3
|
+
export declare function maandagVanWeek(nu: Date, weekStart?: number): string;
|
|
4
4
|
/** ISO-weeknummer van een YYYY-MM-DD datum. */
|
|
5
5
|
export declare function isoWeek(dag: string): number;
|
|
6
6
|
/** "Week 42 · 12–18 okt" voor de week die op deze maandag begint. */
|
|
@@ -8,17 +8,19 @@ export declare function weekLabel(maandag: string): string;
|
|
|
8
8
|
export declare function werkurenWeek(dagen: {
|
|
9
9
|
dag: string;
|
|
10
10
|
uren: number;
|
|
11
|
-
}[], nu: Date, wekenTerug?: number): {
|
|
11
|
+
}[], nu: Date, wekenTerug?: number, maxWekenTerug?: number, weekStart?: number): {
|
|
12
12
|
dag: string;
|
|
13
13
|
uren: number;
|
|
14
14
|
toekomst: boolean;
|
|
15
15
|
label: string;
|
|
16
16
|
}[];
|
|
17
|
-
export declare function WerkurenGrafiek({ dagen, beschikbaar, wekenTerug, onWeek }: {
|
|
17
|
+
export declare function WerkurenGrafiek({ dagen, beschikbaar, wekenTerug, onWeek, maxWekenTerug, weekStart }: {
|
|
18
18
|
dagen: {
|
|
19
19
|
dag: string;
|
|
20
20
|
uren: number;
|
|
21
21
|
}[];
|
|
22
|
+
maxWekenTerug?: number;
|
|
23
|
+
weekStart?: number;
|
|
22
24
|
beschikbaar: boolean;
|
|
23
25
|
wekenTerug?: number;
|
|
24
26
|
onWeek?: (wekenTerug: number) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WerkurenGrafiek.d.ts","sourceRoot":"","sources":["../../src/components/WerkurenGrafiek.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,IAAI,CAAC;AAWjC,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,EAAE,EAAE,IAAI,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"WerkurenGrafiek.d.ts","sourceRoot":"","sources":["../../src/components/WerkurenGrafiek.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,IAAI,CAAC;AAWjC,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,SAAI,GAAG,MAAM,CAI9D;AAED,+CAA+C;AAC/C,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO3C;AAID,qEAAqE;AACrE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAWjD;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,SAAI,EAAE,aAAa,SAAkB,EAAE,SAAS,SAAI;;;;;IAc5I;AAED,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,UAAc,EAAE,MAAM,EAAE,aAA+B,EAAE,SAAa,EAAE,EAAE;IAC9H,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,+BAyCA"}
|
|
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
|
|
|
3
3
|
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
4
4
|
import { Button } from '@flowselections/core';
|
|
5
5
|
export const MAX_WEKEN_TERUG = 6;
|
|
6
|
-
import { DASHBOARD_TIJDZONE } from '../lib/dashboard-constanten
|
|
6
|
+
import { DASHBOARD_TIJDZONE } from '../lib/dashboard-constanten';
|
|
7
7
|
const TZ = DASHBOARD_TIJDZONE;
|
|
8
8
|
function nlDatum(nu) {
|
|
9
9
|
const parts = new Intl.DateTimeFormat('en-CA', { timeZone: TZ, year: 'numeric', month: '2-digit', day: '2-digit' }).formatToParts(nu);
|
|
@@ -11,9 +11,9 @@ function nlDatum(nu) {
|
|
|
11
11
|
return `${value('year')}-${value('month')}-${value('day')}`;
|
|
12
12
|
}
|
|
13
13
|
/** Maandag (NL) van de week waarin `nu` valt, als YYYY-MM-DD. */
|
|
14
|
-
export function maandagVanWeek(nu) {
|
|
14
|
+
export function maandagVanWeek(nu, weekStart = 1) {
|
|
15
15
|
const maandag = new Date(`${nlDatum(nu)}T12:00:00Z`);
|
|
16
|
-
maandag.setUTCDate(maandag.getUTCDate() - ((maandag.getUTCDay() +
|
|
16
|
+
maandag.setUTCDate(maandag.getUTCDate() - ((maandag.getUTCDay() - weekStart + 7) % 7));
|
|
17
17
|
return maandag.toISOString().slice(0, 10);
|
|
18
18
|
}
|
|
19
19
|
/** ISO-weeknummer van een YYYY-MM-DD datum. */
|
|
@@ -39,11 +39,12 @@ export function weekLabel(maandag) {
|
|
|
39
39
|
const bereik = a.maand === b.maand ? `${a.dag}–${b.dag} ${b.maand}` : `${a.dag} ${a.maand}–${b.dag} ${b.maand}`;
|
|
40
40
|
return `Week ${isoWeek(maandag)} · ${bereik}`;
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
const LABELS = ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'];
|
|
43
|
+
export function werkurenWeek(dagen, nu, wekenTerug = 0, maxWekenTerug = MAX_WEKEN_TERUG, weekStart = 1) {
|
|
43
44
|
const vandaag = nlDatum(nu);
|
|
44
|
-
const offset = Math.min(Math.max(wekenTerug, 0),
|
|
45
|
+
const offset = Math.min(Math.max(wekenTerug, 0), maxWekenTerug);
|
|
45
46
|
const doel = new Date(nu.getTime() - offset * 7 * 86400000);
|
|
46
|
-
const maandag = new Date(`${maandagVanWeek(doel)}T12:00:00Z`);
|
|
47
|
+
const maandag = new Date(`${maandagVanWeek(doel, weekStart)}T12:00:00Z`);
|
|
47
48
|
return Array.from({ length: 7 }, (_, i) => {
|
|
48
49
|
const datum = new Date(maandag);
|
|
49
50
|
datum.setUTCDate(datum.getUTCDate() + i);
|
|
@@ -51,21 +52,21 @@ export function werkurenWeek(dagen, nu, wekenTerug = 0) {
|
|
|
51
52
|
// Toekomst-markering alleen in de huidige week; oude weken zijn volledig voorbij.
|
|
52
53
|
const toekomst = offset === 0 && dag > vandaag;
|
|
53
54
|
const uren = toekomst ? 0 : Math.max(0, dagen.find(d => d.dag === dag)?.uren ?? 0);
|
|
54
|
-
return { dag, uren, toekomst, label: [
|
|
55
|
+
return { dag, uren, toekomst, label: LABELS[(weekStart + i) % 7] };
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
|
-
export function WerkurenGrafiek({ dagen, beschikbaar, wekenTerug = 0, onWeek }) {
|
|
58
|
+
export function WerkurenGrafiek({ dagen, beschikbaar, wekenTerug = 0, onWeek, maxWekenTerug = MAX_WEKEN_TERUG, weekStart = 1 }) {
|
|
58
59
|
const [nu, setNu] = useState(null);
|
|
59
60
|
useEffect(() => {
|
|
60
61
|
setNu(new Date());
|
|
61
62
|
const timer = window.setInterval(() => setNu(new Date()), 60000);
|
|
62
63
|
return () => window.clearInterval(timer);
|
|
63
64
|
}, []);
|
|
64
|
-
const week = nu ? werkurenWeek(Array.isArray(dagen) ? dagen : [], nu, wekenTerug) : [];
|
|
65
|
+
const week = nu ? werkurenWeek(Array.isArray(dagen) ? dagen : [], nu, wekenTerug, maxWekenTerug, weekStart) : [];
|
|
65
66
|
const max = Math.max(1, ...week.map(d => d.uren));
|
|
66
67
|
const urenLabel = (uren) => `${uren.toLocaleString('nl-NL', { maximumFractionDigits: 1 })} u`;
|
|
67
68
|
const maandag = week[0]?.dag ?? '';
|
|
68
69
|
const knop = 'inline-flex h-7 w-7 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-40';
|
|
69
|
-
return _jsxs("div", { className: "dashboard-hours space-y-3", children: [_jsxs("div", { className: "dashboard-hours-heading flex items-center justify-between gap-2", children: [_jsx("p", { className: "text-xs font-medium text-muted-foreground", children: "Tot gewerkt" }), onWeek && _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { type: "button", variant: "outline", size: "icon", className: knop, "aria-label": "Een week terug", disabled: wekenTerug >=
|
|
70
|
+
return _jsxs("div", { className: "dashboard-hours space-y-3", children: [_jsxs("div", { className: "dashboard-hours-heading flex items-center justify-between gap-2", children: [_jsx("p", { className: "text-xs font-medium text-muted-foreground", children: "Tot gewerkt" }), onWeek && _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { type: "button", variant: "outline", size: "icon", className: knop, "aria-label": "Een week terug", disabled: wekenTerug >= maxWekenTerug, onClick: () => onWeek(wekenTerug + 1), children: _jsx(ChevronLeft, { className: "h-4 w-4" }) }), _jsx("span", { className: "min-w-32 text-center text-xs font-medium tabular-nums", "aria-live": "polite", children: maandag ? weekLabel(maandag) : '' }), _jsx(Button, { type: "button", variant: "outline", size: "icon", className: knop, "aria-label": "Een week vooruit", disabled: wekenTerug <= 0, onClick: () => onWeek(wekenTerug - 1), children: _jsx(ChevronRight, { className: "h-4 w-4" }) })] })] }), !beschikbaar ? _jsx("p", { className: "text-xs text-muted-foreground", children: "Uren konden niet worden geladen." }) :
|
|
70
71
|
_jsxs("div", { className: "dashboard-hours-chart relative h-56", role: "img", "aria-label": `Gewerkte uren van alle monteurs, ${maandag ? weekLabel(maandag) : 'deze week'}, maandag tot zondag`, children: [_jsx("div", { "aria-hidden": "true", className: "pointer-events-none absolute inset-x-0 bottom-6 top-7 flex flex-col justify-between", children: [0, 1, 2, 3].map(n => _jsx("div", { className: "border-t border-border/60" }, n)) }), _jsx("div", { className: "relative grid h-full grid-cols-7 gap-2", children: week.map(d => _jsxs("div", { className: "flex min-w-0 flex-col", "aria-label": `${d.label}: ${d.toekomst ? 'nog niet gewerkt' : urenLabel(d.uren)}`, children: [_jsxs("div", { className: "flex min-h-0 flex-1 flex-col justify-end", children: [_jsx("span", { className: "mb-1.5 text-center text-[10px] font-medium tabular-nums", children: d.toekomst ? '-' : urenLabel(d.uren) }), _jsx("div", { className: `mx-auto w-full max-w-10 shrink-0 rounded-t-md ${d.toekomst ? 'bg-muted' : 'bg-primary/80'}`, style: { height: d.uren > 0 ? `${(d.uren / max) * 78}%` : '3px' } })] }), _jsx("span", { className: "h-6 pt-1.5 text-center text-xs font-medium text-muted-foreground", children: d.label })] }, d.dag)) })] })] });
|
|
71
72
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardInstellingenCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/DashboardInstellingenCard.tsx"],"names":[],"mappings":"AAkBA,wBAAgB,yBAAyB,gCA0FxC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Instellingenkaart van het installatietechniek-dashboard (tabel dashboard_pit_instellingen).
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle, Button, Input, Label, supabase, toast } from "@flowselections/core";
|
|
5
|
+
import { Settings2 } from "lucide-react";
|
|
6
|
+
import { INSTELLINGEN_TABEL, STANDAARD_INSTELLINGEN, leesInstellingen } from "../../lib/dashboard-instellingen";
|
|
7
|
+
import { CONFLICT_MELDING } from "../../lib/dashboard-dagnotities";
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
const db = supabase;
|
|
10
|
+
const SCHAKELAARS = [
|
|
11
|
+
{ key: "tellen_in_database", label: "Statistieken in de database tellen" },
|
|
12
|
+
{ key: "lokale_maandgrens", label: "Maandgrens in lokale tijdzone" },
|
|
13
|
+
{ key: "uren_uit_duur_minuten", label: "Uren uit duur_minuten (zoals urenregistratie)" },
|
|
14
|
+
{ key: "ftf_met_periode", label: "First-time-fix alleen over een periode" },
|
|
15
|
+
{ key: "notitie_vergrendeling", label: "Dagnotities beschermen tegen overschrijven" },
|
|
16
|
+
];
|
|
17
|
+
export function DashboardInstellingenCard() {
|
|
18
|
+
const [waarden, setWaarden] = useState({ ...STANDAARD_INSTELLINGEN });
|
|
19
|
+
const [versies, setVersies] = useState({});
|
|
20
|
+
const [laden, setLaden] = useState(true);
|
|
21
|
+
const [saving, setSaving] = useState(false);
|
|
22
|
+
const lees = async () => {
|
|
23
|
+
setLaden(true);
|
|
24
|
+
const { data, error } = await db.from(INSTELLINGEN_TABEL).select("key, waarde, updated_at");
|
|
25
|
+
if (error) {
|
|
26
|
+
console.error("[dashboard] instellingen laden:", error);
|
|
27
|
+
toast.error("Instellingen konden niet worden geladen");
|
|
28
|
+
}
|
|
29
|
+
const rijen = Array.isArray(data) ? data : [];
|
|
30
|
+
setWaarden(leesInstellingen(rijen));
|
|
31
|
+
setVersies(Object.fromEntries(rijen.map((r) => [r.key, r.updated_at])));
|
|
32
|
+
setLaden(false);
|
|
33
|
+
};
|
|
34
|
+
useEffect(() => { void lees(); }, []);
|
|
35
|
+
const zet = (k, v) => setWaarden((w) => ({ ...w, [k]: v }));
|
|
36
|
+
const opslaan = async () => {
|
|
37
|
+
const gecontroleerd = leesInstellingen(Object.entries(waarden).map(([key, waarde]) => ({ key, waarde })));
|
|
38
|
+
if (JSON.stringify(gecontroleerd) !== JSON.stringify(waarden)) {
|
|
39
|
+
toast.error("Een of meer waarden zijn ongeldig");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setSaving(true);
|
|
43
|
+
try {
|
|
44
|
+
for (const [key, waarde] of Object.entries(waarden)) {
|
|
45
|
+
const versie = versies[key];
|
|
46
|
+
if (versie) {
|
|
47
|
+
const { data, error } = await db.from(INSTELLINGEN_TABEL).update({ waarde }).eq("key", key).eq("updated_at", versie).select("updated_at");
|
|
48
|
+
if (error)
|
|
49
|
+
throw error;
|
|
50
|
+
if (!Array.isArray(data) || data.length === 0) {
|
|
51
|
+
toast.error(CONFLICT_MELDING);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const { error } = await db.from(INSTELLINGEN_TABEL).insert({ key, waarde });
|
|
57
|
+
if (error)
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
toast.success("Instellingen opgeslagen");
|
|
62
|
+
await lees();
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
console.error("[dashboard] instellingen opslaan:", e);
|
|
66
|
+
toast.error("Fout bij het opslaan (alleen beheerders mogen wijzigen)");
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
setSaving(false);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const getal = (k, label) => (_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: k, children: label }), _jsx(Input, { id: k, type: "number", value: waarden[k], onChange: (e) => zet(k, Number(e.target.value)) })] }));
|
|
73
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Settings2, { className: "h-5 w-5 text-primary" }), _jsx(CardTitle, { children: "Dashboard installatietechniek" })] }), _jsx(CardDescription, { children: "Periodes en schakelaars. Standaard werkt alles zoals altijd." })] }), _jsxs(CardContent, { className: "space-y-4", children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "tijdzone", children: "Tijdzone" }), _jsx(Input, { id: "tijdzone", value: waarden.tijdzone, onChange: (e) => zet("tijdzone", e.target.value) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "week_start", children: "Week begint op" }), _jsxs("select", { id: "week_start", value: waarden.week_start, onChange: (e) => zet("week_start", Number(e.target.value)), className: "h-9 w-full rounded-md border border-input bg-background px-2 text-sm", children: [_jsx("option", { value: 1, children: "Maandag" }), _jsx("option", { value: 0, children: "Zondag" })] })] }), getal("betaal_periode_dagen", "Betaalpercentage over (dagen)"), getal("max_weken_terug", "Weken terug in urengrafiek (max.)"), getal("ftf_periode_dagen", "First-time-fix periode (dagen)")] }), _jsx("div", { className: "space-y-2", children: SCHAKELAARS.map((s) => (_jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx("input", { type: "checkbox", checked: waarden[s.key] === true, onChange: (e) => zet(s.key, e.target.checked) }), s.label] }, s.key))) }), _jsx(Button, { onClick: opslaan, disabled: saving || laden, children: saving ? "Opslaan..." : "Opslaan" })] })] }));
|
|
74
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sankey-chart.d.ts","sourceRoot":"","sources":["../../../src/components/ui/sankey-chart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sankey-chart.d.ts","sourceRoot":"","sources":["../../../src/components/ui/sankey-chart.tsx"],"names":[],"mappings":"AAwBA,OAAO,EAAsC,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEpG,UAAU,IAAI;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;AAC/F,UAAU,IAAI;IAAG,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;AAC/E,MAAM,WAAW,eAAe;IAAG,KAAK,EAAE,IAAI,EAAE,CAAC;IAAC,KAAK,EAAE,IAAI,EAAE,CAAA;CAAE;AA0TjE,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,QAA6B,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;IAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,KAAK,IAAI,CAAA;CAAE,+BAgC/Q"}
|
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { ParentSize } from '@visx/responsive';
|
|
2
|
+
import { sankey, sankeyLeft, sankeyLinkHorizontal } from 'd3-sankey';
|
|
4
3
|
import { useEffect, useId, useRef, useState } from 'react';
|
|
4
|
+
// Meet de ouder (zoals vroeger ParentSize) met een ResizeObserver, licht vertraagd.
|
|
5
|
+
function Afmeting({ children }) {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const [maat, setMaat] = useState({ width: 0, height: 0 });
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const el = ref.current;
|
|
10
|
+
if (!el)
|
|
11
|
+
return;
|
|
12
|
+
let timer;
|
|
13
|
+
const meet = () => {
|
|
14
|
+
const r = el.getBoundingClientRect();
|
|
15
|
+
setMaat(m => (m.width === r.width && m.height === r.height ? m : { width: r.width, height: r.height }));
|
|
16
|
+
};
|
|
17
|
+
meet();
|
|
18
|
+
const ro = new ResizeObserver(() => { window.clearTimeout(timer); timer = window.setTimeout(meet, 30); });
|
|
19
|
+
ro.observe(el);
|
|
20
|
+
return () => { ro.disconnect(); window.clearTimeout(timer); };
|
|
21
|
+
}, []);
|
|
22
|
+
return _jsx("div", { ref: ref, style: { width: '100%', height: '100%' }, children: children(maat) });
|
|
23
|
+
}
|
|
5
24
|
import { doekPunt, doekProfiel, doekNabijheid, stapDoekVeer } from '../../lib/sankey-doek';
|
|
6
25
|
import { rangFunnelNode, FUNNEL_EXTRA } from '../../lib/dashboard-werkbon-funnel';
|
|
7
26
|
import { plaatsIndeling, STANDAARD_INDELING } from '../../lib/funnel-indeling';
|
|
@@ -279,7 +298,7 @@ export function SankeyChart({ data, total, onKleuren, indeling = STANDAARD_INDEL
|
|
|
279
298
|
// De Sankey-layout rekent op een vaste hoogte; het zichtbare vak krimpt op de
|
|
280
299
|
// getekende funnel zodat de pop-up direct onder de funnel komt te staan.
|
|
281
300
|
const LAYOUT = 288;
|
|
282
|
-
return _jsx("div", { className: "dashboard-funnel-chart relative w-full", style: { height: inhoud }, "aria-label": "Werkbonnen van herkomst tot betaald", children: _jsx(
|
|
301
|
+
return _jsx("div", { className: "dashboard-funnel-chart relative w-full", style: { height: inhoud }, "aria-label": "Werkbonnen van herkomst tot betaald", children: _jsx(Afmeting, { children: ({ width, height }) => {
|
|
283
302
|
if (width < 40 || height < 40 || total <= 0)
|
|
284
303
|
return null;
|
|
285
304
|
// Ruimte onder de hoofdstroom voor de paarse tak, op de afgevlakte schaal
|
|
@@ -287,6 +306,15 @@ export function SankeyChart({ data, total, onKleuren, indeling = STANDAARD_INDEL
|
|
|
287
306
|
const druk = (v) => Math.pow(Math.max(0, v), 0.75);
|
|
288
307
|
const extraDruk = druk(extraAantal) * EXTRA_SCHAAL;
|
|
289
308
|
const reserve = extraAantal > 0 ? (LAYOUT - 28 - 18 - 8 * Math.max(0, eindAantal - 1)) * (extraDruk / (druk(total) + extraDruk)) + 18 + 8 * Math.max(0, eindAantal - 1) : 0;
|
|
290
|
-
|
|
309
|
+
const layout = sankey()
|
|
310
|
+
.nodeWidth(10).nodePadding(12).nodeAlign(sankeyLeft)
|
|
311
|
+
.nodeSort((a, b) => rangFunnelNode(a.name) - rangFunnelNode(b.name))
|
|
312
|
+
.extent([[8, 14], [width - 28, LAYOUT - 14 - reserve]]);
|
|
313
|
+
const graph = layout({
|
|
314
|
+
nodes: data.nodes.map(n => ({ ...n, aantal: n.value, value: Math.pow(Math.max(0, n.value), 0.75) })),
|
|
315
|
+
links: data.links.map(l => l.target === extraNode ? { ...l, echt: l.value, value: 1e-4 } : { ...l, echt: l.value, value: Math.pow(Math.max(0, l.value), 0.75) }),
|
|
316
|
+
});
|
|
317
|
+
const createPath = sankeyLinkHorizontal();
|
|
318
|
+
return _jsx("svg", { "data-sankey": true, width: width, height: height, viewBox: `0 0 ${width} ${inhoud}`, preserveAspectRatio: "none", role: "img", "aria-label": "Werkbonnenfunnel", children: _jsx(Grafiek, { graph: graph, createPath: createPath, total: total, onKleuren: onKleuren, setTip: setTip, indeling: indeling, hoogte: LAYOUT, textScale: inhoud / height, onInhoud: h => setInhoud(h + 8) }) });
|
|
291
319
|
} }) });
|
|
292
320
|
}
|
package/dist-lib/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { DashboardPlannerInstallatieTechniekPage } from "./components/DashboardP
|
|
|
4
4
|
export { DashboardSnelkoppelingen, SnelkoppelingToevoegenDialog } from "./components/DashboardSnelkoppelingen";
|
|
5
5
|
export { PlannerPaginaKiezer } from "./components/PlannerPaginaKiezer";
|
|
6
6
|
export { ModulePlaceholderPage } from "./components/ModulePlaceholderPage";
|
|
7
|
+
export { DashboardInstellingenCard } from "./components/settings/DashboardInstellingenCard";
|
|
7
8
|
export { PlannerInstallatieTechniekLogo } from "./components/PlannerInstallatieTechniekLogo";
|
|
8
9
|
export { WerkbonnenFunnel, WerkbonnenFunnelInhoud } from './components/WerkbonnenFunnel';
|
|
9
10
|
export type { WerkbonFunnelData, FunnelPeriode } from './lib/dashboard-werkbon-funnel';
|
package/dist-lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIvD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,uCAAuC,EAAE,MAAM,sDAAsD,CAAC;AAC/G,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAC/G,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,OAAO,EAAE,8BAA8B,EAAE,MAAM,6CAA6C,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACzF,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACvF,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,yCAAyC,EAAE,UAYvD,CAAC"}
|
package/dist-lib/index.js
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
// ============================================================================
|
|
6
6
|
import { Gauge } from "lucide-react";
|
|
7
7
|
import { DASHBOARD_MODULE_ID } from "./lib/dashboard-module-id";
|
|
8
|
+
import { DashboardInstellingenCard } from "./components/settings/DashboardInstellingenCard";
|
|
8
9
|
export * from "./_core-safelist";
|
|
9
10
|
export { DashboardPlannerInstallatieTechniekPage } from "./components/DashboardPlannerInstallatieTechniekPage";
|
|
10
11
|
export { DashboardSnelkoppelingen, SnelkoppelingToevoegenDialog } from "./components/DashboardSnelkoppelingen";
|
|
11
12
|
export { PlannerPaginaKiezer } from "./components/PlannerPaginaKiezer";
|
|
12
13
|
export { ModulePlaceholderPage } from "./components/ModulePlaceholderPage";
|
|
14
|
+
export { DashboardInstellingenCard } from "./components/settings/DashboardInstellingenCard";
|
|
13
15
|
export { PlannerInstallatieTechniekLogo } from "./components/PlannerInstallatieTechniekLogo";
|
|
14
16
|
export { WerkbonnenFunnel, WerkbonnenFunnelInhoud } from './components/WerkbonnenFunnel';
|
|
15
17
|
export const dashboardPlannerInstallatieTechniekModule = {
|
|
@@ -21,5 +23,5 @@ export const dashboardPlannerInstallatieTechniekModule = {
|
|
|
21
23
|
href: "/dashboard-planner-installatie-techniek",
|
|
22
24
|
icon: Gauge,
|
|
23
25
|
},
|
|
24
|
-
settingsCards: [],
|
|
26
|
+
settingsCards: [{ component: DashboardInstellingenCard, order: 50 }],
|
|
25
27
|
};
|