import { useState, useRef, useEffect } from 'react'; import { Send, BarChart, LineChart, PieChart, Download } from 'lucide-react'; export default function DataInsightsAgent() { const [messages, setMessages] = useState([]); const [input, setInput] = useState(''); const [isLoading, setIsLoading] = useState(false); const messagesEndRef = useRef(null); const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }); }; useEffect(() => { scrollToBottom(); }, [messages]); const handleSubmit = async (e) => { e.preventDefault(); if (!input.trim()) return; const newMessage = { type: 'user', content: input, timestamp: new Date().toISOString(), }; setMessages(prev => [...prev, newMessage]); setInput(''); setIsLoading(true); // Simulate AI response (replace with actual API call) setTimeout(() => { const aiResponse = { type: 'assistant', content: 'Based on your query, here are the insights...', timestamp: new Date().toISOString(), visualization: { type: 'bar', data: { labels: ['Jan', 'Feb', 'Mar'], values: [300, 450, 280], }, }, }; setMessages(prev => [...prev, aiResponse]); setIsLoading(false); }, 1000); }; return (
{message.content}
{message.visualization && (