"use client"; import Link from "next/link"; import { useState } from "react"; import { useRouter } from "next/navigation"; import Image from "next/image"; import { useQuery } from "@tanstack/react-query"; import { Layers, ExternalLink, ImageIcon, Loader2 } from "lucide-react"; import { promoteExportThumbnail } from "@/actions/shots"; import { useToast } from "@/components/ui/use-toast"; import { cn } from "@/lib/utils"; import { EXPORT_STATUS_STYLES, statusLabel, } from "@/app/(dashboard)/pipeline/status-colors"; interface ExportRow { id: string; versionString: string; status: string; statusChangedAt: string; createdAt: string; outputDir: string; thumbnailUrl: string | null; job: { attempt: number; progress: number; machineName: string | null; errorMessage: string | null; } | null; } /** * "Exports" tab on the shot detail page (RenderPipeline2 §13) — the render * pipeline history for this shot, linking into the Export detail page. */ export function ShotExportsTab({ shotId }: { shotId: string }) { const router = useRouter(); const { toast } = useToast(); const [promotingId, setPromotingId] = useState(null); // Take this export's frame as the shot's thumbnail. Fills in only where the // shot has no reference frame of its own (§9.1a) — it never overwrites one. const promote = async (exportId: string, versionString: string) => { setPromotingId(exportId); try { await promoteExportThumbnail(shotId, exportId); toast({ title: `Shot thumbnail taken from ${versionString}` }); router.refresh(); } catch (err) { toast({ title: "Could not use that frame", description: (err as Error).message, variant: "destructive", }); } finally { setPromotingId(null); } }; const { data, isLoading } = useQuery({ queryKey: ["shot-exports", shotId], queryFn: async () => { const res = await fetch(`/api/render/queue?shotId=${shotId}&limit=100`); if (!res.ok) throw new Error("Failed to load exports"); return res.json() as Promise<{ exports: ExportRow[] }>; }, refetchInterval: 10000, }); const exports = data?.exports ?? []; if (isLoading) { return
Loading exports…
; } if (exports.length === 0) { return (

No pipeline exports yet — queue one from the After Effects panel.

); } return (
{exports.map((e) => (
{e.thumbnailUrl ? ( ) : ( )} {e.versionString} {statusLabel(e.status)} {e.job?.machineName ? `${e.job.machineName} · attempt ${e.job.attempt} · ` : ""} {e.outputDir} {new Date(e.createdAt).toLocaleDateString()} {e.thumbnailUrl && ( )}
))}
); }