import { notFound } from "next/navigation"; import { loadEnv } from "@peppa/shared"; import { AutoRefresh } from "@/components/AutoRefresh"; import { Flash, SessionCard } from "@/components/ui"; import { Board, type Card } from "@/components/Board"; import { columnOf } from "@peppa/runner"; import { requireUser } from "@/lib/auth"; import { board, projectForUserByKey, projectSessions } from "@/lib/queries"; import { listMembers } from "@peppa/core"; import { db } from "@/lib/db"; import { addGoal, addProjectMember, addTask, removeProjectMember } from "../../actions"; export default async function ProjectPage({ params, searchParams }: { params: Promise<{ key: string }>; searchParams: Promise<{ error?: string }> }) { const user = await requireUser(); const { key } = await params; const { error } = await searchParams; const p = await projectForUserByKey(user.id, key).catch(() => null); if (!p) notFound(); const [{ goals, tasks }, sessions, team] = await Promise.all([board(p.id), projectSessions(p.id), listMembers(db, p)]); const isOwner = p.ownerId === user.id; const back = `/p/${p.key}`; const groups = [...goals.map((g) => ({ goal: g })), { goal: null }]; const goalTitle = new Map(goals.map((g) => [g.id, g.title])); const cards: Card[] = tasks.map((t) => ({ key: `${p.key}-${t.number}`, title: t.title, status: t.status, column: columnOf(t.status), goal: t.goalId ? (goalTitle.get(t.goalId) ?? null) : null, })); return ( <>

{p.key} {p.name}

{p.giteaOwner}/{p.giteaRepo} · {p.workspacePath}

{groups.map(({ goal }) => (
+ Задача{goal ? ` · 🎯 ${goal.title}` : " без цели"}
{goal && }