peppa/apps/web/app/(app)/projects/page.tsx
2026-11-15 18:05:34 +05:00

42 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Link from "next/link";
import { Plus } from "lucide-react";
import { listOtherProjects, listUserProjects } from "@peppa/core";
import { ProjectList } from "@/components/cards";
import { Flash, PageHeader, Section } from "@/components/common";
import { Button } from "@/components/ui/button";
import { Workspace } from "@/components/Workspace";
import { requireUser, words } from "@/lib/auth";
import { db } from "@/lib/db";
export default async function Projects({ searchParams }: { searchParams: Promise<{ error?: string }> }) {
const user = await requireUser();
const w = await words();
const { error } = await searchParams;
const [projects, others] = await Promise.all([listUserProjects(db, user.id), listOtherProjects(db, user.id)]);
return (
<Workspace>
<Flash error={error} />
<PageHeader
title="Проекты"
actions={
<Button asChild variant="default" size="sm">
<Link href="/projects/new">
<Plus />
Новый проект
</Link>
</Button>
}
>
{w.engineer ? "Свои и общие проекты: доска стори, код, PR, релизы, ошибки из прода, участники." : "Ваши проекты и те, куда вас пригласили. Откройте проект, чтобы поставить задачу или посмотреть результат."}
</PageHeader>
<ProjectList projects={projects} userId={user.id} engineer={w.engineer} />
{others.length > 0 && (
<Section title="Проекты других" count={others.length}>
<p className="m-0 text-sm text-muted-foreground">Видны вам как суперадмину. Вопросы агентов и уведомления этих проектов к вам не приходят.</p>
<ProjectList projects={others} userId={user.id} engineer={w.engineer} />
</Section>
)}
</Workspace>
);
}