import { useState } from 'react'; import { createPortal } from 'react-dom'; import { motion, AnimatePresence } from 'framer-motion'; import { Mail, Phone, Building2, User, X, BookOpen, ChevronRight, Monitor, Command, GraduationCap, Briefcase, Microscope, Clock } from 'lucide-react'; import type { Faculty } from '@/types'; interface FacultyCardProps { faculty: Faculty; } const AVATAR_COLORS = [ ['#F97316', '#FB923C'], ['#8B5CF6', '#A78BFA'], ['#10B981', '#34D399'], ['#3B82F6', '#60A5FA'], ['#EC4899', '#F472B6'], ['#F59E0B', '#FCD34D'], ]; export default function FacultyCard({ faculty }: FacultyCardProps) { const [showModal, setShowModal] = useState(false); const [showEmailOptions, setShowEmailOptions] = useState(false); const colorIndex = parseInt(faculty.id) % AVATAR_COLORS.length; const [from, to] = AVATAR_COLORS[colorIndex]; const initials = faculty.name .split(' ') .filter((_, i) => i === 0 || i === faculty.name.split(' ').length - 1) .map((n) => n[0]) .join(''); const mailOptions = [ { name: 'Default Mail App', url: `mailto:${faculty.email}`, icon: Monitor, color: 'text-gray-700', bg: 'bg-gray-100' }, { name: 'Gmail', url: `https://mail.google.com/mail/?view=cm&fs=1&to=${faculty.email}`, icon: Mail, color: 'text-red-500', bg: 'bg-red-50' }, { name: 'Outlook', url: `https://outlook.office.com/mail/deeplink/compose?to=${faculty.email}`, icon: Mail, color: 'text-blue-600', bg: 'bg-blue-50' }, { name: 'Yahoo Mail', url: `https://compose.mail.yahoo.com/?to=${faculty.email}`, icon: Mail, color: 'text-purple-600', bg: 'bg-purple-50' }, ]; return ( <> {/* Avatar + Name */}
{initials}
{/* Online Indicator */}

{faculty.name}

{faculty.designation}

{/* Details */}
{faculty.department}
{/* Contact & Actions */}
{/* Profile Modal */} {createPortal( {showModal && (
setShowModal(false)} className="absolute inset-0 bg-[#0F172A]/40 backdrop-blur-sm" />
{/* LEFT PANEL */}
{initials}

{faculty.name}

{faculty.designation}

{faculty.department}


{faculty.phone && (

Phone Number

{faculty.phone}

)}
{/* RIGHT PANEL */}
{/* Section 1: Professional Details */}

Professional Details

Department

{faculty.department}

Specialization

{faculty.specialization || 'Not specified'}

Qualification

{faculty.qualification || 'Not specified'}

Experience

{faculty.experience || 'Not specified'}

{faculty.joinedInstitution && (

Joined Institution

{faculty.joinedInstitution}

)}
{/* Section 2: Academic Info */}

Academic Information

Subjects Handling

{faculty.subjectsHandling || 'Not specified'}

Research Areas

{faculty.researchAreas || 'Not specified'}

{faculty.studentsGuided && (

Students Guided

{faculty.studentsGuided.ug} UG
{faculty.studentsGuided.pg} PG
{faculty.studentsGuided.phd} Ph.D.
)}
{/* Section 3: Achievements (Render only if present) */} {(faculty.achievements || faculty.publications) && (

Achievements

{faculty.achievements && faculty.achievements.length > 0 && (

Awards & Certifications

    {faculty.achievements.map((ach, i) => (
  • {ach}
  • ))}
)} {faculty.publications && faculty.publications.length > 0 && (

Recent Publications

    {faculty.publications.map((pub, i) => (
  • {pub}
  • ))}
)}
)} {/* Section 4: Office Info */}

Office Information

Office Hours

{faculty.officeHours || 'Not specified'}

Office Location

{faculty.office || 'Not specified'}

)}
, document.body )} {/* Email Options Modal */} {createPortal( {showEmailOptions && (
setShowEmailOptions(false)} className="absolute inset-0 bg-[#0F172A]/40 backdrop-blur-sm" />

Choose Mail App

Compose email to {faculty.name}

)}
, document.body )} ); }