import { PageParams } from "@/types/next"; import { Page, PageContent, PageTitle } from "@/features/layout/page"; import { ButtonDeleteProject } from "@/features/projects/project-delete-button"; import { CardsWithPagination } from "@/components/common/cards-with-pagination"; import { ProjectDatabaseCard } from "@/features/projects/project-database-card"; import { notFound, redirect } from "next/navigation"; import { db } from "@/db"; import { eq } from "drizzle-orm"; import { getActiveMember, getOrganization } from "@/lib/auth/auth"; import * as drizzleDb from "@/db"; import { capitalizeFirstLetter, isUUID } from "@/utils/text"; import { ProjectDialog } from "@/features/projects/project-dialog"; import { ProjectWith } from "@/db/schema/06_project"; import { getOrganizationAvailableDatabases } from "@/db/services/database"; export default async function RoutePage( props: PageParams<{ projectId: string; }>, ) { const { projectId } = await props.params; if (!isUUID(projectId)) { notFound(); } const organization = await getOrganization({}); const activeMember = await getActiveMember(); if (!organization) { notFound(); } const org = await db.query.organization.findFirst({ where: eq(drizzleDb.schemas.organization.slug, organization.slug), }); if (!org) notFound(); const proj = await db.query.project.findFirst({ where: (proj, { and, eq, not }) => and( eq(proj.id, projectId), eq(proj.organizationId, org.id), not(eq(proj.isArchived, true)), ), with: { databases: true, }, }); if (!proj) { redirect("/dashboard/projects"); } const availableDatabases = await getOrganizationAvailableDatabases( organization.id, proj.id, ); const isMember = activeMember?.role === "member"; return (
{capitalizeFirstLetter(proj.name)}
{!isMember && (
)}
{proj.databases.length > 0 ? ( new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), )} organizationSlug={organization.slug} // @ts-ignore cardItem={ProjectDatabaseCard} cardsPerPage={20} numberOfColumns={3} pageSizeOptions={[10, 20, 50]} extendedProps={proj} /> ) : (

No databases found

You haven’t added any databases to this project yet.

)}
); }