Files
bobinoo/src/components/social/PersonRow.tsx
T
Claude 9974027925
deploy / deploy (push) Successful in 36s
Recherche unifiée (titres, personnes, membres) et pages des acteurs / réalisateurs
- « Ajouter » devient « Rechercher » : un seul champ, onglets Tout / Titres /
  Personnes / Membres (pseudo), ajout manuel conservé.
- Page d'une personne : photo, naissance, biographie, filmographie par métier
  (jeu, doublage, réalisation, scénario, production, autres), tri populaires /
  récents, titres déjà dans la bibliothèque marqués ; TMDB et AniList (doubleurs,
  staff d'anime).
- Casting et réalisateur·rice cliquables sur la fiche ; pile de fenêtres
  (titre → personne → titre…) avec retour cran par cran.
- Proxy tmdb : /search/person, /person/{id}, combined_credits (redéployé).
- 18 langues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
2026-10-10 10:36:07 +00:00

67 lines
2.4 KiB
TypeScript

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 (
<div className="flex items-center gap-3 py-2.5">
<button
onClick={() => {
onOpen?.()
social.openProfile(person.username)
}}
className="flex min-w-0 flex-1 items-center gap-3 text-start"
>
<Avatar url={person.avatarUrl} name={person.displayName} size={44} />
<span className="min-w-0">
<span className="block truncate text-sm font-semibold">{person.displayName}</span>
<span className="flex items-center gap-1 text-xs text-ink-3">
@{person.username}
{person.isPrivate && <Lock size={10} />}
</span>
</span>
</button>
{actions ??
(!isMe && (
<button
onClick={toggle}
disabled={busy}
className={cx(
'flex h-8 shrink-0 items-center gap-1 rounded-full px-3 text-xs font-semibold transition active:scale-95',
relation === 'none' ? 'bg-accent-fill text-on-accent' : 'border border-line-strong text-ink-2',
)}
>
{busy ? <Loader2 size={13} className="animate-spin" /> : relation === 'accepted' ? <Check size={13} /> : null}
{relation === 'accepted' ? t('social.following') : relation === 'pending' ? t('social.requested') : t('social.follow')}
</button>
))}
</div>
)
}