import { Check, Loader2, Lock } from 'lucide-react' import { useState, type ReactNode } from 'react' import { t } from '../../i18n' import { follow, unfollow, type ProfileCard } from '../../lib/cloud/social' import { cx } from '../../lib/utils' import Avatar from './Avatar' import { useSocial } from './SocialProvider' /** Ligne « personne » : photo, nom, @pseudo, et bouton d'abonnement (ou actions personnalisées). */ export default function PersonRow({ person, actions, onOpen }: { person: ProfileCard; actions?: ReactNode; /** Appelé juste avant d'ouvrir le profil */ onOpen?: () => void }) { const social = useSocial() const [relation, setRelation] = useState(person.relation) const [busy, setBusy] = useState(false) const isMe = social.me?.id === person.id const toggle = async () => { setBusy(true) try { if (relation === 'none') setRelation(await follow(person.id)) else { await unfollow(person.id) setRelation('none') } void social.refresh() } catch { /* réseau : rien ne change */ } finally { setBusy(false) } } return (
{actions ?? (!isMe && ( ))}
) }