import Link from "next/link"; import { buttonVariants } from "@/components/ui/button"; import { clipBenchHref, projectHref, presentHref } from "@/lib/hrefs"; import PlayLink from "./PlayLink"; import SaveVersionButton from "./SaveVersionButton"; import type { ClipDetail } from "./report/shared"; // --------------------------------------------------------------------------- // A report video's ONE PRIMARY ROW, in the piece head on every tab // (lane/ui-simplify, 5 Nov; the working draft, L3): Play the draft, Walk its // clips, Save version, Add a clip. Every edit lands in the draft (the // project's manifest); a saved version is frozen and played read-only from // Play's version switch. `words` says what the draft is from ("from v5 · 3 edits"). // --------------------------------------------------------------------------- type Working = { latest: { id: string; seconds: number | null; builtAt: string | null } | null; parent?: { id: string } | null; edits?: { count: number } | null; } | null; /** The head's status: "7 open notes · ". */ export function primaryStatus(working: Working, openNotes: number, cut: string): string { void working; return `${openNotes} open note${openNotes === 1 ? "" : "s"} · ${cut}`; } /** "from v5 · 3 edits" / "unsaved": the draft, beside its Play. */ export function latestWords(working: Working): string | null { const p = working?.parent ?? null; if (!p) return working ? "unsaved" : null; const e = working?.edits; return `from ${p.id} · ${!e ? "edits unknown" : e.count === 0 ? "no edits" : `${e.count} edit${e.count === 1 ? "" : "s"}`}`; } export default function ProjectPrimary({ project, detail, latest, words = null }: { project: string; detail: ClipDetail; latest: string | null; words?: string | null }) { const entries = detail.entries; if (entries.length === 0) { return ( + Add a clip ); } const firstClip = entries.find((e) => e.kind === "clip")?.id ?? null; return ( <> Present {words && ( {words} )} {/* A walk is of clips: a cut of posts alone has none to walk. The draft's first clip. */} {firstClip ? ( Walk ) : null} + Add a clip ); }