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:
@@ -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 });
|
||||
});
|
||||
Reference in New Issue
Block a user