"use client"; import { useEffect, useState } from "react"; interface DemoSeedTriggerProps { hasTraces: boolean; children: React.ReactNode; } export function DemoSeedTrigger({ hasTraces, children }: DemoSeedTriggerProps) { const [seeding, setSeeding] = useState(false); useEffect(() => { if (hasTraces || seeding) return; async function seedIfNeeded() { setSeeding(true); try { const res = await fetch("/api/demo/seed", { method: "POST" }); if (res.ok) { window.location.reload(); } } catch { // Seed failed, continue showing empty state } finally { setSeeding(false); } } seedIfNeeded(); }, [hasTraces, seeding]); if (!hasTraces && seeding) { return (
Setting up your workspace with sample data...