import { useQuery } from '@tanstack/react-query' import api from '../lib/api' import { UserGroupIcon, UserPlusIcon } from '@heroicons/react/24/outline' import { Link } from 'react-router-dom' interface SocialStatsProps { userId?: number showBreakdown?: boolean clickable?: boolean } interface FollowerStats { followers: number following: number following_users: number following_leaders: number following_organizations: number following_causes: number } export default function SocialStats({ userId, showBreakdown = false, clickable = true }: SocialStatsProps) { const { data: stats, isLoading } = useQuery({ queryKey: ['social', 'stats', userId], queryFn: async () => { const params = userId ? `?user_id=${userId}` : '' const response = await api.get(`/social/stats${params}`) return response.data } }) if (isLoading) { return (
) } if (!stats) return null const StatsContent = () => ( <> {/* LinkedIn-style stat display */}
{stats.followers.toLocaleString()} {stats.followers === 1 ? 'Follower' : 'Followers'}
{stats.following.toLocaleString()} Following
{/* Breakdown of what they're following */} {showBreakdown && stats.following > 0 && (
{stats.following_leaders > 0 && (
{stats.following_leaders}
Leaders
)} {stats.following_organizations > 0 && (
{stats.following_organizations}
Charities
)} {stats.following_causes > 0 && (
{stats.following_causes}
Causes
)} {stats.following_users > 0 && (
{stats.following_users}
People
)}
)} ) if (clickable) { return ( ) } return }