import React, { useState, useEffect } from 'react';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { Avatar } from 'lucide-react';
// AI Tutor Avatar Component
const TutorAvatar = ({ state = 'neutral', speaking = false }) => {
const [isBlinking, setIsBlinking] = useState(false);
useEffect(() => {
const blinkInterval = setInterval(() => {
setIsBlinking(true);
setTimeout(() => setIsBlinking(false), 200);
}, Math.random() * 4000 + 2000);
return () => clearInterval(blinkInterval);
}, []);
return (
);
};
// Chat Message Component
const ChatMessage = ({ message, role }) => (
);
// Learning Module Component
const LearningModule = ({ module, onComplete }) => (
{module.name}
Introduction
{module.content.introduction}
Key Points
{module.content.key_points.map((point, idx) => (
- {point}
))}
Examples
{module.content.examples.map((example, idx) => (
- {example}
))}
Practice Problems
{module.content.practice_problems.map((problem, idx) => (
- {problem}
))}
);
// Main App Component
const App = () => {
const [activeTab, setActiveTab] = useState('learning');
const [messages, setMessages] = useState([]);
const [userInput, setUserInput] = useState('');
const [tutorState, setTutorState] = useState('neutral');
const [selectedPath, setSelectedPath] = useState(null);
// Simulated learning paths data (would come from API)
const learningPaths = {
'physics_mechanics': {
name: 'Classical Mechanics',
// ... rest of the data structure
},
'ai_fundamentals': {
name: 'AI Fundamentals',
// ... rest of the data structure
}
};
const handleSendMessage = async () => {
if (!userInput.trim()) return;
// Add user message
setMessages(prev => [...prev, { role: 'user', content: userInput }]);
setTutorState('thinking');
try {
// API call to get AI response
const response = await fetch('/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ message: userInput })
});
const data = await response.json();
// Add AI response
setMessages(prev => [...prev, { role: 'assistant', content: data.response }]);
setTutorState('happy');
} catch (error) {
console.error('Error:', error);
setTutorState('neutral');
}
setUserInput('');
};
return (
📚 Learning Paths
🤖 AI Tutor
💻 Code Playground
{/* Learning Paths Content */}
{Object.entries(learningPaths).map(([id, path]) => (
{path.name}
{/* Add learning path content */}
))}
{/* AI Tutor Content */}
{/* Code Playground Content */}
);
};
export default App;