feat: pages list

This commit is contained in:
Ivan Rezchikov
2026-07-13 19:31:55 +03:00
parent 22122aedeb
commit 2e356e4c47
2 changed files with 47 additions and 6 deletions
+14 -6
View File
@@ -220,7 +220,7 @@ export default async function Page({ params }: { params: Promise<{ type: string;
if (!PAGE_TYPES.includes(pageType)) notFound();
const page = await getPageBySlug(slug, pageType);
if (!page || (!user?.isAdmin && page.status == "ARCHIVED")) notFound();
if (!page || (!user?.isAdmin && (page.status === "ARCHIVED" || page.status === "DRAFT"))) notFound();
const navlink = await getNavLinkByPageId(page.id);
@@ -233,7 +233,8 @@ export default async function Page({ params }: { params: Promise<{ type: string;
const isNews = page.type === "NEWS";
const isArchived = page.status === "ARCHIVED";
const wasUpdated = formatDate(page.publishedAt) !== formatDate(page.updatedAt);
const isDraft = page.status === "DRAFT";
const wasUpdated = page.updatedAt !== page.publishedAt;
const location = (page.meta as PageMeta)?.location;
const wasUpdatedByOther = page.updatedBy && page.createdBy !== page.updatedBy;
@@ -241,8 +242,15 @@ export default async function Page({ params }: { params: Promise<{ type: string;
publishedAt: isNews ? formatDate(page.publishedAt) : null,
updatedAt: (wasUpdated || !isNews) ? formatDate(page.updatedAt) : null,
location: location ?? null,
author: user?.isAdmin ? `${createdBy?.firstName} ${createdBy?.secondName}` : null,
updatedBy: user?.isAdmin && wasUpdatedByOther ? `${updatedBy?.firstName} ${updatedBy?.secondName}` : null,
author:
user?.isAdmin && createdBy
? `${createdBy.firstName} ${createdBy.secondName}`
: null,
updatedBy:
user?.isAdmin && wasUpdatedByOther && updatedBy
? `${updatedBy.firstName} ${updatedBy.secondName}`
: null,
};
return (
@@ -255,8 +263,8 @@ export default async function Page({ params }: { params: Promise<{ type: string;
<Link href={`/${page.type.toLowerCase()}/${page.slug}/edit`}>
<Button variant="secondary" size="icon-sm"><PencilIcon /></Button>
</Link>
{!isArchived && <ArchiveButton pageId={page.id} slug={page.slug} type={page.type} />}
{!isArchived && <PinToggleButton pageId={page.id} isPinned={!!navlink} />}
{!(isArchived || isDraft) && <ArchiveButton pageId={page.id} slug={page.slug} type={page.type} />}
{!(isArchived || isDraft) && <PinToggleButton pageId={page.id} isPinned={!!navlink} />}
</div>
)}
</div>