Adjusted SMTP

This commit is contained in:
2026-04-11 12:21:34 +02:00
parent 9a96d74f5c
commit 97b483c121
9 changed files with 339 additions and 24 deletions

View File

@@ -2,11 +2,12 @@ import { NextResponse } from "next/server";
import { requirePlatformRole } from "@/lib/session";
import { getTenantRequestById, updateTenantRequestStatus } from "@/lib/db";
import { createTenant } from "@/lib/k8s";
import { sendApprovalEmail } from "@/lib/email";
/**
* POST /api/admin/requests/[id]/approve
* Approve a tenant request: create the PiecedTenant CR and update status.
* Also supports re-approving a previously rejected request.
* Approve a tenant request: create the PiecedTenant CR, update status, notify customer.
* Also supports re-approving a previously rejected request (clears admin notes).
*/
export async function POST(
request: Request,
@@ -37,6 +38,8 @@ export async function POST(
);
}
const isReApproval = tenantRequest.status === "rejected";
// Derive tenant name from company name: lowercase, alphanumeric + hyphens
const tenantName = tenantRequest.companyName
.toLowerCase()
@@ -61,12 +64,20 @@ export async function POST(
}
);
// Update request status
// Update request status — clear admin notes on re-approval
const updated = await updateTenantRequestStatus(id, "provisioning", {
adminNotes,
adminNotes: isReApproval ? null : adminNotes,
tenantName,
clearAdminNotes: isReApproval,
});
// Notify customer
await sendApprovalEmail(
tenantRequest.contactEmail,
tenantRequest.contactName,
tenantRequest.companyName
);
return NextResponse.json({
message: "Tenant approved and provisioning started.",
request: updated,

View File

@@ -1,10 +1,11 @@
import { NextResponse } from "next/server";
import { requirePlatformRole } from "@/lib/session";
import { getTenantRequestById, updateTenantRequestStatus } from "@/lib/db";
import { sendRejectionEmail } from "@/lib/email";
/**
* POST /api/admin/requests/[id]/reject
* Reject a tenant request.
* Reject a tenant request and notify the customer.
*/
export async function POST(
request: Request,
@@ -36,6 +37,14 @@ export async function POST(
adminNotes,
});
// Notify customer
await sendRejectionEmail(
tenantRequest.contactEmail,
tenantRequest.contactName,
tenantRequest.companyName,
adminNotes
);
return NextResponse.json({
message: "Request rejected.",
request: updated,