32 lines
2.0 KiB
TypeScript
32 lines
2.0 KiB
TypeScript
import { listUserProjects } from "@peppa/core";
|
||
import { AutoRefresh } from "@/components/AutoRefresh";
|
||
import { ActivityAside } from "@/components/ActivityAside";
|
||
import { ProjectList, QuestionCard, SessionCard } from "@/components/cards";
|
||
import { Empty, Flash, MoreLink, PageHeader, Section } from "@/components/common";
|
||
import { Workspace } from "@/components/Workspace";
|
||
import { requireUser } from "@/lib/auth";
|
||
import { db } from "@/lib/db";
|
||
import { activeSessions, inbox } from "@/lib/queries";
|
||
|
||
export default async function Home({ searchParams }: { searchParams: Promise<{ error?: string }> }) {
|
||
const user = await requireUser();
|
||
const { error } = await searchParams;
|
||
const [items, sessions, projects] = await Promise.all([inbox(user.id), activeSessions(user.id), listUserProjects(db, user.id)]);
|
||
return (
|
||
<Workspace aside={<ActivityAside questions={false} />}>
|
||
<AutoRefresh />
|
||
<Flash error={error} />
|
||
<PageHeader title="Главная">{items.length ? "Агенты ждут твоего решения — ответь здесь, в Telegram или через MCP." : "Всё идёт само: агентам от тебя ничего не нужно."}</PageHeader>
|
||
<Section title="Вопросы агентов" count={items.length}>
|
||
{items.length === 0 ? <Empty>Агентам от тебя ничего не нужно.</Empty> : items.map((q) => <QuestionCard key={q.id} q={q} taskKey={q.taskKey} taskStatus={q.taskStatus} back="/" />)}
|
||
</Section>
|
||
<Section title="Активные раннеры" actions={<MoreLink href="/runners">все раннеры</MoreLink>}>
|
||
{sessions.length === 0 ? <Empty>Сейчас ничего не запущено.</Empty> : sessions.map((s) => <SessionCard key={s.id} s={s} back="/" showTitle />)}
|
||
</Section>
|
||
<Section title="Мои проекты" actions={<MoreLink href="/projects">все проекты</MoreLink>}>
|
||
<ProjectList projects={projects} userId={user.id} />
|
||
</Section>
|
||
</Workspace>
|
||
);
|
||
}
|