SPB Git
643 B · 8 lines tsx
1"use client";2import { useState } from "react";3import { api } from "./api";4export function EnqueueButton({ kind, label, payload }: { kind: string; label: string; payload?: Record<string, unknown> }) {5  const [msg, setMsg] = useState("");6  return <span className="inline-flex items-center gap-2"><button onClick={async () => { try { const r = await api("/api/admin/jobs", { method: "POST", body: JSON.stringify({ kind, payload: payload ?? {} }) }); setMsg(`queued #${r.id ?? "dup"}`); } catch (e) { setMsg((e as Error).message); } }} className="btn-ghost">{label}</button>{msg && <span className="text-xs text-fg-2">{msg}</span>}</span>;7}8
Files · 46938d6ac5f58761d53852ca0feac60f53dc39c1
Menu

Theme