24 lines
789 B
TypeScript
24 lines
789 B
TypeScript
import { usePluginAction, usePluginData, type PluginWidgetProps } from "@paperclipai/plugin-sdk/ui";
|
|
|
|
type HealthData = {
|
|
status: "ok" | "degraded" | "error";
|
|
checkedAt: string;
|
|
};
|
|
|
|
export function DashboardWidget(_props: PluginWidgetProps) {
|
|
const { data, loading, error } = usePluginData<HealthData>("health");
|
|
const ping = usePluginAction("ping");
|
|
|
|
if (loading) return <div>Loading plugin health...</div>;
|
|
if (error) return <div>Plugin error: {error.message}</div>;
|
|
|
|
return (
|
|
<div style={{ display: "grid", gap: "0.5rem" }}>
|
|
<strong>Plugin Authoring Smoke Example</strong>
|
|
<div>Health: {data?.status ?? "unknown"}</div>
|
|
<div>Checked: {data?.checkedAt ?? "never"}</div>
|
|
<button onClick={() => void ping()}>Ping Worker</button>
|
|
</div>
|
|
);
|
|
}
|