@flowselections/e-mail-installatie-techniek 1.0.4 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/integrations/supabase/previewAuthStorage.d.ts +11 -5
- package/dist-lib/integrations/supabase/previewAuthStorage.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/previewAuthStorage.js +59 -24
- package/dist-lib/integrations/supabase/types.d.ts +4007 -43
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/package.json +9 -2
- package/dist-lib/components/PostvakIn.d.ts +0 -2
- package/dist-lib/components/PostvakIn.d.ts.map +0 -1
- package/dist-lib/components/PostvakIn.js +0 -117
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowselections/e-mail-installatie-techniek",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"flowselections": {
|
|
5
5
|
"moduleId": "werkbon_postvak",
|
|
6
6
|
"pages": [
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
"route": "werkbon-mail",
|
|
15
15
|
"title": "Verwerkt"
|
|
16
16
|
}
|
|
17
|
+
],
|
|
18
|
+
"ai": [
|
|
19
|
+
{
|
|
20
|
+
"moduleKey": "werkbon-postvak",
|
|
21
|
+
"name": "Postvak Werkbonnen",
|
|
22
|
+
"description": "Leest werkbon-mails met AI"
|
|
23
|
+
}
|
|
17
24
|
]
|
|
18
25
|
},
|
|
19
26
|
"private": false,
|
|
@@ -66,7 +73,7 @@
|
|
|
66
73
|
"devDependencies": {
|
|
67
74
|
"@cloudflare/vite-plugin": "^1.25.5",
|
|
68
75
|
"@eslint/js": "^9.32.0",
|
|
69
|
-
"@flowselections/core": "1.0.
|
|
76
|
+
"@flowselections/core": "1.0.30",
|
|
70
77
|
"@lovable.dev/vite-tanstack-config": "2.26.5",
|
|
71
78
|
"@rsbuild/core": "^1.0.0",
|
|
72
79
|
"@tailwindcss/vite": "^4.2.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PostvakIn.d.ts","sourceRoot":"","sources":["../../src/components/PostvakIn.tsx"],"names":[],"mappings":"AAsFA,wBAAgB,SAAS,gCA+KxB"}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
3
|
-
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
-
import { useServerFn } from "@tanstack/react-start";
|
|
5
|
-
import { Badge, Button, Card, CardContent, CardHeader, CardTitle, toast, useAuth, } from "@flowselections/core";
|
|
6
|
-
import { RefreshCw } from "lucide-react";
|
|
7
|
-
import { listInboxEvents, markEventsConsumed, } from "@flowselections/e-mail-authenticatie-module";
|
|
8
|
-
import { purposeLabel } from "../lib/email-purposes";
|
|
9
|
-
import { useEmailPurpose } from "../hooks/useEmailPurpose";
|
|
10
|
-
import { sanitizeHtml } from "../lib/sanitizeHtml";
|
|
11
|
-
function str(v) {
|
|
12
|
-
return typeof v === "string" ? v : "";
|
|
13
|
-
}
|
|
14
|
-
function toView(ev) {
|
|
15
|
-
const p = (ev.payload && typeof ev.payload === "object" ? ev.payload : {});
|
|
16
|
-
const fromRaw = p["from"];
|
|
17
|
-
const from = typeof fromRaw === "string"
|
|
18
|
-
? fromRaw
|
|
19
|
-
: fromRaw && typeof fromRaw === "object"
|
|
20
|
-
? str(fromRaw["address"]) ||
|
|
21
|
-
str(fromRaw["email"])
|
|
22
|
-
: "";
|
|
23
|
-
return {
|
|
24
|
-
id: ev.id,
|
|
25
|
-
received_at: ev.received_at ?? str(p["received_at"]) ?? null,
|
|
26
|
-
consumed_at: ev.consumed_at ?? null,
|
|
27
|
-
from,
|
|
28
|
-
subject: str(p["subject"]),
|
|
29
|
-
snippet: str(p["snippet"]),
|
|
30
|
-
text: str(p["text"]) || str(p["text_body"]),
|
|
31
|
-
html: str(p["html"]) || str(p["html_body"]),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function describeError(e) {
|
|
35
|
-
if (typeof Response !== "undefined" && e instanceof Response) {
|
|
36
|
-
if (e.status === 401 || e.status === 403)
|
|
37
|
-
return "Niet geautoriseerd. Je sessie is verlopen of nog niet actief — log opnieuw in.";
|
|
38
|
-
return `Serverfout (${e.status} ${e.statusText}).`;
|
|
39
|
-
}
|
|
40
|
-
if (e instanceof Error)
|
|
41
|
-
return e.message;
|
|
42
|
-
return "Onbekende fout.";
|
|
43
|
-
}
|
|
44
|
-
const fmt = (iso) => iso ? new Date(iso).toLocaleString("nl-NL", { dateStyle: "short", timeStyle: "short" }) : "";
|
|
45
|
-
export function PostvakIn() {
|
|
46
|
-
const { session, loading } = useAuth();
|
|
47
|
-
const sessionReady = !loading && !!session?.access_token;
|
|
48
|
-
const qc = useQueryClient();
|
|
49
|
-
const { purpose } = useEmailPurpose(sessionReady);
|
|
50
|
-
const [openId, setOpenId] = useState(null);
|
|
51
|
-
const [statusFilter, setStatusFilter] = useState("alle");
|
|
52
|
-
const fetchEvents = useServerFn(listInboxEvents);
|
|
53
|
-
const markConsumed = useServerFn(markEventsConsumed);
|
|
54
|
-
const query = useQuery({
|
|
55
|
-
queryKey: ["postvak", purpose],
|
|
56
|
-
enabled: sessionReady && !!purpose,
|
|
57
|
-
refetchInterval: 60000,
|
|
58
|
-
retry: 2,
|
|
59
|
-
retryDelay: (i) => Math.min(1000 * 2 ** i, 5000),
|
|
60
|
-
queryFn: () => fetchEvents({
|
|
61
|
-
data: {
|
|
62
|
-
purpose: purpose,
|
|
63
|
-
direction: "receive",
|
|
64
|
-
unconsumed_only: false,
|
|
65
|
-
limit: 200,
|
|
66
|
-
},
|
|
67
|
-
}),
|
|
68
|
-
});
|
|
69
|
-
const events = useMemo(() => {
|
|
70
|
-
const rows = Array.isArray(query.data?.events) ? query.data.events : [];
|
|
71
|
-
return rows.map(toView);
|
|
72
|
-
}, [query.data]);
|
|
73
|
-
const connectionIds = Array.isArray(query.data?.connectionIds) ? query.data.connectionIds : [];
|
|
74
|
-
const visible = useMemo(() => {
|
|
75
|
-
if (statusFilter === "alle")
|
|
76
|
-
return events;
|
|
77
|
-
return events.filter((ev) => statusFilter === "verwerkt" ? Boolean(ev.consumed_at) : !ev.consumed_at);
|
|
78
|
-
}, [events, statusFilter]);
|
|
79
|
-
const onRefresh = async () => {
|
|
80
|
-
try {
|
|
81
|
-
await query.refetch();
|
|
82
|
-
}
|
|
83
|
-
catch (e) {
|
|
84
|
-
toast.error(describeError(e));
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const onMark = async (id) => {
|
|
88
|
-
try {
|
|
89
|
-
await markConsumed({ data: { event_ids: [id] } });
|
|
90
|
-
toast.success("Gemarkeerd als verwerkt");
|
|
91
|
-
qc.invalidateQueries({ queryKey: ["postvak", purpose] });
|
|
92
|
-
}
|
|
93
|
-
catch (e) {
|
|
94
|
-
toast.error(describeError(e));
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
if (!purpose) {
|
|
98
|
-
return (_jsx("p", { className: "p-6 text-sm text-muted-foreground", children: "Er is nog geen doeleinde gekozen. Ga naar Instellingen \u2192 E-maildoeleinde." }));
|
|
99
|
-
}
|
|
100
|
-
if (!sessionReady || query.isLoading) {
|
|
101
|
-
return _jsx("p", { className: "p-6 text-sm text-muted-foreground", children: "Laden\u2026" });
|
|
102
|
-
}
|
|
103
|
-
if (query.isError) {
|
|
104
|
-
return (_jsxs("div", { className: "space-y-2 p-6", children: [_jsx("p", { className: "text-sm text-foreground", children: describeError(query.error) }), _jsx(Button, { onClick: () => query.refetch(), children: "Opnieuw proberen" })] }));
|
|
105
|
-
}
|
|
106
|
-
if (connectionIds.length === 0) {
|
|
107
|
-
return (_jsxs("p", { className: "p-6 text-sm text-muted-foreground", children: ["Er is nog geen e-mailadres gekoppeld aan \u201C", purposeLabel(purpose), "\u201D. Vraag een beheerder om in E-mailkoppeling een adres aan dit doeleinde te hangen."] }));
|
|
108
|
-
}
|
|
109
|
-
return (_jsxs("div", { className: "space-y-3 p-6", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("h2", { className: "text-lg font-semibold text-foreground", children: ["Postvak in \u2014 ", purposeLabel(purpose)] }), _jsxs("div", { className: "flex items-center gap-1", children: [[
|
|
110
|
-
{ key: "alle", label: `Alle (${events.length})` },
|
|
111
|
-
{ key: "nieuw", label: "Nieuw" },
|
|
112
|
-
{ key: "verwerkt", label: "Verwerkt" },
|
|
113
|
-
].map((opt) => (_jsx(Button, { size: "sm", variant: statusFilter === opt.key ? "default" : "outline", onClick: () => setStatusFilter(opt.key), children: opt.label }, opt.key))), _jsxs(Button, { size: "sm", variant: "outline", onClick: onRefresh, disabled: query.isFetching, title: "Postvak vernieuwen", children: [_jsx(RefreshCw, { className: `h-4 w-4 ${query.isFetching ? "animate-spin" : ""}` }), "Vernieuwen"] })] })] }), visible.length === 0 && (_jsx("p", { className: "text-sm text-muted-foreground", children: statusFilter === "alle" ? "Nog geen berichten." : "Geen berichten in deze selectie." })), visible.map((ev) => {
|
|
114
|
-
const isOpen = openId === ev.id;
|
|
115
|
-
return (_jsxs(Card, { children: [_jsx(CardHeader, { className: "cursor-pointer", onClick: () => setOpenId(isOpen ? null : ev.id), children: _jsxs("div", { className: "flex items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx(CardTitle, { className: "text-base", children: ev.subject || "(geen onderwerp)" }), _jsxs("p", { className: "text-xs text-muted-foreground", children: [ev.from || "Onbekende afzender", " \u00B7 ", fmt(ev.received_at)] })] }), _jsx(Badge, { variant: ev.consumed_at ? "secondary" : "default", children: ev.consumed_at ? "Verwerkt" : "Nieuw" })] }) }), isOpen && (_jsxs(CardContent, { className: "space-y-3", children: [ev.html ? (_jsx("div", { className: "prose prose-sm max-w-none text-sm text-foreground", dangerouslySetInnerHTML: { __html: sanitizeHtml(ev.html) } })) : (_jsx("p", { className: "whitespace-pre-wrap text-sm text-foreground", children: ev.text || ev.snippet || "(geen inhoud beschikbaar)" })), !ev.consumed_at && (_jsx(Button, { variant: "outline", onClick: () => onMark(ev.id), children: "Markeer als verwerkt" }))] }))] }, ev.id));
|
|
116
|
-
})] }));
|
|
117
|
-
}
|