import { useState, useRef, useEffect } from 'react'; import { Send, Bot, User, Music, Sparkles } from 'lucide-react'; export default function ChatInterface({ messages, onSendMessage, isLoading, spotifyData }) { const [input, setInput] = useState(''); const messagesEndRef = useRef(null); const inputRef = useRef(null); const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); }; useEffect(() => { scrollToBottom(); }, [messages]); const handleSubmit = (e) => { e.preventDefault(); if (!input.trim() || isLoading) return; onSendMessage(input); setInput(''); }; return (
{/* Chat Header */}

AI Music Assistant

{spotifyData ? 'Connected to Spotify' : 'Waiting for Spotify data...'}

{isLoading && (
Thinking...
)}
{/* Messages Area */}
{messages.length === 0 ? (

Start the conversation

Ask for recommendations based on your taste

) : ( messages.map((msg, idx) => (
{msg.role === 'assistant' && (
)}
{msg.role === 'assistant' ? (
{/* Simple markdown-like rendering for newlines */} {msg.content.split('\n').map((line, i) => (

{line}

))}
) : ( msg.content )}
{msg.role === 'user' && (
)}
)) )}
{/* Input Area */}
setInput(e.target.value)} placeholder="Ask for music recommendations..." disabled={isLoading} className="w-full bg-[#282828] text-white pl-4 pr-12 py-3 rounded-full border border-transparent focus:border-spotify-green focus:bg-[#3e3e3e] focus:outline-none transition-all disabled:opacity-50 disabled:cursor-not-allowed" />

AI can make mistakes. Verify important info.

); }