Initial commit: page-manager Next.js app with Coolify deploy support
Replace Vercel-specific infra (Cron, Blob) with self-hosted equivalents for deployment to Coolify: in-container cron scheduler (scripts/cron-runner.mjs) and disk-based upload storage served via /api/uploads/[...path]. Add Dockerfile, .dockerignore, and /api/health for container health checks. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import { notFound } from "next/navigation";
|
||||
import { prisma } from "@/lib/db";
|
||||
import { getConsoleContext } from "@/lib/console";
|
||||
import { REQUIRED_APPROVALS } from "@/lib/posts/workflow";
|
||||
import { PostEditor } from "@/components/PostEditor";
|
||||
import { PageTitle } from "@/components/ui";
|
||||
|
||||
export default async function PostPage(props: PageProps<"/posts/[id]">) {
|
||||
const { id } = await props.params;
|
||||
const ctx = await getConsoleContext();
|
||||
const post = await prisma.post.findUnique({ where: { id } });
|
||||
const page = post && ctx.pages.find((p) => p.id === post.pageId);
|
||||
if (!post || !page) notFound();
|
||||
|
||||
const [approvalsCount, log] = await Promise.all([
|
||||
prisma.postApproval.count({ where: { postId: id } }),
|
||||
prisma.auditLog.findMany({ where: { postId: id }, orderBy: { createdAt: "desc" }, take: 30 }),
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageTitle title={post.title} subtitle={page.name} />
|
||||
<PostEditor
|
||||
// Remount on every server update so local form state matches the saved post.
|
||||
key={post.updatedAt.toISOString()}
|
||||
pages={[{ id: page.id, name: page.name, pictureUrl: page.pictureUrl, igUsername: page.igUsername, role: page.role }]}
|
||||
post={{
|
||||
id: post.id,
|
||||
pageId: post.pageId,
|
||||
title: post.title,
|
||||
caption: post.caption,
|
||||
imageBlobUrl: post.imageBlobUrl,
|
||||
targets: post.targets,
|
||||
status: post.status,
|
||||
scheduledPublishAt: post.scheduledPublishAt?.toISOString() ?? null,
|
||||
fbPermalink: post.fbPermalink,
|
||||
igPermalink: post.igPermalink,
|
||||
lastError: post.lastError,
|
||||
lastEditedById: post.lastEditedById,
|
||||
createdById: post.createdById,
|
||||
aiAssisted: post.aiAssisted,
|
||||
}}
|
||||
log={log.map((l) => ({
|
||||
id: l.id,
|
||||
action: l.action,
|
||||
actorLabel: l.actorLabel,
|
||||
createdAt: l.createdAt.toISOString(),
|
||||
note: (l.detail as { note?: string } | null)?.note ?? null,
|
||||
}))}
|
||||
approvalsCount={approvalsCount}
|
||||
requiredApprovals={REQUIRED_APPROVALS}
|
||||
currentUserId={ctx.user.id}
|
||||
superadmin={ctx.user.globalRole === "SUPERADMIN"}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user