import React, { useEffect, useRef } from 'react'; import { StaffBadge, CertifiedBadge, BugHunterBadge, VerifiedBotBadge } from './Badges'; interface MiniProfileProps { user: { name: string; avatarUrl: string; isBot: boolean; username: string; color: string; theme?: string; bannerUrl?: string; }; position: { x: number, y: number }; onClose: () => void; onOpenFullProfile: (user: any) => void; } const MiniProfile: React.FC = ({ user, position, onClose, onOpenFullProfile }) => { const ref = useRef(null); useEffect(() => { const handleClickOutside = (event: MouseEvent) => { if (ref.current && !ref.current.contains(event.target as Node)) { onClose(); } }; document.addEventListener('mousedown', handleClickOutside); return () => document.removeEventListener('mousedown', handleClickOutside); }, [onClose]); const style: React.CSSProperties = { top: Math.min(position.y, window.innerHeight - 400), // Prevent going off bottom left: position.x + 20, // Offset to right background: user.theme || '#232428' }; const handleAvatarClick = () => { onClose(); // Close mini profile onOpenFullProfile(user); // Open full profile }; return (
{/* Banner */}
{/* Avatar */}
{user.name}
VIEW PROFILE
{/* Badges */} {user.isBot && (
)} {!user.isBot &&
} {/* Info */}
{user.name} {user.isBot && }
{user.username}
About Me
{user.isBot ? "I am a helpful AI assistant residing in your Discord DMs." : "Just a human chatting with an AI."}
Member Since
Feb 21, 2024
); }; export default MiniProfile;