import React, { useEffect, useState } from 'react'; import { motion } from 'framer-motion'; import { X, Copy, Check, Loader2 } from 'lucide-react'; import { QRCode } from 'react-qrcode-logo'; import AeThexLogo from './AeThexLogo'; import { useAuth } from '@/contexts/SupabaseAuthContext'; import { supabase } from '@/lib/customSupabaseClient'; import toast from 'react-hot-toast'; const backdropVariants = { visible: { opacity: 1 }, hidden: { opacity: 0 } }; const modalVariants = { hidden: { opacity: 0, scale: 0.9, y: 50 }, visible: { opacity: 1, scale: 1, y: 0, transition: { type: 'spring', damping: 25, stiffness: 200 } }, exit: { opacity: 0, scale: 0.9, y: 50, transition: { duration: 0.2 } } }; const PassportModal = ({ onClose }) => { const { user } = useAuth(); const [profile, setProfile] = useState(null); const [loading, setLoading] = useState(true); const [copied, setCopied] = useState(false); useEffect(() => { const fetchProfile = async () => { if (user) { setLoading(true); const { data, error } = await supabase .from('profiles') .select('username, avatar_url, aethex_passport_id, created_at') .eq('id', user.id) .single(); if (error) { console.error('Error fetching profile:', error); toast.error("Failed to load Passport data."); } else { setProfile(data); } setLoading(false); } }; fetchProfile(); }, [user]); const handleCopy = () => { if (profile?.aethex_passport_id) { navigator.clipboard.writeText(profile.aethex_passport_id); setCopied(true); toast.success("Passport ID Copied!"); setTimeout(() => setCopied(false), 2000); } }; return ( e.stopPropagation()} >
User Avatar

{profile?.username || 'Loading...'}

{user?.email}

{loading ? (
) : (

Passport ID

{profile?.aethex_passport_id}

Member Since

{profile ? new Date(profile.created_at).toLocaleDateString() : '...'}

)}
); }; export default PassportModal;