import { useState, useRef, useEffect } from 'react'; import { Upload, MessageSquare, Home, Star, Check } from 'lucide-react'; type AnalysisResult = { skinCondition: string; hairHealth: string; eyeHealth: string; posture: string; overallGlow: number; }; type DailyRoutine = { morning: string[]; afternoon: string[]; evening: string[]; }; type ChatMessage = { sender: 'user' | 'ai'; text: string; timestamp: Date; }; export default function Faceify() { const [activeTab, setActiveTab] = useState<'home' | 'chat'>('home'); const [image, setImage] = useState(null); const [isAnalyzing, setIsAnalyzing] = useState(false); const [analysis, setAnalysis] = useState(null); const [routine, setRoutine] = useState(null); const [chatMessages, setChatMessages] = useState([]); const [userMessage, setUserMessage] = useState(''); const fileInputRef = useRef(null); const chatContainerRef = useRef(null); // Scroll chat to bottom when new messages arrive useEffect(() => { if (chatContainerRef.current) { chatContainerRef.current.scrollTop = chatContainerRef.current.scrollHeight; } }, [chatMessages]); const handleImageUpload = (e: React.ChangeEvent) => { const file = e.target.files?.[0]; if (file) { const reader = new FileReader(); reader.onload = (event) => { setImage(event.target?.result as string); analyzeImage(); }; reader.readAsDataURL(file); } }; const analyzeImage = () => { setIsAnalyzing(true); // Mock analysis - in a real app this would be an API call setTimeout(() => { const mockAnalysis: AnalysisResult = { skinCondition: ['Dry', 'Oily', 'Normal', 'Combination'][Math.floor(Math.random() * 4)], hairHealth: ['Healthy', 'Dry', 'Oily', 'Damaged'][Math.floor(Math.random() * 4)], eyeHealth: ['Bright', 'Tired', 'Puffy', 'Dark circles'][Math.floor(Math.random() * 4)], posture: ['Good', 'Fair', 'Poor', 'Excellent'][Math.floor(Math.random() * 4)], overallGlow: Math.floor(Math.random() * 5) + 1 }; setAnalysis(mockAnalysis); generateRoutine(mockAnalysis); setIsAnalyzing(false); }, 2000); }; const generateRoutine = (analysis: AnalysisResult) => { const mockRoutine: DailyRoutine = { morning: [ 'Cleanse face with gentle cleanser', 'Apply moisturizer with SPF', analysis.hairHealth === 'Dry' ? 'Use hydrating hair mask' : 'Use regular conditioner' ], afternoon: [ 'Reapply sunscreen if going outside', 'Drink at least 8oz of water', analysis.eyeHealth === 'Tired' ? 'Use cooling eye patches' : 'Take a short break from screens' ], evening: [ 'Double cleanse face', 'Apply night cream', analysis.skinCondition === 'Oily' ? 'Use oil-free moisturizer' : 'Use hydrating serum', 'Practice good posture exercises' ] }; setRoutine(mockRoutine); }; const handleSendMessage = () => { if (!userMessage.trim()) return; const newUserMessage: ChatMessage = { sender: 'user', text: userMessage, timestamp: new Date() }; setChatMessages(prev => [...prev, newUserMessage]); setUserMessage(''); // Mock AI response setTimeout(() => { const aiResponses = [ "Based on your analysis, I recommend focusing on hydration for your skin.", "Your hair health could benefit from weekly deep conditioning treatments.", "For better posture, try these exercises: shoulder rolls, chin tucks, and wall angels.", "To improve your glow, consider adding vitamin C serum to your routine.", "Your eye health suggests you might need more sleep. Aim for 7-8 hours nightly." ]; const newAiMessage: ChatMessage = { sender: 'ai', text: aiResponses[Math.floor(Math.random() * aiResponses.length)], timestamp: new Date() }; setChatMessages(prev => [...prev, newAiMessage]); }, 1000); }; const resetAnalysis = () => { setImage(null); setAnalysis(null); setRoutine(null); if (fileInputRef.current) { fileInputRef.current.value = ''; } }; return (
{/* Header */}

Faceify

{activeTab === 'home' ? (
{/* Upload Section */}

Upload Your Photo

Upload a clear selfie or full-body photo for analysis. Your photo is processed locally and never stored on our servers.

{!image ? (

Or drag and drop your image here

) : (
Uploaded preview {isAnalyzing && (
)}
)}
{/* Analysis Results */} {analysis && (

Your Analysis Results

Based on our AI assessment of your uploaded image

{analysis.skinCondition}
{analysis.hairHealth}
{analysis.eyeHealth}
{analysis.posture}
{[...Array(5)].map((_, i) => ( ))}
)} {/* Daily Routine */} {routine && (

Your Personalized Daily Routine

Recommendations based on your analysis

Morning

    {routine.morning.map((item, i) => (
  • {item}
  • ))}

Afternoon

    {routine.afternoon.map((item, i) => (
  • {item}
  • ))}

Evening

    {routine.evening.map((item, i) => (
  • {item}
  • ))}
)}
) : ( /* Chat Assistant */

AI Wellness Assistant

Ask any questions about your grooming, styling, or wellness routine

{chatMessages.length === 0 ? (

Ask our AI assistant about your wellness routine

) : ( chatMessages.map((message, i) => (
{message.text}
)) )}