diff --git a/app/list/page.tsx b/app/pages/page.tsx similarity index 89% rename from app/list/page.tsx rename to app/pages/page.tsx index 3b90101..529ed9f 100644 --- a/app/list/page.tsx +++ b/app/pages/page.tsx @@ -10,11 +10,12 @@ export const metadata: Metadata = { title: "List of pages" }; export default async function List() { const user = await getCurrentUser(); - if (!user?.isAdmin) redirect("/"); + const isAdmin = user?.isAdmin; + if (!isAdmin) redirect("/"); const pagesPublished = await getPages("PAGE", "PUBLISHED"); - const pagesArchived = await getPages("PAGE", "ARCHIVED"); - const pagesDraft = await getPages("PAGE", "DRAFT"); + const pagesArchived = isAdmin ? await getPages("PAGE", "ARCHIVED") : []; + const pagesDraft = isAdmin ? await getPages("PAGE", "DRAFT") : []; const pages = [...pagesPublished, ...pagesArchived, ...pagesDraft].sort((a, b) => { const aDate = new Date(a.updatedAt ?? a.publishedAt).getTime();