@flowselections/e-mail-installatie-techniek 0.0.0-stage → 1.0.5
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/_core-safelist.d.ts +2 -0
- package/dist-lib/_core-safelist.d.ts.map +1 -0
- package/dist-lib/_core-safelist.js +15 -0
- package/dist-lib/components/EmailDoeleindeInstelling.d.ts +2 -0
- package/dist-lib/components/EmailDoeleindeInstelling.d.ts.map +1 -0
- package/dist-lib/components/EmailDoeleindeInstelling.js +57 -0
- package/dist-lib/components/FlowSelectionsLayout.d.ts +8 -0
- package/dist-lib/components/FlowSelectionsLayout.d.ts.map +1 -0
- package/dist-lib/components/FlowSelectionsLayout.js +7 -0
- package/dist-lib/components/MailAiInstructieInstelling.d.ts +2 -0
- package/dist-lib/components/MailAiInstructieInstelling.d.ts.map +1 -0
- package/dist-lib/components/MailAiInstructieInstelling.js +66 -0
- package/dist-lib/components/PostvakIn.d.ts +2 -0
- package/dist-lib/components/PostvakIn.d.ts.map +1 -0
- package/dist-lib/components/PostvakIn.js +117 -0
- package/dist-lib/components/TemplateModuleLogo.d.ts +6 -0
- package/dist-lib/components/TemplateModuleLogo.d.ts.map +1 -0
- package/dist-lib/components/TemplateModuleLogo.js +4 -0
- package/dist-lib/components/TemplateModulePage.d.ts +2 -0
- package/dist-lib/components/TemplateModulePage.d.ts.map +1 -0
- package/dist-lib/components/TemplateModulePage.js +44 -0
- package/dist-lib/components/TemplatePage.d.ts +2 -0
- package/dist-lib/components/TemplatePage.d.ts.map +1 -0
- package/dist-lib/components/TemplatePage.js +4 -0
- package/dist-lib/components/WerkbonMailPage.d.ts +5 -0
- package/dist-lib/components/WerkbonMailPage.d.ts.map +1 -0
- package/dist-lib/components/WerkbonMailPage.js +169 -0
- package/dist-lib/components/WerkbonVerwerktPage.d.ts +2 -0
- package/dist-lib/components/WerkbonVerwerktPage.d.ts.map +1 -0
- package/dist-lib/components/WerkbonVerwerktPage.js +5 -0
- package/dist-lib/components/klanten/NieuweKlantDialog.d.ts +23 -0
- package/dist-lib/components/klanten/NieuweKlantDialog.d.ts.map +1 -0
- package/dist-lib/components/klanten/NieuweKlantDialog.js +129 -0
- package/dist-lib/components/mail/MailAttachments.d.ts +5 -0
- package/dist-lib/components/mail/MailAttachments.d.ts.map +1 -0
- package/dist-lib/components/mail/MailAttachments.js +34 -0
- package/dist-lib/components/mail/MailListItem.d.ts +9 -0
- package/dist-lib/components/mail/MailListItem.d.ts.map +1 -0
- package/dist-lib/components/mail/MailListItem.js +26 -0
- package/dist-lib/components/mail/MailPane.d.ts +9 -0
- package/dist-lib/components/mail/MailPane.d.ts.map +1 -0
- package/dist-lib/components/mail/MailPane.js +127 -0
- package/dist-lib/components/mail/MailReader.d.ts +8 -0
- package/dist-lib/components/mail/MailReader.d.ts.map +1 -0
- package/dist-lib/components/mail/MailReader.js +21 -0
- package/dist-lib/components/mail/WerkbonProposalDialog.d.ts +15 -0
- package/dist-lib/components/mail/WerkbonProposalDialog.d.ts.map +1 -0
- package/dist-lib/components/mail/WerkbonProposalDialog.js +363 -0
- package/dist-lib/components/mail/WerkbonProposalForm.d.ts +30 -0
- package/dist-lib/components/mail/WerkbonProposalForm.d.ts.map +1 -0
- package/dist-lib/components/mail/WerkbonProposalForm.js +422 -0
- package/dist-lib/components/mail/WerkbonProposalTable.d.ts +13 -0
- package/dist-lib/components/mail/WerkbonProposalTable.d.ts.map +1 -0
- package/dist-lib/components/mail/WerkbonProposalTable.js +43 -0
- package/dist-lib/hooks/useAutoAnalyse.d.ts +4 -0
- package/dist-lib/hooks/useAutoAnalyse.d.ts.map +1 -0
- package/dist-lib/hooks/useAutoAnalyse.js +103 -0
- package/dist-lib/hooks/useEmailPurpose.d.ts +9 -0
- package/dist-lib/hooks/useEmailPurpose.d.ts.map +1 -0
- package/dist-lib/hooks/useEmailPurpose.js +43 -0
- package/dist-lib/hooks/useMijnModuleData.d.ts +13 -0
- package/dist-lib/hooks/useMijnModuleData.d.ts.map +1 -0
- package/dist-lib/hooks/useMijnModuleData.js +49 -0
- package/dist-lib/index.d.ts +17 -0
- package/dist-lib/index.d.ts.map +1 -0
- package/dist-lib/index.js +60 -0
- package/dist-lib/integrations/supabase/auth-attacher.d.ts +2 -0
- package/dist-lib/integrations/supabase/auth-attacher.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/auth-attacher.js +57 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +10 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/auth-middleware.js +49 -0
- package/dist-lib/integrations/supabase/client.d.ts +4 -0
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/client.js +29 -0
- package/dist-lib/integrations/supabase/client.server.d.ts +4 -0
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/client.server.js +30 -0
- package/dist-lib/integrations/supabase/previewAuthStorage.d.ts +6 -0
- package/dist-lib/integrations/supabase/previewAuthStorage.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/previewAuthStorage.js +99 -0
- package/dist-lib/integrations/supabase/types.d.ts +36447 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -0
- package/dist-lib/integrations/supabase/types.js +94 -0
- package/dist-lib/lib/email-purposes.d.ts +14 -0
- package/dist-lib/lib/email-purposes.d.ts.map +1 -0
- package/dist-lib/lib/email-purposes.js +39 -0
- package/dist-lib/lib/email.functions.d.ts +89 -0
- package/dist-lib/lib/email.functions.d.ts.map +1 -0
- package/dist-lib/lib/email.functions.js +294 -0
- package/dist-lib/lib/klanten.functions.d.ts +52 -0
- package/dist-lib/lib/klanten.functions.d.ts.map +1 -0
- package/dist-lib/lib/klanten.functions.js +232 -0
- package/dist-lib/lib/mail-ai-defaults.d.ts +3 -0
- package/dist-lib/lib/mail-ai-defaults.d.ts.map +1 -0
- package/dist-lib/lib/mail-ai-defaults.js +81 -0
- package/dist-lib/lib/mail-attachment-text.server.d.ts +12 -0
- package/dist-lib/lib/mail-attachment-text.server.d.ts.map +1 -0
- package/dist-lib/lib/mail-attachment-text.server.js +190 -0
- package/dist-lib/lib/mail-body.functions.d.ts +25 -0
- package/dist-lib/lib/mail-body.functions.d.ts.map +1 -0
- package/dist-lib/lib/mail-body.functions.js +185 -0
- package/dist-lib/lib/mail-fetch.server.d.ts +13 -0
- package/dist-lib/lib/mail-fetch.server.d.ts.map +1 -0
- package/dist-lib/lib/mail-fetch.server.js +127 -0
- package/dist-lib/lib/mail-mime.server.d.ts +20 -0
- package/dist-lib/lib/mail-mime.server.d.ts.map +1 -0
- package/dist-lib/lib/mail-mime.server.js +168 -0
- package/dist-lib/lib/mail-settings.functions.d.ts +44 -0
- package/dist-lib/lib/mail-settings.functions.d.ts.map +1 -0
- package/dist-lib/lib/mail-settings.functions.js +102 -0
- package/dist-lib/lib/sanitizeHtml.d.ts +9 -0
- package/dist-lib/lib/sanitizeHtml.d.ts.map +1 -0
- package/dist-lib/lib/sanitizeHtml.js +93 -0
- package/dist-lib/lib/utils.d.ts +3 -0
- package/dist-lib/lib/utils.d.ts.map +1 -0
- package/dist-lib/lib/utils.js +5 -0
- package/dist-lib/lib/validationSchemas.d.ts +15 -0
- package/dist-lib/lib/validationSchemas.d.ts.map +1 -0
- package/dist-lib/lib/validationSchemas.js +25 -0
- package/dist-lib/lib/werkbon-confirmation-mail.d.ts +18 -0
- package/dist-lib/lib/werkbon-confirmation-mail.d.ts.map +1 -0
- package/dist-lib/lib/werkbon-confirmation-mail.js +122 -0
- package/dist-lib/lib/werkbon-proposals.functions.d.ts +282 -0
- package/dist-lib/lib/werkbon-proposals.functions.d.ts.map +1 -0
- package/dist-lib/lib/werkbon-proposals.functions.js +1200 -0
- package/dist-lib/styles.css +1 -0
- package/package.json +96 -4
- package/public/logo.png +0 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_core-safelist.d.ts","sourceRoot":"","sources":["../src/_core-safelist.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Forceert Tailwind classes die uit @flowselections/core komen maar niet
|
|
2
|
+
// voorkomen in de eigen broncode van deze module.
|
|
3
|
+
// Zonder dit bestand worden deze classes weggeoptimaliseerd op de
|
|
4
|
+
// Lovable productie build.
|
|
5
|
+
const _safelist = [
|
|
6
|
+
// Layout — Sidebar en shell structuur
|
|
7
|
+
'h-full', 'flex-col', 'flex-1', 'min-h-screen', 'ml-64', 'pt-16',
|
|
8
|
+
'items-start', 'items-center', 'justify-between', 'border-t',
|
|
9
|
+
'w-64', 'h-screen', 'h-20', 'overflow-y-auto',
|
|
10
|
+
// Grid — InstellingenPage
|
|
11
|
+
'grid', 'lg:grid-cols-2', 'gap-6', 'p-6', 'space-y-6',
|
|
12
|
+
// Toggle/Switch — aan/uit zichtbaarheid
|
|
13
|
+
'data-[state=checked]:bg-primary', 'data-[state=unchecked]:bg-input',
|
|
14
|
+
];
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmailDoeleindeInstelling.d.ts","sourceRoot":"","sources":["../../src/components/EmailDoeleindeInstelling.tsx"],"names":[],"mappings":"AAwBA,wBAAgB,wBAAwB,gCAiFvC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
4
|
+
import { Card, CardContent, CardDescription, CardHeader, CardTitle, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, toast, } from "@flowselections/core";
|
|
5
|
+
import { Mail } from "lucide-react";
|
|
6
|
+
import { EMAIL_PURPOSES, cachePurpose } from "../lib/email-purposes";
|
|
7
|
+
import { getMyEmailPurpose, setMyEmailPurpose } from "../lib/mail-settings.functions";
|
|
8
|
+
function describeError(e) {
|
|
9
|
+
if (e instanceof Error)
|
|
10
|
+
return e.message;
|
|
11
|
+
return "Er ging iets mis. Probeer het opnieuw.";
|
|
12
|
+
}
|
|
13
|
+
export function EmailDoeleindeInstelling() {
|
|
14
|
+
const load = useServerFn(getMyEmailPurpose);
|
|
15
|
+
const save = useServerFn(setMyEmailPurpose);
|
|
16
|
+
const [value, setValue] = useState("");
|
|
17
|
+
const [loading, setLoading] = useState(true);
|
|
18
|
+
const [saving, setSaving] = useState(false);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
let active = true;
|
|
21
|
+
load({})
|
|
22
|
+
.then((res) => {
|
|
23
|
+
if (!active)
|
|
24
|
+
return;
|
|
25
|
+
const stored = res?.purpose ?? "";
|
|
26
|
+
setValue(stored);
|
|
27
|
+
cachePurpose(stored || null);
|
|
28
|
+
})
|
|
29
|
+
.catch((e) => toast.error(describeError(e)))
|
|
30
|
+
.finally(() => {
|
|
31
|
+
if (active)
|
|
32
|
+
setLoading(false);
|
|
33
|
+
});
|
|
34
|
+
return () => {
|
|
35
|
+
active = false;
|
|
36
|
+
};
|
|
37
|
+
}, [load]);
|
|
38
|
+
const purposes = Array.isArray(EMAIL_PURPOSES) ? EMAIL_PURPOSES : [];
|
|
39
|
+
const onChange = async (v) => {
|
|
40
|
+
const previous = value;
|
|
41
|
+
setValue(v);
|
|
42
|
+
setSaving(true);
|
|
43
|
+
try {
|
|
44
|
+
await save({ data: { purpose: v } });
|
|
45
|
+
cachePurpose(v);
|
|
46
|
+
toast.success("Doeleinde opgeslagen");
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
setValue(previous);
|
|
50
|
+
toast.error(describeError(e));
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
setSaving(false);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
return (_jsxs(Card, { children: [_jsx(CardHeader, { children: _jsxs("div", { className: "flex items-start gap-3", children: [_jsx(Mail, { className: "mt-1 h-5 w-5 text-primary" }), _jsxs("div", { children: [_jsx(CardTitle, { children: "E-maildoeleinde" }), _jsx(CardDescription, { children: "Kies welk doeleinde het Postvak toont. Je keuze blijft bewaard bij je account, ook na uitloggen. Welk e-mailadres daarbij hoort, stelt een beheerder in bij E-mailkoppeling." })] })] }) }), _jsx(CardContent, { children: _jsxs(Select, { value: value || undefined, onValueChange: onChange, disabled: loading || saving, children: [_jsx(SelectTrigger, { className: "w-72", children: _jsx(SelectValue, { placeholder: loading ? "Laden…" : "Kies een doeleinde" }) }), _jsx(SelectContent, { children: purposes.map((p) => (_jsx(SelectItem, { value: p.key, children: _jsxs("span", { className: "flex flex-col", children: [_jsx("span", { children: p.label }), _jsx("span", { className: "text-xs text-muted-foreground", children: p.description })] }) }, p.key))) })] }) })] }));
|
|
57
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
interface FlowSelectionsLayoutProps {
|
|
3
|
+
title: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function FlowSelectionsLayout({ title, children }: FlowSelectionsLayoutProps): import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=FlowSelectionsLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FlowSelectionsLayout.d.ts","sourceRoot":"","sources":["../../src/components/FlowSelectionsLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,UAAU,yBAAyB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,yBAAyB,+BAYlF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Header, Sidebar, useAuthState } from "@flowselections/core";
|
|
3
|
+
import { werkbonPostvakModule } from "../index";
|
|
4
|
+
export function FlowSelectionsLayout({ title, children }) {
|
|
5
|
+
const auth = useAuthState();
|
|
6
|
+
return (_jsxs("div", { className: "min-h-screen bg-background", children: [_jsx(Sidebar, { auth: auth, modules: [werkbonPostvakModule] }), _jsxs("div", { className: "ml-64 flex min-h-screen flex-col", children: [_jsx(Header, { title: title }), children] })] }));
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MailAiInstructieInstelling.d.ts","sourceRoot":"","sources":["../../src/components/MailAiInstructieInstelling.tsx"],"names":[],"mappings":"AA6BA,wBAAgB,0BAA0B,gCA2HzC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
4
|
+
import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Label, Textarea, toast, } from "@flowselections/core";
|
|
5
|
+
import { Sparkles } from "lucide-react";
|
|
6
|
+
import { getMailAiSettings, saveMailAiSettings, WERKBON_REQUIRED_FIELD_OPTIONS, } from "../lib/mail-settings.functions";
|
|
7
|
+
import { DEFAULT_MAIL_AI_PROMPT, DEFAULT_MAIL_AI_REQUIRED_FIELDS, } from "../lib/mail-ai-defaults";
|
|
8
|
+
function describeError(e) {
|
|
9
|
+
if (e instanceof Error)
|
|
10
|
+
return e.message;
|
|
11
|
+
return "Er ging iets mis. Probeer het opnieuw.";
|
|
12
|
+
}
|
|
13
|
+
export function MailAiInstructieInstelling() {
|
|
14
|
+
const load = useServerFn(getMailAiSettings);
|
|
15
|
+
const save = useServerFn(saveMailAiSettings);
|
|
16
|
+
const [prompt, setPrompt] = useState("");
|
|
17
|
+
const [fields, setFields] = useState([]);
|
|
18
|
+
const [loading, setLoading] = useState(true);
|
|
19
|
+
const [saving, setSaving] = useState(false);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
let active = true;
|
|
22
|
+
load({})
|
|
23
|
+
.then((res) => {
|
|
24
|
+
if (!active)
|
|
25
|
+
return;
|
|
26
|
+
setPrompt(res?.system_prompt || DEFAULT_MAIL_AI_PROMPT);
|
|
27
|
+
setFields(Array.isArray(res?.required_fields) && res.required_fields.length > 0
|
|
28
|
+
? res.required_fields
|
|
29
|
+
: DEFAULT_MAIL_AI_REQUIRED_FIELDS);
|
|
30
|
+
})
|
|
31
|
+
.catch((e) => toast.error(describeError(e)))
|
|
32
|
+
.finally(() => {
|
|
33
|
+
if (active)
|
|
34
|
+
setLoading(false);
|
|
35
|
+
});
|
|
36
|
+
return () => {
|
|
37
|
+
active = false;
|
|
38
|
+
};
|
|
39
|
+
}, [load]);
|
|
40
|
+
const options = Array.isArray(WERKBON_REQUIRED_FIELD_OPTIONS)
|
|
41
|
+
? WERKBON_REQUIRED_FIELD_OPTIONS
|
|
42
|
+
: [];
|
|
43
|
+
const toggle = (key) => {
|
|
44
|
+
setFields((prev) => (prev.includes(key) ? prev.filter((k) => k !== key) : [...prev, key]));
|
|
45
|
+
};
|
|
46
|
+
const onSave = async (next) => {
|
|
47
|
+
const payload = next ?? { prompt, fields };
|
|
48
|
+
setSaving(true);
|
|
49
|
+
try {
|
|
50
|
+
await save({ data: { system_prompt: payload.prompt, required_fields: payload.fields } });
|
|
51
|
+
setPrompt(payload.prompt);
|
|
52
|
+
setFields(payload.fields);
|
|
53
|
+
toast.success("AI-instructie opgeslagen");
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
toast.error(describeError(e));
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
setSaving(false);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
return (_jsxs(Card, { className: "lg:col-span-2", children: [_jsx(CardHeader, { children: _jsxs("div", { className: "flex items-start gap-3", children: [_jsx(Sparkles, { className: "mt-1 h-5 w-5 text-primary" }), _jsxs("div", { children: [_jsx(CardTitle, { children: "AI-instructie aanvraagmails" }), _jsx(CardDescription, { children: "Deze instructie helpt de AI om aanvraagmails goed uit te lezen, zodat de werkbon zo volledig mogelijk wordt voorgevuld. In het Postvak pas je alles daarna nog zelf aan. De instructie geldt voor iedereen die dit Postvak gebruikt." })] })] }) }), _jsxs(CardContent, { className: "space-y-5", children: [_jsxs("div", { className: "space-y-2", children: [_jsx(Label, { htmlFor: "mail-ai-prompt", children: "Instructie" }), _jsx(Textarea, { id: "mail-ai-prompt", rows: 22, className: "font-mono text-xs", value: loading ? "Laden…" : prompt, disabled: loading || saving, onChange: (e) => setPrompt(e.target.value) })] }), _jsxs("div", { className: "space-y-2", children: [_jsx(Label, { children: "Verplichte velden" }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Ontbreekt een aangevinkt veld in de mail, dan wordt het in het werkbonvoorstel gemarkeerd als \u201Ccontroleren\u201D." }), _jsx("div", { className: "grid gap-2 sm:grid-cols-2 lg:grid-cols-3", children: options.map((opt) => (_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: fields.includes(opt.key), disabled: loading || saving, onChange: () => toggle(opt.key) }), _jsx("span", { children: opt.label })] }, opt.key))) })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsx(Button, { onClick: () => onSave(), disabled: loading || saving, children: "Opslaan" }), _jsx(Button, { variant: "outline", disabled: loading || saving, onClick: () => onSave({
|
|
63
|
+
prompt: DEFAULT_MAIL_AI_PROMPT,
|
|
64
|
+
fields: DEFAULT_MAIL_AI_REQUIRED_FIELDS,
|
|
65
|
+
}), children: "Terugzetten naar standaard" })] })] })] }));
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostvakIn.d.ts","sourceRoot":"","sources":["../../src/components/PostvakIn.tsx"],"names":[],"mappings":"AAsFA,wBAAgB,SAAS,gCA+KxB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateModuleLogo.d.ts","sourceRoot":"","sources":["../../src/components/TemplateModuleLogo.tsx"],"names":[],"mappings":"AAQA,UAAU,uBAAuB;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAAC,EAAE,SAAS,EAAE,EAAE,uBAAuB,+BAwBxE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function TemplateModuleLogo({ className }) {
|
|
3
|
+
return (_jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: className, "aria-hidden": "true", children: [_jsx("rect", { width: "40", height: "40", rx: "8", fill: "currentColor", opacity: "0.1" }), _jsx("text", { x: "50%", y: "50%", dominantBaseline: "middle", textAnchor: "middle", fontSize: "18", fontWeight: "600", fill: "currentColor", children: "M" })] }));
|
|
4
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateModulePage.d.ts","sourceRoot":"","sources":["../../src/components/TemplateModulePage.tsx"],"names":[],"mappings":"AAsBA,wBAAgB,kBAAkB,gCAmFjC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// src/components/TemplateModulePage.tsx — EXAMPLE PAGE COMPONENT
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Pagina-componenten horen in src/components/, NIET alleen in src/routes/.
|
|
6
|
+
// src/routes/ wordt NIET naar npm gepubliceerd (zie tsconfig.build.json exclude).
|
|
7
|
+
//
|
|
8
|
+
// GEEN <Header /> hier — die zit in _authenticated.tsx via staticData.title
|
|
9
|
+
// ============================================================================
|
|
10
|
+
import { useState, useEffect } from "react";
|
|
11
|
+
import { useAuth, supabase, Button, Card, CardContent, CardHeader, CardTitle, toast, } from "@flowselections/core";
|
|
12
|
+
import { TemplateModuleLogo } from './TemplateModuleLogo';
|
|
13
|
+
export function TemplateModulePage() {
|
|
14
|
+
// Auth is guaranteed — this user is already logged in
|
|
15
|
+
const { user, isAdmin } = useAuth();
|
|
16
|
+
// Example state — replace with your own
|
|
17
|
+
const [items, setItems] = useState([]);
|
|
18
|
+
const [loading, setLoading] = useState(true);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
loadData();
|
|
21
|
+
}, []);
|
|
22
|
+
const loadData = async () => {
|
|
23
|
+
setLoading(true);
|
|
24
|
+
try {
|
|
25
|
+
// Example query — replace "products" with your table
|
|
26
|
+
const { data, error } = await supabase
|
|
27
|
+
.from("products")
|
|
28
|
+
.select("*")
|
|
29
|
+
.limit(10);
|
|
30
|
+
if (error)
|
|
31
|
+
throw error;
|
|
32
|
+
// ✅ Altijd Array.isArray bewaken op server-function data
|
|
33
|
+
// const safeItems = Array.isArray(data?.items) ? data.items : [];
|
|
34
|
+
setItems(Array.isArray(data) ? data : []);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
toast.error("Fout bij het laden van gegevens");
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
setLoading(false);
|
|
41
|
+
}
|
|
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..." })) : 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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplatePage.d.ts","sourceRoot":"","sources":["../../src/components/TemplatePage.tsx"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,gCAS3B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function TemplatePage() {
|
|
3
|
+
return (_jsxs("div", { className: "p-6", children: [_jsx("h1", { className: "text-2xl font-semibold", children: "Module pagina" }), _jsx("p", { className: "text-muted-foreground mt-2", children: "Vervang dit component met de pagina's van jouw module." })] }));
|
|
4
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WerkbonMailPage.d.ts","sourceRoot":"","sources":["../../src/components/WerkbonMailPage.tsx"],"names":[],"mappings":"AAmCA,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,UAAU,CAAC;AAEzD,wBAAgB,eAAe,CAAC,EAAE,IAAoB,EAAE,GAAE;IAAE,IAAI,CAAC,EAAE,eAAe,CAAA;CAAO,+BA0QxF"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { RefreshCw } from "lucide-react";
|
|
4
|
+
import { supabase, toast, Button, Input, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Tabs, TabsList, TabsTrigger, } from "@flowselections/core";
|
|
5
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
6
|
+
import { listInboxEvents, getInboxEvent, setEmailState, } from "../lib/email.functions";
|
|
7
|
+
import { useEmailPurpose } from "../hooks/useEmailPurpose";
|
|
8
|
+
import { useAutoAnalyse } from "../hooks/useAutoAnalyse";
|
|
9
|
+
import { listWerkbonSummaries, } from "../lib/werkbon-proposals.functions";
|
|
10
|
+
import { WerkbonProposalTable } from "./mail/WerkbonProposalTable";
|
|
11
|
+
import { WerkbonProposalDialog } from "./mail/WerkbonProposalDialog";
|
|
12
|
+
export function WerkbonMailPage({ mode = "voorstellen" } = {}) {
|
|
13
|
+
const readOnly = mode === "verwerkt";
|
|
14
|
+
const fetchInbox = useServerFn(listInboxEvents);
|
|
15
|
+
const fetchFullEvent = useServerFn(getInboxEvent);
|
|
16
|
+
const updateState = useServerFn(setEmailState);
|
|
17
|
+
const fetchSummaries = useServerFn(listWerkbonSummaries);
|
|
18
|
+
const { purpose } = useEmailPurpose();
|
|
19
|
+
const [tab, setTab] = useState("inbox");
|
|
20
|
+
const [mails, setMails] = useState([]);
|
|
21
|
+
const [summaries, setSummaries] = useState({});
|
|
22
|
+
const [loading, setLoading] = useState(true);
|
|
23
|
+
const [search, setSearch] = useState("");
|
|
24
|
+
const [period, setPeriod] = useState("alles");
|
|
25
|
+
const [sort, setSort] = useState("nieuwste");
|
|
26
|
+
const [openMail, setOpenMail] = useState(null);
|
|
27
|
+
const [mailLoading, setMailLoading] = useState(false);
|
|
28
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
29
|
+
const loadSummaries = useCallback(async (list) => {
|
|
30
|
+
const ids = Array.isArray(list) ? list.map((m) => m.id) : [];
|
|
31
|
+
if (ids.length === 0) {
|
|
32
|
+
setSummaries({});
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const res = await fetchSummaries({ data: { event_ids: ids } });
|
|
37
|
+
const rows = Array.isArray(res?.summaries) ? res.summaries : [];
|
|
38
|
+
const map = {};
|
|
39
|
+
for (const row of rows)
|
|
40
|
+
map[row.event_id] = row;
|
|
41
|
+
setSummaries(map);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
setSummaries({});
|
|
45
|
+
}
|
|
46
|
+
}, [fetchSummaries]);
|
|
47
|
+
const load = useCallback(async (archived) => {
|
|
48
|
+
if (!purpose)
|
|
49
|
+
return;
|
|
50
|
+
setLoading(true);
|
|
51
|
+
try {
|
|
52
|
+
const res = await fetchInbox({ data: { purpose, archived, limit: 200 } });
|
|
53
|
+
const list = Array.isArray(res?.events) ? res.events : [];
|
|
54
|
+
setMails(list);
|
|
55
|
+
void loadSummaries(list);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
toast.error("Fout bij het laden van de berichten");
|
|
59
|
+
setMails([]);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
setLoading(false);
|
|
63
|
+
}
|
|
64
|
+
}, [fetchInbox, purpose, loadSummaries]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
setOpenMail(null);
|
|
67
|
+
load(tab === "archief");
|
|
68
|
+
}, [tab, load]);
|
|
69
|
+
// Elke 60 seconden automatisch nieuwe mails ophalen
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const timer = setInterval(() => {
|
|
72
|
+
load(tab === "archief");
|
|
73
|
+
}, 60000);
|
|
74
|
+
return () => clearInterval(timer);
|
|
75
|
+
}, [tab, load]);
|
|
76
|
+
// Nieuwe mails automatisch op de achtergrond analyseren zodra ze in de
|
|
77
|
+
// lijst verschijnen; daarna de samenvattingen verversen zodat de status
|
|
78
|
+
// en klantnaam meteen bijwerken.
|
|
79
|
+
const analysingIds = useAutoAnalyse(mails, summaries, !readOnly && tab === "inbox", useCallback(() => void loadSummaries(mails), [loadSummaries, mails]));
|
|
80
|
+
const handleRefresh = useCallback(async () => {
|
|
81
|
+
setRefreshing(true);
|
|
82
|
+
try {
|
|
83
|
+
await load(tab === "archief");
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
setRefreshing(false);
|
|
87
|
+
}
|
|
88
|
+
}, [load, tab]);
|
|
89
|
+
// Realtime: nieuwe of gewijzigde mail direct tonen
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const channel = supabase
|
|
92
|
+
.channel("werkbon-mail")
|
|
93
|
+
.on("postgres_changes", { event: "*", schema: "public", table: "email_auth_events" }, () => load(tab === "archief"))
|
|
94
|
+
.on("postgres_changes", { event: "*", schema: "public", table: "werkbon_email_state" }, () => load(tab === "archief"))
|
|
95
|
+
.subscribe();
|
|
96
|
+
return () => {
|
|
97
|
+
supabase.removeChannel(channel);
|
|
98
|
+
};
|
|
99
|
+
}, [tab, load]);
|
|
100
|
+
const filtered = useMemo(() => {
|
|
101
|
+
const q = search.trim().toLowerCase();
|
|
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]);
|
|
127
|
+
const openIndex = openMail ? filtered.findIndex((m) => m.id === openMail.id) : -1;
|
|
128
|
+
const handleOpen = async (mail) => {
|
|
129
|
+
setOpenMail(mail);
|
|
130
|
+
setMailLoading(true);
|
|
131
|
+
// Volledige inhoud (html/bijlagen) pas ophalen bij openen.
|
|
132
|
+
try {
|
|
133
|
+
const res = await fetchFullEvent({ data: { event_id: mail.id } });
|
|
134
|
+
if (res?.event)
|
|
135
|
+
setOpenMail(res.event);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// lijstversie blijft bruikbaar (platte tekst)
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
setMailLoading(false);
|
|
142
|
+
}
|
|
143
|
+
if (mail.is_read)
|
|
144
|
+
return;
|
|
145
|
+
setMails((prev) => prev.map((m) => (m.id === mail.id ? { ...m, is_read: true } : m)));
|
|
146
|
+
try {
|
|
147
|
+
await updateState({ data: { event_id: mail.id, is_read: true } });
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
toast.error("Kon het bericht niet als gelezen markeren");
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const handleToggleArchive = async (mail) => {
|
|
154
|
+
const next = !mail.is_archived;
|
|
155
|
+
setMails((prev) => prev.filter((m) => m.id !== mail.id));
|
|
156
|
+
setOpenMail(null);
|
|
157
|
+
try {
|
|
158
|
+
await updateState({ data: { event_id: mail.id, is_archived: next, is_read: true } });
|
|
159
|
+
toast.success(next ? "Bericht gearchiveerd" : "Bericht teruggezet");
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
toast.error("Actie mislukt");
|
|
163
|
+
load(tab === "archief");
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
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) => setTab(v), 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, title: "Berichten vernieuwen", 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) => setPeriod(v), 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(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" })] })] })] }), _jsxs("p", { className: "text-xs text-muted-foreground", children: [filtered.length, " van ", mails.length, " berichten"] })] }), _jsx(WerkbonProposalTable, { mails: filtered, summaries: summaries, analysingIds: analysingIds, loading: loading, emptyLabel: tab === "archief" ? "Geen gearchiveerde berichten." : "Geen berichten.", onOpen: handleOpen })] }), 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
|
+
? () => void handleOpen(filtered[openIndex + 1])
|
|
168
|
+
: null, positionLabel: openIndex >= 0 ? `${openIndex + 1}/${filtered.length}` : null, readOnly: readOnly }))] }));
|
|
169
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WerkbonVerwerktPage.d.ts","sourceRoot":"","sources":["../../src/components/WerkbonVerwerktPage.tsx"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,gCAElC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type KlantContactInput, type KlantCreated, type KlantLocatieInput, type KlantSegment } from "../../lib/klanten.functions";
|
|
2
|
+
interface Props {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
/** Wordt aangeroepen zodra de klant in het klantenbestand staat. */
|
|
6
|
+
onCreated: (klant: KlantCreated) => void;
|
|
7
|
+
/** Gegevens om het formulier mee voor te vullen (bijv. uit een mail). */
|
|
8
|
+
defaults?: NieuweKlantDefaults | null;
|
|
9
|
+
}
|
|
10
|
+
export interface NieuweKlantDefaults {
|
|
11
|
+
name?: string | null;
|
|
12
|
+
segment?: KlantSegment | null;
|
|
13
|
+
general_email?: string | null;
|
|
14
|
+
general_phone?: string | null;
|
|
15
|
+
billing_street?: string | null;
|
|
16
|
+
billing_postcode?: string | null;
|
|
17
|
+
billing_city?: string | null;
|
|
18
|
+
contacts?: KlantContactInput[];
|
|
19
|
+
locations?: KlantLocatieInput[];
|
|
20
|
+
}
|
|
21
|
+
export declare function NieuweKlantDialog({ open, onOpenChange, onCreated, defaults, }: Props): import("react").JSX.Element;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=NieuweKlantDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NieuweKlantDialog.d.ts","sourceRoot":"","sources":["../../../src/components/klanten/NieuweKlantDialog.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAClB,MAAM,6BAA6B,CAAC;AAErC,UAAU,KAAK;IACb,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,oEAAoE;IACpE,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACzC,yEAAyE;IACzE,QAAQ,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC/B,SAAS,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACjC;AA+BD,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,QAAe,GAChB,EAAE,KAAK,+BAoYP"}
|