24 lines
736 B
TypeScript
24 lines
736 B
TypeScript
import Link from "next/link";
|
||
import { listUserProjects } from "@peppa/core";
|
||
import { Flash, ProjectList } from "@/components/ui";
|
||
import { requireUser } from "@/lib/auth";
|
||
import { db } from "@/lib/db";
|
||
|
||
export default async function Projects({ searchParams }: { searchParams: Promise<{ error?: string }> }) {
|
||
const user = await requireUser();
|
||
const { error } = await searchParams;
|
||
const projects = await listUserProjects(db, user.id);
|
||
return (
|
||
<>
|
||
<Flash error={error} />
|
||
<h1>
|
||
Проекты{" "}
|
||
<Link href="/projects/new" className="button primary small">
|
||
Новый проект
|
||
</Link>
|
||
</h1>
|
||
<ProjectList projects={projects} userId={user.id} />
|
||
</>
|
||
);
|
||
}
|