import React, { useState, ChangeEvent, useContext } from 'react'; import { Camera, Edit3, Save, X, Calendar, Globe } from 'lucide-react'; import { UserProfile } from '../types/user'; import { ThemeContext } from '../contexts/ThemeContext'; interface ProfileHeaderProps { user: UserProfile; isEditing: boolean; editForm: any; setEditForm: (form: any) => void; onEdit: () => void; onSave: () => void; onCancel: () => void; onAvatarChange: (file: File) => void; } const ProfileHeader: React.FC = ({ user, isEditing, editForm, setEditForm, onEdit, onSave, onCancel, onAvatarChange, }) => { const { theme } = useContext(ThemeContext); // ✅ ThemeContext const [avatarPreview, setAvatarPreview] = useState(user.avatar); const handleAvatarUpload = (e: ChangeEvent) => { if (e.target.files?.[0]) { const file = e.target.files[0]; setAvatarPreview(URL.createObjectURL(file)); onAvatarChange(file); } }; // Inputs still adapt to theme const inputBg = theme === 'dark' ? 'bg-gray-800 text-white placeholder-gray-400' : 'bg-gray-100 text-gray-900 placeholder-gray-500'; return (
{/* Gradient Background */}
{/* Avatar */}
{`${user.name
{/* Name, Email, Username, Bio */}
{isEditing ? (
setEditForm({ ...editForm, name: e.target.value })} className={`px-4 py-3 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent ${inputBg}`} placeholder="Full Name" /> setEditForm({ ...editForm, nickname: e.target.value })} className={`px-4 py-3 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent ${inputBg}`} placeholder="Nickname" />