feat: add dynamic favicon, dynamic titles and public portal page
This commit is contained in:
53
src/app/portal/page.tsx
Normal file
53
src/app/portal/page.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { redirect } from "next/navigation";
|
||||
import PortalClient from "./PortalClient";
|
||||
|
||||
export default async function PortalPage() {
|
||||
const organization = await prisma.organization.findFirst();
|
||||
|
||||
if (!organization) {
|
||||
redirect("/setup");
|
||||
}
|
||||
|
||||
// Get all public root folders (projects)
|
||||
const publicFolders = await prisma.folder.findMany({
|
||||
where: {
|
||||
organizationId: organization.id,
|
||||
parentId: null,
|
||||
isPublished: true,
|
||||
},
|
||||
orderBy: { createdAt: "desc" },
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
documents: {
|
||||
where: { isPublished: true }
|
||||
},
|
||||
children: {
|
||||
where: { isPublished: true }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<PortalClient
|
||||
organization={{
|
||||
name: organization.name,
|
||||
logoUrl: organization.logoUrl,
|
||||
primaryColor: organization.primaryColor,
|
||||
}}
|
||||
folders={publicFolders.map((f: any) => ({
|
||||
id: f.id,
|
||||
name: f.name,
|
||||
description: f.description,
|
||||
color: f.color,
|
||||
imageUrl: f.imageUrl,
|
||||
documentsCount: f._count.documents,
|
||||
foldersCount: f._count.children,
|
||||
createdAt: f.createdAt,
|
||||
}))}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user