import Link from "next/link"; import { ExternalLink, KeyRound, Rocket, X } from "lucide-react"; import type { ProductNeedView, ProductReview, ProjectProduct } 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 «где это работает?». Nothing is shown before the first accepted story. */ export async function ProductCard({ product, projectKey, chat = true, engineer = false, projectId, needs = [], review = null, back, }: { 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; }) { 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) return null; const deployed = !!(live || check); const mayEdit = chat && projectId != null && !!back; const next = chat && (

{t("Что дальше: опишите следующую задачу")} {t("аналитику в чате")} — {t("он поможет сформулировать {task}, агенты сделают.", { task: task("acc") })}

); return (
{live ? (
{t("Ваш продукт работает")} {t("Открыт для всех по адресу")} {host(live.url)} · {t("обновлён {when}", { when: ago(live.at, t) })} {live.stories.length > 0 && <> · {t("вошли {tasks} {keys}", { tasks: task("pl"), keys: live.stories.slice(0, 6).join(", ") })}}
) : check ? (
{t("Версия для проверки готова")} {t("Пока её видите только вы:")} {host(check.url)} · {t("обновлена {when}.", { when: ago(check.at, t) })} {t("Посмотрите — и, если всё хорошо,")} {showAll}
) : doneStories === 0 ? null : (
{t("Готово {tasks}: {n}", { tasks: task("genPl"), n: doneStories })} {engineer ? t("Этот проект пока не открывается по ссылке как сайт. Что получилось — на странице каждой готовой {task}, вкладка «Результат», и во вкладке «Код». Хотите открывать продукт по ссылке — попросите аналитика в чате: «сделай, чтобы продукт открывался по ссылке».", { task: task("gen") }) : t("Этот проект пока не открывается по ссылке как сайт. Что получилось — на странице каждой готовой {task}, вкладка «Результат». Хотите открывать продукт по ссылке — попросите аналитика в чате: «сделай, чтобы продукт открывался по ссылке».", { task: task("gen") })}
)} {live && check && (

{t("Есть новая версия для проверки:")}{" "} {host(check.url)} {check.stories.length > 0 && ({check.stories.slice(0, 6).join(", ")})} — {showAll}

)} {open.length > 0 && (
{deployed ? t("Работает в демо-режиме — чтобы заработало по-настоящему, нужно от вас:") : t("Продукт будет работать в демо-режиме — чтобы заработало по-настоящему, нужно от вас:")} {t("Пока этого нет, продукт показывает примеры вместо настоящей работы. Ключи хранятся зашифрованными; Peppa FACTORY сама передаст их продукту и перезапустит его — через пару минут после сохранения.")}
    {open.map((n) => (
  • {n.title} {n.why && {t("Зачем: {why}", { why: n.why })}} {n.how && {t("Где взять: {how}", { how: n.how })}}
    {mayEdit && (
    )}
    {mayEdit && (n.secret ? (
    ) : (
    ))}
  • ))}
)} {review && deployed && (review.howto.length > 0 || review.notReal.length > 0) && (
{t("Как пользоваться продуктом")}

{review.summary}

{review.howto.length > 0 && (
    {review.howto.map((step, i) => (
  1. {step}
  2. ))}
)} {review.notReal.length > 0 && (
{t("Пока не настоящее")}
    {review.notReal.map((x, i) => (
  • {x}
  • ))}
)}

{t("Продукт посмотрел продакт-агент {when} — подробности в", { when: ago(new Date(review.at), t) })} {t("обсуждении проекта")}.

)} {next}
); }