L11 Kundenversand: Bericht-PDF an Kunden senden (Service, Action, API, Berichtsseite)

- sendReportToCustomer: report:approve, Scope, nur approved mit PDF, Empfänger
  Ansprechpartner -> Kunde, Dedupe je Adresse+Version, Audit export
- Server Action + POST /api/v1/reports/{id}/send inkl. OpenAPI-Eintrag
- /reports/[id]: Abschnitt „An Kunden senden" mit bisherigen Versänden, Texte de/en

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-14 18:48:57 +02:00
co-authored by Claude Opus 5
parent e0106b8f8e
commit 29c80a0e73
9 changed files with 413 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
import { requireApiContext } from "@/server/api/context";
import { json, readJsonObject, withApi } from "@/server/api/respond";
import { sendReportToCustomer } from "@/server/services/reports/send-to-customer";
/**
* POST /api/v1/reports/:id/send — e-mail the approved report PDF to the customer (L11).
* Body (optional): { to?: string, message?: string }. 202 queued, 200 sent/duplicate/failed.
*/
export const POST = withApi(async (req: Request, { params }: { params: Promise<{ id: string }> }) => {
const ctx = await requireApiContext("reports", "report:approve");
const { id } = await params;
const body = await readJsonObject(req, { allowEmpty: true });
const res = await sendReportToCustomer(ctx, { reportId: id, to: body.to, message: body.message });
return json(res, { status: res.status === "queued" ? 202 : 200 });
});