@flowselections/mailbox-orders 1.0.50 → 1.0.53

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.
@@ -1 +1 @@
1
- {"version":3,"file":"MailboxFilterSettingsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/MailboxFilterSettingsCard.tsx"],"names":[],"mappings":"AAkCA,wBAAgB,yBAAyB,gCAyHxC"}
1
+ {"version":3,"file":"MailboxFilterSettingsCard.d.ts","sourceRoot":"","sources":["../../../src/components/settings/MailboxFilterSettingsCard.tsx"],"names":[],"mappings":"AAkCA,wBAAgB,yBAAyB,gCA6IxC"}
@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
3
3
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
4
4
  import { useServerFn } from "@tanstack/react-start";
5
5
  import { Card, CardContent, CardDescription, CardHeader, CardTitle, Button, Label, Textarea, Input, Switch, toast, } from "@flowselections/core";
6
- import { getMailboxFilterSettings, saveMailboxFilterSettings, countLikelyFakeProposals, } from "../../lib/mailbox-filter-settings.functions.js";
6
+ import { getMailboxFilterSettings, saveMailboxFilterSettings, countLikelyFakeProposals, addStandardOrderKeywords, } from "../../lib/mailbox-filter-settings.functions.js";
7
7
  const LISTS = [
8
8
  { key: "order_keywords", label: "Bestelwoorden", help: "Eén per regel. Woorden die op een bestelling wijzen (NL, EN, DE)." },
9
9
  { key: "order_patterns", label: "Bestelpatronen", help: "Eén per regel. Zoekpatronen, bijvoorbeeld een aantal gevolgd door fust of stuks." },
@@ -61,9 +61,20 @@ export function MailboxFilterSettingsCard() {
61
61
  },
62
62
  onError: (e) => toast.error(e?.message ?? "Opslaan mislukt"),
63
63
  });
64
+ const addStd = useServerFn(addStandardOrderKeywords);
65
+ const addMut = useMutation({
66
+ mutationFn: () => addStd(),
67
+ onSuccess: (r) => {
68
+ toast.success(`${r?.added ?? 0} standaardwoorden toegevoegd`);
69
+ setForm(null);
70
+ void qc.invalidateQueries({ queryKey: ["mailbox-filter-settings"] });
71
+ },
72
+ onError: (e) => toast.error(e?.message ?? "Toevoegen mislukt"),
73
+ });
74
+ const savedKeywords = Array.isArray(data?.settings?.order_keywords) ? data.settings.order_keywords : [];
64
75
  const set = (k, v) => setForm((p) => ({ ...(p ?? {}), [k]: v }));
65
76
  const u = data?.usage;
66
- return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Voorfilter en kosten bestelmails" }), _jsx(CardDescription, { children: "Bepaalt welke mails de AI leest en hoeveel analyses er maximaal mogen. Mails die geen bestelling zijn, kosten geen AI-analyse." })] }), _jsxs(CardContent, { className: "space-y-5", children: [error && _jsx("p", { className: "text-sm text-destructive", children: "De instellingen konden niet worden geladen." }), u && (_jsxs("div", { className: "rounded-md border bg-muted/30 p-3 text-sm grid gap-1 sm:grid-cols-2", children: [_jsxs("div", { children: ["AI-analyses deze maand: ", _jsx("strong", { children: u.month_analyses }), form ? ` van ${form.max_ai_per_month}` : ""] }), _jsxs("div", { children: ["Vandaag: ", _jsx("strong", { children: u.today_analyses }), form ? ` van ${form.max_ai_per_day}` : ""] }), _jsxs("div", { children: ["Tokens deze maand: ", Number(u.input_tokens).toLocaleString("nl-NL"), " in \u00B7 ", Number(u.output_tokens).toLocaleString("nl-NL"), " uit"] }), _jsxs("div", { children: ["AI-aanroepen volgens het AI-logboek: ", u.ai_calls_month] }), u.test_analyses > 0 && _jsxs("div", { children: ["Waarvan testset: ", u.test_analyses] }), u.waiting > 0 && _jsxs("div", { className: "text-amber-700", children: ["Wachten op analyse: ", u.waiting] })] })), form && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "space-y-3", children: [_jsxs("label", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-sm", children: "Automatisch analyseren" }), _jsx(Switch, { checked: !!form.auto_analyze, onCheckedChange: (v) => set("auto_analyze", v) })] }), _jsxs("label", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-sm", children: "Onbekende afzender met bestel-signalen ook analyseren" }), _jsx(Switch, { checked: !!form.analyze_unknown_with_signals, onCheckedChange: (v) => set("analyze_unknown_with_signals", v) })] }), _jsxs("label", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-sm", children: "Klant herkennen op domein van het e-mailadres" }), _jsx(Switch, { checked: !!form.domain_match, onCheckedChange: (v) => set("domain_match", v) })] })] }), _jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: NUMBERS.map((n) => (_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { className: "text-xs", children: n.label }), _jsx(Input, { type: "number", step: n.step ?? "1", value: form[n.key] ?? "", onChange: (e) => set(n.key, e.target.value) })] }, n.key))) }), LISTS.map((l) => (_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: l.label }), _jsx(Textarea, { rows: 4, className: "font-mono text-xs", value: form[l.key] ?? "", onChange: (e) => set(l.key, e.target.value) }), _jsx("p", { className: "text-xs text-muted-foreground", children: l.help })] }, l.key))), _jsx(Button, { onClick: () => mut.mutate(), disabled: mut.isPending, children: mut.isPending ? "Opslaan..." : "Opslaan" })] })), _jsxs("div", { className: "border-t pt-4 space-y-2", children: [_jsx(Label, { children: "Bestaande voorstellen tellen" }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Telt hoeveel openstaande voorstellen het filter nu als \"geen bestelling\" zou zien. Er wordt niets verborgen of verwijderd." }), _jsx(Button, { variant: "outline", disabled: counting, onClick: async () => {
77
+ return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Voorfilter en kosten bestelmails" }), _jsx(CardDescription, { children: "Bepaalt welke mails de AI leest en hoeveel analyses er maximaal mogen. Mails die geen bestelling zijn, kosten geen AI-analyse." })] }), _jsxs(CardContent, { className: "space-y-5", children: [error && _jsx("p", { className: "text-sm text-destructive", children: "De instellingen konden niet worden geladen." }), u && (_jsxs("div", { className: "rounded-md border bg-muted/30 p-3 text-sm grid gap-1 sm:grid-cols-2", children: [_jsxs("div", { children: ["AI-analyses deze maand: ", _jsx("strong", { children: u.month_analyses }), form ? ` van ${form.max_ai_per_month}` : ""] }), _jsxs("div", { children: ["Vandaag: ", _jsx("strong", { children: u.today_analyses }), form ? ` van ${form.max_ai_per_day}` : ""] }), _jsxs("div", { children: ["Tokens deze maand: ", Number(u.input_tokens).toLocaleString("nl-NL"), " in \u00B7 ", Number(u.output_tokens).toLocaleString("nl-NL"), " uit"] }), _jsxs("div", { children: ["AI-aanroepen volgens het AI-logboek: ", u.ai_calls_month] }), u.test_analyses > 0 && _jsxs("div", { children: ["Waarvan testset: ", u.test_analyses] }), u.waiting > 0 && _jsxs("div", { className: "text-amber-700", children: ["Wachten op analyse: ", u.waiting] })] })), data?.settings && savedKeywords.length === 0 && (_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3 rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm", children: [_jsx("span", { children: "Er zijn geen bestelwoorden; de mailbox herkent dan weinig bestellingen" }), _jsx(Button, { size: "sm", variant: "outline", onClick: () => addMut.mutate(), disabled: addMut.isPending, children: addMut.isPending ? "Toevoegen…" : "Standaardwoorden toevoegen" })] })), form && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "space-y-3", children: [_jsxs("label", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-sm", children: "Automatisch analyseren" }), _jsx(Switch, { checked: !!form.auto_analyze, onCheckedChange: (v) => set("auto_analyze", v) })] }), _jsxs("label", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-sm", children: "Onbekende afzender met bestel-signalen ook analyseren" }), _jsx(Switch, { checked: !!form.analyze_unknown_with_signals, onCheckedChange: (v) => set("analyze_unknown_with_signals", v) })] }), _jsxs("label", { className: "flex items-center justify-between gap-3", children: [_jsx("span", { className: "text-sm", children: "Klant herkennen op domein van het e-mailadres" }), _jsx(Switch, { checked: !!form.domain_match, onCheckedChange: (v) => set("domain_match", v) })] })] }), _jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: NUMBERS.map((n) => (_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { className: "text-xs", children: n.label }), _jsx(Input, { type: "number", step: n.step ?? "1", value: form[n.key] ?? "", onChange: (e) => set(n.key, e.target.value) })] }, n.key))) }), LISTS.map((l) => (_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { children: l.label }), _jsx(Textarea, { rows: 4, className: "font-mono text-xs", value: form[l.key] ?? "", onChange: (e) => set(l.key, e.target.value) }), _jsx("p", { className: "text-xs text-muted-foreground", children: l.help })] }, l.key))), _jsx(Button, { onClick: () => mut.mutate(), disabled: mut.isPending, children: mut.isPending ? "Opslaan..." : "Opslaan" })] })), _jsxs("div", { className: "border-t pt-4 space-y-2", children: [_jsx(Label, { children: "Bestaande voorstellen tellen" }), _jsx("p", { className: "text-xs text-muted-foreground", children: "Telt hoeveel openstaande voorstellen het filter nu als \"geen bestelling\" zou zien. Er wordt niets verborgen of verwijderd." }), _jsx(Button, { variant: "outline", disabled: counting, onClick: async () => {
67
78
  setCounting(true);
68
79
  try {
69
80
  setCount(await fetchCount());