"use client";
import Link from "next/link";
import { useState } from "react";
import { buttonVariants } from "@/components/ui/button";
import { jobsHref } from "@/lib/hrefs";
// FETCH THIS WINDOW AGAIN (lane/ui-simplify, 5 Nov; terminal-only before: `umtool fetch
--refetch `):
// a window known bad -- a cut that froze, the wrong rendition -- evicted through the editor and fetched again,
// as a step of the queue (its state, Retry and Cancel on Jobs). POST /api/report/takes/tools {op: "queue-refetch"}.
export default function RefetchButton({ project, clip, take = null, disabled = false }: { project: string; clip: string; take?: string | null; disabled?: boolean }) {
const [busy, setBusy] = useState(false);
const [said, setSaid] = useState<{ queued?: string; error?: string } | null>(null);
const go = async () => {
setBusy(true);
const r = await fetch("/api/report/takes/tools", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ project, take, op: "queue-refetch", clip }),
});
const j = (await r.json().catch(() => ({}))) as { queued?: string; error?: string };
setBusy(false);
setSaid(r.ok ? j : { error: j.error ?? `HTTP ${r.status}` });
};
return (
{said?.queued && (
queued {said.queued} —{" "}
Jobs
)}
{said?.error && {said.error}}
);
}