import Link from "next/link"; import { notFound } from "next/navigation"; import { acceptAllSummary, acceptScreen, type AcceptItem } from "@peppa/core"; import { acceptAllAction, fixStoryAction } from "@/app/(app)/actions"; import { Empty, Flash, Key, Notice, PageHeader } from "@/components/common"; import { LiveRefresh } from "@/components/LiveRefresh"; import { Button } from "@/components/ui/button"; import { Textarea } from "@/components/ui/input"; import { Workspace } from "@/components/Workspace"; import { requireUser } from "@/lib/auth"; import { db } from "@/lib/db"; import { getT } from "@/lib/i18n"; import { projectForUserByKey } from "@/lib/queries"; export async function generateMetadata() { const t = await getT(); return { title: t("Приёмка — FORGE") }; } const BIG = "min-h-11"; // PEP-209: buttons at least 44 px on a phone /** * PEP-209: acceptance on one screen — every story waiting for «Принять», grouped by product page, * with «было» / «стало», «Принять», «Поправить» and «Принять всё» on top. */ export default async function AcceptPage({ params, searchParams }: { params: Promise<{ key: string }>; searchParams: Promise<{ error?: string; ok?: string; pending?: string; failed?: string }> }) { const user = await requireUser(); const { key } = await params; const sp = await searchParams; const t = await getT(); const p = await projectForUserByKey(user.id, key).catch(() => null); if (!p) notFound(); const screen = await acceptScreen(db, p); const back = `/p/${p.key}/accept`; const all = screen.groups.flatMap((g) => g.items); const done = sp.ok != null ? { accepted: Number(sp.ok) || 0, pending: Number(sp.pending) || 0, failed: Number(sp.failed) || 0 } : null; return ( {p.name}} title={t("Приёмка")}> {screen.total ? t("Работа, которая ждёт вашего решения: посмотрите и примите или напишите, что поправить.") : t("Принимать пока нечего: агенты пришлют задачи, когда работа будет готова.")} {done && ( {t.text(acceptAllSummary(done))} {screen.liveUrl && done.accepted + done.pending > 0 && ( {t("Открыть продукт")} → )} )} {screen.total > 0 && (
{screen.checkUrl && ( {t("Открыть версию для проверки")} )}
{t("Принять всё · {n}", { n: all.length })}

{t("Будут приняты по очереди:")}

    {all.map((it) => (
  • {it.key} {it.title}
  • ))}

{t("Если какая-то не примется, остальные всё равно примутся, а у неё будет написано почему.")}

)} {screen.total === 0 && !done && {t("Задач на приёмке нет.")}} {screen.groups.map((g) => (

{g.page ? t("Страница {page}", { page: g.page }) : t("Без снимков страниц")} · {g.items.length}

{g.items.map((it) => )}
))}
); } async function AcceptCard({ it, back }: { it: AcceptItem; back: string }) { const t = await getT(); return (
{it.key} {it.title}
{it.summary !== it.title &&

{t.text(it.summary)}

} {it.failed && (

{t("Не принялась: {reason}", { reason: t.text(it.failed) })}

)} {it.pending &&

{t("Вы уже приняли — изменения обновляются, задача закроется сама.")}

} {it.shots.length > 0 ? ( // Scrolls sideways on a phone: one page per screen, «было» above «стало».
{it.shots.map((s, i) => (
{s.path}
))}
) : it.previewUrl ? (

{t("Открыть в версии для проверки")} →

) : (

{t("Снимков и версии для проверки нет — посмотрите описание задачи.")}

)} {it.shots.length > 0 && it.previewUrl && (

{t("Открыть в версии для проверки")} →

)} {!it.pending && (
{t("Поправить")}