import Link from "next/link"; import { ExternalLink, Hourglass, KeyRound, Rocket, Wrench, X } from "lucide-react"; import type { ProductNeedView, ProductReview, ProjectProduct, PublishMode } from "@peppa/core"; import { Hidden } from "@/components/cards"; import { ago } from "@/components/common"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { getT } from "@/lib/i18n"; import { deployProdAction, removeNeedAction, saveProjectSecretAction, setNeedDoneAction } from "@/app/(app)/actions"; import { wording } from "@peppa/shared/wording"; const host = (url: string) => url.replace(/^https?:\/\//, ""); /** * PEP-111: «Ваш продукт» on the project page — where the result is and what to do next, for a * product manager who asks «где это работает?». PEP-145: one big «Открыть продукт»; without a * link — the honest status («Готовим ссылку», the system story), never «попросите аналитика». */ export async function ProductCard({ product, projectKey, chat = true, engineer = false, projectId, needs = [], review = null, back, publish = "button", }: { product: ProjectProduct; projectKey: string; chat?: boolean; /** PEP-119: «Инженер» gets the link to the releases tab, «Продакт» — the button right here. */ engineer?: boolean; projectId?: number; /** PEP-112: what the owner has to give before the product is real. */ needs?: ProductNeedView[]; /** PEP-112: the product agent's last acceptance. */ review?: ProductReview | null; back?: string; /** PEP-145: «Показывать всем: сам» — no button, Peppa shows the version to everyone itself. */ publish?: PublishMode; }) { const t = await getT(); // «Показать всем»: the same action as the button in «Релизы», without sending a product manager there. const showAll = engineer ? ( <> {t("показать её всем можно в")} {t("Релизах")}. > ) : (
); const { task } = wording(engineer ? "engineer" : "product", t.locale); const { live, check, doneStories } = product; const open = needs.filter((n) => n.open); if (!live && !check && doneStories === 0 && !open.length && !product.preparing) return null; // PEP-145: one big button — the working product, else the version to check. const link = live ?? check; const deployed = !!(live || check); const mayEdit = chat && projectId != null && !!back; const next = chat && ({t("Что дальше: опишите следующую задачу")} {t("аналитику в чате")} — {t("он поможет сформулировать {task}, агенты сделают.", { task: task("acc") })}
); return (
{review.summary}
{review.howto.length > 0 && ({t("Продукт посмотрел агент приёмки {when} — подробности в", { when: ago(new Date(review.at), t) })} {t("обсуждении проекта")}.