import Link from "next/link"; import { notFound } from "next/navigation"; import { and, desc, eq, isNull } from "drizzle-orm"; import { auth } from "@/auth"; import { db } from "@/lib/db/client"; import { memories, projects } from "@/lib/db/schema"; import { Container, PageHeader } from "@/app/_components/ui/container"; import { Card, CardBody } from "@/app/_components/ui/card"; import { Badge } from "@/app/_components/ui/badge"; import { Button } from "@/app/_components/ui/button"; import { EmptyState } from "@/app/_components/ui/empty-state"; export const dynamic = "force-dynamic"; export default async function ProjectDetailPage({ params, }: { params: Promise<{ key: string }>; }) { const session = await auth(); const userId = session!.user.id; const { key: rawKey } = await params; const key = decodeURIComponent(rawKey); const projectRow = await db .select() .from(projects) .where(and(eq(projects.userId, userId), eq(projects.key, key))) .limit(1); const project = projectRow[0]; if (!project) notFound(); const mem = await db .select({ id: memories.id, scope: memories.scope, content: memories.content, tags: memories.tags, createdAt: memories.createdAt, }) .from(memories) .where( and( eq(memories.userId, userId), eq(memories.projectId, project.id), isNull(memories.deletedAt), ), ) .orderBy(desc(memories.createdAt)) .limit(100); return ( {project.key} {" ยท "} {mem.length} memor{mem.length === 1 ? "y" : "ies"} } actions={ <> } /> {mem.length === 0 ? ( } /> ) : (
    {mem.map((m) => (
  • {m.scope} {new Date(m.createdAt).toLocaleString()}

    {m.content}

    {m.tags.length ? (
    {m.tags.map((t) => ( {t} ))}
    ) : null}
  • ))}
)}
); }