Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e2d6532bf | ||
|
|
46490cbcb9 | ||
|
|
72ac84ddd6 | ||
|
|
8683bbff59 | ||
|
|
c38fd95e8b | ||
|
|
e6ae9b9c1d | ||
|
|
28b8d27be7 | ||
|
|
d2e2ef9ece | ||
|
|
fdd5cd4573 | ||
|
|
9c7b3e69ad | ||
|
|
5482616f3d | ||
|
|
45337cd0dc |
No files matched your search
+2
-2
@@ -12,7 +12,7 @@ metadata:
|
||||
title: Courier
|
||||
description: Transaktionsmail für deine Apps über Amazon SES.
|
||||
icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png
|
||||
version: 26.11.6
|
||||
version: 26.11.18
|
||||
categories:
|
||||
- Applications
|
||||
|
||||
@@ -106,7 +106,7 @@ envs:
|
||||
default: "1000"
|
||||
|
||||
spec:
|
||||
versionName: '26.11.6'
|
||||
versionName: '26.11.18'
|
||||
fullDescription: |
|
||||
**Courier** ist ein kleiner Versanddienst für transaktionale E-Mails:
|
||||
eine Resend-kompatible HTTP-API, Warteschlange, Retry, Logs und
|
||||
|
||||
+61
-55
@@ -3,71 +3,77 @@
|
||||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
import {
|
||||
Ban,
|
||||
BookOpen,
|
||||
Globe,
|
||||
KeyRound,
|
||||
LayoutDashboard,
|
||||
Mail,
|
||||
type LucideIcon,
|
||||
Ban,
|
||||
BarChart3,
|
||||
Calculator,
|
||||
BookOpen,
|
||||
Globe,
|
||||
KeyRound,
|
||||
LayoutDashboard,
|
||||
Mail,
|
||||
type LucideIcon,
|
||||
} from "lucide-react";
|
||||
|
||||
type Item = { href: string; label: string; icon: LucideIcon };
|
||||
|
||||
const groups: { title: string; items: Item[] }[] = [
|
||||
{
|
||||
title: "Senden",
|
||||
items: [
|
||||
{ href: "/", label: "Übersicht", icon: LayoutDashboard },
|
||||
{ href: "/messages", label: "Nachrichten", icon: Mail },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Konfiguration",
|
||||
items: [
|
||||
{ href: "/domains", label: "Domains", icon: Globe },
|
||||
{ href: "/keys", label: "API-Keys", icon: KeyRound },
|
||||
{ href: "/suppressions", label: "Suppressions", icon: Ban },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Betrieb",
|
||||
items: [{ href: "/docs", label: "Dokumentation", icon: BookOpen }],
|
||||
},
|
||||
{
|
||||
title: "Senden",
|
||||
items: [
|
||||
{ href: "/", label: "Übersicht", icon: LayoutDashboard },
|
||||
{ href: "/messages", label: "Nachrichten", icon: Mail },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Konfiguration",
|
||||
items: [
|
||||
{ href: "/domains", label: "Domains", icon: Globe },
|
||||
{ href: "/keys", label: "API-Keys", icon: KeyRound },
|
||||
{ href: "/suppressions", label: "Suppressions", icon: Ban },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Betrieb",
|
||||
items: [
|
||||
{ href: "/metrics", label: "Metriken", icon: BarChart3 },
|
||||
{ href: "/pricing", label: "Preise", icon: Calculator },
|
||||
{ href: "/docs", label: "Dokumentation", icon: BookOpen },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
function isActive(pathname: string, href: string) {
|
||||
if (href === "/") return pathname === "/";
|
||||
return pathname === href || pathname.startsWith(`${href}/`);
|
||||
if (href === "/") return pathname === "/";
|
||||
return pathname === href || pathname.startsWith(`${href}/`);
|
||||
}
|
||||
|
||||
export function AppNav({ variant = "sidebar" }: { variant?: "sidebar" | "mobile" }) {
|
||||
const pathname = usePathname().replace(/^\/__preview\/\d+/, "") || "/";
|
||||
const pathname = usePathname().replace(/^\/__preview\/\d+/, "") || "/";
|
||||
|
||||
return (
|
||||
<nav
|
||||
className={variant === "sidebar" ? "app-nav app-nav--sidebar" : "app-nav app-nav--mobile"}
|
||||
aria-label="Hauptnavigation"
|
||||
>
|
||||
{groups.map((group) => (
|
||||
<div className="app-nav__group" key={group.title}>
|
||||
{variant === "sidebar" ? <p className="app-nav__title">{group.title}</p> : null}
|
||||
{group.items.map((item) => {
|
||||
const Icon = item.icon;
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
className="app-nav__link"
|
||||
aria-current={isActive(pathname, item.href) ? "page" : undefined}
|
||||
>
|
||||
<Icon className="app-nav__icon" aria-hidden="true" />
|
||||
<span>{item.label}</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
return (
|
||||
<nav
|
||||
className={variant === "sidebar" ? "app-nav app-nav--sidebar" : "app-nav app-nav--mobile"}
|
||||
aria-label="Hauptnavigation"
|
||||
>
|
||||
{groups.map((group) => (
|
||||
<div className="app-nav__group" key={group.title}>
|
||||
{variant === "sidebar" ? <p className="app-nav__title">{group.title}</p> : null}
|
||||
{group.items.map((item) => {
|
||||
const Icon = item.icon;
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
className="app-nav__link"
|
||||
aria-current={isActive(pathname, item.href) ? "page" : undefined}
|
||||
>
|
||||
<Icon className="app-nav__icon" aria-hidden="true" />
|
||||
<span>{item.label}</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
+15
-15
@@ -3,21 +3,21 @@
|
||||
import { useState } from "react";
|
||||
|
||||
export function CopyButton({ value, label = "Kopieren" }: { value: string; label?: string }) {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
async function copy() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
} catch {
|
||||
setCopied(false);
|
||||
}
|
||||
}
|
||||
async function copy() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
setCopied(true);
|
||||
setTimeout(() => setCopied(false), 2000);
|
||||
} catch {
|
||||
setCopied(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<button type="button" className="ds-button ds-button--secondary ds-button--sm" onClick={copy}>
|
||||
{copied ? "Kopiert" : label}
|
||||
</button>
|
||||
);
|
||||
return (
|
||||
<button type="button" className="btn btn-sekundaer btn-klein" onClick={copy}>
|
||||
{copied ? "Kopiert" : label}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
+62
-62
@@ -3,79 +3,79 @@ import { PageHeader } from "@/app/page-header";
|
||||
export const metadata = { title: "Courier – Dokumentation" };
|
||||
|
||||
export default function Docs() {
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Dokumentation"
|
||||
lead="Die Courier-API ist weitgehend Resend-kompatibel. Basis-URL: /api"
|
||||
code={false}
|
||||
eyebrow="Courier"
|
||||
/>
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Dokumentation"
|
||||
lead="Die Courier-API ist weitgehend Resend-kompatibel. Basis-URL: /api"
|
||||
code={false}
|
||||
eyebrow="Courier"
|
||||
/>
|
||||
|
||||
<section className="ds-card app-panel">
|
||||
<h2>Authentifizierung</h2>
|
||||
<p className="app-muted">
|
||||
Jede Anfrage braucht einen API-Key als Bearer-Token. Der Key gilt nur für seine
|
||||
Absenderdomain.
|
||||
</p>
|
||||
<pre className="app-code">{`Authorization: Bearer ck_live_…`}</pre>
|
||||
</section>
|
||||
<section className="karte app-panel">
|
||||
<h2>Authentifizierung</h2>
|
||||
<p className="app-muted">
|
||||
Jede Anfrage braucht einen API-Key als Bearer-Token. Der Key gilt nur für seine
|
||||
Absenderdomain.
|
||||
</p>
|
||||
<pre className="app-code">{`Authorization: Bearer ck_live_…`}</pre>
|
||||
</section>
|
||||
|
||||
<section className="ds-card app-panel app-section">
|
||||
<h2>Mail senden</h2>
|
||||
<pre className="app-code">{`curl -X POST https://<courier-adresse>/api/emails/ \\
|
||||
-H "Authorization: Bearer ck_live_…" \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-d '{
|
||||
"from": "plan <plan@hubsport.club>",
|
||||
"to": "kunde@example.com",
|
||||
"subject": "Dein Anmeldelink",
|
||||
"html": "<p>Hallo</p>",
|
||||
"text": "Hallo"
|
||||
}'`}</pre>
|
||||
<p className="app-muted">
|
||||
Unterstützt <code>from</code>, <code>to</code>, <code>cc</code>, <code>bcc</code>,{" "}
|
||||
<code>reply_to</code>, <code>subject</code>, <code>html</code>, <code>text</code>,{" "}
|
||||
<code>headers</code>, <code>attachments</code> und <code>tags</code>.
|
||||
</p>
|
||||
</section>
|
||||
<section className="karte app-panel app-section">
|
||||
<h2>Mail senden</h2>
|
||||
<pre className="app-code">{`curl -X POST https://<courier-adresse>/api/emails/ \\
|
||||
-H "Authorization: Bearer ck_live_…" \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-d '{
|
||||
"from": "plan <plan@hubsport.club>",
|
||||
"to": "kunde@example.com",
|
||||
"subject": "Dein Anmeldelink",
|
||||
"html": "<p>Hallo</p>",
|
||||
"text": "Hallo"
|
||||
}'`}</pre>
|
||||
<p className="app-muted">
|
||||
Unterstützt <code>from</code>, <code>to</code>, <code>cc</code>, <code>bcc</code>,{" "}
|
||||
<code>reply_to</code>, <code>subject</code>, <code>html</code>, <code>text</code>,{" "}
|
||||
<code>headers</code>, <code>attachments</code> und <code>tags</code>.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section className="ds-card app-panel app-section">
|
||||
<h2>Resend-SDK</h2>
|
||||
<pre className="app-code">{`import { Resend } from "resend";
|
||||
<section className="karte app-panel app-section">
|
||||
<h2>Resend-SDK</h2>
|
||||
<pre className="app-code">{`import { Resend } from "resend";
|
||||
|
||||
const resend = new Resend(process.env.COURIER_API_KEY, {
|
||||
baseUrl: "https://<courier-adresse>/api",
|
||||
baseUrl: "https://<courier-adresse>/api",
|
||||
});
|
||||
|
||||
await resend.emails.send({
|
||||
from: "plan <plan@hubsport.club>",
|
||||
to: "kunde@example.com",
|
||||
subject: "Test",
|
||||
html: "<p>Hallo</p>",
|
||||
from: "plan <plan@hubsport.club>",
|
||||
to: "kunde@example.com",
|
||||
subject: "Test",
|
||||
html: "<p>Hallo</p>",
|
||||
});`}</pre>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section className="ds-card app-panel app-section">
|
||||
<h2>Batch und Status</h2>
|
||||
<pre className="app-code">{`POST /api/emails/batch // bis zu 100 Mails
|
||||
GET /api/emails/:id // Status einer Mail
|
||||
GET /api/health // Health-Check`}</pre>
|
||||
<p className="app-muted">
|
||||
Ein <code>Idempotency-Key</code>-Header verhindert doppelte Sendungen.
|
||||
</p>
|
||||
</section>
|
||||
<section className="karte app-panel app-section">
|
||||
<h2>Batch und Status</h2>
|
||||
<pre className="app-code">{`POST /api/emails/batch // bis zu 100 Mails
|
||||
GET /api/emails/:id // Status einer Mail
|
||||
GET /api/health // Health-Check`}</pre>
|
||||
<p className="app-muted">
|
||||
Ein <code>Idempotency-Key</code>-Header verhindert doppelte Sendungen.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section className="ds-card app-panel app-section">
|
||||
<h2>Fehler</h2>
|
||||
<pre className="app-code">{`{ "statusCode": 422, "name": "validation_error", "message": "…" }
|
||||
<section className="karte app-panel app-section">
|
||||
<h2>Fehler</h2>
|
||||
<pre className="app-code">{`{ "statusCode": 422, "name": "validation_error", "message": "…" }
|
||||
{ "statusCode": 429, "name": "rate_limit_exceeded", "message": "…" }
|
||||
{ "statusCode": 422, "name": "recipient_suppressed", "message": "…" }`}</pre>
|
||||
<p className="app-muted">
|
||||
Gesperrte Empfänger stehen unter <a href="/suppressions">Suppressions</a>. Domains und
|
||||
Keys werden unter <a href="/domains">Domains</a> und <a href="/keys">API-Keys</a> gepflegt.
|
||||
</p>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
<p className="app-muted">
|
||||
Gesperrte Empfänger stehen unter <a href="/suppressions">Suppressions</a>. Domains und
|
||||
Keys werden unter <a href="/domains">Domains</a> und <a href="/keys">API-Keys</a> gepflegt.
|
||||
</p>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+130
-131
@@ -1,6 +1,5 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { Globe } from "lucide-react";
|
||||
|
||||
import { CopyButton } from "@/app/copy-button";
|
||||
import { PageHeader } from "@/app/page-header";
|
||||
@@ -13,149 +12,149 @@ import { verifyDomainAction } from "../actions";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
function statusBadge(status: string) {
|
||||
if (status === "verified") return <span className="ds-badge ds-badge--success">Verifiziert</span>;
|
||||
if (status === "failed") return <span className="ds-badge ds-badge--danger">Fehler</span>;
|
||||
return <span className="ds-badge ds-badge--warning">Ausstehend</span>;
|
||||
if (status === "verified") return <span className="ds-badge ds-badge--success">Verifiziert</span>;
|
||||
if (status === "failed") return <span className="ds-badge ds-badge--danger">Fehler</span>;
|
||||
return <span className="ds-badge ds-badge--warning">Ausstehend</span>;
|
||||
}
|
||||
|
||||
export default async function DomainDetail({ params }: { params: Promise<{ domain: string }> }) {
|
||||
const raw = (await params).domain;
|
||||
let domain = raw;
|
||||
try {
|
||||
domain = decodeURIComponent(raw);
|
||||
} catch {
|
||||
// Der Parameter ist bereits dekodiert.
|
||||
}
|
||||
const raw = (await params).domain;
|
||||
let domain = raw;
|
||||
try {
|
||||
domain = decodeURIComponent(raw);
|
||||
} catch {
|
||||
// Der Parameter ist bereits dekodiert.
|
||||
}
|
||||
|
||||
if (!domain.includes(".")) notFound();
|
||||
let row = await getDomainRow(domain);
|
||||
if (!row) {
|
||||
row = await verifyDomain(domain);
|
||||
}
|
||||
if (!row) notFound();
|
||||
if (!domain.includes(".")) notFound();
|
||||
let row = await getDomainRow(domain);
|
||||
if (!row) {
|
||||
row = await verifyDomain(domain);
|
||||
}
|
||||
if (!row) notFound();
|
||||
|
||||
const ses = await sesAccountStatus();
|
||||
const mailFrom = row.mail_from_domain || `bounce.${domain}`;
|
||||
const dkim = row.dkim_tokens ?? [];
|
||||
const ses = await sesAccountStatus();
|
||||
const mailFrom = row.mail_from_domain || `bounce.${domain}`;
|
||||
const dkim = row.dkim_tokens ?? [];
|
||||
|
||||
return (
|
||||
<>
|
||||
<p>
|
||||
<Link href="/domains">← Domains</Link>
|
||||
</p>
|
||||
<PageHeader
|
||||
eyebrow="Domain"
|
||||
title={row.domain}
|
||||
lead={row.status === "verified" ? "Die Domain ist bei SES verifiziert und kann senden." : "Die DNS-Records unten müssen noch gesetzt und geprüft werden."}
|
||||
code={false}
|
||||
actions={
|
||||
<>
|
||||
{statusBadge(row.status)}
|
||||
<form action={verifyDomainAction}>
|
||||
<input type="hidden" name="domain" value={row.domain} />
|
||||
<button className="ds-button ds-button--secondary ds-button--sm" type="submit">
|
||||
Status prüfen
|
||||
</button>
|
||||
</form>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
return (
|
||||
<>
|
||||
<p>
|
||||
<Link href="/domains">← Domains</Link>
|
||||
</p>
|
||||
<PageHeader
|
||||
eyebrow="Domain"
|
||||
title={row.domain}
|
||||
lead={row.status === "verified" ? "Die Domain ist bei SES verifiziert und kann senden." : "Die DNS-Records unten müssen noch gesetzt und geprüft werden."}
|
||||
code={false}
|
||||
actions={
|
||||
<>
|
||||
{statusBadge(row.status)}
|
||||
<form action={verifyDomainAction}>
|
||||
<input type="hidden" name="domain" value={row.domain} />
|
||||
<button className="btn btn-sekundaer btn-klein" type="submit">
|
||||
Status prüfen
|
||||
</button>
|
||||
</form>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
{!ses.production ? (
|
||||
<div className="ds-alert ds-alert--warning">
|
||||
<div>
|
||||
<p className="ds-alert__title">SES Production Access fehlt</p>
|
||||
<p className="ds-alert__text">
|
||||
Die Domain kann verifiziert sein, aber beliebige Empfänger erst nach der AWS-Freigabe.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{!ses.production ? (
|
||||
<div className="ds-alert ds-alert--warning">
|
||||
<div>
|
||||
<p className="ds-alert__title">SES Production Access fehlt</p>
|
||||
<p className="ds-alert__text">
|
||||
Die Domain kann verifiziert sein, aber beliebige Empfänger erst nach der AWS-Freigabe.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<section className="ds-card app-panel">
|
||||
<div className="app-panel__head">
|
||||
<h2>Status</h2>
|
||||
</div>
|
||||
<dl className="app-dl">
|
||||
<dt>SES-Status</dt>
|
||||
<dd>{statusBadge(row.status)}</dd>
|
||||
<dt>DKIM</dt>
|
||||
<dd>{dkim.length ? `${dkim.length} Tokens` : "Noch keine Tokens"}</dd>
|
||||
<dt>MAIL FROM</dt>
|
||||
<dd className="app-mono">
|
||||
{row.mail_from_domain || "–"} {row.mail_from_status ? `(${row.mail_from_status})` : ""}
|
||||
</dd>
|
||||
<dt>Zuletzt geprüft</dt>
|
||||
<dd className="app-mono">{datum(row.last_checked_at)}</dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section className="karte app-panel">
|
||||
<div className="app-panel__head">
|
||||
<h2>Status</h2>
|
||||
</div>
|
||||
<dl className="app-dl">
|
||||
<dt>SES-Status</dt>
|
||||
<dd>{statusBadge(row.status)}</dd>
|
||||
<dt>DKIM</dt>
|
||||
<dd>{dkim.length ? `${dkim.length} Tokens` : "Noch keine Tokens"}</dd>
|
||||
<dt>MAIL FROM</dt>
|
||||
<dd className="app-mono">
|
||||
{row.mail_from_domain || "–"} {row.mail_from_status ? `(${row.mail_from_status})` : ""}
|
||||
</dd>
|
||||
<dt>Zuletzt geprüft</dt>
|
||||
<dd className="app-mono">{datum(row.last_checked_at)}</dd>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section className="ds-card app-panel app-section">
|
||||
<div className="app-panel__head">
|
||||
<h2>DNS-Records</h2>
|
||||
</div>
|
||||
<p className="app-muted">
|
||||
Bei Cloudflare als <strong>DNS only</strong> eintragen. Die Namen sind relativ zu{" "}
|
||||
<code className="app-mono">{row.domain}</code>.
|
||||
</p>
|
||||
<section className="karte app-panel app-section">
|
||||
<div className="app-panel__head">
|
||||
<h2>DNS-Records</h2>
|
||||
</div>
|
||||
<p className="app-muted">
|
||||
Bei Cloudflare als <strong>DNS only</strong> eintragen. Die Namen sind relativ zu{" "}
|
||||
<code className="app-mono">{row.domain}</code>.
|
||||
</p>
|
||||
|
||||
<div className="app-code-list">
|
||||
{dkim.map((token) => {
|
||||
const name = `${token}._domainkey.${row.domain}`;
|
||||
const value = `${token}.dkim.amazonses.com`;
|
||||
return (
|
||||
<div className="app-code-row" key={token}>
|
||||
<span className="ds-badge">CNAME</span>
|
||||
<code className="app-mono">{name}</code>
|
||||
<code className="app-mono">{value}</code>
|
||||
<CopyButton value={value} label="Kopieren" />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<div className="app-code-list">
|
||||
{dkim.map((token) => {
|
||||
const name = `${token}._domainkey.${row.domain}`;
|
||||
const value = `${token}.dkim.amazonses.com`;
|
||||
return (
|
||||
<div className="app-code-row" key={token}>
|
||||
<span className="ds-badge">CNAME</span>
|
||||
<code className="app-mono">{name}</code>
|
||||
<code className="app-mono">{value}</code>
|
||||
<CopyButton value={value} label="Kopieren" />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
<div className="app-code-row">
|
||||
<span className="ds-badge">MX 10</span>
|
||||
<code className="app-mono">{mailFrom}</code>
|
||||
<code className="app-mono">feedback-smtp.{config.awsRegion}.amazonses.com</code>
|
||||
<CopyButton value={`feedback-smtp.${config.awsRegion}.amazonses.com`} label="Kopieren" />
|
||||
</div>
|
||||
<div className="app-code-row">
|
||||
<span className="ds-badge">MX 10</span>
|
||||
<code className="app-mono">{mailFrom}</code>
|
||||
<code className="app-mono">feedback-smtp.{config.awsRegion}.amazonses.com</code>
|
||||
<CopyButton value={`feedback-smtp.${config.awsRegion}.amazonses.com`} label="Kopieren" />
|
||||
</div>
|
||||
|
||||
<div className="app-code-row">
|
||||
<span className="ds-badge">TXT</span>
|
||||
<code className="app-mono">{mailFrom}</code>
|
||||
<code className="app-mono">v=spf1 include:amazonses.com ~all</code>
|
||||
<CopyButton value="v=spf1 include:amazonses.com ~all" label="Kopieren" />
|
||||
</div>
|
||||
<div className="app-code-row">
|
||||
<span className="ds-badge">TXT</span>
|
||||
<code className="app-mono">{mailFrom}</code>
|
||||
<code className="app-mono">v=spf1 include:amazonses.com ~all</code>
|
||||
<CopyButton value="v=spf1 include:amazonses.com ~all" label="Kopieren" />
|
||||
</div>
|
||||
|
||||
<div className="app-code-row">
|
||||
<span className="ds-badge">TXT</span>
|
||||
<code className="app-mono">_dmarc.{row.domain}</code>
|
||||
<code className="app-mono">v=DMARC1; p=none;</code>
|
||||
<CopyButton value="v=DMARC1; p=none;" label="Kopieren" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="app-code-row">
|
||||
<span className="ds-badge">TXT</span>
|
||||
<code className="app-mono">_dmarc.{row.domain}</code>
|
||||
<code className="app-mono">v=DMARC1; p=none;</code>
|
||||
<CopyButton value="v=DMARC1; p=none;" label="Kopieren" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!dkim.length ? (
|
||||
<div className="ds-alert ds-alert--warning">
|
||||
<div>
|
||||
<p className="ds-alert__title">Noch keine DKIM-Tokens</p>
|
||||
<p className="ds-alert__text">
|
||||
Klicke oben auf „Status prüfen“, um die Identity erneut von SES zu laden.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
{!dkim.length ? (
|
||||
<div className="ds-alert ds-alert--warning">
|
||||
<div>
|
||||
<p className="ds-alert__title">Noch keine DKIM-Tokens</p>
|
||||
<p className="ds-alert__text">
|
||||
Klicke oben auf „Status prüfen“, um die Identity erneut von SES zu laden.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</section>
|
||||
|
||||
<section className="ds-card app-panel app-section">
|
||||
<div className="app-panel__head">
|
||||
<h2>API-Key für diese Domain</h2>
|
||||
</div>
|
||||
<p className="app-muted">
|
||||
Lege unter <Link href="/keys">API-Keys</Link> einen Key mit genau dieser Domain an. Der
|
||||
Key darf dann nur Absender aus <code className="app-mono">{row.domain}</code> verwenden.
|
||||
</p>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
<section className="karte app-panel app-section">
|
||||
<div className="app-panel__head">
|
||||
<h2>API-Key für diese Domain</h2>
|
||||
</div>
|
||||
<p className="app-muted">
|
||||
Lege unter <Link href="/keys">API-Keys</Link> einen Key mit genau dieser Domain an. Der
|
||||
Key darf dann nur Absender aus <code className="app-mono">{row.domain}</code> verwenden.
|
||||
</p>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+48
-48
@@ -5,57 +5,57 @@ import { createDomainAction } from "../actions";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function NewDomain({
|
||||
searchParams,
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ error?: string }>;
|
||||
searchParams: Promise<{ error?: string }>;
|
||||
}) {
|
||||
const { error } = await searchParams;
|
||||
const { error } = await searchParams;
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Domain hinzufügen"
|
||||
lead="Courier legt die SES-Identity an und zeigt danach die DNS-Records zum Kopieren."
|
||||
code={false}
|
||||
/>
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Domain hinzufügen"
|
||||
lead="Courier legt die SES-Identity an und zeigt danach die DNS-Records zum Kopieren."
|
||||
code={false}
|
||||
/>
|
||||
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Domain nicht angelegt</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Domain nicht angelegt</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<section className="ds-card app-panel">
|
||||
<form action={createDomainAction} className="ds-stack app-form">
|
||||
<div className="ds-field">
|
||||
<label className="ds-field__label" htmlFor="domain">
|
||||
Domain
|
||||
</label>
|
||||
<input
|
||||
className="ds-input"
|
||||
id="domain"
|
||||
name="domain"
|
||||
required
|
||||
placeholder="send.aimighty.de"
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
aria-describedby="domain-hint"
|
||||
/>
|
||||
<span className="ds-field__hint" id="domain-hint">
|
||||
Wenn die Hauptdomain bereits Mail nutzt (z. B. One.com), nimm eine Subdomain wie{" "}
|
||||
<code>send.aimighty.de</code>. Die DNS-Records erscheinen nach dem Anlegen.
|
||||
</span>
|
||||
</div>
|
||||
<div className="app-actions">
|
||||
<button className="ds-button ds-button--lg" type="submit">
|
||||
Domain anlegen
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
<section className="karte app-panel">
|
||||
<form action={createDomainAction} className="ds-stack app-form">
|
||||
<div className="feld">
|
||||
<label className="ds-field__label" htmlFor="domain">
|
||||
Domain
|
||||
</label>
|
||||
<input
|
||||
className="input"
|
||||
id="domain"
|
||||
name="domain"
|
||||
required
|
||||
placeholder="send.aimighty.de"
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
aria-describedby="domain-hint"
|
||||
/>
|
||||
<span className="feld-hinweis" id="domain-hint">
|
||||
Wenn die Hauptdomain bereits Mail nutzt (z. B. One.com), nimm eine Subdomain wie{" "}
|
||||
<code>send.aimighty.de</code>. Die DNS-Records erscheinen nach dem Anlegen.
|
||||
</span>
|
||||
</div>
|
||||
<div className="app-actions">
|
||||
<button className="btn btn-primaer" type="submit">
|
||||
Domain anlegen
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+127
-117
@@ -1,5 +1,5 @@
|
||||
import Link from "next/link";
|
||||
import { Globe } from "lucide-react";
|
||||
import { ChevronRight, Globe } from "lucide-react";
|
||||
|
||||
import { EmptyState } from "@/app/empty-state";
|
||||
import { PageHeader } from "@/app/page-header";
|
||||
@@ -9,127 +9,137 @@ import { listDomainRows, sesAccountStatus, syncDomains } from "@/lib/ses-admin";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
function statusBadge(status: string) {
|
||||
if (status === "verified") return <span className="ds-badge ds-badge--success">Verifiziert</span>;
|
||||
if (status === "failed") return <span className="ds-badge ds-badge--danger">Fehler</span>;
|
||||
return <span className="ds-badge ds-badge--warning">Ausstehend</span>;
|
||||
if (status === "verified") return <span className="ds-badge ds-badge--success">Verifiziert</span>;
|
||||
if (status === "failed") return <span className="ds-badge ds-badge--danger">Fehler</span>;
|
||||
return <span className="ds-badge ds-badge--warning">Ausstehend</span>;
|
||||
}
|
||||
|
||||
export default async function Domains() {
|
||||
let rows: Awaited<ReturnType<typeof listDomainRows>> = [];
|
||||
let ses = { production: false, max24h: 0, rate: 0 };
|
||||
let error = "";
|
||||
try {
|
||||
ses = await sesAccountStatus();
|
||||
rows = await syncDomains();
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Domains nicht erreichbar";
|
||||
try {
|
||||
rows = await listDomainRows();
|
||||
} catch {
|
||||
// Die Seite zeigt den Fehler unten.
|
||||
}
|
||||
}
|
||||
let rows: Awaited<ReturnType<typeof listDomainRows>> = [];
|
||||
let ses = { production: false, max24h: 0, rate: 0 };
|
||||
let error = "";
|
||||
try {
|
||||
ses = await sesAccountStatus();
|
||||
rows = await syncDomains();
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Domains nicht erreichbar";
|
||||
try {
|
||||
rows = await listDomainRows();
|
||||
} catch {
|
||||
// Die Seite zeigt den Fehler unten.
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Domains"
|
||||
lead="Verifizierte SES-Identities für den Versand. Jeder API-Key darf nur aus seiner Domain senden."
|
||||
actions={
|
||||
<Link className="ds-button ds-button--sm" href="/domains/new">
|
||||
Domain hinzufügen
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Domains"
|
||||
lead="Verifizierte SES-Identities für den Versand. Jeder API-Key darf nur aus seiner Domain senden."
|
||||
actions={
|
||||
<Link className="btn btn-primaer btn-klein" href="/domains/new">
|
||||
Domain hinzufügen
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
|
||||
{!ses.production ? (
|
||||
<div className="ds-alert ds-alert--warning">
|
||||
<div>
|
||||
<p className="ds-alert__title">SES ist im Sandbox-Modus</p>
|
||||
<p className="ds-alert__text">
|
||||
{Math.round(ses.max24h)} Mails pro 24 Stunden, {ses.rate}/s. Für 500/Tag braucht das
|
||||
AWS-Konto Production Access.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Domains konnten nicht synchronisiert werden</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Domains konnten nicht synchronisiert werden</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="app-grid app-grid--sidebar">
|
||||
{rows.length ? (
|
||||
<section className="karte app-panel" aria-labelledby="domain-list">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="domain-list">Domains</h2>
|
||||
</div>
|
||||
<div className="app-domain-list">
|
||||
{rows.map((row) => (
|
||||
<Link
|
||||
key={row.domain}
|
||||
className="app-domain-row"
|
||||
href={`/domains/${encodeURIComponent(row.domain)}`}
|
||||
>
|
||||
<span className="app-domain-row__icon" aria-hidden="true">
|
||||
<Globe />
|
||||
</span>
|
||||
<span className="app-domain-row__main">
|
||||
<span className="app-domain-row__name">{row.domain}</span>
|
||||
<span className="app-domain-row__meta">
|
||||
<span>
|
||||
{row.dkim_tokens?.length
|
||||
? `${row.dkim_tokens.length} DKIM-Tokens`
|
||||
: "keine DKIM-Tokens"}
|
||||
</span>
|
||||
<span className="app-mono">{row.mail_from_domain || "kein MAIL FROM"}</span>
|
||||
<span title={datum(row.last_checked_at)}>
|
||||
geprüft {row.last_checked_at ? relativ(row.last_checked_at) : "–"}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<span className="app-domain-row__side">
|
||||
{statusBadge(row.status)}
|
||||
<ChevronRight className="app-domain-row__chevron" aria-hidden="true" />
|
||||
</span>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
) : (
|
||||
<EmptyState
|
||||
icon={Globe}
|
||||
title="Noch keine Domains"
|
||||
text="Füge eine Domain hinzu, verifiziere sie mit den angezeigten DNS-Records und lege danach einen API-Key an."
|
||||
action={
|
||||
<Link className="btn btn-primaer btn-klein" href="/domains/new">
|
||||
Domain hinzufügen
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
{rows.length ? (
|
||||
<section className="ds-card app-panel">
|
||||
<div className="app-table-scroll app-desktop-table">
|
||||
<table className="ds-table">
|
||||
<caption className="ds-visually-hidden">SES-Domains</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Domain</th>
|
||||
<th>Status</th>
|
||||
<th>DKIM</th>
|
||||
<th>MAIL FROM</th>
|
||||
<th>Zuletzt geprüft</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((row) => (
|
||||
<tr key={row.domain}>
|
||||
<td>
|
||||
<Link href={`/domains/${encodeURIComponent(row.domain)}`}>{row.domain}</Link>
|
||||
</td>
|
||||
<td>{statusBadge(row.status)}</td>
|
||||
<td>{row.dkim_tokens?.length ? `${row.dkim_tokens.length} Tokens` : "–"}</td>
|
||||
<td className="app-mono">{row.mail_from_domain || "–"}</td>
|
||||
<td className="app-mono">{row.last_checked_at ? relativ(row.last_checked_at) : "–"}</td>
|
||||
<td>
|
||||
<Link
|
||||
className="ds-button ds-button--secondary ds-button--sm"
|
||||
href={`/domains/${encodeURIComponent(row.domain)}`}
|
||||
>
|
||||
Öffnen
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="app-mobile-list">
|
||||
{rows.map((row) => (
|
||||
<article key={row.domain} className="app-mobile-item">
|
||||
<div className="app-mobile-item__top">
|
||||
<Link href={`/domains/${encodeURIComponent(row.domain)}`}>{row.domain}</Link>
|
||||
{statusBadge(row.status)}
|
||||
</div>
|
||||
<div className="app-mobile-item__meta">
|
||||
<span className="app-mono">{row.mail_from_domain || "kein MAIL FROM"}</span>
|
||||
<span className="app-mono" title={datum(row.last_checked_at)}>
|
||||
{row.last_checked_at ? relativ(row.last_checked_at) : "–"}
|
||||
</span>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
) : (
|
||||
<EmptyState
|
||||
icon={Globe}
|
||||
title="Noch keine Domains"
|
||||
text="Füge eine Domain hinzu, verifiziere sie mit den angezeigten DNS-Records und lege danach einen API-Key an."
|
||||
action={
|
||||
<Link className="ds-button ds-button--sm" href="/domains/new">
|
||||
Domain hinzufügen
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
<aside className="karte app-panel" aria-labelledby="ses-konto">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="ses-konto">SES-Konto</h2>
|
||||
{ses.production ? (
|
||||
<span className="ds-badge ds-badge--success">Production</span>
|
||||
) : (
|
||||
<span className="ds-badge ds-badge--warning">Sandbox</span>
|
||||
)}
|
||||
</div>
|
||||
<dl className="app-dl">
|
||||
<dt>Tagesquote</dt>
|
||||
<dd>{Math.round(ses.max24h)} Mails</dd>
|
||||
<dt>Rate</dt>
|
||||
<dd>{ses.rate}/s</dd>
|
||||
<dt>Region</dt>
|
||||
<dd className="app-mono">eu-west-1</dd>
|
||||
</dl>
|
||||
|
||||
{!ses.production ? (
|
||||
<div className="ds-alert ds-alert--warning">
|
||||
<div>
|
||||
<p className="ds-alert__title">Sandbox aktiv</p>
|
||||
<p className="ds-alert__text">
|
||||
Für 500/Tag braucht das AWS-Konto Production Access. Bis dahin nur verifizierte
|
||||
Empfänger.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<h2 className="app-section">So funktioniert's</h2>
|
||||
<ol className="app-steps">
|
||||
<li>Domain anlegen und die DNS-Records setzen.</li>
|
||||
<li>Status prüfen, bis DKIM und SES „Verifiziert“ melden.</li>
|
||||
<li>API-Key mit dieser Domain erzeugen.</li>
|
||||
</ol>
|
||||
</aside>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+16
-18
@@ -1,24 +1,22 @@
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
|
||||
export function EmptyState({
|
||||
icon: Icon,
|
||||
title,
|
||||
text,
|
||||
action,
|
||||
icon: Icon,
|
||||
title,
|
||||
text,
|
||||
action,
|
||||
}: {
|
||||
icon: LucideIcon;
|
||||
title: string;
|
||||
text: string;
|
||||
action?: React.ReactNode;
|
||||
icon: LucideIcon;
|
||||
title: string;
|
||||
text: string;
|
||||
action?: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<div className="app-empty">
|
||||
<span className="app-empty__icon" aria-hidden="true">
|
||||
<Icon />
|
||||
</span>
|
||||
<p className="app-empty__title">{title}</p>
|
||||
<p className="app-empty__text">{text}</p>
|
||||
{action ? <div className="app-actions">{action}</div> : null}
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div className="leerzustand">
|
||||
<Icon size={48} aria-hidden="true" />
|
||||
<h4 className="leerzustand-titel">{title}</h4>
|
||||
<p>{text}</p>
|
||||
{action ? <div className="btn-reihe">{action}</div> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+1508
-9
File diff suppressed because it is too large.
Load diff
+120
-119
@@ -3,135 +3,136 @@
|
||||
import { useActionState } from "react";
|
||||
|
||||
import { CopyButton } from "@/app/copy-button";
|
||||
import { Select } from "@/app/select";
|
||||
|
||||
import { createKey, type KeyState } from "./actions";
|
||||
|
||||
export function KeyForm({ domains }: { domains: string[] }) {
|
||||
const [state, action, pending] = useActionState<KeyState, FormData>(createKey, {});
|
||||
const [state, action, pending] = useActionState<KeyState, FormData>(createKey, {});
|
||||
|
||||
return (
|
||||
<>
|
||||
<form action={action} className="ds-stack app-form">
|
||||
<div className="ds-field">
|
||||
<label className="ds-field__label" htmlFor="app">
|
||||
App
|
||||
</label>
|
||||
<input
|
||||
className="ds-input"
|
||||
id="app"
|
||||
name="app"
|
||||
required
|
||||
placeholder="plan"
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
aria-describedby="app-hint"
|
||||
/>
|
||||
<span className="ds-field__hint" id="app-hint">
|
||||
Technischer Name, z. B. plan, lunch oder places.
|
||||
</span>
|
||||
</div>
|
||||
return (
|
||||
<>
|
||||
<form action={action} className="ds-stack app-form">
|
||||
<div className="feld">
|
||||
<label className="ds-field__label" htmlFor="app">
|
||||
App
|
||||
</label>
|
||||
<input
|
||||
className="input"
|
||||
id="app"
|
||||
name="app"
|
||||
required
|
||||
placeholder="plan"
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
aria-describedby="app-hint"
|
||||
/>
|
||||
<span className="feld-hinweis" id="app-hint">
|
||||
Technischer Name, z. B. plan, lunch oder places.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="ds-field">
|
||||
<label className="ds-field__label" htmlFor="name">
|
||||
Bezeichnung
|
||||
</label>
|
||||
<input
|
||||
className="ds-input"
|
||||
id="name"
|
||||
name="name"
|
||||
required
|
||||
placeholder="Plan"
|
||||
autoComplete="off"
|
||||
/>
|
||||
</div>
|
||||
<div className="feld">
|
||||
<label className="ds-field__label" htmlFor="name">
|
||||
Bezeichnung
|
||||
</label>
|
||||
<input
|
||||
className="input"
|
||||
id="name"
|
||||
name="name"
|
||||
required
|
||||
placeholder="Plan"
|
||||
autoComplete="off"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="ds-field">
|
||||
<label className="ds-field__label" htmlFor="domain">
|
||||
Absenderdomain
|
||||
</label>
|
||||
<select className="ds-select" id="domain" name="domain" defaultValue={domains[0]} required>
|
||||
{domains.map((domain) => (
|
||||
<option key={domain} value={domain}>
|
||||
{domain}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<span className="ds-field__hint" id="domain-hint">
|
||||
Nur Adressen dieser Domain werden akzeptiert. Weitere Domain unter{" "}
|
||||
<a href="/domains/new">Domains</a> anlegen.
|
||||
</span>
|
||||
</div>
|
||||
<div className="feld">
|
||||
<label className="ds-field__label" htmlFor="domain">
|
||||
Absenderdomain
|
||||
</label>
|
||||
<Select id="domain" name="domain" defaultValue={domains[0]} required>
|
||||
{domains.map((domain) => (
|
||||
<option key={domain} value={domain}>
|
||||
{domain}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
<span className="feld-hinweis" id="domain-hint">
|
||||
Nur Adressen dieser Domain werden akzeptiert. Weitere Domain unter{" "}
|
||||
<a href="/domains/new">Domains</a> anlegen.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="ds-field">
|
||||
<label className="ds-field__label" htmlFor="from">
|
||||
Nur diese Absenderadresse (optional)
|
||||
</label>
|
||||
<input
|
||||
className="ds-input"
|
||||
id="from"
|
||||
name="from"
|
||||
placeholder="noreply@hubsport.club"
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
/>
|
||||
</div>
|
||||
<div className="feld">
|
||||
<label className="ds-field__label" htmlFor="from">
|
||||
Nur diese Absenderadresse (optional)
|
||||
</label>
|
||||
<input
|
||||
className="input"
|
||||
id="from"
|
||||
name="from"
|
||||
placeholder="noreply@hubsport.club"
|
||||
autoComplete="off"
|
||||
spellCheck={false}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="app-form-row">
|
||||
<div className="ds-field">
|
||||
<label className="ds-field__label" htmlFor="daily">
|
||||
Tageslimit
|
||||
</label>
|
||||
<input
|
||||
className="ds-input"
|
||||
id="daily"
|
||||
name="daily"
|
||||
type="number"
|
||||
min={1}
|
||||
defaultValue={500}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="ds-field">
|
||||
<label className="ds-field__label" htmlFor="monthly">
|
||||
Monatslimit
|
||||
</label>
|
||||
<input
|
||||
className="ds-input"
|
||||
id="monthly"
|
||||
name="monthly"
|
||||
type="number"
|
||||
min={1}
|
||||
defaultValue={15000}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="app-form-row">
|
||||
<div className="feld">
|
||||
<label className="ds-field__label" htmlFor="daily">
|
||||
Tageslimit
|
||||
</label>
|
||||
<input
|
||||
className="input"
|
||||
id="daily"
|
||||
name="daily"
|
||||
type="number"
|
||||
min={1}
|
||||
defaultValue={500}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="feld">
|
||||
<label className="ds-field__label" htmlFor="monthly">
|
||||
Monatslimit
|
||||
</label>
|
||||
<input
|
||||
className="input"
|
||||
id="monthly"
|
||||
name="monthly"
|
||||
type="number"
|
||||
min={1}
|
||||
defaultValue={15000}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="app-actions">
|
||||
<button className="ds-button ds-button--lg" type="submit" disabled={pending}>
|
||||
{pending ? "Erzeuge…" : "API-Key erzeugen"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div className="app-actions">
|
||||
<button className="btn btn-primaer" type="submit" disabled={pending}>
|
||||
{pending ? "Erzeuge…" : "API-Key erzeugen"}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{state.error ? (
|
||||
<p className="ds-field__error" role="alert">
|
||||
{state.error}
|
||||
</p>
|
||||
) : null}
|
||||
{state.error ? (
|
||||
<p className="feld-fehlertext" role="alert">
|
||||
{state.error}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{state.key ? (
|
||||
<div className="ds-alert ds-alert--success app-section" role="status">
|
||||
<div>
|
||||
<p className="ds-alert__title">API-Key erzeugt</p>
|
||||
<p className="ds-alert__text">Der Key wird nur jetzt angezeigt. Bitte sicher ablegen.</p>
|
||||
<code className="app-key app-section">{state.key}</code>
|
||||
<div className="app-actions app-section">
|
||||
<CopyButton value={state.key} label="Key kopieren" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
{state.key ? (
|
||||
<div className="ds-alert ds-alert--success app-section" role="status">
|
||||
<div>
|
||||
<p className="ds-alert__title">API-Key erzeugt</p>
|
||||
<p className="ds-alert__text">Der Key wird nur jetzt angezeigt. Bitte sicher ablegen.</p>
|
||||
<code className="app-key app-section">{state.key}</code>
|
||||
<div className="app-actions app-section">
|
||||
<CopyButton value={state.key} label="Key kopieren" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
+164
-164
@@ -13,175 +13,175 @@ import { revokeKey } from "./actions";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function Keys() {
|
||||
let keys: Awaited<ReturnType<typeof listApiKeys>> = [];
|
||||
let domains: string[] = ["hubsport.club"];
|
||||
let error = "";
|
||||
try {
|
||||
keys = await listApiKeys();
|
||||
domains = (await listDomainRows()).map((row) => row.domain);
|
||||
if (!domains.length) domains = ["hubsport.club"];
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar";
|
||||
}
|
||||
let keys: Awaited<ReturnType<typeof listApiKeys>> = [];
|
||||
let domains: string[] = ["hubsport.club"];
|
||||
let error = "";
|
||||
try {
|
||||
keys = await listApiKeys();
|
||||
domains = (await listDomainRows()).map((row) => row.domain);
|
||||
if (!domains.length) domains = ["hubsport.club"];
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar";
|
||||
}
|
||||
|
||||
const active = keys.filter((key) => !key.revoked_at).length;
|
||||
const active = keys.filter((key) => !key.revoked_at).length;
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="API-Keys"
|
||||
lead="Jede App bekommt einen eigenen Key. Er gilt nur für die eingetragene Absenderdomain und wird ausschließlich gehasht gespeichert."
|
||||
actions={
|
||||
<Link className="ds-button ds-button--secondary ds-button--sm" href="#neu">
|
||||
Neuer Key
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="API-Keys"
|
||||
lead="Jede App bekommt einen eigenen Key. Er gilt nur für die eingetragene Absenderdomain und wird ausschließlich gehasht gespeichert."
|
||||
actions={
|
||||
<Link className="btn btn-sekundaer btn-klein" href="#neu">
|
||||
Neuer Key
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Datenbank nicht erreichbar</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Datenbank nicht erreichbar</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<section className="ds-card app-panel" id="neu" aria-labelledby="neu">
|
||||
<div className="app-panel__head">
|
||||
<div>
|
||||
<h2 id="neu">Neuen Key erzeugen</h2>
|
||||
<p className="app-muted">Ein Key pro App, mit eigenem Tages- und Monatslimit.</p>
|
||||
</div>
|
||||
</div>
|
||||
<KeyForm domains={domains} />
|
||||
</section>
|
||||
<section className="karte app-panel" id="neu" aria-labelledby="neu">
|
||||
<div className="app-panel__head">
|
||||
<div>
|
||||
<h2 id="neu">Neuen Key erzeugen</h2>
|
||||
<p className="app-muted">Ein Key pro App, mit eigenem Tages- und Monatslimit.</p>
|
||||
</div>
|
||||
</div>
|
||||
<KeyForm domains={domains} />
|
||||
</section>
|
||||
|
||||
<section className="ds-card app-panel app-section" aria-labelledby="vorhanden">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="vorhanden">Vorhandene Keys</h2>
|
||||
<span className="ds-badge">{active} aktiv</span>
|
||||
</div>
|
||||
<section className="karte app-panel app-section" aria-labelledby="vorhanden">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="vorhanden">Vorhandene Keys</h2>
|
||||
<span className="ds-badge">{active} aktiv</span>
|
||||
</div>
|
||||
|
||||
{keys.length ? (
|
||||
<>
|
||||
<div className="app-table-scroll app-desktop-table">
|
||||
<table className="ds-table">
|
||||
<caption className="ds-visually-hidden">API-Keys für die Apps</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>App</th>
|
||||
<th>Bezeichnung</th>
|
||||
<th>Prefix</th>
|
||||
<th className="app-hide-sm">Domain</th>
|
||||
<th>Limit</th>
|
||||
<th className="app-hide-sm">Zuletzt</th>
|
||||
<th>Status</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{keys.map((key) => (
|
||||
<tr key={key.id}>
|
||||
<td>{key.app}</td>
|
||||
<td>{key.name}</td>
|
||||
<td className="app-mono">{key.prefix}…</td>
|
||||
<td className="app-hide-sm">{key.from_domain}</td>
|
||||
<td className="app-mono app-nowrap">
|
||||
{key.daily_limit}/Tag · {key.monthly_limit}/Monat
|
||||
</td>
|
||||
<td className="app-hide-sm app-mono app-nowrap">{datum(key.last_used_at)}</td>
|
||||
<td>
|
||||
{key.revoked_at ? (
|
||||
<span className="ds-badge ds-badge--danger">Gesperrt</span>
|
||||
) : (
|
||||
<span className="ds-badge ds-badge--success">Aktiv</span>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{key.revoked_at ? null : (
|
||||
<form action={revokeKey}>
|
||||
<input type="hidden" name="id" value={key.id} />
|
||||
<button
|
||||
className="ds-button ds-button--danger ds-button--sm"
|
||||
type="submit"
|
||||
aria-label={`Key ${key.name} endgültig sperren`}
|
||||
>
|
||||
Sperren
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="app-mobile-list">
|
||||
{keys.map((key) => (
|
||||
<article key={key.id} className="app-mobile-item">
|
||||
<div className="app-mobile-item__top">
|
||||
<span>
|
||||
<strong>{key.name}</strong> <span className="app-muted">({key.app})</span>
|
||||
</span>
|
||||
{key.revoked_at ? (
|
||||
<span className="ds-badge ds-badge--danger">Gesperrt</span>
|
||||
) : (
|
||||
<span className="ds-badge ds-badge--success">Aktiv</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="app-mobile-item__meta">
|
||||
<span className="app-mono">{key.prefix}…</span>
|
||||
<span className="app-mono">
|
||||
{key.daily_limit}/Tag · {key.monthly_limit}/Monat
|
||||
</span>
|
||||
</div>
|
||||
{key.revoked_at ? null : (
|
||||
<div className="app-mobile-item__actions">
|
||||
<form action={revokeKey}>
|
||||
<input type="hidden" name="id" value={key.id} />
|
||||
<button
|
||||
className="ds-button ds-button--danger ds-button--sm"
|
||||
type="submit"
|
||||
aria-label={`Key ${key.name} endgültig sperren`}
|
||||
>
|
||||
Sperren
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<EmptyState
|
||||
icon={KeyRound}
|
||||
title="Noch keine Keys"
|
||||
text="Erzeuge oben den ersten Key für eine App."
|
||||
action={<Link className="ds-button ds-button--secondary ds-button--sm" href="#neu">Key erzeugen</Link>}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
{keys.length ? (
|
||||
<>
|
||||
<div className="rollbar app-desktop-table">
|
||||
<table className="tabelle">
|
||||
<caption className="ds-visually-hidden">API-Keys für die Apps</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>App</th>
|
||||
<th>Bezeichnung</th>
|
||||
<th>Prefix</th>
|
||||
<th className="app-hide-sm">Domain</th>
|
||||
<th>Limit</th>
|
||||
<th className="app-hide-sm">Zuletzt</th>
|
||||
<th>Status</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{keys.map((key) => (
|
||||
<tr key={key.id}>
|
||||
<td>{key.app}</td>
|
||||
<td>{key.name}</td>
|
||||
<td className="app-mono">{key.prefix}…</td>
|
||||
<td className="app-hide-sm">{key.from_domain}</td>
|
||||
<td className="app-mono app-nowrap">
|
||||
{key.daily_limit}/Tag · {key.monthly_limit}/Monat
|
||||
</td>
|
||||
<td className="app-hide-sm app-mono app-nowrap">{datum(key.last_used_at)}</td>
|
||||
<td>
|
||||
{key.revoked_at ? (
|
||||
<span className="ds-badge ds-badge--danger">Gesperrt</span>
|
||||
) : (
|
||||
<span className="ds-badge ds-badge--success">Aktiv</span>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{key.revoked_at ? null : (
|
||||
<form action={revokeKey}>
|
||||
<input type="hidden" name="id" value={key.id} />
|
||||
<button
|
||||
className="btn btn-gefahr btn-klein"
|
||||
type="submit"
|
||||
aria-label={`Key ${key.name} endgültig sperren`}
|
||||
>
|
||||
Sperren
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="app-mobile-list">
|
||||
{keys.map((key) => (
|
||||
<article key={key.id} className="app-mobile-item">
|
||||
<div className="app-mobile-item__top">
|
||||
<span>
|
||||
<strong>{key.name}</strong> <span className="app-muted">({key.app})</span>
|
||||
</span>
|
||||
{key.revoked_at ? (
|
||||
<span className="ds-badge ds-badge--danger">Gesperrt</span>
|
||||
) : (
|
||||
<span className="ds-badge ds-badge--success">Aktiv</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="app-mobile-item__meta">
|
||||
<span className="app-mono">{key.prefix}…</span>
|
||||
<span className="app-mono">
|
||||
{key.daily_limit}/Tag · {key.monthly_limit}/Monat
|
||||
</span>
|
||||
</div>
|
||||
{key.revoked_at ? null : (
|
||||
<div className="app-mobile-item__actions">
|
||||
<form action={revokeKey}>
|
||||
<input type="hidden" name="id" value={key.id} />
|
||||
<button
|
||||
className="btn btn-gefahr btn-klein"
|
||||
type="submit"
|
||||
aria-label={`Key ${key.name} endgültig sperren`}
|
||||
>
|
||||
Sperren
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<EmptyState
|
||||
icon={KeyRound}
|
||||
title="Noch keine Keys"
|
||||
text="Erzeuge oben den ersten Key für eine App."
|
||||
action={<Link className="btn btn-sekundaer btn-klein" href="#neu">Key erzeugen</Link>}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="ds-card app-panel app-section" aria-labelledby="verwendung">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="verwendung">Verwendung</h2>
|
||||
</div>
|
||||
<p className="app-muted">
|
||||
Die API ist weitgehend Resend-kompatibel. Das Resend-SDK kann mit einer eigenen{" "}
|
||||
<code className="app-mono">baseUrl</code> auf Courier zeigen.
|
||||
</p>
|
||||
<pre className="app-code">{`curl -X POST https://<courier-adresse>/api/emails/ \\
|
||||
-H "Authorization: Bearer ck_live_…" \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-d '{
|
||||
"from": "plan <plan@hubsport.club>",
|
||||
"to": "kunde@example.com",
|
||||
"subject": "Test",
|
||||
"html": "<p>Hallo</p>"
|
||||
}'`}</pre>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
<section className="karte app-panel app-section" aria-labelledby="verwendung">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="verwendung">Verwendung</h2>
|
||||
</div>
|
||||
<p className="app-muted">
|
||||
Die API ist weitgehend Resend-kompatibel. Das Resend-SDK kann mit einer eigenen{" "}
|
||||
<code className="app-mono">baseUrl</code> auf Courier zeigen.
|
||||
</p>
|
||||
<pre className="app-code">{`curl -X POST https://<courier-adresse>/api/emails/ \\
|
||||
-H "Authorization: Bearer ck_live_…" \\
|
||||
-H "Content-Type: application/json" \\
|
||||
-d '{
|
||||
"from": "plan <plan@hubsport.club>",
|
||||
"to": "kunde@example.com",
|
||||
"subject": "Test",
|
||||
"html": "<p>Hallo</p>"
|
||||
}'`}</pre>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+52
-47
@@ -9,60 +9,65 @@ import { ThemeToggle } from "./theme-toggle";
|
||||
import "./globals.css";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Courier",
|
||||
description: "Transaktionsmail für hubsport.club",
|
||||
robots: { index: false, follow: false },
|
||||
title: "Courier",
|
||||
description: "Transaktionsmail für hubsport.club",
|
||||
robots: { index: false, follow: false },
|
||||
};
|
||||
|
||||
const themeScript = `try {
|
||||
var t = localStorage.getItem('courier-theme');
|
||||
if (!t) t = matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
document.documentElement.dataset.theme = t;
|
||||
var t = localStorage.getItem('courier-theme');
|
||||
if (!t) t = matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
||||
document.documentElement.dataset.theme = t;
|
||||
document.documentElement.classList.toggle('dunkel', t === 'dark');
|
||||
} catch (e) {}`;
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<html lang="de" className={`${GeistSans.variable} ${GeistMono.variable}`} suppressHydrationWarning>
|
||||
<body>
|
||||
<script dangerouslySetInnerHTML={{ __html: themeScript }} />
|
||||
<a className="ds-skip" href="#inhalt">
|
||||
Zum Inhalt
|
||||
</a>
|
||||
return (
|
||||
<html lang="de" data-dichte="weit" className={`${GeistSans.variable} ${GeistMono.variable}`} suppressHydrationWarning>
|
||||
<body>
|
||||
<script dangerouslySetInnerHTML={{ __html: themeScript }} />
|
||||
<a className="ds-skip" href="#inhalt">
|
||||
Zum Inhalt
|
||||
</a>
|
||||
|
||||
<div className="app-shell">
|
||||
<aside className="app-sidebar">
|
||||
<div className="app-sidebar__top">
|
||||
<Link className="app-brand" href="/">
|
||||
<span className="app-brand__mark" aria-hidden="true" />
|
||||
Courier
|
||||
</Link>
|
||||
<AppNav />
|
||||
</div>
|
||||
<div className="app-sidebar__footer">
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</aside>
|
||||
<div className="app-shell">
|
||||
<aside className="app-sidebar">
|
||||
<div className="app-sidebar__top">
|
||||
<Link className="app-brand" href="/">
|
||||
<span className="app-brand__mark" aria-hidden="true" />
|
||||
Courier
|
||||
</Link>
|
||||
<AppNav />
|
||||
</div>
|
||||
<div className="app-sidebar__footer">
|
||||
<div className="app-sidebar__status">
|
||||
<span className="app-sidebar__dot" aria-hidden="true" />
|
||||
Amazon SES
|
||||
</div>
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div className="app-content">
|
||||
<header className="app-mobilebar">
|
||||
<div className="app-mobilebar__row">
|
||||
<Link className="app-brand" href="/">
|
||||
<span className="app-brand__mark" aria-hidden="true" />
|
||||
Courier
|
||||
</Link>
|
||||
<div className="app-mobilebar__actions">
|
||||
<ThemeToggle />
|
||||
<MobileMenu />
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div className="app-content">
|
||||
<header className="app-mobilebar">
|
||||
<div className="app-mobilebar__row">
|
||||
<Link className="app-brand" href="/">
|
||||
<span className="app-brand__mark" aria-hidden="true" />
|
||||
Courier
|
||||
</Link>
|
||||
<div className="app-mobilebar__actions">
|
||||
<ThemeToggle />
|
||||
<MobileMenu />
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main id="inhalt" className="app-main">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
<main id="inhalt" className="app-main">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
+103
-103
@@ -9,113 +9,113 @@ import { messageDetail } from "@/lib/queries";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function Nachricht({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
const detail = await messageDetail(id).catch(() => null);
|
||||
if (!detail) notFound();
|
||||
const { message, events } = detail;
|
||||
const payload = message.payload as { text?: string; html?: string } | null;
|
||||
const content = payload?.text || payload?.html || "";
|
||||
const { id } = await params;
|
||||
const detail = await messageDetail(id).catch(() => null);
|
||||
if (!detail) notFound();
|
||||
const { message, events } = detail;
|
||||
const payload = message.payload as { text?: string; html?: string } | null;
|
||||
const content = payload?.text || payload?.html || "";
|
||||
|
||||
return (
|
||||
<>
|
||||
<nav className="ds-breadcrumb" aria-label="Brotkrümel">
|
||||
<ol>
|
||||
<li>
|
||||
<Link href="/messages">Nachrichten</Link>
|
||||
<span className="ds-breadcrumb__sep" aria-hidden="true">
|
||||
/
|
||||
</span>
|
||||
</li>
|
||||
<li aria-current="page">Details</li>
|
||||
</ol>
|
||||
</nav>
|
||||
return (
|
||||
<>
|
||||
<nav className="ds-breadcrumb" aria-label="Brotkrümel">
|
||||
<ol>
|
||||
<li>
|
||||
<Link href="/messages">Nachrichten</Link>
|
||||
<span className="ds-breadcrumb__sep" aria-hidden="true">
|
||||
/
|
||||
</span>
|
||||
</li>
|
||||
<li aria-current="page">Details</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<div className="app-pagehead app-section">
|
||||
<p className="app-eyebrow">Nachricht</p>
|
||||
<h1>{message.subject}</h1>
|
||||
<div className="app-actions">
|
||||
<StatusBadge status={message.status} />
|
||||
<span className="app-mono app-muted">{message.id}</span>
|
||||
<CopyButton value={message.id} label="ID kopieren" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="app-pagehead app-section">
|
||||
<p className="app-eyebrow">Nachricht</p>
|
||||
<h1>{message.subject}</h1>
|
||||
<div className="app-actions">
|
||||
<StatusBadge status={message.status} />
|
||||
<span className="app-mono app-muted">{message.id}</span>
|
||||
<CopyButton value={message.id} label="ID kopieren" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{message.error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Zustellung fehlgeschlagen</p>
|
||||
<p className="ds-alert__text">{message.error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{message.error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Zustellung fehlgeschlagen</p>
|
||||
<p className="ds-alert__text">{message.error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="app-grid app-grid--sidebar">
|
||||
<section className="ds-card app-panel" aria-labelledby="kopf">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="kopf">Kopf</h2>
|
||||
</div>
|
||||
<dl className="app-dl">
|
||||
<dt>App</dt>
|
||||
<dd>{message.app}</dd>
|
||||
<dt>Von</dt>
|
||||
<dd>
|
||||
{message.from_name ? `${message.from_name} <${message.from_email}>` : message.from_email}
|
||||
</dd>
|
||||
<dt>An</dt>
|
||||
<dd>{message.to_emails.join(", ")}</dd>
|
||||
<dt>CC / BCC</dt>
|
||||
<dd>
|
||||
{message.cc_emails.join(", ") || "–"} / {message.bcc_emails.join(", ") || "–"}
|
||||
</dd>
|
||||
<dt>SES-ID</dt>
|
||||
<dd className="app-mono">{message.provider_message_id || "–"}</dd>
|
||||
<dt>Erstellt</dt>
|
||||
<dd className="app-mono">{datum(message.created_at)}</dd>
|
||||
<dt>Gesendet</dt>
|
||||
<dd className="app-mono">{datum(message.sent_at)}</dd>
|
||||
<dt>Abgeschlossen</dt>
|
||||
<dd className="app-mono">{datum(message.completed_at)}</dd>
|
||||
<dt>Versuche</dt>
|
||||
<dd className="app-mono">{message.attempts}</dd>
|
||||
</dl>
|
||||
<div className="app-grid app-grid--sidebar">
|
||||
<section className="karte app-panel" aria-labelledby="kopf">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="kopf">Kopf</h2>
|
||||
</div>
|
||||
<dl className="app-dl">
|
||||
<dt>App</dt>
|
||||
<dd>{message.app}</dd>
|
||||
<dt>Von</dt>
|
||||
<dd>
|
||||
{message.from_name ? `${message.from_name} <${message.from_email}>` : message.from_email}
|
||||
</dd>
|
||||
<dt>An</dt>
|
||||
<dd>{message.to_emails.join(", ")}</dd>
|
||||
<dt>CC / BCC</dt>
|
||||
<dd>
|
||||
{message.cc_emails.join(", ") || "–"} / {message.bcc_emails.join(", ") || "–"}
|
||||
</dd>
|
||||
<dt>SES-ID</dt>
|
||||
<dd className="app-mono">{message.provider_message_id || "–"}</dd>
|
||||
<dt>Erstellt</dt>
|
||||
<dd className="app-mono">{datum(message.created_at)}</dd>
|
||||
<dt>Gesendet</dt>
|
||||
<dd className="app-mono">{datum(message.sent_at)}</dd>
|
||||
<dt>Abgeschlossen</dt>
|
||||
<dd className="app-mono">{datum(message.completed_at)}</dd>
|
||||
<dt>Versuche</dt>
|
||||
<dd className="app-mono">{message.attempts}</dd>
|
||||
</dl>
|
||||
|
||||
{content ? (
|
||||
<details>
|
||||
<summary>Inhalt anzeigen</summary>
|
||||
<pre className="app-code app-section">{kurz(content, 6000)}</pre>
|
||||
</details>
|
||||
) : null}
|
||||
</section>
|
||||
{content ? (
|
||||
<details>
|
||||
<summary>Inhalt anzeigen</summary>
|
||||
<pre className="app-code app-section">{kurz(content, 6000)}</pre>
|
||||
</details>
|
||||
) : null}
|
||||
</section>
|
||||
|
||||
<section className="ds-card app-panel" aria-labelledby="events">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="events">Ereignisse</h2>
|
||||
</div>
|
||||
{events.length ? (
|
||||
<ol className="app-timeline">
|
||||
{events.map((event) => (
|
||||
<li key={event.id} className="app-timeline__item">
|
||||
<div className="app-timeline__head">
|
||||
<EventBadge type={event.type} />
|
||||
<span className="app-mono app-muted">{datum(event.created_at)}</span>
|
||||
</div>
|
||||
<details>
|
||||
<summary>Rohdaten</summary>
|
||||
<pre className="app-code app-section">{JSON.stringify(event.payload, null, 2)}</pre>
|
||||
</details>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
) : (
|
||||
<div className="ds-empty">
|
||||
<p className="ds-empty__title">Noch keine Zustellereignisse</p>
|
||||
<p className="ds-empty__text">
|
||||
SES meldet Zustellung, Bounce und Beschwerde über SNS zurück.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
<section className="karte app-panel" aria-labelledby="events">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="events">Ereignisse</h2>
|
||||
</div>
|
||||
{events.length ? (
|
||||
<ol className="app-timeline">
|
||||
{events.map((event) => (
|
||||
<li key={event.id} className="app-timeline__item">
|
||||
<div className="app-timeline__head">
|
||||
<EventBadge type={event.type} />
|
||||
<span className="app-mono app-muted">{datum(event.created_at)}</span>
|
||||
</div>
|
||||
<details>
|
||||
<summary>Rohdaten</summary>
|
||||
<pre className="app-code app-section">{JSON.stringify(event.payload, null, 2)}</pre>
|
||||
</details>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
) : (
|
||||
<div className="ds-empty">
|
||||
<p className="ds-empty__title">Noch keine Zustellereignisse</p>
|
||||
<p className="ds-empty__text">
|
||||
SES meldet Zustellung, Bounce und Beschwerde über SNS zurück.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+211
-215
@@ -1,8 +1,9 @@
|
||||
import Link from "next/link";
|
||||
import { Mail } from "lucide-react";
|
||||
import { Mail, Search } from "lucide-react";
|
||||
|
||||
import { EmptyState } from "@/app/empty-state";
|
||||
import { PageHeader } from "@/app/page-header";
|
||||
import { Select } from "@/app/select";
|
||||
import { StatusBadge } from "@/app/status-badge";
|
||||
import { datum, relativ } from "@/lib/format";
|
||||
import { listApiKeys, listMessages } from "@/lib/queries";
|
||||
@@ -10,231 +11,226 @@ import { listApiKeys, listMessages } from "@/lib/queries";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const STATUS = [
|
||||
{ value: "", label: "Alle Status" },
|
||||
{ value: "queued", label: "Warteschlange" },
|
||||
{ value: "sending", label: "Wird gesendet" },
|
||||
{ value: "sent", label: "Gesendet" },
|
||||
{ value: "delivered", label: "Zugestellt" },
|
||||
{ value: "bounced", label: "Bounce" },
|
||||
{ value: "complained", label: "Beschwerde" },
|
||||
{ value: "failed", label: "Fehlgeschlagen" },
|
||||
{ value: "", label: "Alle Status" },
|
||||
{ value: "queued", label: "Warteschlange" },
|
||||
{ value: "sending", label: "Wird gesendet" },
|
||||
{ value: "sent", label: "Gesendet" },
|
||||
{ value: "delivered", label: "Zugestellt" },
|
||||
{ value: "bounced", label: "Bounce" },
|
||||
{ value: "complained", label: "Beschwerde" },
|
||||
{ value: "failed", label: "Fehlgeschlagen" },
|
||||
];
|
||||
|
||||
const DAYS = [
|
||||
{ value: "1", label: "24 Stunden" },
|
||||
{ value: "7", label: "7 Tage" },
|
||||
{ value: "30", label: "30 Tage" },
|
||||
{ value: "0", label: "Alle" },
|
||||
{ value: "1", label: "24 Stunden" },
|
||||
{ value: "7", label: "7 Tage" },
|
||||
{ value: "30", label: "30 Tage" },
|
||||
{ value: "0", label: "Alle" },
|
||||
];
|
||||
|
||||
export default async function Nachrichten({
|
||||
searchParams,
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ q?: string; status?: string; key?: string; days?: string }>;
|
||||
searchParams: Promise<{ q?: string; status?: string; key?: string; days?: string }>;
|
||||
}) {
|
||||
const params = await searchParams;
|
||||
const q = String(params.q ?? "").trim();
|
||||
const status = String(params.status ?? "");
|
||||
const keyId = String(params.key ?? "");
|
||||
const days = Number(params.days ?? 7);
|
||||
const params = await searchParams;
|
||||
const q = String(params.q ?? "").trim();
|
||||
const status = String(params.status ?? "");
|
||||
const keyId = String(params.key ?? "");
|
||||
const days = Number(params.days ?? 7);
|
||||
|
||||
let messages: Awaited<ReturnType<typeof listMessages>> = [];
|
||||
let keys: Awaited<ReturnType<typeof listApiKeys>> = [];
|
||||
let error = "";
|
||||
try {
|
||||
[messages, keys] = await Promise.all([
|
||||
listMessages({ q, status, keyId, days, limit: 100 }),
|
||||
listApiKeys(),
|
||||
]);
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar";
|
||||
}
|
||||
let messages: Awaited<ReturnType<typeof listMessages>> = [];
|
||||
let keys: Awaited<ReturnType<typeof listApiKeys>> = [];
|
||||
let error = "";
|
||||
try {
|
||||
[messages, keys] = await Promise.all([
|
||||
listMessages({ q, status, keyId, days, limit: 100 }),
|
||||
listApiKeys(),
|
||||
]);
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar";
|
||||
}
|
||||
|
||||
const query = new URLSearchParams();
|
||||
if (q) query.set("q", q);
|
||||
if (status) query.set("status", status);
|
||||
if (keyId) query.set("key", keyId);
|
||||
query.set("days", String(days));
|
||||
const exportHref = `/messages/export/${query.size ? `?${query.toString()}` : ""}`;
|
||||
const resetHref = "/messages";
|
||||
const filtered = q || status || keyId || Number(params.days);
|
||||
const query = new URLSearchParams();
|
||||
if (q) query.set("q", q);
|
||||
if (status) query.set("status", status);
|
||||
if (keyId) query.set("key", keyId);
|
||||
query.set("days", String(days));
|
||||
const exportHref = `/messages/export/${query.size ? `?${query.toString()}` : ""}`;
|
||||
const resetHref = "/messages";
|
||||
const filtered = q || status || keyId || Number(params.days);
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Nachrichten"
|
||||
lead="Die letzten 100 Mails, neueste zuerst. Suche und Filter bleiben in der Adresse."
|
||||
actions={
|
||||
<>
|
||||
<Link className="ds-button ds-button--secondary ds-button--sm" href="/suppressions">
|
||||
Suppressions
|
||||
</Link>
|
||||
<Link className="ds-button ds-button--secondary ds-button--sm" href={exportHref}>
|
||||
CSV exportieren
|
||||
</Link>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Nachrichten"
|
||||
lead="Die letzten 100 Mails, neueste zuerst. Suche und Filter bleiben in der Adresse."
|
||||
actions={
|
||||
<>
|
||||
<Link className="btn btn-sekundaer btn-klein" href="/suppressions">
|
||||
Suppressions
|
||||
</Link>
|
||||
<Link className="btn btn-sekundaer btn-klein" href={exportHref}>
|
||||
CSV exportieren
|
||||
</Link>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
<form className="app-toolbar" method="get">
|
||||
<div className="ds-field">
|
||||
<label className="ds-visually-hidden" htmlFor="q">
|
||||
Suche
|
||||
</label>
|
||||
<input
|
||||
className="ds-input"
|
||||
id="q"
|
||||
name="q"
|
||||
defaultValue={q}
|
||||
placeholder="Betreff, Empfänger, ID…"
|
||||
/>
|
||||
</div>
|
||||
<div className="ds-field">
|
||||
<label className="ds-visually-hidden" htmlFor="status">
|
||||
Status
|
||||
</label>
|
||||
<select className="ds-select" id="status" name="status" defaultValue={status}>
|
||||
{STATUS.map((item) => (
|
||||
<option key={item.value || "all"} value={item.value}>
|
||||
{item.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="ds-field">
|
||||
<label className="ds-visually-hidden" htmlFor="key">
|
||||
API-Key
|
||||
</label>
|
||||
<select className="ds-select" id="key" name="key" defaultValue={keyId}>
|
||||
<option value="">Alle API-Keys</option>
|
||||
{keys.map((key) => (
|
||||
<option key={key.id} value={key.id}>
|
||||
{key.app} · {key.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="ds-field">
|
||||
<label className="ds-visually-hidden" htmlFor="days">
|
||||
Zeitraum
|
||||
</label>
|
||||
<select className="ds-select" id="days" name="days" defaultValue={String(days)}>
|
||||
{DAYS.map((item) => (
|
||||
<option key={item.value} value={item.value}>
|
||||
{item.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="app-toolbar__actions">
|
||||
<button className="ds-button" type="submit">
|
||||
Filtern
|
||||
</button>
|
||||
{filtered ? (
|
||||
<Link className="ds-button ds-button--secondary" href={resetHref}>
|
||||
Zurücksetzen
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
</form>
|
||||
<form className="werkzeugleiste" method="get">
|
||||
<div className="suchfeld">
|
||||
<Search aria-hidden="true" size={16} />
|
||||
<label className="ds-visually-hidden" htmlFor="q">
|
||||
Suche
|
||||
</label>
|
||||
<input id="q" name="q" defaultValue={q} placeholder="Betreff, Empfänger, ID…" />
|
||||
</div>
|
||||
<div className="feld">
|
||||
<label className="ds-visually-hidden" htmlFor="status">
|
||||
Status
|
||||
</label>
|
||||
<Select id="status" name="status" defaultValue={status}>
|
||||
{STATUS.map((item) => (
|
||||
<option key={item.value || "all"} value={item.value}>
|
||||
{item.label}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<div className="feld">
|
||||
<label className="ds-visually-hidden" htmlFor="key">
|
||||
API-Key
|
||||
</label>
|
||||
<Select id="key" name="key" defaultValue={keyId}>
|
||||
<option value="">Alle API-Keys</option>
|
||||
{keys.map((key) => (
|
||||
<option key={key.id} value={key.id}>
|
||||
{key.app} · {key.name}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<div className="feld">
|
||||
<label className="ds-visually-hidden" htmlFor="days">
|
||||
Zeitraum
|
||||
</label>
|
||||
<Select id="days" name="days" defaultValue={String(days)}>
|
||||
{DAYS.map((item) => (
|
||||
<option key={item.value} value={item.value}>
|
||||
{item.label}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<div className="app-toolbar__actions">
|
||||
<button className="btn btn-primaer" type="submit">
|
||||
Filtern
|
||||
</button>
|
||||
{filtered ? (
|
||||
<Link className="btn btn-sekundaer" href={resetHref}>
|
||||
Zurücksetzen
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Datenbank nicht erreichbar</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : messages.length ? (
|
||||
<section className="ds-card app-panel">
|
||||
<div className="app-table-scroll app-desktop-table">
|
||||
<table className="ds-table app-table--messages">
|
||||
<caption className="ds-visually-hidden">Gefilterte Nachrichten</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zeit</th>
|
||||
<th className="app-hide-sm">App</th>
|
||||
<th>Empfänger</th>
|
||||
<th>Betreff</th>
|
||||
<th className="app-hide-sm">Versuche</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{messages.map((message) => (
|
||||
<tr key={message.id}>
|
||||
<td className="app-mono app-nowrap">
|
||||
<time dateTime={message.created_at} title={datum(message.created_at)}>
|
||||
{relativ(message.created_at)}
|
||||
</time>
|
||||
</td>
|
||||
<td className="app-hide-sm">{message.app}</td>
|
||||
<td>
|
||||
{message.to_emails[0]}
|
||||
{message.to_emails.length > 1 ? (
|
||||
<span className="app-muted"> +{message.to_emails.length - 1}</span>
|
||||
) : null}
|
||||
</td>
|
||||
<td>
|
||||
<Link href={`/messages/${message.id}`}>
|
||||
<span className="app-ellipsis">{message.subject}</span>
|
||||
</Link>
|
||||
{message.error ? <span className="ds-field__error">{message.error}</span> : null}
|
||||
</td>
|
||||
<td className="app-hide-sm app-mono">{message.attempts}</td>
|
||||
<td>
|
||||
<StatusBadge status={message.status} />
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="app-mobile-list">
|
||||
{messages.map((message) => (
|
||||
<article key={message.id} className="app-mobile-item">
|
||||
<div className="app-mobile-item__top">
|
||||
<Link href={`/messages/${message.id}`}>{message.subject}</Link>
|
||||
<StatusBadge status={message.status} />
|
||||
</div>
|
||||
<div className="app-mobile-item__meta">
|
||||
<span>
|
||||
{message.to_emails[0]}
|
||||
{message.to_emails.length > 1 ? ` +${message.to_emails.length - 1}` : ""}
|
||||
</span>
|
||||
<span className="app-mono" title={datum(message.created_at)}>
|
||||
{relativ(message.created_at)}
|
||||
</span>
|
||||
</div>
|
||||
{message.error ? (
|
||||
<span className="app-mobile-item__error">{message.error}</span>
|
||||
) : null}
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
) : (
|
||||
<EmptyState
|
||||
icon={Mail}
|
||||
title={filtered ? "Keine Treffer" : "Noch keine Nachrichten"}
|
||||
text={
|
||||
filtered
|
||||
? "Kein Eintrag passt zu Suche und Filtern."
|
||||
: "Sobald eine App über die API sendet, erscheint sie hier."
|
||||
}
|
||||
action={
|
||||
filtered ? (
|
||||
<Link className="ds-button ds-button--sm" href="/messages">
|
||||
Filter zurücksetzen
|
||||
</Link>
|
||||
) : (
|
||||
<Link className="ds-button ds-button--sm" href="/docs">
|
||||
API ansehen
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Datenbank nicht erreichbar</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : messages.length ? (
|
||||
<section className="karte app-panel">
|
||||
<div className="rollbar app-desktop-table" tabIndex={0}>
|
||||
<table className="tabelle">
|
||||
<caption className="ds-visually-hidden">Gefilterte Nachrichten</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zeit</th>
|
||||
<th className="app-hide-sm">App</th>
|
||||
<th>Empfänger</th>
|
||||
<th>Betreff</th>
|
||||
<th className="app-hide-sm zahl">Versuche</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{messages.map((message) => (
|
||||
<tr key={message.id}>
|
||||
<td className="app-mono app-nowrap">
|
||||
<time dateTime={message.created_at} title={datum(message.created_at)}>
|
||||
{relativ(message.created_at)}
|
||||
</time>
|
||||
</td>
|
||||
<td className="app-hide-sm">{message.app}</td>
|
||||
<td>
|
||||
{message.to_emails[0]}
|
||||
{message.to_emails.length > 1 ? (
|
||||
<span className="app-muted"> +{message.to_emails.length - 1}</span>
|
||||
) : null}
|
||||
</td>
|
||||
<td className="haupt">
|
||||
<Link className="zeilen-ziel" href={`/messages/${message.id}`}>
|
||||
<span className="app-ellipsis">{message.subject}</span>
|
||||
</Link>
|
||||
{message.error ? <span className="feld-fehlertext">{message.error}</span> : null}
|
||||
</td>
|
||||
<td className="app-hide-sm zahl">{message.attempts}</td>
|
||||
<td>
|
||||
<StatusBadge status={message.status} />
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="app-mobile-list">
|
||||
{messages.map((message) => (
|
||||
<article key={message.id} className="app-mobile-item">
|
||||
<div className="app-mobile-item__top">
|
||||
<Link href={`/messages/${message.id}`}>{message.subject}</Link>
|
||||
<StatusBadge status={message.status} />
|
||||
</div>
|
||||
<div className="app-mobile-item__meta">
|
||||
<span>
|
||||
{message.to_emails[0]}
|
||||
{message.to_emails.length > 1 ? ` +${message.to_emails.length - 1}` : ""}
|
||||
</span>
|
||||
<span className="app-mono" title={datum(message.created_at)}>
|
||||
{relativ(message.created_at)}
|
||||
</span>
|
||||
</div>
|
||||
{message.error ? (
|
||||
<span className="app-mobile-item__error">{message.error}</span>
|
||||
) : null}
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
) : (
|
||||
<EmptyState
|
||||
icon={Mail}
|
||||
title={filtered ? "Keine Treffer" : "Noch keine Nachrichten"}
|
||||
text={
|
||||
filtered
|
||||
? "Kein Eintrag passt zu Suche und Filtern."
|
||||
: "Sobald eine App über die API sendet, erscheint sie hier."
|
||||
}
|
||||
action={
|
||||
filtered ? (
|
||||
<Link className="btn btn-klein" href="/messages">
|
||||
Filter zurücksetzen
|
||||
</Link>
|
||||
) : (
|
||||
<Link className="btn btn-klein" href="/docs">
|
||||
API ansehen
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
import Link from "next/link";
|
||||
import { BarChart3 } from "lucide-react";
|
||||
|
||||
import { EmptyState } from "@/app/empty-state";
|
||||
import { PageHeader } from "@/app/page-header";
|
||||
import { Select } from "@/app/select";
|
||||
import { datum } from "@/lib/format";
|
||||
import { dailyMetrics, listApiKeys } from "@/lib/queries";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const RANGES = [
|
||||
{ value: "7", label: "7 Tage" },
|
||||
{ value: "14", label: "14 Tage" },
|
||||
{ value: "30", label: "30 Tage" },
|
||||
];
|
||||
|
||||
function dayLabel(day: string): string {
|
||||
return new Intl.DateTimeFormat("de-DE", { day: "2-digit", month: "2-digit" }).format(
|
||||
new Date(`${day}T12:00:00`),
|
||||
);
|
||||
}
|
||||
|
||||
function percent(value: number, total: number): string {
|
||||
if (!total) return "–";
|
||||
return `${Math.round((value / total) * 1000) / 10} %`;
|
||||
}
|
||||
|
||||
export default async function Metrics({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ days?: string; key?: string }>;
|
||||
}) {
|
||||
const params = await searchParams;
|
||||
const days = Number(params.days ?? 14);
|
||||
const keyId = String(params.key ?? "");
|
||||
|
||||
let rows: Awaited<ReturnType<typeof dailyMetrics>> = [];
|
||||
let keys: Awaited<ReturnType<typeof listApiKeys>> = [];
|
||||
let error = "";
|
||||
try {
|
||||
[rows, keys] = await Promise.all([dailyMetrics(days, keyId), listApiKeys()]);
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar";
|
||||
}
|
||||
|
||||
const total = rows.reduce((sum, row) => sum + row.total, 0);
|
||||
const delivered = rows.reduce((sum, row) => sum + row.delivered, 0);
|
||||
const bounced = rows.reduce((sum, row) => sum + row.bounced, 0);
|
||||
const complained = rows.reduce((sum, row) => sum + row.complained, 0);
|
||||
const failed = rows.reduce((sum, row) => sum + row.failed, 0);
|
||||
const final = delivered + bounced + complained + failed;
|
||||
|
||||
const W = 760;
|
||||
const H = 220;
|
||||
const padX = 16;
|
||||
const padTop = 16;
|
||||
const padBottom = 28;
|
||||
const max = Math.max(...rows.map((row) => row.total), 1);
|
||||
const x = (index: number) => padX + (index * (W - 2 * padX)) / Math.max(rows.length - 1, 1);
|
||||
const y = (value: number) => H - padBottom - (value / max) * (H - padTop - padBottom);
|
||||
const line = rows.map((row, index) => `${index === 0 ? "M" : "L"}${x(index)},${y(row.total)}`).join(" ");
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Metriken"
|
||||
lead="Volumen, Zustellung und Fehler der letzten Tage. Tageswerte, keine Marketingzahlen."
|
||||
/>
|
||||
|
||||
<form className="app-toolbar app-toolbar--metrics" method="get">
|
||||
<div className="feld">
|
||||
<label className="ds-visually-hidden" htmlFor="days">
|
||||
Zeitraum
|
||||
</label>
|
||||
<Select id="days" name="days" defaultValue={String(days)}>
|
||||
{RANGES.map((range) => (
|
||||
<option key={range.value} value={range.value}>
|
||||
{range.label}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<div className="feld">
|
||||
<label className="ds-visually-hidden" htmlFor="key">
|
||||
API-Key
|
||||
</label>
|
||||
<Select id="key" name="key" defaultValue={keyId}>
|
||||
<option value="">Alle API-Keys</option>
|
||||
{keys.map((key) => (
|
||||
<option key={key.id} value={key.id}>
|
||||
{key.app} · {key.name}
|
||||
</option>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<div className="app-toolbar__actions">
|
||||
<button className="btn btn-primaer" type="submit">
|
||||
Anzeigen
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Datenbank nicht erreichbar</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : total === 0 ? (
|
||||
<EmptyState
|
||||
icon={BarChart3}
|
||||
title="Noch keine Daten"
|
||||
text="Sobald Courier Mails verarbeitet, erscheinen hier Volumen und Zustellraten."
|
||||
action={
|
||||
<Link className="btn btn-klein" href="/docs">
|
||||
API ansehen
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<dl className="kennzahlen app-kennzahlen" aria-label="Kennzahlen">
|
||||
<div className="kennzahl">
|
||||
<dt>Mails</dt>
|
||||
<dd>{total}</dd>
|
||||
<dd className="kennzahl-fuss">{days} Tage</dd>
|
||||
</div>
|
||||
<div className="kennzahl">
|
||||
<dt>Zustellrate</dt>
|
||||
<dd>{percent(delivered, final)}</dd>
|
||||
<dd className="kennzahl-fuss">{delivered} zugestellt</dd>
|
||||
</div>
|
||||
<div className="kennzahl">
|
||||
<dt>Bounce-Rate</dt>
|
||||
<dd>{percent(bounced, final)}</dd>
|
||||
<dd className="kennzahl-fuss">{bounced} Bounces</dd>
|
||||
</div>
|
||||
<div className="kennzahl">
|
||||
<dt>Complaint-Rate</dt>
|
||||
<dd>{percent(complained, final)}</dd>
|
||||
<dd className="kennzahl-fuss">{complained} Beschwerden</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<section className="karte app-panel" aria-labelledby="verlauf">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="verlauf">Verlauf</h2>
|
||||
</div>
|
||||
<div className="app-chart">
|
||||
<svg
|
||||
viewBox={`0 0 ${W} ${H}`}
|
||||
role="img"
|
||||
aria-label={`Tägliches Mailvolumen der letzten ${days} Tage`}
|
||||
>
|
||||
<title>Mailvolumen pro Tag</title>
|
||||
{[0, 0.5, 1].map((fraction) => (
|
||||
<line
|
||||
key={fraction}
|
||||
x1={padX}
|
||||
x2={W - padX}
|
||||
y1={y(max * fraction)}
|
||||
y2={y(max * fraction)}
|
||||
className="app-chart__grid"
|
||||
/>
|
||||
))}
|
||||
<path d={line} className="app-chart__line" />
|
||||
{rows.map((row, index) => (
|
||||
<circle
|
||||
key={row.day}
|
||||
cx={x(index)}
|
||||
cy={y(row.total)}
|
||||
r={3}
|
||||
className="app-chart__dot"
|
||||
>
|
||||
<title>{`${dayLabel(row.day)}: ${row.total}`}</title>
|
||||
</circle>
|
||||
))}
|
||||
</svg>
|
||||
<div className="app-chart__axis">
|
||||
<span>{dayLabel(rows[0]?.day ?? "")}</span>
|
||||
<span>{dayLabel(rows[rows.length - 1]?.day ?? "")}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="rollbar app-desktop-table app-section">
|
||||
<table className="tabelle">
|
||||
<caption className="ds-visually-hidden">Tageswerte</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Tag</th>
|
||||
<th className="zahl">Mails</th>
|
||||
<th className="zahl">Zugestellt</th>
|
||||
<th className="zahl">Bounce</th>
|
||||
<th className="zahl">Beschwerde</th>
|
||||
<th className="zahl">Fehler</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((row) => (
|
||||
<tr key={row.day}>
|
||||
<td>{dayLabel(row.day)}</td>
|
||||
<td className="zahl">{row.total}</td>
|
||||
<td className="zahl">{row.delivered}</td>
|
||||
<td className="zahl">{row.bounced}</td>
|
||||
<td className="zahl">{row.complained}</td>
|
||||
<td className="zahl">{row.failed}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="app-mobile-list">
|
||||
{rows.map((row) => (
|
||||
<article key={row.day} className="app-mobile-item">
|
||||
<div className="app-mobile-item__top">
|
||||
<span>{dayLabel(row.day)}</span>
|
||||
<span className="ds-badge">{row.total} Mails</span>
|
||||
</div>
|
||||
<div className="app-mobile-item__meta">
|
||||
<span>{row.delivered} zugestellt</span>
|
||||
<span>{row.bounced} Bounce</span>
|
||||
<span>{row.complained} Beschwerde</span>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p className="app-muted app-section">
|
||||
Stand: {datum(new Date())}. Zustellrate = zugestellt / (zugestellt + Bounce +
|
||||
Beschwerde + Fehler).
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
+24
-24
@@ -7,30 +7,30 @@ import { Menu } from "lucide-react";
|
||||
import { AppNav } from "./app-nav";
|
||||
|
||||
export function MobileMenu() {
|
||||
const [open, setOpen] = useState(false);
|
||||
const pathname = usePathname();
|
||||
const [open, setOpen] = useState(false);
|
||||
const pathname = usePathname();
|
||||
|
||||
useEffect(() => {
|
||||
setOpen(false);
|
||||
}, [pathname]);
|
||||
useEffect(() => {
|
||||
setOpen(false);
|
||||
}, [pathname]);
|
||||
|
||||
return (
|
||||
<div className="app-mobilemenu">
|
||||
<button
|
||||
type="button"
|
||||
className="app-mobilemenu__toggle"
|
||||
aria-expanded={open}
|
||||
aria-controls="mobile-navigation"
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
>
|
||||
<Menu className="app-nav__icon" aria-hidden="true" />
|
||||
Menü
|
||||
</button>
|
||||
{open ? (
|
||||
<div className="app-mobilemenu__panel" id="mobile-navigation">
|
||||
<AppNav variant="mobile" />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div className="app-mobilemenu">
|
||||
<button
|
||||
type="button"
|
||||
className="app-mobilemenu__toggle"
|
||||
aria-expanded={open}
|
||||
aria-controls="mobile-navigation"
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
>
|
||||
<Menu className="app-nav__icon" aria-hidden="true" />
|
||||
Menü
|
||||
</button>
|
||||
{open ? (
|
||||
<div className="app-mobilemenu__panel" id="mobile-navigation">
|
||||
<AppNav variant="mobile" />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+30
-30
@@ -2,36 +2,36 @@ import Link from "next/link";
|
||||
import { Code2 } from "lucide-react";
|
||||
|
||||
export function PageHeader({
|
||||
eyebrow = "Courier",
|
||||
title,
|
||||
lead,
|
||||
actions,
|
||||
code = true,
|
||||
eyebrow = "Courier",
|
||||
title,
|
||||
lead,
|
||||
actions,
|
||||
code = true,
|
||||
}: {
|
||||
eyebrow?: string;
|
||||
title: string;
|
||||
lead?: string;
|
||||
actions?: React.ReactNode;
|
||||
code?: boolean;
|
||||
eyebrow?: string;
|
||||
title: string;
|
||||
lead?: string;
|
||||
actions?: React.ReactNode;
|
||||
code?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div className="app-pagehead">
|
||||
<div className="app-pagehead__row">
|
||||
<div>
|
||||
<p className="app-eyebrow">{eyebrow}</p>
|
||||
<h1>{title}</h1>
|
||||
{lead ? <p className="app-lead">{lead}</p> : null}
|
||||
</div>
|
||||
<div className="app-pagehead__actions">
|
||||
{actions}
|
||||
{code ? (
|
||||
<Link className="ds-button ds-button--secondary ds-button--sm" href="/docs" aria-label="API-Dokumentation">
|
||||
<Code2 className="app-nav__icon" aria-hidden="true" />
|
||||
API
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div className="app-pagehead">
|
||||
<div className="app-pagehead__row">
|
||||
<div>
|
||||
<p className="app-eyebrow">{eyebrow}</p>
|
||||
<h1>{title}</h1>
|
||||
{lead ? <p className="app-lead">{lead}</p> : null}
|
||||
</div>
|
||||
<div className="app-pagehead__actions">
|
||||
{actions}
|
||||
{code ? (
|
||||
<Link className="btn btn-sekundaer btn-klein" href="/docs" aria-label="API-Dokumentation">
|
||||
<Code2 className="app-nav__icon" aria-hidden="true" />
|
||||
API
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+135
-137
@@ -13,151 +13,149 @@ import { StatusBadge } from "./status-badge";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
function transportLabel() {
|
||||
if (config.transport === "ses") return { label: "Amazon SES", tone: "success" };
|
||||
if (config.transport === "resend") return { label: "Resend", tone: "info" };
|
||||
return { label: "Dry-Run", tone: "warning" };
|
||||
if (config.transport === "ses") return { label: "Amazon SES", tone: "success" };
|
||||
if (config.transport === "resend") return { label: "Resend", tone: "info" };
|
||||
return { label: "Dry-Run", tone: "warning" };
|
||||
}
|
||||
|
||||
export default async function Startseite() {
|
||||
let stats: Awaited<ReturnType<typeof dashboardStats>> | null = null;
|
||||
let error = "";
|
||||
try {
|
||||
stats = await dashboardStats();
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar";
|
||||
}
|
||||
let stats: Awaited<ReturnType<typeof dashboardStats>> | null = null;
|
||||
let error = "";
|
||||
try {
|
||||
stats = await dashboardStats();
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar";
|
||||
}
|
||||
|
||||
const transport = transportLabel();
|
||||
const transport = transportLabel();
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Übersicht"
|
||||
lead="Transaktionsmail für deine Apps: eine API, eine Warteschlange, klare Zustellereignisse."
|
||||
/>
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Übersicht"
|
||||
lead="Transaktionsmail für deine Apps: eine API, eine Warteschlange, klare Zustellereignisse."
|
||||
/>
|
||||
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Datenbank nicht erreichbar</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
<p className="ds-alert__text">
|
||||
Migration ausführen: <code className="app-mono">npm run db:migrate</code>, danach einen Key
|
||||
erzeugen: <code className="app-mono">npm run db:key -- --app plan --name Plan</code>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<section className="app-stats" aria-label="Kennzahlen der letzten 24 Stunden">
|
||||
<article className="ds-card app-stat">
|
||||
<span className="ds-stat__value">{stats?.counts.queued ?? 0}</span>
|
||||
<span className="ds-stat__label">In Warteschlange</span>
|
||||
<span className="ds-stat__meta">werden gleich gesendet</span>
|
||||
</article>
|
||||
<article className="ds-card app-stat">
|
||||
<span className="ds-stat__value">
|
||||
{(stats?.counts.sent ?? 0) + (stats?.counts.delivered ?? 0)}
|
||||
</span>
|
||||
<span className="ds-stat__label">Gesendet / zugestellt</span>
|
||||
<span className="ds-stat__meta">letzte 24 Stunden</span>
|
||||
</article>
|
||||
<article className="ds-card app-stat">
|
||||
<span className="ds-stat__value">
|
||||
{(stats?.counts.failed ?? 0) +
|
||||
(stats?.counts.bounced ?? 0) +
|
||||
(stats?.counts.complained ?? 0)}
|
||||
</span>
|
||||
<span className="ds-stat__label">Fehler</span>
|
||||
<span className="ds-stat__meta">Bounce, Beschwerde, fehlgeschlagen</span>
|
||||
</article>
|
||||
<article className="ds-card app-stat">
|
||||
<span className="ds-stat__value">{stats?.suppressed ?? 0}</span>
|
||||
<span className="ds-stat__label">Gesperrte Empfänger</span>
|
||||
<span className="ds-stat__meta">nach hartem Bounce oder Beschwerde</span>
|
||||
</article>
|
||||
</section>
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Datenbank nicht erreichbar</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
<p className="ds-alert__text">
|
||||
Migration ausführen: <code className="app-mono">npm run db:migrate</code>, danach einen Key
|
||||
erzeugen: <code className="app-mono">npm run db:key -- --app plan --name Plan</code>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<dl className="kennzahlen app-kennzahlen" aria-label="Kennzahlen der letzten 24 Stunden">
|
||||
<div className="kennzahl">
|
||||
<dt>In Warteschlange</dt>
|
||||
<dd>{stats?.counts.queued ?? 0}</dd>
|
||||
<dd className="kennzahl-fuss">werden gleich gesendet</dd>
|
||||
</div>
|
||||
<div className="kennzahl">
|
||||
<dt>Gesendet / zugestellt</dt>
|
||||
<dd>{(stats?.counts.sent ?? 0) + (stats?.counts.delivered ?? 0)}</dd>
|
||||
<dd className="kennzahl-fuss">letzte 24 Stunden</dd>
|
||||
</div>
|
||||
<div className="kennzahl">
|
||||
<dt>Fehler</dt>
|
||||
<dd>
|
||||
{(stats?.counts.failed ?? 0) +
|
||||
(stats?.counts.bounced ?? 0) +
|
||||
(stats?.counts.complained ?? 0)}
|
||||
</dd>
|
||||
<dd className="kennzahl-fuss">Bounce, Beschwerde, fehlgeschlagen</dd>
|
||||
</div>
|
||||
<div className="kennzahl">
|
||||
<dt>Gesperrte Empfänger</dt>
|
||||
<dd>{stats?.suppressed ?? 0}</dd>
|
||||
<dd className="kennzahl-fuss">nach hartem Bounce oder Beschwerde</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<div className="app-grid app-grid--sidebar">
|
||||
<section className="ds-card app-panel" aria-labelledby="letzte-nachrichten">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="letzte-nachrichten">Letzte Nachrichten</h2>
|
||||
<Link className="ds-button ds-button--secondary ds-button--sm" href="/messages">
|
||||
Alle ansehen
|
||||
</Link>
|
||||
</div>
|
||||
{stats?.recent.length ? (
|
||||
<div className="app-message-list">
|
||||
{stats.recent.map((message) => (
|
||||
<Link key={message.id} className="app-message-row" href={`/messages/${message.id}`}>
|
||||
<span className="app-message-row__main">
|
||||
<span className="app-message-row__subject">{message.subject}</span>
|
||||
<span className="app-message-row__meta">
|
||||
<span>
|
||||
{message.to_emails[0]}
|
||||
{message.to_emails.length > 1 ? ` +${message.to_emails.length - 1}` : ""}
|
||||
</span>
|
||||
<span className="app-mono">{datum(message.created_at)}</span>
|
||||
</span>
|
||||
</span>
|
||||
<StatusBadge status={message.status} />
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState
|
||||
icon={Mail}
|
||||
title="Noch keine Nachrichten"
|
||||
text="Sobald eine App über die API sendet, erscheint sie hier."
|
||||
action={<Link className="ds-button ds-button--sm" href="/docs">API ansehen</Link>}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
<div className="app-grid app-grid--sidebar">
|
||||
<section className="karte app-panel" aria-labelledby="letzte-nachrichten">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="letzte-nachrichten">Letzte Nachrichten</h2>
|
||||
<Link className="btn btn-sekundaer btn-klein" href="/messages">
|
||||
Alle ansehen
|
||||
</Link>
|
||||
</div>
|
||||
{stats?.recent.length ? (
|
||||
<div className="app-message-list">
|
||||
{stats.recent.map((message) => (
|
||||
<Link key={message.id} className="app-message-row" href={`/messages/${message.id}`}>
|
||||
<span className="app-message-row__main">
|
||||
<span className="app-message-row__subject">{message.subject}</span>
|
||||
<span className="app-message-row__meta">
|
||||
<span>
|
||||
{message.to_emails[0]}
|
||||
{message.to_emails.length > 1 ? ` +${message.to_emails.length - 1}` : ""}
|
||||
</span>
|
||||
<span className="app-mono">{datum(message.created_at)}</span>
|
||||
</span>
|
||||
</span>
|
||||
<StatusBadge status={message.status} />
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState
|
||||
icon={Mail}
|
||||
title="Noch keine Nachrichten"
|
||||
text="Sobald eine App über die API sendet, erscheint sie hier."
|
||||
action={<Link className="btn btn-klein" href="/docs">API ansehen</Link>}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<aside className="ds-card app-panel" aria-labelledby="system">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="system">System</h2>
|
||||
</div>
|
||||
<dl className="app-dl">
|
||||
<dt>Transport</dt>
|
||||
<dd>
|
||||
<span
|
||||
className={`ds-badge${transport.tone === "success" ? " ds-badge--success" : ` ds-badge--${transport.tone}`}`}
|
||||
>
|
||||
{transport.label}
|
||||
</span>
|
||||
</dd>
|
||||
<dt>Standarddomain</dt>
|
||||
<dd className="app-mono">{config.fromDomain}</dd>
|
||||
<dt>Konfiguration</dt>
|
||||
<dd className="app-mono">{config.sesConfigurationSet}</dd>
|
||||
<dt>Region</dt>
|
||||
<dd className="app-mono">{config.awsRegion}</dd>
|
||||
</dl>
|
||||
<aside className="karte app-panel" aria-labelledby="system">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="system">System</h2>
|
||||
</div>
|
||||
<dl className="app-dl">
|
||||
<dt>Transport</dt>
|
||||
<dd>
|
||||
<span
|
||||
className={`ds-badge${transport.tone === "success" ? " ds-badge--success" : ` ds-badge--${transport.tone}`}`}
|
||||
>
|
||||
{transport.label}
|
||||
</span>
|
||||
</dd>
|
||||
<dt>Standarddomain</dt>
|
||||
<dd className="app-mono">{config.fromDomain}</dd>
|
||||
<dt>Konfiguration</dt>
|
||||
<dd className="app-mono">{config.sesConfigurationSet}</dd>
|
||||
<dt>Region</dt>
|
||||
<dd className="app-mono">{config.awsRegion}</dd>
|
||||
</dl>
|
||||
|
||||
{config.transport === "dry-run" ? (
|
||||
<div className="ds-alert ds-alert--warning">
|
||||
<div>
|
||||
<p className="ds-alert__title">Dry-Run aktiv</p>
|
||||
<p className="ds-alert__text">
|
||||
Mails werden nur protokolliert, nicht an SES übergeben.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{config.transport === "dry-run" ? (
|
||||
<div className="ds-alert ds-alert--warning">
|
||||
<div>
|
||||
<p className="ds-alert__title">Dry-Run aktiv</p>
|
||||
<p className="ds-alert__text">
|
||||
Mails werden nur protokolliert, nicht an SES übergeben.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="app-actions">
|
||||
<Link className="ds-button ds-button--secondary ds-button--sm" href="/keys">
|
||||
API-Keys
|
||||
</Link>
|
||||
<Link className="ds-button ds-button--secondary ds-button--sm" href="/domains">
|
||||
Domains
|
||||
</Link>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
<div className="app-actions">
|
||||
<Link className="btn btn-sekundaer btn-klein" href="/keys">
|
||||
API-Keys
|
||||
</Link>
|
||||
<Link className="btn btn-sekundaer btn-klein" href="/domains">
|
||||
Domains
|
||||
</Link>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
import Link from "next/link";
|
||||
import { Calculator } from "lucide-react";
|
||||
|
||||
import { PageHeader } from "@/app/page-header";
|
||||
import { monthlyVolume } from "@/lib/queries";
|
||||
import { SES_PLANS, estimateMonthly, usd } from "@/lib/pricing";
|
||||
import { sesAccountStatus } from "@/lib/ses-admin";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function Pricing({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ volume?: string }>;
|
||||
}) {
|
||||
const params = await searchParams;
|
||||
const requested = Number(params.volume);
|
||||
const volume = Number.isFinite(requested) && requested > 0 ? Math.floor(requested) : 15000;
|
||||
|
||||
let usage = { month: 0, last30: 0 };
|
||||
let ses = { production: false, max24h: 0, rate: 0 };
|
||||
try {
|
||||
[usage, ses] = await Promise.all([monthlyVolume(), sesAccountStatus()]);
|
||||
} catch {
|
||||
// Die Preisliste funktioniert auch ohne Datenbank.
|
||||
}
|
||||
|
||||
const plans = SES_PLANS.map((plan) => ({ plan, cost: estimateMonthly(plan, volume) })).sort(
|
||||
(a, b) => a.cost - b.cost,
|
||||
);
|
||||
const cheapest = plans[0];
|
||||
const daysInMonth = new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0).getDate();
|
||||
const projected = usage.month
|
||||
? Math.round((usage.month / new Date().getDate()) * daysInMonth)
|
||||
: 0;
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Preise"
|
||||
lead="Was Amazon SES bei deinem Volumen kostet – AWS-Listenpreise, keine Schätzung aus Marketingmaterial."
|
||||
/>
|
||||
|
||||
<dl className="kennzahlen app-kennzahlen" aria-label="Preis-Kennzahlen">
|
||||
<div className="kennzahl">
|
||||
<dt>Mails diesen Monat</dt>
|
||||
<dd>{usage.month}</dd>
|
||||
<dd className="kennzahl-fuss">Hochrechnung: {projected} / Monat</dd>
|
||||
</div>
|
||||
<div className="kennzahl">
|
||||
<dt>Beispielvolumen</dt>
|
||||
<dd>{volume.toLocaleString("de-DE")}</dd>
|
||||
<dd className="kennzahl-fuss">entspricht 500 Mails/Tag</dd>
|
||||
</div>
|
||||
<div className="kennzahl">
|
||||
<dt>Günstigster Plan</dt>
|
||||
<dd>{usd(cheapest.cost)}</dd>
|
||||
<dd className="kennzahl-fuss">{cheapest.plan.name} bei diesem Volumen</dd>
|
||||
</div>
|
||||
<div className="kennzahl">
|
||||
<dt>SES-Status</dt>
|
||||
<dd>{ses.production ? "Production" : "Sandbox"}</dd>
|
||||
<dd className="kennzahl-fuss">
|
||||
{Math.round(ses.max24h)} Mails/Tag · {ses.rate}/s
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<section className="karte app-panel" aria-labelledby="rechner">
|
||||
<div className="app-panel__head">
|
||||
<div>
|
||||
<h2 id="rechner">Kostenrechner</h2>
|
||||
<p className="app-muted">AWS-Listenpreise für eu-west-1, ohne Steuern.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="app-calc">
|
||||
<form className="app-calc__form" method="get">
|
||||
<div className="feld">
|
||||
<label className="ds-field__label" htmlFor="volume">
|
||||
Mails pro Monat
|
||||
</label>
|
||||
<input
|
||||
className="input"
|
||||
id="volume"
|
||||
name="volume"
|
||||
type="number"
|
||||
min={1}
|
||||
step={1000}
|
||||
defaultValue={volume}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="app-toolbar__actions">
|
||||
<button className="btn btn-primaer" type="submit">
|
||||
<Calculator className="app-nav__icon" aria-hidden="true" />
|
||||
Berechnen
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<div className="app-calc__result">
|
||||
<span className="ds-stat__label">Günstigster Plan bei {volume.toLocaleString("de-DE")} Mails</span>
|
||||
<span className="ds-stat__value app-calc__value">{usd(cheapest.cost)}</span>
|
||||
<span className="app-muted">{cheapest.plan.name}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p className="feld-hinweis app-section">Standard: 15.000 (500/Tag).</p>
|
||||
</section>
|
||||
|
||||
<section className="app-plan-grid app-section" aria-label="SES-Preispläne">
|
||||
{plans.map(({ plan, cost }) => (
|
||||
<article className="karte app-plan" key={plan.id}>
|
||||
<div className="app-plan__head">
|
||||
<h2>{plan.name}</h2>
|
||||
{plan.id === cheapest.plan.id ? (
|
||||
<span className="ds-badge ds-badge--success">Günstigster</span>
|
||||
) : null}
|
||||
</div>
|
||||
<span className="ds-stat__value app-plan__cost">{usd(cost)}</span>
|
||||
<span className="app-plan__price">
|
||||
{plan.base ? `${usd(plan.base)}/Monat + ` : "keine Grundgebühr + "}
|
||||
{usd(plan.tiers[0].rate)}/1.000
|
||||
</span>
|
||||
<p className="app-plan__note">{plan.note}</p>
|
||||
<ul className="app-plan__conditions">
|
||||
<li>0–10 Mio.: {usd(plan.tiers[0].rate)}/1.000</li>
|
||||
{plan.tiers[1] ? (
|
||||
<li>10–100 Mio.: {usd(plan.tiers[1].rate)}/1.000</li>
|
||||
) : null}
|
||||
{plan.tiers[2] ? <li>> 100 Mio.: {usd(plan.tiers[2].rate)}/1.000</li> : null}
|
||||
</ul>
|
||||
</article>
|
||||
))}
|
||||
</section>
|
||||
|
||||
<div className="ds-alert app-section">
|
||||
<div>
|
||||
<p className="ds-alert__title">Was in der Schätzung fehlt</p>
|
||||
<p className="ds-alert__text">
|
||||
Steuern, Datenübertragung für Anhänge ($0,12/GB), Dedicated IPs und SNS-Kosten sind
|
||||
nicht enthalten. Neue SES-Konten starten häufig auf <strong>Essentials</strong>; der
|
||||
Wechsel zu À la carte ist möglich. Preisstand: 23.11.2026, Quelle AWS SES Pricing.
|
||||
</p>
|
||||
<p className="ds-alert__text">
|
||||
<a href="https://aws.amazon.com/ses/pricing/" target="_blank" rel="noreferrer">
|
||||
AWS SES Preise öffnen
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { SelectHTMLAttributes } from "react";
|
||||
|
||||
export function Select({ className, children, ...props }: SelectHTMLAttributes<HTMLSelectElement>) {
|
||||
return (
|
||||
<select className={`input${className ? ` ${className}` : ""}`} {...props}>
|
||||
{children}
|
||||
</select>
|
||||
);
|
||||
}
|
||||
+24
-24
@@ -1,35 +1,35 @@
|
||||
const STATUS: Record<string, { label: string; tone: string }> = {
|
||||
queued: { label: "In Warteschlange", tone: "warning" },
|
||||
sending: { label: "Wird gesendet", tone: "info" },
|
||||
sent: { label: "Gesendet", tone: "info" },
|
||||
delivered: { label: "Zugestellt", tone: "success" },
|
||||
bounced: { label: "Bounce", tone: "danger" },
|
||||
complained: { label: "Beschwerde", tone: "danger" },
|
||||
failed: { label: "Fehlgeschlagen", tone: "danger" },
|
||||
queued: { label: "In Warteschlange", tone: "warning" },
|
||||
sending: { label: "Wird gesendet", tone: "info" },
|
||||
sent: { label: "Gesendet", tone: "info" },
|
||||
delivered: { label: "Zugestellt", tone: "success" },
|
||||
bounced: { label: "Bounce", tone: "danger" },
|
||||
complained: { label: "Beschwerde", tone: "danger" },
|
||||
failed: { label: "Fehlgeschlagen", tone: "danger" },
|
||||
};
|
||||
|
||||
const EVENTS: Record<string, { label: string; tone: string }> = {
|
||||
Send: { label: "Angenommen", tone: "info" },
|
||||
Delivery: { label: "Zugestellt", tone: "success" },
|
||||
Bounce: { label: "Bounce", tone: "danger" },
|
||||
Complaint: { label: "Beschwerde", tone: "danger" },
|
||||
Reject: { label: "Abgelehnt", tone: "danger" },
|
||||
Send: { label: "Angenommen", tone: "info" },
|
||||
Delivery: { label: "Zugestellt", tone: "success" },
|
||||
Bounce: { label: "Bounce", tone: "danger" },
|
||||
Complaint: { label: "Beschwerde", tone: "danger" },
|
||||
Reject: { label: "Abgelehnt", tone: "danger" },
|
||||
};
|
||||
|
||||
export function StatusBadge({ status }: { status: string }) {
|
||||
const entry = STATUS[status] ?? { label: status, tone: "neutral" };
|
||||
return (
|
||||
<span className={`ds-badge${entry.tone === "neutral" ? "" : ` ds-badge--${entry.tone}`}`}>
|
||||
{entry.label}
|
||||
</span>
|
||||
);
|
||||
const entry = STATUS[status] ?? { label: status, tone: "neutral" };
|
||||
return (
|
||||
<span className={`ds-badge${entry.tone === "neutral" ? "" : ` ds-badge--${entry.tone}`}`}>
|
||||
{entry.label}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
export function EventBadge({ type }: { type: string }) {
|
||||
const entry = EVENTS[type] ?? { label: type, tone: "neutral" };
|
||||
return (
|
||||
<span className={`ds-badge${entry.tone === "neutral" ? "" : ` ds-badge--${entry.tone}`}`}>
|
||||
{entry.label}
|
||||
</span>
|
||||
);
|
||||
const entry = EVENTS[type] ?? { label: type, tone: "neutral" };
|
||||
return (
|
||||
<span className={`ds-badge${entry.tone === "neutral" ? "" : ` ds-badge--${entry.tone}`}`}>
|
||||
{entry.label}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
+172
-171
@@ -3,6 +3,7 @@ import { Ban } from "lucide-react";
|
||||
|
||||
import { EmptyState } from "@/app/empty-state";
|
||||
import { PageHeader } from "@/app/page-header";
|
||||
import { Select } from "@/app/select";
|
||||
import { datum } from "@/lib/format";
|
||||
import { listSuppressions } from "@/lib/queries";
|
||||
|
||||
@@ -11,185 +12,185 @@ import { addSuppression, removeSuppression } from "./actions";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
const REASONS: Record<string, string> = {
|
||||
hard_bounce: "Harter Bounce",
|
||||
complaint: "Beschwerde",
|
||||
manual: "Manuell",
|
||||
hard_bounce: "Harter Bounce",
|
||||
complaint: "Beschwerde",
|
||||
manual: "Manuell",
|
||||
};
|
||||
|
||||
export default async function Suppressions({
|
||||
searchParams,
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ q?: string; error?: string; ok?: string }>;
|
||||
searchParams: Promise<{ q?: string; error?: string; ok?: string }>;
|
||||
}) {
|
||||
const params = await searchParams;
|
||||
const q = String(params.q ?? "").trim();
|
||||
let rows: Awaited<ReturnType<typeof listSuppressions>> = [];
|
||||
let error = "";
|
||||
try {
|
||||
rows = await listSuppressions(q);
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar";
|
||||
}
|
||||
const params = await searchParams;
|
||||
const q = String(params.q ?? "").trim();
|
||||
let rows: Awaited<ReturnType<typeof listSuppressions>> = [];
|
||||
let error = "";
|
||||
try {
|
||||
rows = await listSuppressions(q);
|
||||
} catch (cause) {
|
||||
error = cause instanceof Error ? cause.message : "Datenbank nicht erreichbar";
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Suppressions"
|
||||
lead="Adressen, an die Courier nicht mehr sendet – nach hartem Bounce, Beschwerde oder manueller Sperre."
|
||||
actions={
|
||||
<Link className="ds-button ds-button--secondary ds-button--sm" href="#neu">
|
||||
Empfänger sperren
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
return (
|
||||
<>
|
||||
<PageHeader
|
||||
title="Suppressions"
|
||||
lead="Adressen, an die Courier nicht mehr sendet – nach hartem Bounce, Beschwerde oder manueller Sperre."
|
||||
actions={
|
||||
<Link className="btn btn-sekundaer btn-klein" href="#neu">
|
||||
Empfänger sperren
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
|
||||
{params.error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Nicht gespeichert</p>
|
||||
<p className="ds-alert__text">{params.error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{params.ok ? (
|
||||
<div className="ds-alert ds-alert--success" role="status">
|
||||
<div>
|
||||
<p className="ds-alert__title">Gespeichert</p>
|
||||
<p className="ds-alert__text">{params.ok}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{params.error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Nicht gespeichert</p>
|
||||
<p className="ds-alert__text">{params.error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{params.ok ? (
|
||||
<div className="ds-alert ds-alert--success" role="status">
|
||||
<div>
|
||||
<p className="ds-alert__title">Gespeichert</p>
|
||||
<p className="ds-alert__text">{params.ok}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<form className="app-toolbar" method="get" style={{ gridTemplateColumns: "minmax(12rem, 1fr) auto" }}>
|
||||
<div className="ds-field">
|
||||
<label className="ds-visually-hidden" htmlFor="q">
|
||||
Suche
|
||||
</label>
|
||||
<input
|
||||
className="ds-input"
|
||||
id="q"
|
||||
name="q"
|
||||
defaultValue={q}
|
||||
placeholder="E-Mail oder Grund…"
|
||||
/>
|
||||
</div>
|
||||
<div className="app-toolbar__actions">
|
||||
<button className="ds-button ds-button--secondary" type="submit">
|
||||
Suchen
|
||||
</button>
|
||||
{q ? (
|
||||
<Link className="ds-button ds-button--secondary" href="/suppressions">
|
||||
Zurücksetzen
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
</form>
|
||||
<form className="app-toolbar app-toolbar--compact" method="get">
|
||||
<div className="feld">
|
||||
<label className="ds-visually-hidden" htmlFor="q">
|
||||
Suche
|
||||
</label>
|
||||
<input
|
||||
className="input"
|
||||
id="q"
|
||||
name="q"
|
||||
defaultValue={q}
|
||||
placeholder="E-Mail oder Grund…"
|
||||
/>
|
||||
</div>
|
||||
<div className="app-toolbar__actions">
|
||||
<button className="btn btn-sekundaer" type="submit">
|
||||
Suchen
|
||||
</button>
|
||||
{q ? (
|
||||
<Link className="btn btn-sekundaer" href="/suppressions">
|
||||
Zurücksetzen
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Datenbank nicht erreichbar</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : rows.length ? (
|
||||
<section className="ds-card app-panel">
|
||||
<div className="app-table-scroll app-desktop-table">
|
||||
<table className="ds-table">
|
||||
<caption className="ds-visually-hidden">Gesperrte Empfänger</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>E-Mail</th>
|
||||
<th>Grund</th>
|
||||
<th>Seit</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((row) => (
|
||||
<tr key={row.email}>
|
||||
<td>{row.email}</td>
|
||||
<td>
|
||||
<span className="ds-badge ds-badge--danger">
|
||||
{REASONS[row.reason] ?? row.reason}
|
||||
</span>
|
||||
</td>
|
||||
<td className="app-mono">{datum(row.created_at)}</td>
|
||||
<td>
|
||||
<form action={removeSuppression}>
|
||||
<input type="hidden" name="email" value={row.email} />
|
||||
<button className="ds-button ds-button--secondary ds-button--sm" type="submit">
|
||||
Entsperren
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="app-mobile-list">
|
||||
{rows.map((row) => (
|
||||
<article key={row.email} className="app-mobile-item">
|
||||
<div className="app-mobile-item__top">
|
||||
<span>{row.email}</span>
|
||||
<span className="ds-badge ds-badge--danger">
|
||||
{REASONS[row.reason] ?? row.reason}
|
||||
</span>
|
||||
</div>
|
||||
<div className="app-mobile-item__meta">
|
||||
<span className="app-mono">{datum(row.created_at)}</span>
|
||||
<form action={removeSuppression}>
|
||||
<input type="hidden" name="email" value={row.email} />
|
||||
<button className="ds-button ds-button--secondary ds-button--sm" type="submit">
|
||||
Entsperren
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
) : (
|
||||
<EmptyState
|
||||
icon={Ban}
|
||||
title={q ? "Keine Treffer" : "Keine gesperrten Empfänger"}
|
||||
text={
|
||||
q
|
||||
? "Keine Adresse passt zur Suche."
|
||||
: "Harte Bounces und Beschwerden landen automatisch hier."
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{error ? (
|
||||
<div className="ds-alert ds-alert--danger" role="alert">
|
||||
<div>
|
||||
<p className="ds-alert__title">Datenbank nicht erreichbar</p>
|
||||
<p className="ds-alert__text">{error}</p>
|
||||
</div>
|
||||
</div>
|
||||
) : rows.length ? (
|
||||
<section className="karte app-panel">
|
||||
<div className="rollbar app-desktop-table">
|
||||
<table className="tabelle">
|
||||
<caption className="ds-visually-hidden">Gesperrte Empfänger</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>E-Mail</th>
|
||||
<th>Grund</th>
|
||||
<th>Seit</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((row) => (
|
||||
<tr key={row.email}>
|
||||
<td>{row.email}</td>
|
||||
<td>
|
||||
<span className="ds-badge ds-badge--danger">
|
||||
{REASONS[row.reason] ?? row.reason}
|
||||
</span>
|
||||
</td>
|
||||
<td className="app-mono">{datum(row.created_at)}</td>
|
||||
<td>
|
||||
<form action={removeSuppression}>
|
||||
<input type="hidden" name="email" value={row.email} />
|
||||
<button className="btn btn-sekundaer btn-klein" type="submit">
|
||||
Entsperren
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="app-mobile-list">
|
||||
{rows.map((row) => (
|
||||
<article key={row.email} className="app-mobile-item">
|
||||
<div className="app-mobile-item__top">
|
||||
<span>{row.email}</span>
|
||||
<span className="ds-badge ds-badge--danger">
|
||||
{REASONS[row.reason] ?? row.reason}
|
||||
</span>
|
||||
</div>
|
||||
<div className="app-mobile-item__meta">
|
||||
<span className="app-mono">{datum(row.created_at)}</span>
|
||||
<form action={removeSuppression}>
|
||||
<input type="hidden" name="email" value={row.email} />
|
||||
<button className="btn btn-sekundaer btn-klein" type="submit">
|
||||
Entsperren
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
) : (
|
||||
<EmptyState
|
||||
icon={Ban}
|
||||
title={q ? "Keine Treffer" : "Keine gesperrten Empfänger"}
|
||||
text={
|
||||
q
|
||||
? "Keine Adresse passt zur Suche."
|
||||
: "Harte Bounces und Beschwerden landen automatisch hier."
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<section className="ds-card app-panel app-section" id="neu" aria-labelledby="neu-titel">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="neu-titel">Empfänger manuell sperren</h2>
|
||||
</div>
|
||||
<form action={addSuppression} className="ds-stack app-form">
|
||||
<div className="ds-field">
|
||||
<label className="ds-field__label" htmlFor="email">
|
||||
E-Mail-Adresse
|
||||
</label>
|
||||
<input className="ds-input" id="email" name="email" type="email" required autoComplete="off" />
|
||||
</div>
|
||||
<div className="ds-field">
|
||||
<label className="ds-field__label" htmlFor="reason">
|
||||
Grund
|
||||
</label>
|
||||
<select className="ds-select" id="reason" name="reason" defaultValue="manual">
|
||||
<option value="manual">Manuell</option>
|
||||
<option value="hard_bounce">Harter Bounce</option>
|
||||
<option value="complaint">Beschwerde</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="app-actions">
|
||||
<button className="ds-button" type="submit">
|
||||
Sperren
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
<section className="karte app-panel app-section" id="neu" aria-labelledby="neu-titel">
|
||||
<div className="app-panel__head">
|
||||
<h2 id="neu-titel">Empfänger manuell sperren</h2>
|
||||
</div>
|
||||
<form action={addSuppression} className="ds-stack app-form">
|
||||
<div className="feld">
|
||||
<label className="ds-field__label" htmlFor="email">
|
||||
E-Mail-Adresse
|
||||
</label>
|
||||
<input className="input" id="email" name="email" type="email" required autoComplete="off" />
|
||||
</div>
|
||||
<div className="feld">
|
||||
<label className="ds-field__label" htmlFor="reason">
|
||||
Grund
|
||||
</label>
|
||||
<Select id="reason" name="reason" defaultValue="manual">
|
||||
<option value="manual">Manuell</option>
|
||||
<option value="hard_bounce">Harter Bounce</option>
|
||||
<option value="complaint">Beschwerde</option>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="app-actions">
|
||||
<button className="btn btn-primaer" type="submit">
|
||||
Sperren
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+31
-30
@@ -3,37 +3,38 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function ThemeToggle() {
|
||||
const [dark, setDark] = useState(false);
|
||||
const [dark, setDark] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const read = () => setDark(document.documentElement.dataset.theme === "dark");
|
||||
read();
|
||||
const onChange = () => read();
|
||||
window.addEventListener("courier-theme", onChange);
|
||||
return () => window.removeEventListener("courier-theme", onChange);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
const read = () => setDark(document.documentElement.dataset.theme === "dark");
|
||||
read();
|
||||
const onChange = () => read();
|
||||
window.addEventListener("courier-theme", onChange);
|
||||
return () => window.removeEventListener("courier-theme", onChange);
|
||||
}, []);
|
||||
|
||||
function toggle() {
|
||||
const next = dark ? "light" : "dark";
|
||||
document.documentElement.dataset.theme = next;
|
||||
try {
|
||||
localStorage.setItem("courier-theme", next);
|
||||
} catch {
|
||||
// Privater Modus: die Wahl gilt nur für diese Sitzung.
|
||||
}
|
||||
setDark(!dark);
|
||||
window.dispatchEvent(new Event("courier-theme"));
|
||||
}
|
||||
function toggle() {
|
||||
const next = dark ? "light" : "dark";
|
||||
document.documentElement.dataset.theme = next;
|
||||
document.documentElement.classList.toggle("dunkel", next === "dark");
|
||||
try {
|
||||
localStorage.setItem("courier-theme", next);
|
||||
} catch {
|
||||
// Privater Modus: die Wahl gilt nur für diese Sitzung.
|
||||
}
|
||||
setDark(!dark);
|
||||
window.dispatchEvent(new Event("courier-theme"));
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="app-theme-toggle"
|
||||
onClick={toggle}
|
||||
aria-pressed={dark}
|
||||
aria-label={dark ? "Hellen Modus einschalten" : "Dunklen Modus einschalten"}
|
||||
>
|
||||
{dark ? "Hell" : "Dunkel"}
|
||||
</button>
|
||||
);
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="app-theme-toggle"
|
||||
onClick={toggle}
|
||||
aria-pressed={dark}
|
||||
aria-label={dark ? "Hellen Modus einschalten" : "Dunklen Modus einschalten"}
|
||||
>
|
||||
{dark ? "Hell" : "Dunkel"}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
export type SesPlan = {
|
||||
id: string;
|
||||
name: string;
|
||||
base: number;
|
||||
tiers: { upTo: number | null; rate: number }[];
|
||||
note: string;
|
||||
};
|
||||
|
||||
export const SES_PLANS: SesPlan[] = [
|
||||
{
|
||||
id: "a-la-carte",
|
||||
name: "À la carte",
|
||||
base: 0,
|
||||
tiers: [{ upTo: null, rate: 0.1 }],
|
||||
note: "Pay-as-you-go, keine Grundgebühr.",
|
||||
},
|
||||
{
|
||||
id: "essentials",
|
||||
name: "Essentials",
|
||||
base: 0,
|
||||
tiers: [
|
||||
{ upTo: 10_000_000, rate: 0.16 },
|
||||
{ upTo: 100_000_000, rate: 0.14 },
|
||||
{ upTo: null, rate: 0.11 },
|
||||
],
|
||||
note: "Standard für neue SES-Konten, ohne Grundgebühr.",
|
||||
},
|
||||
{
|
||||
id: "pro",
|
||||
name: "Pro",
|
||||
base: 105,
|
||||
tiers: [
|
||||
{ upTo: 10_000_000, rate: 0.22 },
|
||||
{ upTo: 100_000_000, rate: 0.17 },
|
||||
{ upTo: null, rate: 0.12 },
|
||||
],
|
||||
note: "Mit Dedicated IPs und erweiterten Deliverability-Funktionen.",
|
||||
},
|
||||
{
|
||||
id: "enterprise",
|
||||
name: "Enterprise",
|
||||
base: 500,
|
||||
tiers: [
|
||||
{ upTo: 10_000_000, rate: 0.23 },
|
||||
{ upTo: 100_000_000, rate: 0.18 },
|
||||
{ upTo: null, rate: 0.13 },
|
||||
],
|
||||
note: "Mehrere Domains, viele Dedicated IPs und Seedlist-Tests.",
|
||||
},
|
||||
];
|
||||
|
||||
export function estimateMonthly(plan: SesPlan, volume: number): number {
|
||||
let remaining = Math.max(0, Math.floor(volume));
|
||||
let last = 0;
|
||||
let cost = plan.base;
|
||||
for (const tier of plan.tiers) {
|
||||
const limit = tier.upTo === null ? remaining : Math.min(remaining, tier.upTo - last);
|
||||
if (limit <= 0) break;
|
||||
cost += (limit / 1000) * tier.rate;
|
||||
remaining -= limit;
|
||||
last = tier.upTo ?? last;
|
||||
if (remaining <= 0) break;
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
export function usd(value: number): string {
|
||||
return new Intl.NumberFormat("de-DE", {
|
||||
style: "currency",
|
||||
currency: "USD",
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2,
|
||||
}).format(value);
|
||||
}
|
||||
@@ -145,3 +145,46 @@ export async function listSuppressions(q?: string, limit = 200) {
|
||||
return rows;
|
||||
}
|
||||
|
||||
|
||||
export type DailyMetric = {
|
||||
day: string;
|
||||
total: number;
|
||||
delivered: number;
|
||||
bounced: number;
|
||||
complained: number;
|
||||
failed: number;
|
||||
};
|
||||
|
||||
export async function dailyMetrics(days = 14, keyId = ""): Promise<DailyMetric[]> {
|
||||
const span = Math.min(Math.max(days, 1), 90);
|
||||
const { rows } = await query<DailyMetric>(
|
||||
`with days as (
|
||||
select generate_series(current_date - ($1::int - 1), current_date, interval '1 day')::date as day
|
||||
)
|
||||
select to_char(d.day, 'YYYY-MM-DD') as day,
|
||||
count(m.id)::int as total,
|
||||
count(m.id) filter (where m.status = 'delivered')::int as delivered,
|
||||
count(m.id) filter (where m.status = 'bounced')::int as bounced,
|
||||
count(m.id) filter (where m.status = 'complained')::int as complained,
|
||||
count(m.id) filter (where m.status = 'failed')::int as failed
|
||||
from days d
|
||||
left join messages m
|
||||
on m.created_at >= d.day
|
||||
and m.created_at < d.day + interval '1 day'
|
||||
and ($2::uuid is null or m.api_key_id = $2)
|
||||
group by d.day
|
||||
order by d.day`,
|
||||
[span, keyId || null],
|
||||
);
|
||||
return rows;
|
||||
}
|
||||
|
||||
export async function monthlyVolume(): Promise<{ month: number; last30: number }> {
|
||||
const { rows } = await query<{ month: number; last30: number }>(
|
||||
`select
|
||||
count(*) filter (where created_at >= date_trunc('month', now()))::int as month,
|
||||
count(*) filter (where created_at >= now() - interval '30 days')::int as last30
|
||||
from messages`,
|
||||
);
|
||||
return rows[0] ?? { month: 0, last30: 0 };
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@ apiVersion: v2
|
||||
name: courier
|
||||
description: Transaktionsmail-Gateway für hubsport.club über Amazon SES.
|
||||
type: application
|
||||
version: 26.11.6
|
||||
appVersion: "26.11.6"
|
||||
version: 26.11.18
|
||||
appVersion: "26.11.18"
|
||||
icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png
|
||||
home: https://git.aimighty.olares.de/aimighty/courier
|
||||
@@ -12,7 +12,7 @@ metadata:
|
||||
title: Courier
|
||||
description: Transaktionsmail für deine Apps über Amazon SES.
|
||||
icon: https://git.aimighty.olares.de/aimighty/courier/raw/branch/main/icon.png
|
||||
version: 26.11.6
|
||||
version: 26.11.18
|
||||
categories:
|
||||
- Applications
|
||||
|
||||
@@ -106,7 +106,7 @@ envs:
|
||||
default: "1000"
|
||||
|
||||
spec:
|
||||
versionName: '26.11.6'
|
||||
versionName: '26.11.18'
|
||||
fullDescription: |
|
||||
**Courier** ist ein kleiner Versanddienst für transaktionale E-Mails:
|
||||
eine Resend-kompatible HTTP-API, Warteschlange, Retry, Logs und
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "courier",
|
||||
"version": "26.11.6",
|
||||
"version": "26.11.18",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -H 0.0.0.0 -p 3400",
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"source": "aimighty/aimighty-ci",
|
||||
"stand": "ci-26.11.6",
|
||||
"commit": "8bdd77cc5642af40ca5e7ab80517a2e16b1a27c7",
|
||||
"note": "Phase 1: tokens/app.css ist in app/globals.css eingebettet; HB-Bausteine folgen in Phase 2."
|
||||
}
|
||||
Reference in new issue
Block a user