@flowselections/dashboard-planner-installatie-techniek 1.0.42 → 1.2.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 +41 -0
- package/dist-lib/components/DashboardDagNotities.d.ts +5 -1
- package/dist-lib/components/DashboardDagNotities.d.ts.map +1 -1
- package/dist-lib/components/DashboardDagNotities.js +105 -24
- package/dist-lib/components/DashboardPlannerInstallatieTechniekPage.d.ts.map +1 -1
- package/dist-lib/components/DashboardPlannerInstallatieTechniekPage.js +5 -4
- package/dist-lib/components/DashboardStatistieken.d.ts +4 -1
- package/dist-lib/components/DashboardStatistieken.d.ts.map +1 -1
- package/dist-lib/components/DashboardStatistieken.js +13 -6
- package/dist-lib/components/WerkbonnenFunnel.d.ts +3 -1
- package/dist-lib/components/WerkbonnenFunnel.d.ts.map +1 -1
- package/dist-lib/components/WerkbonnenFunnel.js +4 -4
- package/dist-lib/components/WerkurenGrafiek.d.ts +9 -4
- package/dist-lib/components/WerkurenGrafiek.d.ts.map +1 -1
- package/dist-lib/components/WerkurenGrafiek.js +26 -18
- 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 +3969 -1
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/dashboard-constanten.d.ts +2 -2
- package/dist-lib/lib/dashboard-constanten.d.ts.map +1 -1
- package/dist-lib/lib/dashboard-constanten.js +4 -5
- package/dist-lib/lib/dashboard-dagnotities.d.ts +16 -1
- package/dist-lib/lib/dashboard-dagnotities.d.ts.map +1 -1
- package/dist-lib/lib/dashboard-dagnotities.js +28 -5
- 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-onvolledig.d.ts +6 -0
- package/dist-lib/lib/dashboard-onvolledig.d.ts.map +1 -0
- package/dist-lib/lib/dashboard-onvolledig.js +9 -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 +8 -4
- package/dist-lib/lib/dashboard-planner-installatie-techniek.stats.server.d.ts +46 -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 +218 -81
- package/dist-lib/lib/dashboard-planner-installatie-techniek.types.d.ts +9 -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 +139 -0
- package/package.json +95 -16
- package/supabase/dashboard-planner-installatie-techniek-installatie.sql +1034 -0
package/README.md
CHANGED
|
@@ -21,3 +21,44 @@ 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 in alle tellingen, grafieken, funnel en dagnotities |
|
|
31
|
+
| betaal_periode_dagen | 28 | Periode van het betaalpercentage |
|
|
32
|
+
| week_start | 1 (maandag) | Eerste dag van de urengrafiek; bij zondag toont het weeknummer de ISO-week van ma–za |
|
|
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). Uit: een waarschuwingsicoon verschijnt zodra een oude telling 1000 rijen raakt |
|
|
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
|
+
## Installatie in een nieuwe database
|
|
44
|
+
|
|
45
|
+
Draai `supabase/dashboard-planner-installatie-techniek-installatie.sql` (meegeleverd in het package) in de SQL-editor van de doel-database, bij voorkeur nadat de modules werkbonnen, facturen, offertes en planning zijn geïnstalleerd. Ontbreken die, dan maakt het script toch alle eigen tabellen aan en slaat het de triggers op hun tabellen over met een NOTICE; draai het script daarna gewoon nog een keer.
|
|
46
|
+
|
|
47
|
+
Het script bevat geen omgevingswaarden en wijzigt geen bestaande gegevens of objecten van andere modules. Optionele snelheidsindexen op tabellen van andere modules (aan te maken door die modules): `invoices(sent_at)`, `invoices(status, due_date)`, `planning_items(werkbon_id)`.
|
|
48
|
+
|
|
49
|
+
### Test op een lege database
|
|
50
|
+
Het script is niet op een gedeelde database gedraaid (het schrijft in `public`). Statisch gecontroleerd: syntaxis (libpg-query), functies/triggers/policies/indexen letterlijk uit `pg_get_functiondef`, `pg_get_triggerdef`, `pg_policies` en `pg_indexes`, en geen UPDATE/DELETE/DROP/TRUNCATE/setval buiten functiebodies.
|
|
51
|
+
Test zelf op een lege (lokale) Supabase:
|
|
52
|
+
1. `pg_dump --schema-only > voor.sql` na een eerste run van het script.
|
|
53
|
+
2. Draai het script een tweede keer: geen fouten.
|
|
54
|
+
3. `pg_dump --schema-only > na.sql` en `diff voor.sql na.sql`: geen verschil. `select count(*) from dashboard_pit_instellingen` blijft 10.
|
|
55
|
+
|
|
56
|
+
## Changelog
|
|
57
|
+
Zie ook `CHANGELOG.md`.
|
|
58
|
+
|
|
59
|
+
### 1.1.2
|
|
60
|
+
- Tijdzone-instelling overal gebruikt; weeknummer volgt de weekstart; waarschuwing bij mogelijk onvolledige oude telling. Geen migratie, geen nieuwe instelling.
|
|
61
|
+
### 1.1.0
|
|
62
|
+
- 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).
|
|
63
|
+
- Nieuwe instellingen en schakelaars (alle schakelaars standaard uit = huidig gedrag).
|
|
64
|
+
- Dagnotities: direct opslaan bij dag-/zichtwissel (altijd aan).
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/** `vergrendeling`: optimistische vergrendeling (instelling notitie_vergrendeling, standaard uit). */
|
|
2
|
+
export declare function DashboardDagNotities({ vergrendeling, tijdzone }?: {
|
|
3
|
+
vergrendeling?: boolean;
|
|
4
|
+
tijdzone?: string;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
2
6
|
//# 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,QAAQ,EAAE,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,+BAsI5H"}
|
|
@@ -1,54 +1,135 @@
|
|
|
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, tijdzone } = {}) {
|
|
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
|
+
if (window.localStorage.getItem("dashboard-notitie-zicht") === "mij")
|
|
23
|
+
setZicht("mij");
|
|
24
|
+
}, []);
|
|
25
|
+
// Vandaag volgens de tijdzone-instelling; niet verspringen terwijl er ongeschreven tekst is.
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!vuil.current)
|
|
28
|
+
setDatum(dashboardDatum(new Date(), tijdzone));
|
|
29
|
+
}, [tijdzone]);
|
|
30
|
+
const eigenaar = notitieEigenaar(zicht, user?.id);
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
const filter2 = (q, eig) => (eig === null ? q.is("eigenaar", null) : q.eq("eigenaar", eig));
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
const filter = (q) => (eigenaar === null ? q.is("eigenaar", null) : q.eq("eigenaar", eigenaar));
|
|
17
35
|
const { data, isLoading } = useQuery({
|
|
18
|
-
queryKey: ["dashboard-dagnotitie", datum],
|
|
19
|
-
enabled: !!datum,
|
|
36
|
+
queryKey: ["dashboard-dagnotitie", datum, zicht, user?.id],
|
|
37
|
+
enabled: !!datum && eigenaar !== undefined,
|
|
20
38
|
queryFn: async () => {
|
|
21
|
-
const { data, error } = await db.from("dashboard_dagnotities").select("tekst, updated_at").eq("datum", datum).maybeSingle();
|
|
39
|
+
const { data, error } = await filter(db.from("dashboard_dagnotities").select("tekst, updated_at").eq("datum", datum)).maybeSingle();
|
|
22
40
|
if (error)
|
|
23
41
|
throw error;
|
|
24
42
|
return { tekst: typeof data?.tekst === "string" ? data.tekst : "", updated_at: data?.updated_at ?? null };
|
|
25
43
|
},
|
|
26
44
|
});
|
|
27
45
|
useEffect(() => {
|
|
28
|
-
if (data && !vuil.current)
|
|
46
|
+
if (data && !vuil.current) {
|
|
29
47
|
setTekst(metPunten(data.tekst));
|
|
48
|
+
geladen.current = data.updated_at;
|
|
49
|
+
}
|
|
30
50
|
}, [data]);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const d = datum;
|
|
35
|
-
const t = window.setTimeout(async () => {
|
|
51
|
+
/** Slaat één notitie op; met vergrendeling via de RPC (conflict = niet overschrijven). */
|
|
52
|
+
const bewaar = async (d, z, eig, t, opDezePagina) => {
|
|
53
|
+
if (opDezePagina)
|
|
36
54
|
setBewaren("bezig");
|
|
37
|
-
|
|
55
|
+
const sleutel = ["dashboard-dagnotitie", d, z, user?.id];
|
|
56
|
+
let updatedAt = new Date().toISOString();
|
|
57
|
+
if (bewaarWijze(vergrendeling) === "vergrendeld") {
|
|
58
|
+
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 });
|
|
59
|
+
const u = error ? null : leesBewaarUitkomst(r);
|
|
60
|
+
if (!u) {
|
|
61
|
+
console.error("[dagnotities] bewaren mislukt:", error ?? r);
|
|
62
|
+
if (opDezePagina)
|
|
63
|
+
setBewaren("");
|
|
64
|
+
toast.error("Notitie kon niet worden bewaard");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (u.status === "conflict") {
|
|
68
|
+
if (opDezePagina) {
|
|
69
|
+
setBewaren("");
|
|
70
|
+
vuil.current = false;
|
|
71
|
+
}
|
|
72
|
+
toast.error(CONFLICT_MELDING);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
updatedAt = u.updated_at;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const upd = await filter2(db.from("dashboard_dagnotities").update({ tekst: t }).eq("datum", d), eig).select("id, updated_at");
|
|
79
|
+
let error = upd.error;
|
|
80
|
+
if (!error && Array.isArray(upd.data) && upd.data[0]?.updated_at)
|
|
81
|
+
updatedAt = upd.data[0].updated_at;
|
|
82
|
+
if (!error && (!Array.isArray(upd.data) || upd.data.length === 0)) {
|
|
83
|
+
const ins = await db.from("dashboard_dagnotities").insert({ datum: d, tekst: t, eigenaar: eig }).select("updated_at").maybeSingle();
|
|
84
|
+
error = ins.error;
|
|
85
|
+
if (ins.data?.updated_at)
|
|
86
|
+
updatedAt = ins.data.updated_at;
|
|
87
|
+
}
|
|
38
88
|
if (error) {
|
|
39
|
-
|
|
89
|
+
console.error("[dagnotities] bewaren mislukt:", error);
|
|
90
|
+
if (opDezePagina)
|
|
91
|
+
setBewaren("");
|
|
40
92
|
toast.error("Notitie kon niet worden bewaard");
|
|
41
93
|
return;
|
|
42
94
|
}
|
|
95
|
+
}
|
|
96
|
+
if (opDezePagina) {
|
|
43
97
|
vuil.current = false;
|
|
44
98
|
setBewaren("bewaard");
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
99
|
+
geladen.current = updatedAt;
|
|
100
|
+
}
|
|
101
|
+
queryClient.setQueryData(sleutel, { tekst: t, updated_at: updatedAt });
|
|
102
|
+
};
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (!vuil.current || !datum || eigenaar === undefined)
|
|
105
|
+
return;
|
|
106
|
+
const d = datum, z = zicht, eig = eigenaar, t = tekst;
|
|
107
|
+
timer.current = window.setTimeout(() => { timer.current = null; void bewaar(d, z, eig, t, true); }, 800);
|
|
108
|
+
return () => { if (timer.current !== null)
|
|
109
|
+
window.clearTimeout(timer.current); timer.current = null; };
|
|
110
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
111
|
+
}, [tekst, datum, zicht, eigenaar, queryClient]);
|
|
112
|
+
/** Openstaande wijziging direct opslaan vóór een wissel (niets kwijt). */
|
|
113
|
+
const flush = () => {
|
|
114
|
+
if (timer.current !== null) {
|
|
115
|
+
window.clearTimeout(timer.current);
|
|
116
|
+
timer.current = null;
|
|
117
|
+
}
|
|
118
|
+
if (moetFlushen(vuil.current, datum, eigenaar))
|
|
119
|
+
void bewaar(datum, zicht, eigenaar, tekst, false);
|
|
120
|
+
vuil.current = false;
|
|
121
|
+
geladen.current = null;
|
|
122
|
+
};
|
|
123
|
+
const wissel = (n) => { flush(); setBewaren(""); setTekst(""); setDatum(n); };
|
|
124
|
+
const kiesZicht = (z) => {
|
|
125
|
+
flush();
|
|
126
|
+
setBewaren("");
|
|
127
|
+
setTekst("");
|
|
128
|
+
setZicht(z);
|
|
129
|
+
window.localStorage.setItem("dashboard-notitie-zicht", z);
|
|
130
|
+
};
|
|
131
|
+
const naam = datum ? dagNaam(datum, new Date(), tijdzone) : "vandaag";
|
|
132
|
+
const vandaag = datum ? dashboardDatum(new Date(), tijdzone) : "";
|
|
52
133
|
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";
|
|
53
134
|
return (_jsxs("div", { className: "dashboard-notes flex w-full max-w-sm flex-col gap-1 rounded-xl border border-border bg-card p-2 shadow-sm", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsxs("p", { className: "flex items-center gap-1.5 whitespace-nowrap text-xs font-semibold", children: [_jsx(StickyNote, { className: "h-3.5 w-3.5 text-muted-foreground" }), "Notities voor ", naam] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx("button", { type: "button", className: knop, "aria-label": "Vorige dag", onClick: () => datum && wissel(verschuifDag(datum, -1)), children: _jsx(ChevronLeft, { className: "h-3.5 w-3.5" }) }), _jsx("button", { type: "button", className: "h-6 rounded-md border border-border px-2 text-[11px] hover:bg-accent disabled:opacity-50", disabled: datum === vandaag, onClick: () => wissel(vandaag), children: "Vandaag" }), _jsx("button", { type: "button", className: "h-6 rounded-md border border-border px-2 text-[11px] hover:bg-accent disabled:opacity-50", disabled: !!datum && datum === verschuifDag(vandaag, 1), onClick: () => wissel(verschuifDag(vandaag, 1)), children: "Morgen" }), _jsx("button", { type: "button", className: knop, "aria-label": "Volgende dag", onClick: () => datum && wissel(verschuifDag(datum, 1)), children: _jsx(ChevronRight, { className: "h-3.5 w-3.5" }) })] })] }), _jsx("textarea", { "aria-label": `Notities voor ${naam}`, value: tekst, disabled: isLoading || !datum, maxLength: MAX_NOTITIE_LENGTE, onChange: (e) => {
|
|
54
135
|
const el = e.target;
|
|
@@ -61,5 +142,5 @@ export function DashboardDagNotities() {
|
|
|
61
142
|
setTekst(nieuw);
|
|
62
143
|
requestAnimationFrame(() => { const c = Math.min(nieuw.length, pos + (nieuw === "" ? -pos : extra)); el.setSelectionRange(c, c); });
|
|
63
144
|
}, onFocus: () => { if (tekst === "")
|
|
64
|
-
setTekst(PUNT); }, placeholder: isLoading ? "Laden…" : `Schrijf een notitie voor ${naam}…`, className: "h-[
|
|
145
|
+
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
146
|
}
|
|
@@ -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,+BA8GnG;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"}
|
|
@@ -134,8 +134,9 @@ export function DashboardPlannerInstallatieTechniekPage({ modules } = {}) {
|
|
|
134
134
|
staleTime: 30000,
|
|
135
135
|
retry: false,
|
|
136
136
|
});
|
|
137
|
+
const tijdzone = data?.instellingen?.tijdzone || DASHBOARD_TIJDZONE;
|
|
137
138
|
useEffect(() => {
|
|
138
|
-
const formatter = new Intl.DateTimeFormat("en-CA", { timeZone:
|
|
139
|
+
const formatter = new Intl.DateTimeFormat("en-CA", { timeZone: tijdzone, year: "numeric", month: "2-digit", day: "2-digit" });
|
|
139
140
|
let day = formatter.format(new Date());
|
|
140
141
|
const checkDay = () => {
|
|
141
142
|
const next = formatter.format(new Date());
|
|
@@ -152,16 +153,16 @@ export function DashboardPlannerInstallatieTechniekPage({ modules } = {}) {
|
|
|
152
153
|
window.removeEventListener("focus", checkDay);
|
|
153
154
|
document.removeEventListener("visibilitychange", checkDay);
|
|
154
155
|
};
|
|
155
|
-
}, [queryClient]);
|
|
156
|
+
}, [queryClient, tijdzone]);
|
|
156
157
|
const dashboard = normaliseerDashboard(data);
|
|
157
158
|
const handleVernieuwen = () => {
|
|
158
159
|
queryClient.invalidateQueries({ queryKey: ["dashboard-planner-installatie-techniek"] });
|
|
159
160
|
refetch();
|
|
160
161
|
toast.success("Dashboard ververst");
|
|
161
162
|
};
|
|
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')
|
|
163
|
+
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, { tijdzone: tijdzone, 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
164
|
? '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 })] }));
|
|
165
|
+
: '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, tijdzone: tijdzone, loading: isLoading })] }));
|
|
165
166
|
}
|
|
166
167
|
export function DashboardModuleNavigatie({ kpis, loading }) {
|
|
167
168
|
const router = useRouter();
|
|
@@ -1,8 +1,11 @@
|
|
|
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, tijdzone }: {
|
|
4
4
|
stats: DashboardStats;
|
|
5
5
|
loading: boolean;
|
|
6
|
+
maxWekenTerug?: number;
|
|
7
|
+
weekStart?: number;
|
|
8
|
+
tijdzone?: string;
|
|
6
9
|
wekenTerug?: number;
|
|
7
10
|
onWeek?: (wekenTerug: number) => void;
|
|
8
11
|
}): 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;
|
|
1
|
+
{"version":3,"file":"DashboardStatistieken.d.ts","sourceRoot":"","sources":["../../src/components/DashboardStatistieken.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;AAa1F,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAkD7D;AAuCD,wBAAgB,qBAAqB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,UAAc,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE;IACpH,KAAK,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IACvG,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5D,+BA6EA"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
// Statistieken-blok onder de module-vakken: drie kaarten met kerngetallen
|
|
3
3
|
// kerngetallen en een klein ingebouwd grafiekje (geen extra pakket).
|
|
4
|
-
import { CalendarCheck, FileSignature, Wallet } from "lucide-react";
|
|
4
|
+
import { AlertTriangle, CalendarCheck, FileSignature, Wallet } from "lucide-react";
|
|
5
5
|
import { Card, CardContent, Skeleton } from "@flowselections/core";
|
|
6
6
|
import { WerkbonnenFunnel } from "./WerkbonnenFunnel";
|
|
7
7
|
import { WerkurenGrafiek } from "./WerkurenGrafiek";
|
|
8
|
+
import { ONVOLLEDIG_MELDING } from "../lib/dashboard-onvolledig";
|
|
8
9
|
const euro = (cents) => cents === null
|
|
9
10
|
? "–"
|
|
10
11
|
: new Intl.NumberFormat("nl-NL", { style: "currency", currency: "EUR", maximumFractionDigits: 0 }).format(cents / 100);
|
|
@@ -20,7 +21,9 @@ export function normaliseerStats(raw) {
|
|
|
20
21
|
const ws = s.werkbonSoorten ?? {};
|
|
21
22
|
const wd = s.werkbonDuur ?? {};
|
|
22
23
|
const fb = s.facturenBetaald ?? {};
|
|
24
|
+
const mo = raw?.mogelijkOnvolledig;
|
|
23
25
|
return {
|
|
26
|
+
mogelijkOnvolledig: Array.isArray(mo) ? mo.filter((k) => k === "omzetOpen" || k === "offertes" || k === "werkuren") : [],
|
|
24
27
|
facturenBetaald: { verzondenAantal: num0(fb.verzondenAantal), betaaldAantal: num0(fb.betaaldAantal) },
|
|
25
28
|
omzetOpen: {
|
|
26
29
|
bedragCents: num0(o.bedragCents),
|
|
@@ -61,20 +64,24 @@ export function normaliseerStats(raw) {
|
|
|
61
64
|
},
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
|
-
function StatKaart({ titel, icon: Icon, children, regels, loading }) {
|
|
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: [
|
|
67
|
+
function StatKaart({ titel, icon: Icon, children, regels, loading, waarschuwing }) {
|
|
68
|
+
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: [_jsxs("p", { className: "flex items-center gap-1 text-sm font-medium text-muted-foreground", children: [titel, waarschuwing && _jsx(Onvolledig, {})] }), _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
69
|
}
|
|
67
|
-
|
|
70
|
+
function Onvolledig() {
|
|
71
|
+
return _jsx("span", { className: "inline-flex text-destructive", title: ONVOLLEDIG_MELDING, role: "img", "aria-label": ONVOLLEDIG_MELDING, children: _jsx(AlertTriangle, { className: "h-3.5 w-3.5" }) });
|
|
72
|
+
}
|
|
73
|
+
export function DashboardStatistieken({ stats, loading, wekenTerug = 0, onWeek, maxWekenTerug, weekStart, tijdzone }) {
|
|
68
74
|
const { omzetOpen: o, offertePijplijn: p, werkUren: w } = stats;
|
|
75
|
+
const onv = new Set(Array.isArray(stats.mogelijkOnvolledig) ? stats.mogelijkOnvolledig : []);
|
|
69
76
|
const fb = stats.facturenBetaald;
|
|
70
77
|
const betaaldPct = fb.verzondenAantal !== null && fb.verzondenAantal > 0 && fb.betaaldAantal !== null
|
|
71
78
|
? Math.round((fb.betaaldAantal / fb.verzondenAantal) * 100) : null;
|
|
72
|
-
return (_jsxs("section", { className: "dashboard-stats space-y-3", children: [_jsx("h2", { className: "text-lg font-semibold tracking-tight", children: "Statistieken" }), _jsxs("div", { className: "dashboard-stats-grid grid items-stretch gap-4 xl:grid-cols-3", children: [_jsx(Card, { className: "h-full min-w-0", children: _jsxs(CardContent, { className: "dashboard-stat-content dashboard-financial space-y-3 p-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: "Financieel" }), _jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-primary", children: _jsx(Wallet, { className: "h-4 w-4" }) })] }), loading ? _jsx(Skeleton, { className: "h-56 w-full" }) : _jsxs(_Fragment, { children: [_jsxs("div", { className: "space-y-3", children: [_jsxs("div", { children: [
|
|
79
|
+
return (_jsxs("section", { className: "dashboard-stats space-y-3", children: [_jsx("h2", { className: "text-lg font-semibold tracking-tight", children: "Statistieken" }), _jsxs("div", { className: "dashboard-stats-grid grid items-stretch gap-4 xl:grid-cols-3", children: [_jsx(Card, { className: "h-full min-w-0", children: _jsxs(CardContent, { className: "dashboard-stat-content dashboard-financial space-y-3 p-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("p", { className: "text-sm font-medium text-muted-foreground", children: "Financieel" }), _jsx("div", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-primary", children: _jsx(Wallet, { className: "h-4 w-4" }) })] }), loading ? _jsx(Skeleton, { className: "h-56 w-full" }) : _jsxs(_Fragment, { children: [_jsxs("div", { className: "space-y-3", children: [_jsxs("div", { children: [_jsxs("h3", { className: "flex items-center gap-1 text-sm font-medium", children: ["Openstaande debiteuren", onv.has("omzetOpen") && _jsx(Onvolledig, {})] }), _jsx("p", { className: "dashboard-amount mt-1 text-3xl font-semibold", children: euro(o.bedragCents) }), _jsxs("p", { className: "text-xs text-muted-foreground", children: [num(o.aantal), " verzonden, nog niet betaalde facturen"] })] }), _jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 text-xs", children: [_jsx("span", { className: "text-muted-foreground", children: "Betaald \u00B7 afgelopen 4 weken" }), _jsx("span", { className: "text-sm font-semibold tabular-nums", children: num(betaaldPct, "%") })] }), _jsx("div", { className: "h-2 w-full overflow-hidden rounded-full bg-muted", role: "progressbar", "aria-label": "Betaalde facturen afgelopen vier weken", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": betaaldPct ?? undefined, children: _jsx("div", { className: "h-full bg-primary", style: { width: `${betaaldPct ?? 0}%` } }) }), _jsx("p", { className: "text-xs text-muted-foreground", children: fb.verzondenAantal === 0 ? "Geen facturen verzonden" : fb.verzondenAantal === null || fb.betaaldAantal === null ? "–" : `${num(fb.betaaldAantal)} van ${num(fb.verzondenAantal)} verzonden facturen betaald` })] }), _jsxs("div", { className: "flex flex-wrap justify-between gap-2 text-xs", children: [_jsxs("span", { className: "text-muted-foreground", children: ["Vervallen \u00B7 ", num(o.vervallenAantal), " facturen"] }), _jsx("span", { className: "font-medium", children: euro(o.vervallenCents) })] })] }), _jsxs("div", { className: "dashboard-offers space-y-3 border-t-2 border-border pt-4", children: [_jsxs("div", { children: [_jsxs("h3", { className: "flex items-center gap-2 text-sm font-medium", children: [_jsx(FileSignature, { className: "h-4 w-4 text-primary" }), "Offertes in afwachting", onv.has("offertes") && _jsx(Onvolledig, {})] }), _jsx("p", { className: "dashboard-amount mt-1 text-3xl font-semibold", children: euro(p.verzondenCents) }), _jsxs("p", { className: "text-xs text-muted-foreground", children: [num(p.verzondenAantal), "\u00A0wachten op reactie"] })] }), _jsxs("dl", { className: "grid grid-cols-2 gap-3", children: [_jsxs("div", { children: [_jsx("dt", { className: "text-xs text-muted-foreground", children: "Acceptatiegraad" }), _jsx("dd", { className: "text-sm font-medium", children: num(p.acceptatiePct, "%") })] }), _jsxs("div", { children: [_jsx("dt", { className: "text-xs text-muted-foreground", children: "In concept" }), _jsx("dd", { className: "text-sm font-medium", children: euro(p.conceptCents) })] })] })] })] })] }) }), _jsx(WerkbonnenFunnel, { tijdzone: tijdzone }), _jsx(StatKaart, { titel: "Werk & uren", waarschuwing: onv.has("werkuren"), icon: CalendarCheck, loading: loading, regels: [
|
|
73
80
|
{ k: wekenTerug === 0 ? "Uren deze week" : "Uren in deze week", v: num(w.urenDezeWeek, " u") },
|
|
74
81
|
{ k: wekenTerug === 0 ? "Overuren deze week" : "Overuren in deze week", v: num(w.overurenDezeWeek, " u") },
|
|
75
82
|
{
|
|
76
83
|
k: "In één keer opgelost",
|
|
77
84
|
v: w.firstTimeFixPct === null ? "–" : `${w.firstTimeFixPct}% (van ${w.firstTimeFixBasis})`,
|
|
78
85
|
},
|
|
79
|
-
], children: _jsx(WerkurenGrafiek, { dagen: w.urenPerDag, beschikbaar: w.urenDezeWeek !== null, wekenTerug: wekenTerug, onWeek: onWeek }) })] })] }));
|
|
86
|
+
], children: _jsx(WerkurenGrafiek, { dagen: w.urenPerDag, beschikbaar: w.urenDezeWeek !== null, wekenTerug: wekenTerug, onWeek: onWeek, maxWekenTerug: maxWekenTerug, weekStart: weekStart, tijdzone: tijdzone }) })] })] }));
|
|
80
87
|
}
|
|
@@ -4,5 +4,7 @@ export declare function WerkbonnenFunnelInhoud({ data, indeling }: {
|
|
|
4
4
|
data: WerkbonFunnelData;
|
|
5
5
|
indeling?: FunnelIndeling;
|
|
6
6
|
}): import("react").JSX.Element;
|
|
7
|
-
export declare function WerkbonnenFunnel(
|
|
7
|
+
export declare function WerkbonnenFunnel({ tijdzone }?: {
|
|
8
|
+
tijdzone?: string;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
8
10
|
//# sourceMappingURL=WerkbonnenFunnel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WerkbonnenFunnel.d.ts","sourceRoot":"","sources":["../../src/components/WerkbonnenFunnel.tsx"],"names":[],"mappings":"AAOA,OAAO,EAA6E,KAAK,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpJ,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAkBjF,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,QAA6B,EAAE,EAAE;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;CAAE,+BAarI;AAED,wBAAgB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"WerkbonnenFunnel.d.ts","sourceRoot":"","sources":["../../src/components/WerkbonnenFunnel.tsx"],"names":[],"mappings":"AAOA,OAAO,EAA6E,KAAK,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpJ,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAkBjF,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,QAA6B,EAAE,EAAE;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;CAAE,+BAarI;AAED,wBAAgB,gBAAgB,CAAC,EAAE,QAA6B,EAAE,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,+BA0C7F"}
|
|
@@ -24,16 +24,16 @@ export function WerkbonnenFunnelInhoud({ data, indeling = STANDAARD_INDELING })
|
|
|
24
24
|
const [tip, setTip] = useState(null);
|
|
25
25
|
return _jsxs(_Fragment, { children: [_jsxs("p", { className: "text-xs text-muted-foreground", children: [datum(data.vanaf), " \u2013 ", datum(data.tot)] }), data.totaal > 0 ? _jsxs(_Fragment, { children: [_jsxs("div", { className: "grid grid-cols-4 gap-1 text-center text-[10px] text-muted-foreground", children: [_jsx("span", { children: "Herkomst" }), _jsx("span", { children: "Aangemaakt" }), _jsx("span", { children: "Afgerond" }), _jsx("span", { children: "Betaling / extra werk" })] }), _jsx(SankeyChart, { data: maakFunnelStromen(data), total: data.totaal, onTip: setTip, indeling: indeling }), _jsx("div", { role: "status", "aria-live": "polite", className: "dashboard-funnel-tip min-h-[3rem] rounded-md border border-border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground", children: tip ? _jsxs(_Fragment, { children: [_jsx("div", { className: "font-medium", children: tip.titel }), _jsx("div", { className: "text-muted-foreground", children: tip.tekst })] }) : _jsx("div", { className: "flex flex-wrap gap-x-4 gap-y-1 text-muted-foreground", children: LEGENDA.map(s => _jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: "inline-block h-2.5 w-2.5 shrink-0 rounded-full", style: { backgroundColor: s.kleur }, "aria-hidden": "true" }), s.label] }, s.soort)) }) })] }) : _jsx("p", { className: "py-8 text-center text-sm text-muted-foreground", children: "Geen werkbonnen aangemaakt in deze periode." }), data.onbekend > 0 && _jsxs("p", { className: "text-xs text-muted-foreground", children: ["Van ", aantal(data.onbekend), " eerder getelde werkbonnen is het verdere verloop onbekend."] })] });
|
|
26
26
|
}
|
|
27
|
-
export function WerkbonnenFunnel() {
|
|
27
|
+
export function WerkbonnenFunnel({ tijdzone = DASHBOARD_TIJDZONE } = {}) {
|
|
28
28
|
const [periode, setPeriode] = useState('jaar');
|
|
29
29
|
const { user, signOut } = useAuth();
|
|
30
30
|
const fetchFunnel = useServerFn(getWerkbonFunnel);
|
|
31
31
|
const queryClient = useQueryClient();
|
|
32
32
|
const query = useQuery({ queryKey: ['dashboard-planner-installatie-techniek', 'funnel', user?.id, periode], queryFn: () => fetchFunnel({ data: { periode } }), enabled: Boolean(user?.id), staleTime: 30000, retry: false });
|
|
33
33
|
useEffect(() => {
|
|
34
|
-
let dag = new Intl.DateTimeFormat('en-CA', { timeZone:
|
|
34
|
+
let dag = new Intl.DateTimeFormat('en-CA', { timeZone: tijdzone }).format(new Date());
|
|
35
35
|
const check = () => {
|
|
36
|
-
const nieuw = new Intl.DateTimeFormat('en-CA', { timeZone:
|
|
36
|
+
const nieuw = new Intl.DateTimeFormat('en-CA', { timeZone: tijdzone }).format(new Date());
|
|
37
37
|
if (nieuw !== dag) {
|
|
38
38
|
dag = nieuw;
|
|
39
39
|
void queryClient.invalidateQueries({ queryKey: ['dashboard-planner-installatie-techniek', 'funnel'] });
|
|
@@ -42,7 +42,7 @@ export function WerkbonnenFunnel() {
|
|
|
42
42
|
const timer = window.setInterval(check, 15000);
|
|
43
43
|
window.addEventListener('focus', check);
|
|
44
44
|
return () => { window.clearInterval(timer); window.removeEventListener('focus', check); };
|
|
45
|
-
}, [queryClient]);
|
|
45
|
+
}, [queryClient, tijdzone]);
|
|
46
46
|
// Eerst uitloggen en dan het inlogscherm laden. De app stuurt iemand die volgens
|
|
47
47
|
// de eigen inlogstatus nog ingelogd is direct terug naar het dashboard, dus een
|
|
48
48
|
// interne sprong kan je meteen weer terugslingeren; een nieuwe pagina-lading na
|
|
@@ -1,24 +1,29 @@
|
|
|
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, tz?: string): string;
|
|
4
4
|
/** ISO-weeknummer van een YYYY-MM-DD datum. */
|
|
5
5
|
export declare function isoWeek(dag: string): number;
|
|
6
|
+
/** Weeknummer passend bij de weekstart: bij zondagstart telt de ISO-week van ma–za (de dag erna). */
|
|
7
|
+
export declare function weekNummer(startdag: string, weekStart?: number): number;
|
|
6
8
|
/** "Week 42 · 12–18 okt" voor de week die op deze maandag begint. */
|
|
7
|
-
export declare function weekLabel(maandag: string): string;
|
|
9
|
+
export declare function weekLabel(maandag: string, weekStart?: number): string;
|
|
8
10
|
export declare function werkurenWeek(dagen: {
|
|
9
11
|
dag: string;
|
|
10
12
|
uren: number;
|
|
11
|
-
}[], nu: Date, wekenTerug?: number): {
|
|
13
|
+
}[], nu: Date, wekenTerug?: number, maxWekenTerug?: number, weekStart?: number, tz?: string): {
|
|
12
14
|
dag: string;
|
|
13
15
|
uren: number;
|
|
14
16
|
toekomst: boolean;
|
|
15
17
|
label: string;
|
|
16
18
|
}[];
|
|
17
|
-
export declare function WerkurenGrafiek({ dagen, beschikbaar, wekenTerug, onWeek }: {
|
|
19
|
+
export declare function WerkurenGrafiek({ dagen, beschikbaar, wekenTerug, onWeek, maxWekenTerug, weekStart, tijdzone }: {
|
|
18
20
|
dagen: {
|
|
19
21
|
dag: string;
|
|
20
22
|
uren: number;
|
|
21
23
|
}[];
|
|
24
|
+
maxWekenTerug?: number;
|
|
25
|
+
weekStart?: number;
|
|
26
|
+
tijdzone?: string;
|
|
22
27
|
beschikbaar: boolean;
|
|
23
28
|
wekenTerug?: number;
|
|
24
29
|
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;
|
|
1
|
+
{"version":3,"file":"WerkurenGrafiek.d.ts","sourceRoot":"","sources":["../../src/components/WerkurenGrafiek.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,IAAI,CAAC;AASjC,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,SAAI,EAAE,EAAE,GAAE,MAA2B,GAAG,MAAM,CAI/F;AAED,+CAA+C;AAC/C,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO3C;AAED,qGAAqG;AACrG,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,MAAM,CAKlE;AAID,qEAAqE;AACrE,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,MAAM,CAWhE;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,EAAE,EAAE,GAAE,MAA2B;;;;;IAc7K;AAED,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,UAAc,EAAE,MAAM,EAAE,aAA+B,EAAE,SAAa,EAAE,QAA6B,EAAE,EAAE;IAC7J,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,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,+BAyCA"}
|
|
@@ -3,17 +3,16 @@ 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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const parts = new Intl.DateTimeFormat('en-CA', { timeZone: TZ, year: 'numeric', month: '2-digit', day: '2-digit' }).formatToParts(nu);
|
|
6
|
+
import { DASHBOARD_TIJDZONE } from '../lib/dashboard-constanten';
|
|
7
|
+
function nlDatum(nu, tz = DASHBOARD_TIJDZONE) {
|
|
8
|
+
const parts = new Intl.DateTimeFormat('en-CA', { timeZone: tz, year: 'numeric', month: '2-digit', day: '2-digit' }).formatToParts(nu);
|
|
10
9
|
const value = (type) => parts.find(p => p.type === type)?.value ?? '';
|
|
11
10
|
return `${value('year')}-${value('month')}-${value('day')}`;
|
|
12
11
|
}
|
|
13
12
|
/** Maandag (NL) van de week waarin `nu` valt, als YYYY-MM-DD. */
|
|
14
|
-
export function maandagVanWeek(nu) {
|
|
15
|
-
const maandag = new Date(`${nlDatum(nu)}T12:00:00Z`);
|
|
16
|
-
maandag.setUTCDate(maandag.getUTCDate() - ((maandag.getUTCDay() +
|
|
13
|
+
export function maandagVanWeek(nu, weekStart = 1, tz = DASHBOARD_TIJDZONE) {
|
|
14
|
+
const maandag = new Date(`${nlDatum(nu, tz)}T12:00:00Z`);
|
|
15
|
+
maandag.setUTCDate(maandag.getUTCDate() - ((maandag.getUTCDay() - weekStart + 7) % 7));
|
|
17
16
|
return maandag.toISOString().slice(0, 10);
|
|
18
17
|
}
|
|
19
18
|
/** ISO-weeknummer van een YYYY-MM-DD datum. */
|
|
@@ -25,9 +24,17 @@ export function isoWeek(dag) {
|
|
|
25
24
|
eersteDonderdag.setUTCDate(eersteDonderdag.getUTCDate() + 3 - ((eersteDonderdag.getUTCDay() + 6) % 7));
|
|
26
25
|
return 1 + Math.round((donderdag.getTime() - eersteDonderdag.getTime()) / (7 * 86400000));
|
|
27
26
|
}
|
|
27
|
+
/** Weeknummer passend bij de weekstart: bij zondagstart telt de ISO-week van ma–za (de dag erna). */
|
|
28
|
+
export function weekNummer(startdag, weekStart = 1) {
|
|
29
|
+
if (weekStart !== 0)
|
|
30
|
+
return isoWeek(startdag);
|
|
31
|
+
const d = new Date(`${startdag}T12:00:00Z`);
|
|
32
|
+
d.setUTCDate(d.getUTCDate() + 1);
|
|
33
|
+
return isoWeek(d.toISOString().slice(0, 10));
|
|
34
|
+
}
|
|
28
35
|
const MAANDEN = ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'];
|
|
29
36
|
/** "Week 42 · 12–18 okt" voor de week die op deze maandag begint. */
|
|
30
|
-
export function weekLabel(maandag) {
|
|
37
|
+
export function weekLabel(maandag, weekStart = 1) {
|
|
31
38
|
const dag = (d) => {
|
|
32
39
|
const [, m, dd] = d.split('-').map(Number);
|
|
33
40
|
return { dag: dd, maand: MAANDEN[m - 1] };
|
|
@@ -37,13 +44,14 @@ export function weekLabel(maandag) {
|
|
|
37
44
|
const a = dag(maandag);
|
|
38
45
|
const b = dag(zondag.toISOString().slice(0, 10));
|
|
39
46
|
const bereik = a.maand === b.maand ? `${a.dag}–${b.dag} ${b.maand}` : `${a.dag} ${a.maand}–${b.dag} ${b.maand}`;
|
|
40
|
-
return `Week ${
|
|
47
|
+
return `Week ${weekNummer(maandag, weekStart)} · ${bereik}`;
|
|
41
48
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
49
|
+
const LABELS = ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'];
|
|
50
|
+
export function werkurenWeek(dagen, nu, wekenTerug = 0, maxWekenTerug = MAX_WEKEN_TERUG, weekStart = 1, tz = DASHBOARD_TIJDZONE) {
|
|
51
|
+
const vandaag = nlDatum(nu, tz);
|
|
52
|
+
const offset = Math.min(Math.max(wekenTerug, 0), maxWekenTerug);
|
|
45
53
|
const doel = new Date(nu.getTime() - offset * 7 * 86400000);
|
|
46
|
-
const maandag = new Date(`${maandagVanWeek(doel)}T12:00:00Z`);
|
|
54
|
+
const maandag = new Date(`${maandagVanWeek(doel, weekStart, tz)}T12:00:00Z`);
|
|
47
55
|
return Array.from({ length: 7 }, (_, i) => {
|
|
48
56
|
const datum = new Date(maandag);
|
|
49
57
|
datum.setUTCDate(datum.getUTCDate() + i);
|
|
@@ -51,21 +59,21 @@ export function werkurenWeek(dagen, nu, wekenTerug = 0) {
|
|
|
51
59
|
// Toekomst-markering alleen in de huidige week; oude weken zijn volledig voorbij.
|
|
52
60
|
const toekomst = offset === 0 && dag > vandaag;
|
|
53
61
|
const uren = toekomst ? 0 : Math.max(0, dagen.find(d => d.dag === dag)?.uren ?? 0);
|
|
54
|
-
return { dag, uren, toekomst, label: [
|
|
62
|
+
return { dag, uren, toekomst, label: LABELS[(weekStart + i) % 7] };
|
|
55
63
|
});
|
|
56
64
|
}
|
|
57
|
-
export function WerkurenGrafiek({ dagen, beschikbaar, wekenTerug = 0, onWeek }) {
|
|
65
|
+
export function WerkurenGrafiek({ dagen, beschikbaar, wekenTerug = 0, onWeek, maxWekenTerug = MAX_WEKEN_TERUG, weekStart = 1, tijdzone = DASHBOARD_TIJDZONE }) {
|
|
58
66
|
const [nu, setNu] = useState(null);
|
|
59
67
|
useEffect(() => {
|
|
60
68
|
setNu(new Date());
|
|
61
69
|
const timer = window.setInterval(() => setNu(new Date()), 60000);
|
|
62
70
|
return () => window.clearInterval(timer);
|
|
63
71
|
}, []);
|
|
64
|
-
const week = nu ? werkurenWeek(Array.isArray(dagen) ? dagen : [], nu, wekenTerug) : [];
|
|
72
|
+
const week = nu ? werkurenWeek(Array.isArray(dagen) ? dagen : [], nu, wekenTerug, maxWekenTerug, weekStart, tijdzone) : [];
|
|
65
73
|
const max = Math.max(1, ...week.map(d => d.uren));
|
|
66
74
|
const urenLabel = (uren) => `${uren.toLocaleString('nl-NL', { maximumFractionDigits: 1 })} u`;
|
|
67
75
|
const maandag = week[0]?.dag ?? '';
|
|
68
76
|
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
|
-
_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)) })] })] });
|
|
77
|
+
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, weekStart) : '' }), _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." }) :
|
|
78
|
+
_jsxs("div", { className: "dashboard-hours-chart relative h-56", role: "img", "aria-label": `Gewerkte uren van alle monteurs, ${maandag ? weekLabel(maandag, weekStart) : '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
79
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DashboardInstellingenCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/DashboardInstellingenCard.tsx"],"names":[],"mappings":"AAkBA,wBAAgB,yBAAyB,gCA0FxC"}
|