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
+6 -1
View File
@@ -2,6 +2,7 @@ import { notFound } from "next/navigation";
import { prisma } from "@/lib/db";
import { getConsoleContext } from "@/lib/console";
import { REQUIRED_APPROVALS } from "@/lib/posts/workflow";
import { approversForPages } from "@/lib/posts/approvers";
import { PostEditor } from "@/components/PostEditor";
import { PageTitle } from "@/components/ui";
@@ -12,9 +13,11 @@ export default async function PostPage(props: PageProps<"/posts/[id]">) {
const page = post && ctx.pages.find((p) => p.id === post.pageId);
if (!post || !page) notFound();
const [approvalsCount, log] = await Promise.all([
const [approvalsCount, log, approvalRequest, approvers] = await Promise.all([
prisma.postApproval.count({ where: { postId: id } }),
prisma.auditLog.findMany({ where: { postId: id }, orderBy: { createdAt: "desc" }, take: 30 }),
prisma.approvalRequest.findUnique({ where: { postId: id }, select: { assigneeId: true, requesterId: true, status: true, assignee: { select: { name: true } } } }),
approversForPages([post.pageId]),
]);
return (
@@ -48,6 +51,8 @@ export default async function PostPage(props: PageProps<"/posts/[id]">) {
note: (l.detail as { note?: string } | null)?.note ?? null,
}))}
approvalsCount={approvalsCount}
approvers={approvers}
approvalRequest={approvalRequest}
requiredApprovals={REQUIRED_APPROVALS}
currentUserId={ctx.user.id}
superadmin={ctx.user.globalRole === "SUPERADMIN"}