import React, { useEffect, Suspense } from 'react'; import { useParams, useSearchParams } from 'react-router-dom'; import { Loader2 } from 'lucide-react'; import AutonomousDashboard from './AutonomousDashboard'; import MLPredictions from './MLPredictions'; import DataHub from './DataHub'; import { useUserStore } from '@/store/userStore'; const EmbedWidget: React.FC = () => { const { widgetId } = useParams<{ widgetId: string }>(); const [searchParams] = useSearchParams(); const theme = searchParams.get('theme') || 'dark'; useEffect(() => { if (theme === 'dark') { document.documentElement.classList.add('dark'); document.documentElement.classList.remove('light-theme'); document.body.style.backgroundColor = '#0f172a'; useUserStore.setState({ isDark: true }); } else if (theme === 'light') { document.documentElement.classList.remove('dark'); document.documentElement.classList.add('light-theme'); document.body.style.backgroundColor = '#f8fafc'; useUserStore.setState({ isDark: false }); } // No overflow hidden so the dashboard can scroll return () => { document.body.style.backgroundColor = ''; }; }, [theme]); // The api.ts interceptor automatically extracts ?token= from the URL and applies it! if (widgetId === 'full-dashboard') { return (
}> ); } if (widgetId === 'ml-predictions') { return (
}> ); } if (widgetId === 'data-hub') { return (
}> ); } const isDark = theme === 'dark'; return (

DataVision Embed

Connected securely via API Token.

Widget: {widgetId} not natively supported.
); }; export default EmbedWidget;