Adjusted SMTP
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user