import { useState } from 'react' import { useQuery } from '@tanstack/react-query' import { Tab } from '@headlessui/react' import api from '../lib/api' import { formatCityState } from '../utils/formatters' import { UserIcon, BuildingLibraryIcon, HeartIcon, Cog6ToothIcon } from '@heroicons/react/24/outline' import { useAuth } from '../contexts/AuthContext' import SocialStats from '../components/SocialStats' import FollowButton from '../components/FollowButton' interface Leader { id: number name: string slug: string title?: string photo_url?: string office?: string city?: string state?: string follower_count: number is_verified: boolean } interface Organization { master_org_id: string name: string description?: string logo_url?: string org_type?: string city?: string state?: string follower_count: number is_verified?: boolean } interface Tag { tag_id: string label?: string description?: string category?: string breadcrumb?: string icon?: string follower_count: number } function classNames(...classes: string[]) { return classes.filter(Boolean).join(' ') } export default function Profile() { const { user } = useAuth() const [selectedTab, setSelectedTab] = useState(0) const { data: leadersFollowing } = useQuery({ queryKey: ['following', 'leaders'], queryFn: async () => { const response = await api.get('/social/following/leaders') return response.data }, enabled: !!user }) const { data: orgsFollowing } = useQuery({ queryKey: ['following', 'organizations'], queryFn: async () => { const response = await api.get('/social/following/organizations') return response.data }, enabled: !!user }) const { data: tagsFollowing } = useQuery({ queryKey: ['following', 'tags'], queryFn: async () => { const response = await api.get('/social/following/tags') return response.data }, enabled: !!user }) if (!user) { return (

Please sign in

You need to be signed in to view your profile

) } return (
{/* Profile Header */}
{/* Avatar */}
{user.avatar_url ? ( {user.full_name ) : (
{(user.full_name || user.email).charAt(0).toUpperCase()}
)}
{/* Profile Info */}

{user.full_name || 'Community Member'}

{user.email}

{user.city && user.state && (

📍 {user.city}, {user.state}

)} {/* Social Stats */}
{/* Edit Profile Button */} Edit Profile
{/* Following Tabs */}

Following

classNames( 'px-4 py-2 font-medium text-sm border-b-2 transition-colors', selected ? 'border-[#354F52] text-[#354F52]' : 'border-transparent text-gray-500 hover:text-gray-700' ) } >
Leaders ({leadersFollowing?.length || 0})
classNames( 'px-4 py-2 font-medium text-sm border-b-2 transition-colors', selected ? 'border-[#354F52] text-[#354F52]' : 'border-transparent text-gray-500 hover:text-gray-700' ) } >
Charities ({orgsFollowing?.length || 0})
classNames( 'px-4 py-2 font-medium text-sm border-b-2 transition-colors', selected ? 'border-[#354F52] text-[#354F52]' : 'border-transparent text-gray-500 hover:text-gray-700' ) } >
Tags ({tagsFollowing?.length || 0})
{/* Leaders */} {!leadersFollowing || leadersFollowing.length === 0 ? (

You're not following any leaders yet

Find leaders to follow →
) : (
{leadersFollowing.map((leader) => (
{leader.photo_url ? ( {leader.name} ) : (
{leader.name.charAt(0)}
)}

{leader.name} {leader.is_verified && }

{leader.title &&

{leader.title}

} {leader.office &&

{leader.office}

} {leader.city && leader.state && (

{formatCityState(leader.city, leader.state)}

)}

{leader.follower_count.toLocaleString()} followers

))}
)}
{/* Organizations */} {!orgsFollowing || orgsFollowing.length === 0 ? (

You're not following any charities yet

Find charities to follow →
) : (
{orgsFollowing.map((org) => (
{org.logo_url ? ( {org.name} ) : (
{org.name.charAt(0)}
)}

{org.name} {org.is_verified && }

{org.org_type && ( {org.org_type} )} {org.description && (

{org.description}

)} {org.city && org.state && (

{formatCityState(org.city, org.state)}

)}

{org.follower_count.toLocaleString()} followers

))}
)}
{/* Tags */} {!tagsFollowing || tagsFollowing.length === 0 ? (

You're not following any tags yet

Explore tags →
) : (
{tagsFollowing.map((tag) => (

{tag.label || tag.tag_id}

{tag.breadcrumb && (

{tag.breadcrumb}

)} {tag.description && (

{tag.description}

)} {tag.category && ( {tag.category} )}

{tag.follower_count.toLocaleString()} followers

))}
)}
) }