"use client"; import { useCallback, useEffect, useState } from "react"; import { buttonVariants } from "@/components/ui/button"; import FetchWindowsPanel from "./FetchWindowsPanel"; // --------------------------------------------------------------------------- // The clip deck's fetch tools (release 35 O1): "Fetch windows", and under it // the STAND-INS — every montage clip whose window the editor refused (a Rumble // embed lookup answering 403 on every try, a recording gone) and is not on // disk, offered its instance's first public alternate (YouTube first). "Use // stand-in" switches the clip (recorded on it, its ruling and voice score moved // with it); "Restore" puts it back. Then Fetch windows again asks for the new // windows. lib/report/standIns.mjs; `umtool fallback` is the same from a terminal. // --------------------------------------------------------------------------- type Alt = { slug: string; videoId: string; start: number; platform: string | null }; type Plan = { candidates: { clipId: string; channel: string; video: string; refusal: { class: string; message: string }; alternate: Alt }[]; switched: { clipId: string; channel: string; video: string; from: { channel: string; video: string; reason: string } }[]; none: { clipId: string; refusal: { class: string; message: string }; why: string }[]; source: string; }; const NAMES: Record = { youtube: "YouTube", rumble: "Rumble", odysee: "Odysee" }; const pname = (p: string | null) => (p ? (NAMES[p] ?? p) : "other"); export default function MontageFetchTools(props: React.ComponentProps) { const { project } = props; const [plan, setPlan] = useState(null); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const load = useCallback(async () => { const r = await fetch(`/api/report/stand-ins?project=${encodeURIComponent(project)}`, { cache: "no-store" }); const j = await r.json().catch(() => ({})); if (!r.ok) setError(j.error ?? `HTTP ${r.status}`); else setPlan(j as Plan); }, [project]); useEffect(() => { void load(); }, [load]); async function post(body: Record) { setBusy(true); setError(null); try { const r = await fetch("/api/report/stand-ins", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ project, ...body }), cache: "no-store", }); const j = await r.json().catch(() => ({})); if (!r.ok) throw new Error(j.error ?? `HTTP ${r.status}`); // The cards are the server's: read them again with the switched clip. window.location.reload(); } catch (e) { setError(e instanceof Error ? e.message : String(e)); setBusy(false); } } return (
void load()} /> {plan && (plan.candidates.length > 0 || plan.switched.length > 0 || plan.none.length > 0) && (
{plan.candidates.map((c) => (
{c.clipId}: the {c.channel} copy refused ({/\b403\b/.test(c.refusal.message) ? "403" : c.refusal.class}) — the {pname(c.alternate.platform)} upload says it ({c.alternate.slug}/{c.alternate.videoId} @{c.alternate.start.toFixed(1)})
))} {plan.candidates.length > 1 && ( )} {plan.switched.map((s) => (
{s.clipId}: from {s.channel}/{s.video} — the {s.from.channel} copy refused ({s.from.reason})
))} {plan.none.map((n) => (

{n.clipId}: refused ({n.refusal.class}) — {n.why}

))}
)} {error && ( {error} )}
); }