"use client"; import { useState } from "react"; import Link from "next/link"; import { JobProgress } from "./JobProgress"; interface JobRowProps { job: { id: string; library_id: string | null; type: string; status: string; created_at: string; error_opt: string | null; }; libraryName: string | undefined; highlighted?: boolean; onCancel: (id: string) => void; } export function JobRow({ job, libraryName, highlighted, onCancel }: JobRowProps) { const [showProgress, setShowProgress] = useState( highlighted || job.status === "running" || job.status === "pending" ); const handleComplete = () => { setShowProgress(false); // Trigger a page refresh to update the job status window.location.reload(); }; return ( <> {job.id.slice(0, 8)} {job.library_id ? libraryName || job.library_id.slice(0, 8) : "—"} {job.type} {job.status} {job.error_opt && !} {(job.status === "running" || job.status === "pending") && ( )} {new Date(job.created_at).toLocaleString()}
View {(job.status === "pending" || job.status === "running") && ( )}
{showProgress && (job.status === "running" || job.status === "pending") && ( )} ); }