"use client"; import { useCallback, useEffect, useState } from "react"; import { adminFetch } from "@/lib/admin-fetch"; type ExportStatus = { enabled: boolean; pending: number; active: number; running?: boolean; commit?: string; finishedAt?: string; error?: string; }; export function CatalogExportClient() { const [status, setStatus] = useState(null); const [error, setError] = useState(""); const [busy, setBusy] = useState(false); const refresh = useCallback(async () => { try { const response = await adminFetch("/api/admin/catalog-export", { cache: "no-store", }); if (!response.ok) throw new Error("Unable to load export status"); setStatus(await response.json()); setError(""); } catch { setError("Unable to load export status"); } }, []); useEffect(() => { void refresh(); const timer = setInterval(() => { void refresh(); }, 15_000); return () => clearInterval(timer); }, [refresh]); async function retry() { setBusy(true); try { const response = await adminFetch("/api/admin/catalog-export", { method: "POST", }); if (!response.ok) throw new Error("Unable to queue export"); await refresh(); } catch { setError("Unable to queue export"); } finally { setBusy(false); } } return (

Catalog repository export

Automatically publishes bundles, icons, gamedata, translations and catalog SQL to Epicnabbo-Catalogus-Updated-Daily (Beta-3).

{!status ? "Loading…" : !status.enabled ? "Not configured on this server." : status.active ? `Waiting for ${status.active} operation(s) to finish.` : status.running ? "Export in progress…" : status.pending ? `${status.pending} update(s) queued for the worker.` : "No pending updates."} {status?.commit && (

Last published commit:{" "} {status.commit.slice(0, 12)}

)} {status?.finishedAt &&

Last attempt: {status.finishedAt}

}
{(error || status?.error) && (

{error || status?.error}

)}
); }