One clean commit on top of main (the branch history had an intermediate commit with conflict markers). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
88 lines
4.9 KiB
TypeScript
88 lines
4.9 KiB
TypeScript
import Link from "next/link";
|
||
import { ExternalLink, Rocket } from "lucide-react";
|
||
import type { ProjectProduct } from "@peppa/core";
|
||
import { ago } from "@/components/common";
|
||
import { Button } from "@/components/ui/button";
|
||
import { Hidden } from "@/components/cards";
|
||
import { deployProdAction } from "@/app/(app)/actions";
|
||
|
||
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 function ProductCard({ product, projectKey, chat = true, engineer = false, back }: { product: ProjectProduct; projectKey: string; chat?: boolean; /** PEP-119: «Инженер» gets the link to the releases tab, «Продакт» — one button. */ engineer?: boolean; back?: string }) {
|
||
// «Показать всем»: the same action as the button in «Релизы», without sending a product manager there.
|
||
const showAll = engineer ? (
|
||
<>
|
||
показать её всем можно в <Link href={`/p/${projectKey}?tab=releases`}>Релизах</Link>.
|
||
</>
|
||
) : (
|
||
<form action={deployProdAction} className="inline">
|
||
<Hidden fields={{ projectKey, back: back ?? `/p/${projectKey}` }} />
|
||
<Button size="sm" variant="default">Показать всем</Button>
|
||
</form>
|
||
);
|
||
const { live, check, doneStories } = product;
|
||
if (!live && !check && doneStories === 0) return null;
|
||
const next = chat && (
|
||
<p className="m-0 text-sm text-muted-foreground">
|
||
Что дальше: опишите следующую задачу <Link href={`/chats/${projectKey}`}>аналитику в чате</Link> — он поможет сформулировать стори, агенты сделают.
|
||
</p>
|
||
);
|
||
return (
|
||
<section aria-label="Ваш продукт" className="mb-5 flex flex-col gap-3 rounded-xl border border-ok/40 bg-ok/5 p-4">
|
||
{live ? (
|
||
<div className="flex flex-wrap items-center gap-x-4 gap-y-2">
|
||
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
|
||
<span className="text-[15px] font-semibold">Ваш продукт работает</span>
|
||
<span className="text-sm text-muted-foreground">
|
||
Открыт для всех по адресу <span className="font-mono text-foreground">{host(live.url)}</span> · обновлён {ago(live.at)}
|
||
{live.stories.length > 0 && <> · вошли стори {live.stories.slice(0, 6).join(", ")}</>}
|
||
</span>
|
||
</div>
|
||
<Button asChild variant="default">
|
||
<a href={live.url} target="_blank" rel="noreferrer">
|
||
<ExternalLink /> Открыть продукт
|
||
</a>
|
||
</Button>
|
||
</div>
|
||
) : check ? (
|
||
<div className="flex flex-wrap items-center gap-x-4 gap-y-2">
|
||
<div className="flex min-w-0 flex-1 flex-col gap-0.5">
|
||
<span className="text-[15px] font-semibold">Версия для проверки готова</span>
|
||
<span className="text-sm text-muted-foreground">
|
||
Пока её видите только вы: <span className="font-mono text-foreground">{host(check.url)}</span> · обновлена {ago(check.at)}. Посмотрите — и, если всё хорошо, {showAll}
|
||
</span>
|
||
</div>
|
||
<Button asChild variant="default">
|
||
<a href={check.url} target="_blank" rel="noreferrer">
|
||
<ExternalLink /> Посмотреть
|
||
</a>
|
||
</Button>
|
||
</div>
|
||
) : (
|
||
<div className="flex flex-col gap-0.5">
|
||
<span className="text-[15px] font-semibold">Готово стори: {doneStories}</span>
|
||
<span className="text-sm text-muted-foreground">
|
||
Этот проект пока не открывается по ссылке как сайт. Что получилось — на странице каждой готовой стори, вкладка «Результат»{engineer ? ", и во вкладке «Код»" : ""}. Хотите открывать продукт по
|
||
ссылке — попросите аналитика в чате: «сделай, чтобы продукт открывался по ссылке».
|
||
</span>
|
||
</div>
|
||
)}
|
||
{live && check && (
|
||
<p className="m-0 flex flex-wrap items-center gap-2 text-sm">
|
||
<Rocket className="size-4 text-primary" />
|
||
Есть новая версия для проверки:{" "}
|
||
<a href={check.url} target="_blank" rel="noreferrer">
|
||
{host(check.url)}
|
||
</a>
|
||
{check.stories.length > 0 && <span className="text-muted-foreground">({check.stories.slice(0, 6).join(", ")})</span>} — {showAll}
|
||
</p>
|
||
)}
|
||
{next}
|
||
</section>
|
||
);
|
||
}
|