fixes
This commit is contained in:
@@ -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();
|
||||
Reference in New Issue
Block a user