@flowselections/e-mail-installatie-techniek 1.5.1 → 1.8.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 +10 -0
- package/dist-lib/components/TemplateModulePage.js +1 -1
- package/dist-lib/components/WerkbonMailPage.d.ts.map +1 -1
- package/dist-lib/components/WerkbonMailPage.js +104 -39
- package/dist-lib/components/WerkbonPostvakInstelling.d.ts.map +1 -1
- package/dist-lib/components/WerkbonPostvakInstelling.js +1 -6
- package/dist-lib/components/mail/CompetentiePicker.js +1 -1
- package/dist-lib/components/mail/MailPane.d.ts.map +1 -1
- package/dist-lib/components/mail/MailPane.js +2 -9
- package/dist-lib/components/mail/MailReader.d.ts.map +1 -1
- package/dist-lib/components/mail/MailReader.js +2 -9
- package/dist-lib/components/mail/WerkbonProposalDialog.d.ts.map +1 -1
- package/dist-lib/components/mail/WerkbonProposalDialog.js +28 -7
- package/dist-lib/components/mail/WerkbonProposalForm.d.ts +2 -1
- package/dist-lib/components/mail/WerkbonProposalForm.d.ts.map +1 -1
- package/dist-lib/components/mail/WerkbonProposalForm.js +40 -2
- package/dist-lib/components/mail/WerkbonProposalTable.d.ts +12 -1
- package/dist-lib/components/mail/WerkbonProposalTable.d.ts.map +1 -1
- package/dist-lib/components/mail/WerkbonProposalTable.js +22 -15
- package/dist-lib/integrations/supabase/types.d.ts +1463 -15
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/blok-d.test.d.ts +2 -0
- package/dist-lib/lib/blok-d.test.d.ts.map +1 -0
- package/dist-lib/lib/blok-d.test.js +57 -0
- package/dist-lib/lib/competenties.d.ts +4 -0
- package/dist-lib/lib/competenties.d.ts.map +1 -1
- package/dist-lib/lib/competenties.functions.d.ts +10 -0
- package/dist-lib/lib/competenties.functions.d.ts.map +1 -1
- package/dist-lib/lib/competenties.functions.js +21 -0
- package/dist-lib/lib/competenties.js +10 -0
- package/dist-lib/lib/competenties.test.js +13 -0
- package/dist-lib/lib/email.functions.d.ts +14 -0
- package/dist-lib/lib/email.functions.d.ts.map +1 -1
- package/dist-lib/lib/email.functions.js +36 -20
- package/dist-lib/lib/format.d.ts +4 -0
- package/dist-lib/lib/format.d.ts.map +1 -0
- package/dist-lib/lib/format.js +23 -0
- package/dist-lib/lib/inbox-query.d.ts +9 -0
- package/dist-lib/lib/inbox-query.d.ts.map +1 -0
- package/dist-lib/lib/inbox-query.js +27 -0
- package/dist-lib/lib/sneltoetsen.d.ts +17 -0
- package/dist-lib/lib/sneltoetsen.d.ts.map +1 -0
- package/dist-lib/lib/sneltoetsen.js +20 -0
- package/dist-lib/lib/werkbon-postvak-settings.d.ts +2 -0
- package/dist-lib/lib/werkbon-postvak-settings.d.ts.map +1 -1
- package/dist-lib/lib/werkbon-postvak-settings.js +7 -0
- package/dist-lib/lib/werkbon-proposals.functions.d.ts +13 -0
- package/dist-lib/lib/werkbon-proposals.functions.d.ts.map +1 -1
- package/dist-lib/lib/werkbon-proposals.functions.js +30 -11
- package/dist-lib/lib/werkbon-status.d.ts +3 -0
- package/dist-lib/lib/werkbon-status.d.ts.map +1 -0
- package/dist-lib/lib/werkbon-status.js +14 -0
- package/package.json +6 -2
- package/supabase/werkbon-postvak-installatie.sql +114 -1
package/README.md
CHANGED
|
@@ -70,3 +70,13 @@ Geen nieuwe. Alles komt uit bestaande koppelingen en instellingentabellen.
|
|
|
70
70
|
|
|
71
71
|
### AI-materialen alleen uit Artikelen (1.5.0)
|
|
72
72
|
Instelling `ai_materials_catalog_only` (standaard uit). Aan: een materiaal dat de AI in de mail leest wordt alleen een regel als het precies één artikel in `artikelen_cache` vindt; anders verschijnt het als suggestie onder Materialen.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## Competenties en monteurs (1.6.0)
|
|
76
|
+
Onder Monteur staat altijd een meerkeuzemenu met competenties (vanaf 1.7.0 zonder schakelaar). Zodra je een competentie aanvinkt, toont het monteursmenu alleen monteurs met alle aangevinkte competenties (bron: `uren_medewerker_competenties` van Urenregistratie, alleen lezen), en verschijnt een rode melding als de gekozen monteur een competentie mist. Ontbreekt die tabel, dan wordt niet gefilterd. De kolommen `competenties_enabled` en `competenties_filter_monteurs` bestaan nog maar worden niet meer gelezen.
|
|
77
|
+
|
|
78
|
+
## Postvak per pagina en sneltoetsen (1.8.0)
|
|
79
|
+
- Het Postvak haalt mails per pagina op via de RPC `werkbon_inbox_page`. Zoeken (onderwerp, afzender, tekst, klantnaam), filteren en sorteren gebeuren in de database. Het aantal per pagina staat in de instelling `inbox_page_size` (standaard 50).
|
|
80
|
+
- Afwijzen: `werkbon_proposal_reject(p_proposal_id, p_expected_updated_at)` zet `reviewed_by` op `auth.uid()`. `werkbon_proposal_unreject` zet het voorstel terug op open. Beide weigeren bij een gewijzigde `updated_at`.
|
|
81
|
+
- Sneltoetsen: j = volgende, k = vorige, e = archiveren, ? = overzicht. Ze werken niet in invoervelden.
|
|
82
|
+
- Bedragen via `formatEuro` en datums via `formatDatum`/`formatDatumTijd` (src/lib/format.ts).
|
|
@@ -40,5 +40,5 @@ export function TemplateModulePage() {
|
|
|
40
40
|
setLoading(false);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
return (_jsxs("main", { className: "p-6 space-y-6", children: [isAdmin && (_jsxs("div", { className: "text-sm text-muted-foreground", children: ["Ingelogd als admin: ", user?.email] })), _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Overzicht" }) }), _jsxs(CardContent, { children: [loading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Laden
|
|
43
|
+
return (_jsxs("main", { className: "p-6 space-y-6", children: [isAdmin && (_jsxs("div", { className: "text-sm text-muted-foreground", children: ["Ingelogd als admin: ", user?.email] })), _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: "Overzicht" }) }), _jsxs(CardContent, { children: [loading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Laden\u2026" })) : items.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: "Geen gegevens gevonden." })) : (_jsxs("p", { className: "text-sm", children: [items.length, " items geladen."] })), _jsx(Button, { onClick: loadData, className: "mt-4", disabled: loading, children: "Vernieuwen" })] })] }), _jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [_jsx(TemplateModuleLogo, { className: "w-6 h-6 text-primary" }), _jsx("span", { children: "SVG-component (voorkeur voor vector-logo's)" })] })] }));
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WerkbonMailPage.d.ts","sourceRoot":"","sources":["../../src/components/WerkbonMailPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WerkbonMailPage.d.ts","sourceRoot":"","sources":["../../src/components/WerkbonMailPage.tsx"],"names":[],"mappings":"AAiDA,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,UAAU,CAAC;AAEzD,wBAAgB,eAAe,CAAC,EAAE,IAAoB,EAAE,GAAE;IAAE,IAAI,CAAC,EAAE,eAAe,CAAA;CAAO,+BAkVxF"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect,
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { RefreshCw } from "lucide-react";
|
|
4
|
-
import { supabase, toast, Button, Input, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Tabs, TabsList, TabsTrigger, } from "@flowselections/core";
|
|
4
|
+
import { supabase, toast, Button, Input, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Tabs, TabsList, TabsTrigger, Dialog, DialogContent, DialogHeader, DialogTitle, } from "@flowselections/core";
|
|
5
|
+
import { aantalPaginas, normaliseerSort } from "../lib/inbox-query";
|
|
6
|
+
import { SNELTOETSEN, sneltoetsActie } from "../lib/sneltoetsen";
|
|
5
7
|
import { useServerFn } from "@tanstack/react-start";
|
|
6
8
|
import { listInboxEvents, getInboxEvent, setEmailState, } from "../lib/email.functions";
|
|
7
9
|
import { useEmailPurpose } from "../hooks/useEmailPurpose";
|
|
@@ -9,6 +11,15 @@ import { useAutoAnalyse } from "../hooks/useAutoAnalyse";
|
|
|
9
11
|
import { listWerkbonSummaries, } from "../lib/werkbon-proposals.functions";
|
|
10
12
|
import { WerkbonProposalTable } from "./mail/WerkbonProposalTable";
|
|
11
13
|
import { WerkbonProposalDialog } from "./mail/WerkbonProposalDialog";
|
|
14
|
+
const SORT_KEY = "werkbon-postvak:sortering";
|
|
15
|
+
function leesSort() {
|
|
16
|
+
try {
|
|
17
|
+
return normaliseerSort(window.localStorage.getItem(SORT_KEY));
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return "nieuwste";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
12
23
|
export function WerkbonMailPage({ mode = "voorstellen" } = {}) {
|
|
13
24
|
const readOnly = mode === "verwerkt";
|
|
14
25
|
const fetchInbox = useServerFn(listInboxEvents);
|
|
@@ -22,7 +33,34 @@ export function WerkbonMailPage({ mode = "voorstellen" } = {}) {
|
|
|
22
33
|
const [loading, setLoading] = useState(true);
|
|
23
34
|
const [search, setSearch] = useState("");
|
|
24
35
|
const [period, setPeriod] = useState("alles");
|
|
25
|
-
const [sort,
|
|
36
|
+
const [sort, setSortState] = useState("nieuwste");
|
|
37
|
+
const [debounced, setDebounced] = useState("");
|
|
38
|
+
const [page, setPage] = useState(1);
|
|
39
|
+
const [total, setTotal] = useState(0);
|
|
40
|
+
const [pageSize, setPageSize] = useState(50);
|
|
41
|
+
const [loadError, setLoadError] = useState(null);
|
|
42
|
+
const [helpOpen, setHelpOpen] = useState(false);
|
|
43
|
+
const firstLoad = useRef(true);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setSortState(leesSort());
|
|
46
|
+
}, []);
|
|
47
|
+
const setSort = useCallback((v) => {
|
|
48
|
+
setSortState(v);
|
|
49
|
+
setPage(1);
|
|
50
|
+
try {
|
|
51
|
+
window.localStorage.setItem(SORT_KEY, v);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
/* localStorage niet beschikbaar */
|
|
55
|
+
}
|
|
56
|
+
}, []);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
const t = setTimeout(() => {
|
|
59
|
+
setDebounced(search);
|
|
60
|
+
setPage(1);
|
|
61
|
+
}, 300);
|
|
62
|
+
return () => clearTimeout(t);
|
|
63
|
+
}, [search]);
|
|
26
64
|
const [openMail, setOpenMail] = useState(null);
|
|
27
65
|
const [mailLoading, setMailLoading] = useState(false);
|
|
28
66
|
const [refreshing, setRefreshing] = useState(false);
|
|
@@ -47,21 +85,32 @@ export function WerkbonMailPage({ mode = "voorstellen" } = {}) {
|
|
|
47
85
|
const load = useCallback(async (archived) => {
|
|
48
86
|
if (!purpose)
|
|
49
87
|
return;
|
|
50
|
-
|
|
88
|
+
if (firstLoad.current)
|
|
89
|
+
setLoading(true);
|
|
51
90
|
try {
|
|
52
|
-
const
|
|
91
|
+
const days = period === "alles" ? null : Number(period);
|
|
92
|
+
const since = days ? new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString() : null;
|
|
93
|
+
const res = await fetchInbox({
|
|
94
|
+
data: { purpose, archived, search: debounced, sort, page, processed: readOnly, since },
|
|
95
|
+
});
|
|
53
96
|
const list = Array.isArray(res?.events) ? res.events : [];
|
|
54
97
|
setMails(list);
|
|
98
|
+
setTotal(Number(res?.total ?? 0));
|
|
99
|
+
if (res?.page_size)
|
|
100
|
+
setPageSize(res.page_size);
|
|
101
|
+
setLoadError(null);
|
|
55
102
|
void loadSummaries(list);
|
|
56
103
|
}
|
|
57
|
-
catch {
|
|
58
|
-
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.error("Postvak laden", error);
|
|
106
|
+
setLoadError("Controleer je verbinding en probeer het opnieuw.");
|
|
59
107
|
setMails([]);
|
|
60
108
|
}
|
|
61
109
|
finally {
|
|
110
|
+
firstLoad.current = false;
|
|
62
111
|
setLoading(false);
|
|
63
112
|
}
|
|
64
|
-
}, [fetchInbox, purpose, loadSummaries]);
|
|
113
|
+
}, [fetchInbox, purpose, loadSummaries, debounced, sort, page, period, readOnly]);
|
|
65
114
|
useEffect(() => {
|
|
66
115
|
setOpenMail(null);
|
|
67
116
|
load(tab === "archief");
|
|
@@ -97,33 +146,8 @@ export function WerkbonMailPage({ mode = "voorstellen" } = {}) {
|
|
|
97
146
|
supabase.removeChannel(channel);
|
|
98
147
|
};
|
|
99
148
|
}, [tab, load]);
|
|
100
|
-
const filtered =
|
|
101
|
-
|
|
102
|
-
const days = period === "alles" ? null : Number(period);
|
|
103
|
-
const since = days ? Date.now() - days * 24 * 60 * 60 * 1000 : null;
|
|
104
|
-
const list = mails.filter((m) => {
|
|
105
|
-
const status = summaries[m.id]?.status ?? "pending";
|
|
106
|
-
const processed = status === "approved" || status === "rejected";
|
|
107
|
-
if (readOnly !== processed)
|
|
108
|
-
return false;
|
|
109
|
-
if (since) {
|
|
110
|
-
const at = m.received_at ? new Date(m.received_at).getTime() : 0;
|
|
111
|
-
if (!at || at < since)
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
if (!q)
|
|
115
|
-
return true;
|
|
116
|
-
const customer = summaries[m.id]?.customer_name ?? "";
|
|
117
|
-
return (m.from.toLowerCase().includes(q) ||
|
|
118
|
-
m.subject.toLowerCase().includes(q) ||
|
|
119
|
-
m.snippet.toLowerCase().includes(q) ||
|
|
120
|
-
customer.toLowerCase().includes(q));
|
|
121
|
-
});
|
|
122
|
-
return [...list].sort((a, b) => {
|
|
123
|
-
const cmp = (b.received_at ?? "").localeCompare(a.received_at ?? "");
|
|
124
|
-
return sort === "nieuwste" ? cmp : -cmp;
|
|
125
|
-
});
|
|
126
|
-
}, [mails, search, period, sort, summaries, readOnly]);
|
|
149
|
+
const filtered = mails;
|
|
150
|
+
const pages = aantalPaginas(total, pageSize);
|
|
127
151
|
const openIndex = openMail ? filtered.findIndex((m) => m.id === openMail.id) : -1;
|
|
128
152
|
const handleOpen = async (mail) => {
|
|
129
153
|
setOpenMail(mail);
|
|
@@ -158,12 +182,53 @@ export function WerkbonMailPage({ mode = "voorstellen" } = {}) {
|
|
|
158
182
|
await updateState({ data: { event_id: mail.id, is_archived: next, is_read: true } });
|
|
159
183
|
toast.success(next ? "Bericht gearchiveerd" : "Bericht teruggezet");
|
|
160
184
|
}
|
|
161
|
-
catch {
|
|
162
|
-
|
|
185
|
+
catch (error) {
|
|
186
|
+
console.error(error);
|
|
187
|
+
toast.error("Archiveren is niet gelukt. Probeer het opnieuw.");
|
|
163
188
|
load(tab === "archief");
|
|
164
189
|
}
|
|
165
190
|
};
|
|
166
|
-
|
|
191
|
+
const keyRef = useRef(() => { });
|
|
192
|
+
keyRef.current = (e) => {
|
|
193
|
+
const t = e.target;
|
|
194
|
+
const actie = sneltoetsActie({
|
|
195
|
+
key: e.key, ctrlKey: e.ctrlKey, metaKey: e.metaKey, altKey: e.altKey,
|
|
196
|
+
targetTag: t?.tagName ?? null, targetEditable: Boolean(t?.isContentEditable),
|
|
197
|
+
});
|
|
198
|
+
if (!actie)
|
|
199
|
+
return;
|
|
200
|
+
if (actie === "overzicht") {
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
setHelpOpen(true);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (!openMail)
|
|
206
|
+
return;
|
|
207
|
+
if (actie === "volgende" && openIndex >= 0 && openIndex < filtered.length - 1) {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
void handleOpen(filtered[openIndex + 1]);
|
|
210
|
+
}
|
|
211
|
+
else if (actie === "vorige" && openIndex > 0) {
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
void handleOpen(filtered[openIndex - 1]);
|
|
214
|
+
}
|
|
215
|
+
else if (actie === "archiveren") {
|
|
216
|
+
e.preventDefault();
|
|
217
|
+
void handleToggleArchive(openMail);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
const on = (e) => keyRef.current(e);
|
|
222
|
+
window.addEventListener("keydown", on);
|
|
223
|
+
return () => window.removeEventListener("keydown", on);
|
|
224
|
+
}, []);
|
|
225
|
+
return (_jsxs("main", { className: "p-6", children: [_jsxs("div", { className: "rounded-lg border border-border bg-card", children: [_jsxs("div", { className: "space-y-3 border-b border-border p-4", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx(Tabs, { value: tab, onValueChange: (v) => {
|
|
226
|
+
setTab(v);
|
|
227
|
+
setPage(1);
|
|
228
|
+
}, children: _jsxs(TabsList, { children: [_jsx(TabsTrigger, { value: "inbox", children: "Inbox" }), _jsx(TabsTrigger, { value: "archief", children: "Archief" })] }) }), _jsxs(Button, { variant: "outline", size: "sm", onClick: handleRefresh, disabled: refreshing || loading, "aria-label": "Berichten vernieuwen", className: "min-h-11", children: [_jsx(RefreshCw, { className: `mr-2 h-4 w-4 ${refreshing || loading ? "animate-spin" : ""}` }), "Vernieuwen"] })] }), _jsxs("div", { className: "grid grid-cols-1 gap-2 sm:grid-cols-[minmax(0,1fr)_10rem_10rem]", children: [_jsx(Input, { placeholder: "Zoek op klant, afzender of onderwerp", value: search, onChange: (e) => setSearch(e.target.value) }), _jsxs(Select, { value: period, onValueChange: (v) => {
|
|
229
|
+
setPeriod(v);
|
|
230
|
+
setPage(1);
|
|
231
|
+
}, children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: "Periode" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "alles", children: "Alle periodes" }), _jsx(SelectItem, { value: "7", children: "Laatste 7 dagen" }), _jsx(SelectItem, { value: "30", children: "Laatste 30 dagen" }), _jsx(SelectItem, { value: "90", children: "Laatste 90 dagen" })] })] }), _jsxs(Select, { value: sort, onValueChange: (v) => setSort(normaliseerSort(v)), children: [_jsx(SelectTrigger, { children: _jsx(SelectValue, { placeholder: "Sortering" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "nieuwste", children: "Nieuwste eerst" }), _jsx(SelectItem, { value: "oudste", children: "Oudste eerst" }), _jsx(SelectItem, { value: "afzender", children: "Afzender" }), _jsx(SelectItem, { value: "onderwerp", children: "Onderwerp" })] })] })] }), _jsxs("p", { className: "text-xs text-muted-foreground", children: [total, " berichten", pages > 1 ? ` · pagina ${Math.min(page, pages)} van ${pages}` : ""] })] }), _jsx(WerkbonProposalTable, { mails: filtered, summaries: summaries, analysingIds: analysingIds, loading: loading, emptyLabel: tab === "archief" ? "Geen gearchiveerde berichten." : "Geen berichten.", onOpen: handleOpen, serverPaging: { page: Math.min(page, pages), pages, onPage: setPage }, sort: sort, onSort: setSort, error: loadError, onRetry: () => void load(tab === "archief") })] }), openMail && (_jsx(WerkbonProposalDialog, { mail: openMail, mailLoading: mailLoading, onClose: () => setOpenMail(null), onToggleArchive: handleToggleArchive, onSaved: () => loadSummaries(mails), onPrev: openIndex > 0 ? () => void handleOpen(filtered[openIndex - 1]) : null, onNext: openIndex >= 0 && openIndex < filtered.length - 1
|
|
167
232
|
? () => void handleOpen(filtered[openIndex + 1])
|
|
168
|
-
: null, positionLabel: openIndex >= 0 ? `${openIndex + 1}/${filtered.length}` : null, readOnly: readOnly }))] }));
|
|
233
|
+
: null, positionLabel: openIndex >= 0 ? `${openIndex + 1}/${filtered.length}` : null, readOnly: readOnly })), _jsx(Dialog, { open: helpOpen, onOpenChange: setHelpOpen, children: _jsxs(DialogContent, { className: "z-[300]", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: "Sneltoetsen" }) }), _jsx("ul", { className: "space-y-2 text-sm", children: SNELTOETSEN.map((s) => (_jsxs("li", { className: "flex items-center gap-3", children: [_jsx("kbd", { className: "min-w-8 rounded border border-border bg-muted px-2 py-1 text-center font-mono", children: s.toets }), _jsx("span", { children: s.uitleg })] }, s.toets))) }), _jsx("p", { className: "text-xs text-muted-foreground", children: "De sneltoetsen werken niet als je in een invoerveld typt." })] }) })] }));
|
|
169
234
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WerkbonPostvakInstelling.d.ts","sourceRoot":"","sources":["../../src/components/WerkbonPostvakInstelling.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WerkbonPostvakInstelling.d.ts","sourceRoot":"","sources":["../../src/components/WerkbonPostvakInstelling.tsx"],"names":[],"mappings":"AAwDA,wBAAgB,wBAAwB,gCAyHvC"}
|
|
@@ -30,11 +30,6 @@ const TOGGLES = [
|
|
|
30
30
|
label: "Lokale datum voor de AI",
|
|
31
31
|
help: "De AI krijgt de datum van vandaag in de tijdzone hieronder in plaats van de UTC-datum.",
|
|
32
32
|
},
|
|
33
|
-
{
|
|
34
|
-
key: "competenties_enabled",
|
|
35
|
-
label: "Vereiste competenties op werkbon",
|
|
36
|
-
help: "Toont een keuzemenu met competenties uit Urenregistratie. De planning laat de werkbon dan alleen toe bij een monteur met al die competenties.",
|
|
37
|
-
},
|
|
38
33
|
{
|
|
39
34
|
key: "ai_materials_catalog_only",
|
|
40
35
|
label: "AI-materialen alleen uit Artikelen",
|
|
@@ -77,5 +72,5 @@ export function WerkbonPostvakInstelling() {
|
|
|
77
72
|
}
|
|
78
73
|
};
|
|
79
74
|
const busy = loading || saving;
|
|
80
|
-
return (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsxs("div", { className: "flex items-start gap-3", children: [_jsx(ShieldCheck, { className: "mt-1 h-5 w-5 text-primary" }), _jsxs("div", { children: [_jsx(CardTitle, { children: "Werkbonvoorstellen" }), _jsx(CardDescription, { children: "Extra controles. Staat alles uit, dan werkt alles zoals altijd." })] })] }) }), _jsxs(CardContent, { className: "space-y-4", children: [TOGGLES.map((t) => (_jsxs("label", { className: "flex items-start gap-2 text-sm", children: [_jsx("input", { type: "checkbox", className: "mt-0.5 h-4 w-4 accent-[var(--primary)]", checked: value[t.key], disabled: busy, onChange: (e) => setValue((v) => ({ ...v, [t.key]: e.target.checked })) }), _jsxs("span", { children: [_jsx("span", { className: "font-medium", children: t.label }), _jsx("span", { className: "block text-xs text-muted-foreground", children: t.help })] })] }, t.key))), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "postvak-sim", children: "Gelijkenisgrens voor namen (0,1 \u2013 1,0)" }), _jsx(Input, { id: "postvak-sim", type: "number", step: "0.05", min: "0.1", max: "1", className: "w-32", value: value.customer_match_similarity, disabled: busy || !value.customer_match_fuzzy, onChange: (e) => setValue((v) => ({ ...v, customer_match_similarity: Number(e.target.value) })) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "postvak-tz", children: "Tijdzone" }), _jsx(Input, { id: "postvak-tz", className: "w-64", value: value.timezone, disabled: busy, onChange: (e) => setValue((v) => ({ ...v, timezone: e.target.value })) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "postvak-ttl", children: "Maximale duur van een AI-analyse (seconden)" }), _jsx(Input, { id: "postvak-ttl", type: "number", min: "10", step: "10", className: "w-32", value: value.analyse_claim_ttl_seconds, disabled: busy, onChange: (e) => setValue((v) => ({ ...v, analyse_claim_ttl_seconds: Number(e.target.value) })) }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Zolang een mail wordt geanalyseerd, slaan andere open schermen hem over." })] }), _jsx(Button, { onClick: onSave, disabled: busy, children: "Opslaan" })] })] }));
|
|
75
|
+
return (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsxs("div", { className: "flex items-start gap-3", children: [_jsx(ShieldCheck, { className: "mt-1 h-5 w-5 text-primary" }), _jsxs("div", { children: [_jsx(CardTitle, { children: "Werkbonvoorstellen" }), _jsx(CardDescription, { children: "Extra controles. Staat alles uit, dan werkt alles zoals altijd." })] })] }) }), _jsxs(CardContent, { className: "space-y-4", children: [TOGGLES.map((t) => (_jsxs("label", { className: "flex items-start gap-2 text-sm", children: [_jsx("input", { type: "checkbox", className: "mt-0.5 h-4 w-4 accent-[var(--primary)]", checked: value[t.key], disabled: busy, onChange: (e) => setValue((v) => ({ ...v, [t.key]: e.target.checked })) }), _jsxs("span", { children: [_jsx("span", { className: "font-medium", children: t.label }), _jsx("span", { className: "block text-xs text-muted-foreground", children: t.help })] })] }, t.key))), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "postvak-sim", children: "Gelijkenisgrens voor namen (0,1 \u2013 1,0)" }), _jsx(Input, { id: "postvak-sim", type: "number", step: "0.05", min: "0.1", max: "1", className: "w-32", value: value.customer_match_similarity, disabled: busy || !value.customer_match_fuzzy, onChange: (e) => setValue((v) => ({ ...v, customer_match_similarity: Number(e.target.value) })) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "postvak-tz", children: "Tijdzone" }), _jsx(Input, { id: "postvak-tz", className: "w-64", value: value.timezone, disabled: busy, onChange: (e) => setValue((v) => ({ ...v, timezone: e.target.value })) })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "postvak-ttl", children: "Maximale duur van een AI-analyse (seconden)" }), _jsx(Input, { id: "postvak-ttl", type: "number", min: "10", step: "10", className: "w-32", value: value.analyse_claim_ttl_seconds, disabled: busy, onChange: (e) => setValue((v) => ({ ...v, analyse_claim_ttl_seconds: Number(e.target.value) })) }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Zolang een mail wordt geanalyseerd, slaan andere open schermen hem over." })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "postvak-page-size", children: "Mails per pagina in het Postvak" }), _jsx(Input, { id: "postvak-page-size", type: "number", min: "1", max: "500", className: "w-32", value: value.inbox_page_size, disabled: busy, onChange: (e) => setValue((v) => ({ ...v, inbox_page_size: Number(e.target.value) })) })] }), _jsx(Button, { onClick: onSave, disabled: busy, children: "Opslaan" })] })] }));
|
|
81
76
|
}
|
|
@@ -45,5 +45,5 @@ export function CompetentiePicker({ value, disabled, onChange }) {
|
|
|
45
45
|
if (!loading && !available) {
|
|
46
46
|
return _jsx("p", { className: "text-sm text-muted-foreground", children: "Competenties niet beschikbaar." });
|
|
47
47
|
}
|
|
48
|
-
return (_jsxs("div", { className: "space-y-2", children: [_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "outline", className: "w-full justify-between", disabled: disabled || loading, children: [_jsx("span", { className: "truncate", children: loading ? "Laden…" : selected.length ? `${selected.length} gekozen` : "Kies competenties…" }), _jsx(ChevronsUpDown, { className: "h-4 w-4 opacity-50" })] }) }), _jsxs(PopoverContent, { className: "max-h-80 w-[--radix-popover-trigger-width] overflow-y-auto p-2", align: "start", children: [groups.length === 0 && _jsx("p", { className: "p-2 text-sm text-muted-foreground", children: "Geen competenties gevonden." }), groups.map(([cat, list]) => (_jsxs("div", { className: "mb-2", children: [_jsx("p", { className: "px-2 py-1 text-xs font-semibold text-muted-foreground", children: cat }), list.map((c) => (_jsxs("label", { className: "flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-accent", children: [_jsx(Checkbox, { checked: selected.includes(c.id), onCheckedChange: () => toggle(c.id) }), c.naam] }, c.id)))] }, cat)))] })] }), selected.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-1.5", children: selected.map((id) => (_jsxs("span", { className: "inline-flex items-center gap-1 rounded-full bg-secondary px-2 py-0.5 text-xs text-secondary-foreground", children: [byId.get(id)?.naam ?? "Onbekende competentie", !disabled && (_jsx("button", { type: "button", "aria-label": "Verwijderen", onClick: () => toggle(id), children: _jsx(X, { className: "h-3 w-3" }) }))] }, id))) })), _jsx("p", { className: "text-xs text-muted-foreground", children: "Alleen een monteur met al deze competenties kan de werkbon in de planning krijgen." })] }));
|
|
48
|
+
return (_jsxs("div", { className: "space-y-2", children: [_jsxs(Popover, { modal: true, open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "outline", className: "w-full justify-between", disabled: disabled || loading, children: [_jsx("span", { className: "truncate", children: loading ? "Laden…" : selected.length ? `${selected.length} gekozen` : "Kies competenties…" }), _jsx(ChevronsUpDown, { className: "h-4 w-4 opacity-50" })] }) }), _jsxs(PopoverContent, { className: "z-[200] max-h-80 w-[--radix-popover-trigger-width] overflow-y-auto p-2", align: "start", children: [groups.length === 0 && _jsx("p", { className: "p-2 text-sm text-muted-foreground", children: "Geen competenties gevonden." }), groups.map(([cat, list]) => (_jsxs("div", { className: "mb-2", children: [_jsx("p", { className: "px-2 py-1 text-xs font-semibold text-muted-foreground", children: cat }), list.map((c) => (_jsxs("label", { className: "flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-accent", children: [_jsx(Checkbox, { checked: selected.includes(c.id), onCheckedChange: () => toggle(c.id) }), c.naam] }, c.id)))] }, cat)))] })] }), selected.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-1.5", children: selected.map((id) => (_jsxs("span", { className: "inline-flex items-center gap-1 rounded-full bg-secondary px-2 py-0.5 text-xs text-secondary-foreground", children: [byId.get(id)?.naam ?? "Onbekende competentie", !disabled && (_jsx("button", { type: "button", "aria-label": "Verwijderen", onClick: () => toggle(id), children: _jsx(X, { className: "h-3 w-3" }) }))] }, id))) })), _jsx("p", { className: "text-xs text-muted-foreground", children: "Alleen een monteur met al deze competenties kan de werkbon in de planning krijgen." })] }));
|
|
49
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MailPane.d.ts","sourceRoot":"","sources":["../../../src/components/mail/MailPane.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MailPane.d.ts","sourceRoot":"","sources":["../../../src/components/mail/MailPane.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,2BAA2B,CAAC;AAK5E,UAAU,KAAK;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CAC7C;AAkBD,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAe,EAAE,eAAe,EAAE,EAAE,KAAK,+BAsOzE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { formatDatumTijd } from "../../lib/format";
|
|
2
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
4
|
import { Archive, ArchiveRestore, ChevronDown, ChevronUp, LoaderCircle, RefreshCw, ZoomIn, ZoomOut, } from "lucide-react";
|
|
4
5
|
import { Button } from "@flowselections/core";
|
|
@@ -118,14 +119,6 @@ export function MailPane({ mail, loading = false, onToggleArchive }) {
|
|
|
118
119
|
let body = sourceHtml ? sanitizeEmailDocument(sourceHtml) : textToHtml(mail.text);
|
|
119
120
|
if (body && sourceHtml && !full?.html)
|
|
120
121
|
body = resolveInlineImages(body, attachments);
|
|
121
|
-
const received = mail.received_at
|
|
122
|
-
? new Date(mail.received_at).toLocaleString("nl-NL", {
|
|
123
|
-
day: "2-digit",
|
|
124
|
-
month: "2-digit",
|
|
125
|
-
year: "numeric",
|
|
126
|
-
hour: "2-digit",
|
|
127
|
-
minute: "2-digit",
|
|
128
|
-
})
|
|
129
|
-
: "";
|
|
122
|
+
const received = formatDatumTijd(mail.received_at);
|
|
130
123
|
return (_jsxs("div", { className: "flex h-full min-h-0 flex-col bg-card", children: [_jsxs("div", { className: "shrink-0 border-b border-border px-4 py-3", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx("h3", { className: "min-w-0 flex-1 text-lg font-semibold break-words", children: mail.subject || "(geen onderwerp)" }), _jsx(Button, { variant: "ghost", size: "icon", "aria-label": headOpen ? "Gegevens verbergen" : "Gegevens tonen", onClick: toggleHead, children: headOpen ? _jsx(ChevronUp, { className: "h-4 w-4" }) : _jsx(ChevronDown, { className: "h-4 w-4" }) })] }), headOpen ? (_jsxs("dl", { className: "mt-2 grid grid-cols-[3.5rem_minmax(0,1fr)] gap-x-2 gap-y-0.5 text-xs text-muted-foreground", children: [_jsx("dt", { className: "font-medium", children: "Van" }), _jsx("dd", { className: "break-words", children: mail.from || "onbekend" }), mail.to.length > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { className: "font-medium", children: "Aan" }), _jsx("dd", { className: "break-words", children: mail.to.join(", ") })] })), mail.cc.length > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { className: "font-medium", children: "Cc" }), _jsx("dd", { className: "break-words", children: mail.cc.join(", ") })] })), received && (_jsxs(_Fragment, { children: [_jsx("dt", { className: "font-medium", children: "Datum" }), _jsx("dd", { children: received })] }))] })) : (_jsxs("p", { className: "mt-1 truncate text-xs text-muted-foreground", children: [mail.from || "onbekend", received ? ` · ${received}` : ""] })), _jsxs("div", { className: "mt-3 flex flex-wrap items-center gap-2", children: [_jsxs("div", { className: "flex items-center gap-1 rounded-md border border-border px-1", children: [_jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Uitzoomen", onClick: () => changeZoom(-10), children: _jsx(ZoomOut, { className: "h-4 w-4" }) }), _jsxs("span", { className: "w-10 text-center text-xs tabular-nums text-muted-foreground", children: [zoom, "%"] }), _jsx(Button, { variant: "ghost", size: "icon", "aria-label": "Inzoomen", onClick: () => changeZoom(10), children: _jsx(ZoomIn, { className: "h-4 w-4" }) })] }), _jsxs(Button, { variant: "outline", size: "sm", onClick: () => loadFull(true), disabled: fullLoading, "aria-label": "Mail opnieuw ophalen", children: [_jsx(RefreshCw, { className: `mr-2 h-4 w-4 ${fullLoading ? "animate-spin" : ""}` }), "Opnieuw ophalen"] }), _jsx(Button, { variant: "outline", size: "sm", onClick: () => onToggleArchive(mail), children: mail.is_archived ? (_jsxs(_Fragment, { children: [_jsx(ArchiveRestore, { className: "mr-2 h-4 w-4" }), "Terugzetten"] })) : (_jsxs(_Fragment, { children: [_jsx(Archive, { className: "mr-2 h-4 w-4" }), "Archiveren"] })) })] }), full?.error && (_jsxs("p", { className: "mt-2 text-xs text-destructive", children: ["Afbeeldingen ophalen lukte niet: ", full.error] }))] }), _jsx("div", { className: "relative min-h-0 flex-1 overflow-hidden bg-white", children: loading ? (_jsxs("div", { className: "flex h-full items-center justify-center gap-2 text-sm text-muted-foreground", children: [_jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" }), "Volledige mail laden\u2026"] })) : body ? (_jsxs(_Fragment, { children: [_jsx("iframe", { ref: iframeRef, title: mail.subject || "E-mailinhoud", sandbox: "allow-popups allow-popups-to-escape-sandbox allow-same-origin", referrerPolicy: "no-referrer", srcDoc: emailDocument(body), onLoad: applyFitScale, className: "h-full w-full border-0 bg-white" }), fullLoading && (_jsxs("span", { className: "absolute right-3 top-3 flex items-center gap-2 rounded-md bg-background/90 px-2 py-1 text-xs text-muted-foreground shadow", children: [_jsx(LoaderCircle, { className: "h-3 w-3 animate-spin" }), "Afbeeldingen ophalen\u2026"] }))] })) : (_jsx("p", { className: "p-4 text-sm text-muted-foreground", children: "Dit bericht heeft geen inhoud." })) }), !loading && _jsx(MailAttachments, { attachments: attachments })] }));
|
|
131
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MailReader.d.ts","sourceRoot":"","sources":["../../../src/components/mail/MailReader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MailReader.d.ts","sourceRoot":"","sources":["../../../src/components/mail/MailReader.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,UAAU,KAAK;IACb,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB,eAAe,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CAC7C;AAED,wBAAgB,UAAU,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,KAAK,+BA0D1D"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { formatDatumTijd } from "../../lib/format";
|
|
2
3
|
import { Archive, ArchiveRestore, Mail } from "lucide-react";
|
|
3
4
|
import { Button } from "@flowselections/core";
|
|
4
5
|
import { sanitizeHtml, textToHtml } from "../../lib/sanitizeHtml";
|
|
@@ -8,14 +9,6 @@ export function MailReader({ mail, onToggleArchive }) {
|
|
|
8
9
|
return (_jsxs("div", { className: "flex-1 flex flex-col items-center justify-center text-muted-foreground gap-2", children: [_jsx(Mail, { className: "h-8 w-8" }), _jsx("p", { className: "text-sm", children: "Selecteer een bericht om te lezen." })] }));
|
|
9
10
|
}
|
|
10
11
|
const body = mail.html ? sanitizeHtml(mail.html) : textToHtml(mail.text);
|
|
11
|
-
const received = mail.received_at
|
|
12
|
-
? new Date(mail.received_at).toLocaleString("nl-NL", {
|
|
13
|
-
day: "2-digit",
|
|
14
|
-
month: "long",
|
|
15
|
-
year: "numeric",
|
|
16
|
-
hour: "2-digit",
|
|
17
|
-
minute: "2-digit",
|
|
18
|
-
})
|
|
19
|
-
: "";
|
|
12
|
+
const received = formatDatumTijd(mail.received_at);
|
|
20
13
|
return (_jsxs("div", { className: "flex-1 overflow-y-auto", children: [_jsx("div", { className: "border-b border-border p-5", children: _jsxs("div", { className: "flex items-start gap-3", children: [_jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("h2", { className: "text-lg font-semibold break-words", children: mail.subject }), _jsxs("p", { className: "text-sm text-muted-foreground mt-1 break-words", children: ["Van ", mail.from || "onbekend"] }), mail.to.length > 0 && (_jsxs("p", { className: "text-xs text-muted-foreground break-words", children: ["Aan ", mail.to.join(", ")] })), received && _jsx("p", { className: "text-xs text-muted-foreground mt-1", children: received })] }), _jsx(Button, { variant: "outline", size: "sm", onClick: () => onToggleArchive(mail), children: mail.is_archived ? (_jsxs(_Fragment, { children: [_jsx(ArchiveRestore, { className: "h-4 w-4 mr-2" }), "Terugzetten"] })) : (_jsxs(_Fragment, { children: [_jsx(Archive, { className: "h-4 w-4 mr-2" }), "Archiveren"] })) })] }) }), _jsxs("div", { className: "p-5", children: [body ? (_jsx("div", { className: "prose prose-sm max-w-none text-sm [&_a]:text-primary [&_img]:max-w-full", dangerouslySetInnerHTML: { __html: body } })) : (_jsx("p", { className: "text-sm text-muted-foreground", children: "Dit bericht heeft geen inhoud." })), _jsx(MailAttachments, { attachments: mail.attachments })] })] }));
|
|
21
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WerkbonProposalDialog.d.ts","sourceRoot":"","sources":["../../../src/components/mail/WerkbonProposalDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WerkbonProposalDialog.d.ts","sourceRoot":"","sources":["../../../src/components/mail/WerkbonProposalDialog.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AA8B5D,UAAU,KAAK;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA2ED,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,WAAmB,EACnB,OAAO,EACP,eAAe,EACf,OAAO,EACP,MAAa,EACb,MAAa,EACb,aAAoB,EACpB,QAAgB,GACjB,EAAE,KAAK,+BAweP"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { formatDatumTijd } from "../../lib/format";
|
|
2
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
4
|
import { ChevronLeft, ChevronRight, Sparkles, X } from "lucide-react";
|
|
4
5
|
import { Button, Input, toast } from "@flowselections/core";
|
|
5
6
|
import { useServerFn } from "@tanstack/react-start";
|
|
6
7
|
import { sendMailForPurpose } from "@flowselections/e-mail-authenticatie-module";
|
|
7
|
-
import { analyseWerkbonMail, prepareWerkbonAnalyse, approveWerkbonProposal, getWerkbonProposalForMail, listWerkbonOptions, markWerkbonConfirmationSent, getConfirmationDelivery, rejectWerkbonProposal, saveWerkbonProposal, } from "../../lib/werkbon-proposals.functions";
|
|
8
|
+
import { analyseWerkbonMail, prepareWerkbonAnalyse, approveWerkbonProposal, getWerkbonProposalForMail, listWerkbonOptions, markWerkbonConfirmationSent, getConfirmationDelivery, rejectWerkbonProposal, unrejectWerkbonProposal, saveWerkbonProposal, } from "../../lib/werkbon-proposals.functions";
|
|
8
9
|
import { buildConfirmationMail, extractEmail } from "../../lib/werkbon-confirmation-mail";
|
|
9
10
|
import { useEmailPurpose } from "../../hooks/useEmailPurpose";
|
|
10
11
|
import { isValidEmail } from "../../lib/werkbon-approve-rows";
|
|
@@ -83,6 +84,7 @@ export function WerkbonProposalDialog({ mail, mailLoading = false, onClose, onTo
|
|
|
83
84
|
const persist = useServerFn(saveWerkbonProposal);
|
|
84
85
|
const approve = useServerFn(approveWerkbonProposal);
|
|
85
86
|
const reject = useServerFn(rejectWerkbonProposal);
|
|
87
|
+
const unreject = useServerFn(unrejectWerkbonProposal);
|
|
86
88
|
const analyse = useServerFn(analyseWerkbonMail);
|
|
87
89
|
const prepare = useServerFn(prepareWerkbonAnalyse);
|
|
88
90
|
const aiChat = useServerFn(runAiChat);
|
|
@@ -276,7 +278,7 @@ export function WerkbonProposalDialog({ mail, mailLoading = false, onClose, onTo
|
|
|
276
278
|
internal_notes: value.internal_notes,
|
|
277
279
|
lines: value.lines,
|
|
278
280
|
expected_updated_at: settings.optimistic_lock_enabled ? (proposal?.updated_at ?? null) : null,
|
|
279
|
-
|
|
281
|
+
vereiste_competentie_ids: value.vereiste_competentie_ids ?? [],
|
|
280
282
|
});
|
|
281
283
|
const confirmWerkbon = async () => {
|
|
282
284
|
if (!proposal || !form)
|
|
@@ -359,11 +361,30 @@ export function WerkbonProposalDialog({ mail, mailLoading = false, onClose, onTo
|
|
|
359
361
|
rejectedRef.current = true;
|
|
360
362
|
setSaving(true);
|
|
361
363
|
try {
|
|
362
|
-
await persist({ data: payload(proposal.id, form) });
|
|
363
|
-
|
|
364
|
-
|
|
364
|
+
const saved = await persist({ data: payload(proposal.id, form) });
|
|
365
|
+
const id = proposal.id;
|
|
366
|
+
const rejected = await reject({
|
|
367
|
+
data: { proposal_id: id, expected_updated_at: saved?.updated_at ?? null },
|
|
368
|
+
});
|
|
365
369
|
onSaved();
|
|
366
370
|
onClose();
|
|
371
|
+
toast.success("Voorstel afgewezen", {
|
|
372
|
+
duration: 8000,
|
|
373
|
+
action: {
|
|
374
|
+
label: "Ongedaan maken",
|
|
375
|
+
onClick: () => {
|
|
376
|
+
void unreject({ data: { proposal_id: id, expected_updated_at: rejected?.updated_at ?? null } })
|
|
377
|
+
.then(() => {
|
|
378
|
+
toast.success("Voorstel staat weer open");
|
|
379
|
+
onSaved();
|
|
380
|
+
})
|
|
381
|
+
.catch((error) => {
|
|
382
|
+
console.error(error);
|
|
383
|
+
toast.error(errorText(error, "Ongedaan maken is niet gelukt."));
|
|
384
|
+
});
|
|
385
|
+
},
|
|
386
|
+
},
|
|
387
|
+
});
|
|
367
388
|
}
|
|
368
389
|
catch (error) {
|
|
369
390
|
toast.error(errorText(error, "Afwijzen is niet gelukt."));
|
|
@@ -376,10 +397,10 @@ export function WerkbonProposalDialog({ mail, mailLoading = false, onClose, onTo
|
|
|
376
397
|
setSendTo(extractEmail(mail.from));
|
|
377
398
|
setSendConfirmation(true);
|
|
378
399
|
setConfirmOpen(true);
|
|
379
|
-
}, onReject: rejectProposal, onNewCustomer: () => setNewKlantOpen(true), readOnly: readOnly, showCompetenties:
|
|
400
|
+
}, onReject: rejectProposal, onNewCustomer: () => setNewKlantOpen(true), readOnly: readOnly, showCompetenties: true, filterMonteurs: true }) })), readOnly && proposal && (proposal.confirmation_sent_at || proposal.confirmation_error) && (_jsx("div", { className: "shrink-0 border-t border-border px-4 py-2 text-xs text-muted-foreground", children: proposal.confirmation_sent_at ? (_jsxs(_Fragment, { children: [_jsx("p", { children: `Orderbevestiging aangeboden voor ${proposal.confirmation_to ?? "klant"} op ${formatDatumTijd(proposal.confirmation_sent_at)}` }), _jsx("p", { className: delivery?.last_error || delivery?.status === "failed" ? "text-destructive" : undefined, children: !delivery
|
|
380
401
|
? "Verzendstatus mailserver: onbekend"
|
|
381
402
|
: delivery.sent_at
|
|
382
|
-
? `Verstuurd door mailserver op ${
|
|
403
|
+
? `Verstuurd door mailserver op ${formatDatumTijd(delivery.sent_at)}`
|
|
383
404
|
: delivery.last_error
|
|
384
405
|
? `Mailserver-fout: ${delivery.last_error}`
|
|
385
406
|
: `Verzendstatus mailserver: ${delivery.status ?? "in wachtrij"}` })] })) : (_jsx("p", { children: `Orderbevestiging niet verstuurd: ${proposal.confirmation_error}` })) }))] })] })] }), confirmOpen && (_jsx("div", { className: "fixed inset-0 z-[200] flex items-center justify-center bg-foreground/40 p-4", onClick: () => !saving && setConfirmOpen(false), children: _jsxs("div", { className: "w-full max-w-md space-y-4 rounded-lg border border-border bg-card p-5 shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsx("h3", { className: "text-base font-semibold", children: "Werkbon aanmaken" }), _jsxs("label", { className: "flex items-center gap-2 text-sm", children: [_jsx("input", { type: "checkbox", checked: sendConfirmation, onChange: (e) => setSendConfirmation(e.target.checked) }), "Orderbevestiging naar klant sturen"] }), sendConfirmation && (_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: "text-sm", children: extractEmail(sendTo)
|
|
@@ -26,7 +26,8 @@ interface Props {
|
|
|
26
26
|
onNewCustomer: () => void;
|
|
27
27
|
readOnly?: boolean;
|
|
28
28
|
showCompetenties?: boolean;
|
|
29
|
+
filterMonteurs?: boolean;
|
|
29
30
|
}
|
|
30
|
-
export declare function WerkbonProposalForm({ value, options, saving, analysing, onChange, onConfirm, onReject, onNewCustomer, readOnly, showCompetenties, }: Props): import("react").JSX.Element;
|
|
31
|
+
export declare function WerkbonProposalForm({ value, options, saving, analysing, onChange, onConfirm, onReject, onNewCustomer, readOnly, showCompetenties, filterMonteurs, }: Props): import("react").JSX.Element;
|
|
31
32
|
export {};
|
|
32
33
|
//# sourceMappingURL=WerkbonProposalForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WerkbonProposalForm.d.ts","sourceRoot":"","sources":["../../../src/components/mail/WerkbonProposalForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WerkbonProposalForm.d.ts","sourceRoot":"","sources":["../../../src/components/mail/WerkbonProposalForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAQL,KAAK,WAAW,EAChB,KAAK,cAAc,EAEpB,MAAM,uCAAuC,CAAC;AAM/C,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,2BAA2B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IACpC,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB;AAED,UAAU,KAAK;IACb,KAAK,EAAE,gBAAgB,CAAC;IACxB,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACrD,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AA4cD,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,OAAO,EACP,MAAM,EACN,SAAiB,EACjB,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,aAAa,EACb,QAAgB,EAChB,gBAAwB,EACxB,cAAsB,GACvB,EAAE,KAAK,+BAysBP"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { toast } from "sonner";
|
|
3
4
|
import { parseBedragNaarCenten } from "../../lib/rekenregels";
|
|
4
5
|
import { parseAantal } from "../../lib/aantal";
|
|
5
6
|
import { Check, ChevronsUpDown, Plus, Search, Trash2, UserPlus } from "lucide-react";
|
|
@@ -8,6 +9,8 @@ import { useServerFn } from "@tanstack/react-start";
|
|
|
8
9
|
import { computeWerkbonTravel, getWerkbonLinesTotal, formatEuroCents, searchArtikelen, getArtikelFotos, } from "../../lib/werkbon-proposals.functions";
|
|
9
10
|
import { getKlantStatus } from "../../lib/klanten.functions";
|
|
10
11
|
import { CompetentiePicker } from "./CompetentiePicker";
|
|
12
|
+
import { getCompetenties, getMonteurCompetenties } from "../../lib/competenties.functions";
|
|
13
|
+
import { ontbrekendeCompetenties, monteurVoldoet } from "../../lib/competenties";
|
|
11
14
|
function Section({ title, children }) {
|
|
12
15
|
return (_jsxs("section", { className: "space-y-3 rounded-md border border-border p-4", children: [_jsx("h3", { className: "text-sm font-semibold", children: title }), children] }));
|
|
13
16
|
}
|
|
@@ -185,8 +188,43 @@ function toDateInput(value) {
|
|
|
185
188
|
const d = new Date(value);
|
|
186
189
|
return Number.isNaN(d.getTime()) ? "" : d.toISOString().slice(0, 10);
|
|
187
190
|
}
|
|
188
|
-
export function WerkbonProposalForm({ value, options, saving, analysing = false, onChange, onConfirm, onReject, onNewCustomer, readOnly = false, showCompetenties = false, }) {
|
|
191
|
+
export function WerkbonProposalForm({ value, options, saving, analysing = false, onChange, onConfirm, onReject, onNewCustomer, readOnly = false, showCompetenties = false, filterMonteurs = false, }) {
|
|
189
192
|
const lines = Array.isArray(value.lines) ? value.lines : [];
|
|
193
|
+
// Competentiefilter op monteurs (alleen als de schakelaar aan staat).
|
|
194
|
+
const loadComp = useServerFn(getCompetenties);
|
|
195
|
+
const loadMonteurComp = useServerFn(getMonteurCompetenties);
|
|
196
|
+
const [compLijst, setCompLijst] = useState([]);
|
|
197
|
+
const [monteurComp, setMonteurComp] = useState(null);
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
if (!filterMonteurs)
|
|
200
|
+
return;
|
|
201
|
+
let alive = true;
|
|
202
|
+
Promise.all([loadComp(), loadMonteurComp()])
|
|
203
|
+
.then(([c, m]) => {
|
|
204
|
+
if (!alive)
|
|
205
|
+
return;
|
|
206
|
+
setCompLijst(Array.isArray(c?.items) ? c.items : []);
|
|
207
|
+
if (m?.error)
|
|
208
|
+
toast.error(`Competenties van monteurs laden mislukt: ${m.error}`);
|
|
209
|
+
setMonteurComp(m?.available && m.byMonteur && typeof m.byMonteur === "object" ? m.byMonteur : null);
|
|
210
|
+
})
|
|
211
|
+
.catch((e) => {
|
|
212
|
+
console.error("monteur competenties failed", e);
|
|
213
|
+
if (alive)
|
|
214
|
+
toast.error("Competenties van monteurs laden mislukt.");
|
|
215
|
+
});
|
|
216
|
+
return () => {
|
|
217
|
+
alive = false;
|
|
218
|
+
};
|
|
219
|
+
}, [filterMonteurs, loadComp, loadMonteurComp]);
|
|
220
|
+
const vereist = Array.isArray(value.vereiste_competentie_ids) ? value.vereiste_competentie_ids : [];
|
|
221
|
+
const compActief = filterMonteurs && monteurComp !== null && vereist.length > 0;
|
|
222
|
+
const allTechnicians = Array.isArray(options.technicians) ? options.technicians : [];
|
|
223
|
+
const technicianItems = compActief
|
|
224
|
+
? allTechnicians.filter((t) => t.id === value.technician_id || monteurVoldoet(vereist, monteurComp?.[t.id]))
|
|
225
|
+
: allTechnicians;
|
|
226
|
+
const ontbreekt = compActief && value.technician_id ? ontbrekendeCompetenties(vereist, monteurComp?.[value.technician_id]) : [];
|
|
227
|
+
const ontbreektNamen = ontbreekt.map((id) => compLijst.find((c) => c.id === id)?.naam ?? id);
|
|
190
228
|
const [invalidFields, setInvalidFields] = useState(() => new Set());
|
|
191
229
|
const markInvalid = useCallback((key, bad) => {
|
|
192
230
|
setInvalidFields((prev) => {
|
|
@@ -488,7 +526,7 @@ export function WerkbonProposalForm({ value, options, saving, analysing = false,
|
|
|
488
526
|
estimated_duration_minutes: combineDuration(e.target.value, durationMinutes(value.estimated_duration_minutes)),
|
|
489
527
|
}) }), _jsx("span", { className: "text-xs text-muted-foreground", children: "uur" })] }), _jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx(Input, { inputMode: "numeric", placeholder: "0", "aria-label": "Minuten", value: durationMinutes(value.estimated_duration_minutes), onChange: (e) => onChange({
|
|
490
528
|
estimated_duration_minutes: combineDuration(durationHours(value.estimated_duration_minutes), e.target.value),
|
|
491
|
-
}) }), _jsx("span", { className: "text-xs text-muted-foreground", children: "min" })] })] }) })] }),
|
|
529
|
+
}) }), _jsx("span", { className: "text-xs text-muted-foreground", children: "min" })] })] }) })] }), _jsxs(Field, { label: "Monteur", children: [_jsx(OptionPicker, { value: value.technician_id, items: technicianItems, placeholder: "Kies een monteur\u2026", noun: "monteurs", onSelect: (id) => onChange({ technician_id: id }), onClear: () => onChange({ technician_id: null }) }), ontbreekt.length > 0 && (_jsx("p", { className: "mt-1 text-xs text-destructive", children: `Deze monteur heeft niet alle vereiste competenties: ${ontbreektNamen.join(", ")}` }))] }), showCompetenties && (_jsx(Field, { label: "Vereiste competenties", children: _jsx(CompetentiePicker, { value: value.vereiste_competentie_ids ?? [], disabled: readOnly || saving, onChange: (ids) => onChange({ vereiste_competentie_ids: ids }) }) }))] }), _jsx(Section, { title: "Interne notities", children: _jsx(Textarea, { rows: 3, value: value.internal_notes ?? "", placeholder: "Alleen zichtbaar voor collega's", onChange: (e) => onChange({ internal_notes: e.target.value || null }) }) })] }), !readOnly && mandateCents > 0 && (_jsx("div", { className: "shrink-0 border-t border-border px-4 py-2", children: _jsx(MandaatBalk, { totalCents: totalCents ?? 0, mandateCents: mandateCents }) })), !readOnly && klantBlocked && (_jsxs("div", { className: "shrink-0 border-t border-destructive/40 bg-destructive/10 px-4 py-2 text-sm text-destructive", children: [_jsx("p", { className: "font-semibold", children: "Hier kan je geen werkbon van aanmaken" }), klantNotes[0] && _jsxs("p", { children: ["Reden: ", klantNotes[0]] })] })), !readOnly && (_jsxs("div", { className: "grid shrink-0 grid-cols-[minmax(0,1fr)_auto] gap-2 border-t border-border p-4", children: [_jsx(Button, { className: "w-full", onClick: onConfirm, disabled: saving ||
|
|
492
530
|
analysing ||
|
|
493
531
|
overMandate > 0 ||
|
|
494
532
|
klantBlocked ||
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InboxEvent } from "../../lib/email.functions";
|
|
2
|
+
import type { InboxSort } from "../../lib/inbox-query";
|
|
2
3
|
import type { WerkbonSummary } from "../../lib/werkbon-proposals.functions";
|
|
3
4
|
interface Props {
|
|
4
5
|
mails: InboxEvent[];
|
|
@@ -7,7 +8,17 @@ interface Props {
|
|
|
7
8
|
loading: boolean;
|
|
8
9
|
emptyLabel: string;
|
|
9
10
|
onOpen: (mail: InboxEvent) => void;
|
|
11
|
+
/** Paginering door de database: dan geen eigen opdeling in deze tabel. */
|
|
12
|
+
serverPaging?: {
|
|
13
|
+
page: number;
|
|
14
|
+
pages: number;
|
|
15
|
+
onPage: (p: number) => void;
|
|
16
|
+
} | null;
|
|
17
|
+
sort?: InboxSort;
|
|
18
|
+
onSort?: (s: InboxSort) => void;
|
|
19
|
+
error?: string | null;
|
|
20
|
+
onRetry?: () => void;
|
|
10
21
|
}
|
|
11
|
-
export declare function WerkbonProposalTable({ mails, summaries, analysingIds, loading, emptyLabel, onOpen }: Props): import("react").JSX.Element;
|
|
22
|
+
export declare function WerkbonProposalTable({ mails, summaries, analysingIds, loading, emptyLabel, onOpen, serverPaging, sort, onSort, error, onRetry, }: Props): import("react").JSX.Element;
|
|
12
23
|
export {};
|
|
13
24
|
//# sourceMappingURL=WerkbonProposalTable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WerkbonProposalTable.d.ts","sourceRoot":"","sources":["../../../src/components/mail/WerkbonProposalTable.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E,UAAU,KAAK;IACb,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"WerkbonProposalTable.d.ts","sourceRoot":"","sources":["../../../src/components/mail/WerkbonProposalTable.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAE5E,UAAU,KAAK;IACb,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACnC,0EAA0E;IAC1E,YAAY,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACnF,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAgBD,wBAAgB,oBAAoB,CAAC,EACnC,KAAK,EAAE,SAAS,EAAE,YAAiB,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAChE,YAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAY,EAAE,OAAO,GACzD,EAAE,KAAK,+BA2IP"}
|