29 lines
718 B
TypeScript
29 lines
718 B
TypeScript
import { SectionCard } from "../components/SectionCard";
|
|
import { useWidgetData } from "../hooks/useWidgets";
|
|
import type { WidgetInstance } from "../types";
|
|
|
|
interface Props {
|
|
widget: WidgetInstance;
|
|
refreshIntervalMs: number;
|
|
description?: string;
|
|
}
|
|
|
|
export function StaticWidget({
|
|
widget,
|
|
refreshIntervalMs,
|
|
description,
|
|
}: Props) {
|
|
const { data } = useWidgetData(widget.id, refreshIntervalMs);
|
|
const text = data?.data?.text as string | undefined;
|
|
|
|
return (
|
|
<SectionCard title={widget.title} description={description}>
|
|
{text ? (
|
|
<p className="whitespace-pre-wrap text-sm">{text}</p>
|
|
) : (
|
|
<p className="text-sm text-muted-foreground">No content configured.</p>
|
|
)}
|
|
</SectionCard>
|
|
);
|
|
}
|