/** * Following lists (Leaders / Charities / Tags) — used under Settings → Person (#674). * Moved from Profile so following is managed in Settings tabs. */ import { useState } from 'react' import { useQuery } from '@tanstack/react-query' import { Tab } from '@headlessui/react' import { UserIcon, BuildingLibraryIcon, HeartIcon, } from '@heroicons/react/24/outline' import api from '../../lib/api' import { formatCityState } from '../../utils/formatters' import FollowButton from '../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 follower_count: number } function classNames(...classes: string[]) { return classes.filter(Boolean).join(' ') } export default function SettingsFollowing() { const [selectedTab, setSelectedTab] = useState(0) const { data: leadersFollowing } = useQuery({ queryKey: ['following', 'leaders'], queryFn: async () => (await api.get('/social/following/leaders')).data, }) const { data: orgsFollowing } = useQuery({ queryKey: ['following', 'organizations'], queryFn: async () => (await api.get('/social/following/organizations')).data, }) const { data: tagsFollowing } = useQuery({ queryKey: ['following', 'tags'], queryFn: async () => (await api.get('/social/following/tags')).data, }) const tabCls = ({ selected }: { selected: boolean }) => classNames( 'px-3 py-2 font-medium text-sm border-b-2 transition-colors whitespace-nowrap', selected ? 'border-[#354F52] text-[#354F52]' : 'border-transparent text-gray-500 hover:text-gray-700', ) return (

Following

People, charities, and tags you follow

Leaders ({leadersFollowing?.length ?? 0}) Charities ({orgsFollowing?.length ?? 0}) Tags ({tagsFollowing?.length ?? 0}) {!leadersFollowing?.length ? ( } message="You're not following any leaders yet" href="/people" linkLabel="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.city && leader.state && (

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

)}
))}
)}
{!orgsFollowing?.length ? ( } message="You're not following any charities yet" href="/nonprofits" linkLabel="Find charities to follow →" /> ) : (
{orgsFollowing.map((org) => (
{org.logo_url ? ( {org.name} ) : (
{org.name.charAt(0)}
)}

{org.name}

{org.description && (

{org.description}

)}
))}
)}
{!tagsFollowing?.length ? ( } message="You're not following any tags yet" href="/" linkLabel="Explore tags →" /> ) : (
{tagsFollowing.map((tag) => (

{tag.label || tag.tag_id}

{tag.breadcrumb && (

{tag.breadcrumb}

)}
))}
)}
) } function Empty({ icon, message, href, linkLabel, }: { icon: React.ReactNode message: string href: string linkLabel: string }) { return (
{icon}

{message}

{linkLabel}
) }