import Link from "next/link"; import { desc, eq } from "drizzle-orm"; import { auth } from "@/auth"; import { db } from "@/lib/db/client"; import { projects } from "@/lib/db/schema"; import { createSnippetAction } from "@/lib/snippet-actions"; import { Container, PageHeader } from "@/app/_components/ui/container"; import { Card, CardBody } from "@/app/_components/ui/card"; import { Input, Textarea, Label } from "@/app/_components/ui/input"; import { Button } from "@/app/_components/ui/button"; export const dynamic = "force-dynamic"; export default async function NewSnippetPage({ searchParams, }: { searchParams: Promise<{ scope?: string; project?: string; name?: string }>; }) { const session = await auth(); const userId = session!.user.id; const params = await searchParams; const initialScope = params.scope === "project" ? "project" : "user"; const initialProject = params.project ?? ""; const initialName = params.name ?? ""; const projectList = await db .select({ key: projects.key, displayName: projects.displayName }) .from(projects) .where(eq(projects.userId, userId)) .orderBy(desc(projects.updatedAt)) .limit(50); return (
{projectList.length > 0 ? ( {projectList.map((p) => ( ))} ) : null}