"use client"; import { BotIcon, CheckIcon, XIcon } from "lucide-react"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { approveJob, rejectJob } from "@/components/job-actions"; import { Button } from "@/components/ui/button"; import { formatBytes } from "@/lib/format"; const WHAT: Record = { add: " of additional files", repair: " to repair missing or broken files", }; /** A download requested through the API that waits for approval: who asked, how much, approve/reject. */ export function ApprovalBar({ job, onRemoved }: { job: { id: string; requestedBy: string | null; totalBytes: number; purpose: string | null }; onRemoved?: () => void }) { const router = useRouter(); const [busy, setBusy] = useState(false); async function run(fn: () => Promise) { setBusy(true); try { await fn(); router.refresh(); } finally { setBusy(false); } } return (

{job.requestedBy ?? "An API token"} asks to download {job.purpose === "repair" ? "up to " : ""} {formatBytes(job.totalBytes)} {WHAT[job.purpose ?? ""] ?? ""}. It starts once you approve it.

); }