Add self-service teams and assigned post approvals

This commit is contained in:
Loma Bot Ops
2026-11-24 11:13:20 +07:00
parent b14a9286cd
commit 55235718c3
31 changed files with 958 additions and 28 deletions
+4 -3
View File
@@ -19,11 +19,12 @@ export async function GET(_req: Request, ctx: RouteContext<"/api/posts/[id]">) {
const auth = await requirePageAction(post.pageId, "view");
if (!auth.ok) return auth.response;
const [approvals, log] = await Promise.all([
const [approvals, log, approvalRequest] = await Promise.all([
prisma.postApproval.findMany({ where: { postId: id }, orderBy: { createdAt: "asc" } }),
prisma.auditLog.findMany({ where: { postId: id }, orderBy: { createdAt: "desc" }, take: 50 }),
prisma.approvalRequest.findUnique({ where: { postId: id }, select: { status: true, requesterId: true, assigneeId: true, assignee: { select: { name: true } }, createdAt: true, decidedAt: true } }),
]);
return NextResponse.json({ post, approvals, log, role: auth.role });
return NextResponse.json({ post, approvals, approvalRequest, log, role: auth.role });
}
export async function PATCH(req: Request, ctx: RouteContext<"/api/posts/[id]">) {
@@ -82,7 +83,7 @@ export async function POST(req: Request, ctx: RouteContext<"/api/posts/[id]">) {
updated = await planPost(post, auth.user, body.plannedAt ? new Date(str(body.plannedAt)) : null);
break;
case "submit":
updated = await submitForApproval(post, auth.user);
updated = await submitForApproval(post, auth.user, str(body.assigneeId));
break;
case "approve":
updated = await approvePost(post, auth.user, note);