Add self-service teams and assigned post approvals
This commit is contained in:
@@ -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"}
|
||||
|
||||
Reference in New Issue
Block a user