import { useState, useRef, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Send, Bot, User, MessageCircle, Sparkles } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Card } from '@/components/ui/card'; import { ScrollArea } from '@/components/ui/scroll-area'; interface Message { id: number; text: string; isBot: boolean; timestamp: Date; } const ChatbotSection = ({ error, setError }) => { const [messages, setMessages] = useState([ { id: 1, text: "Hello! I'm your AI assistant for resume analysis. Ask me about candidate strengths, skills, or request detailed summaries.", isBot: true, timestamp: new Date() } ]); const [inputText, setInputText] = useState(''); const [isTyping, setIsTyping] = useState(false); const messagesEndRef = useRef(null); const mockResponses = [ "Alex Chen shows exceptional expertise in machine learning with 5+ years of experience in Python and React. His background includes developing AI-powered applications and implementing scalable ML pipelines.", "Sarah Johnson demonstrates strong data science capabilities with proficiency in TensorFlow, SQL, and data visualization. She has led multiple analytics projects and excels in statistical modeling.", "Based on the uploaded resumes, the top candidates for this ML Engineer position are Alex Chen (92% match), Sarah Johnson (88% match), and Michael Rodriguez (85% match). Would you like detailed insights on any specific candidate?", "The skill gap analysis shows that most candidates have strong technical foundations, but may benefit from additional experience in cloud deployment and MLOps practices.", "I can help you analyze candidate qualifications, compare skill sets, generate summaries, or provide insights on the best matches for your requirements." ]; const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); }; useEffect(() => { if (error) { const errorMessage: Message = { id: messages.length + 1, text: `⚠️ Error: ${error}`, isBot: true, timestamp: new Date(), }; setMessages(prev => [...prev, errorMessage]); setError(null); } }, [error, setError, messages.length]); useEffect(() => { scrollToBottom(); }, [messages]); const simulateTyping = async (response: string) => { setIsTyping(true); // Simulate API delay await new Promise(resolve => setTimeout(resolve, 1000 + Math.random() * 1000)); setIsTyping(false); const newMessage: Message = { id: messages.length + 1, text: response, isBot: true, timestamp: new Date() }; setMessages(prev => [...prev, newMessage]); }; const handleSendMessage = async () => { if (!inputText.trim()) return; const userMessage: Message = { id: messages.length + 1, text: inputText, isBot: false, timestamp: new Date() }; setMessages(prev => [...prev, userMessage]); setInputText(''); // Simulate bot response const randomResponse = mockResponses[Math.floor(Math.random() * mockResponses.length)]; await simulateTyping(randomResponse); }; const handleKeyPress = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSendMessage(); } }; const suggestedQuestions = [ "Summarize top candidates' strengths", "What are the top skills across all candidates?", "Compare the top 3 candidates", "Identify skill gaps in the candidate pool" ]; return (
{/* Background Effects */}

AI-Powered
Resume Assistant

Chat with our intelligent assistant to get detailed insights about candidates, skill analyses, and personalized recommendations.

{/* Suggested Questions */}

Quick Questions

{suggestedQuestions.map((question, index) => ( ))}
{/* Chat Interface */}

Resume Analysis Assistant

AI-powered insights at your fingertips

Online
{messages.map((message) => ( {message.isBot && (
)}

{message.text}

{message.timestamp.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}

{!message.isBot && (
)}
))}
{isTyping && (
)}
setInputText(e.target.value)} onKeyPress={handleKeyPress} placeholder="Ask about candidate analysis, skills, or comparisons..." className="flex-1 glass-card border-border/50 focus:border-primary/50" />
); }; export default ChatbotSection;