Stats : page vidée en attendant la refonte (« Soon »)
deploy / deploy (push) Successful in 37s

La page Statistiques (graphiques, records, pays, « Moi vs le public »…) est
retirée ; l'onglet reste, avec seulement « Soon ». Supprime aussi
Disagreements.tsx et lib/publicRatings.ts, qui ne servaient qu'à elle.
lib/stats.ts est gardé (accueil, journal).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
Claude committed 2026-10-09 07:09:28 +00:00
1 parent 618fd66e09
commit 88287fe18d
3 files changed
+7 -655

No files matched your search

-143
View File
@@ -1,143 +0,0 @@
import { t } from '../i18n'
import { Loader2, RefreshCw } from 'lucide-react'
import { useMemo, useState } from 'react'
import { fetchPublicRatings, missingPublic } from '../lib/publicRatings'
import { cx, formatRating } from '../lib/utils'
import { useMedia } from '../store'
import type { MediaItem, RatingScale } from '../types'
import Poster from './Poster'
import { SectionTitle } from './ui'
/** Écart signé, arrondi au dixième dans l'échelle choisie (« 0 » plutôt que « +0,0 »). */
const signed = (v: number, scale: RatingScale) => {
const r = Math.round((scale === '5' ? v / 2 : v) * 10) / 10
if (r === 0) return '0'
return `${r > 0 ? '+' : '−'}${String(Math.abs(r)).replace('.', t('common.decimalSep'))}`
}
function Row({ item, scale }: { item: MediaItem; scale: RatingScale }) {
const gap = item.rating! - item.publicRating!
// barre centrée : moitié gauche = moins aimé, moitié droite = plus aimé (écart max affiché : 5 points /10)
const width = Math.min(50, (Math.abs(gap) / 5) * 50)
return (
<li className="flex items-center gap-3 py-2.5">
<div className="w-9 shrink-0">
<Poster src={item.poster} title={item.title} />
</div>
<div className="min-w-0 flex-1">
<p className="truncate text-sm font-semibold">{item.title}</p>
<p className="text-[11px] text-ink-3">
{t('public.me')} <span className="text-ink-2">{formatRating(item.rating, scale)}</span> · {t('public.label')} <span className="text-ink-2">{formatRating(item.publicRating, scale)}</span>
</p>
<div className="relative mt-1.5 h-1.5 rounded-full bg-surface-2">
<span className="absolute inset-y-0 start-1/2 w-px bg-line" />
<span
className={cx('absolute inset-y-0 rounded-full', gap >= 0 ? 'bg-accent' : 'bg-ink-3')}
style={gap >= 0 ? { left: '50%', width: `${width}%` } : { right: '50%', width: `${width}%` }}
/>
</div>
</div>
<span className={cx('w-11 shrink-0 text-end text-sm font-bold tabular-nums', gap >= 0 ? 'text-accent' : 'text-ink-2')}>{signed(gap, scale)}</span>
</li>
)
}
/** Stats « Moi vs le public » : écarts entre mes notes et la moyenne TMDB / AniList. */
export default function Disagreements({ scoped }: { scoped: MediaItem[] }) {
const { items, settings, patchMany } = useMedia()
const scale = settings.ratingScale
const [progress, setProgress] = useState<[number, number]>()
const [message, setMessage] = useState<string>()
const compared = useMemo(() => scoped.filter((i) => i.rating != null && i.publicRating != null), [scoped])
const rated = useMemo(() => items.filter((i) => i.rating != null), [items])
const missing = useMemo(() => missingPublic(rated, settings.tmdbKey).length, [rated, settings.tmdbKey, progress])
const run = async () => {
if (!navigator.onLine) return setMessage(t('common.offline'))
setMessage(undefined)
setProgress([0, missing])
try {
const patches = await fetchPublicRatings(rated, settings.tmdbKey, (done, total) => setProgress([done, total]))
if (patches.length) await patchMany(patches)
setMessage(patches.length ? t('public.added', { count: patches.length }) : t('public.noneFound'))
} finally {
setProgress(undefined)
}
}
const gaps = compared.map((i) => i.rating! - i.publicRating!)
const avg = gaps.length ? gaps.reduce((a, b) => a + b, 0) / gaps.length : 0
const agree = gaps.length ? Math.round((gaps.filter((g) => Math.abs(g) <= 1).length / gaps.length) * 100) : 0
const sorted = [...compared].sort((a, b) => b.rating! - b.publicRating! - (a.rating! - a.publicRating!))
const loved = sorted.filter((i) => i.rating! - i.publicRating! >= 1).slice(0, 5)
const hated = sorted.filter((i) => i.rating! - i.publicRating! <= -1).reverse().slice(0, 5)
const fetchButton =
missing > 0 || progress ? (
<button onClick={run} disabled={!!progress} className="flex shrink-0 items-center gap-1.5 text-xs font-medium text-ink-3 transition-colors hover:text-ink">
{progress ? <Loader2 size={13} className="animate-spin" /> : <RefreshCw size={13} className="text-accent" />}
{progress ? `${progress[0]}/${progress[1]}` : t('public.fetch', { n: missing })}
</button>
) : undefined
return (
<>
<SectionTitle action={fetchButton}>{t('public.title')}</SectionTitle>
{message && <p className="-mt-2 mb-3 text-xs text-ink-3">{message}</p>}
{compared.length === 0 ? (
<p className="text-sm text-ink-3">
{missing > 0
? t('public.hintFetch')
: settings.tmdbKey
? t('public.hintNone')
: t('public.hintKey')}
</p>
) : (
<>
<div className="grid grid-cols-2 gap-3">
<div className="card p-4">
<div className="eyebrow">{t('public.avgGap')}</div>
<div className={cx('mt-2 text-2xl font-bold leading-none tabular-nums', avg >= 0.3 && 'text-accent')}>{signed(avg, scale)}</div>
<div className="mt-1.5 text-xs text-ink-3">{Math.abs(avg) < 0.3 ? t('public.average') : avg > 0 ? t('public.generous') : t('public.harsh')}</div>
</div>
<div className="card p-4">
<div className="eyebrow">{t('public.agreeTitle')}</div>
<div className="mt-2 text-2xl font-bold leading-none tabular-nums">{agree} %</div>
<div className="mt-1.5 text-xs text-ink-3">
{scale === '5' ? t('public.within5', { count: compared.length }) : t('public.within10', { count: compared.length })}
</div>
</div>
</div>
{loved.length > 0 && (
<div className="card mt-3 px-4 pb-1.5 pt-4">
<h3 className="text-sm font-semibold">
{t('public.lovedPre')}<span className="text-accent">{t('public.lovedAccent')}</span>{t('public.lovedPost')}
</h3>
<ul className="divide-y divide-line">
{loved.map((i) => (
<Row key={i.id} item={i} scale={scale} />
))}
</ul>
</div>
)}
{hated.length > 0 && (
<div className="card mt-3 px-4 pb-1.5 pt-4">
<h3 className="text-sm font-semibold">
{t('public.hatedPre')}<span className="text-ink-2">{t('public.hatedAccent')}</span>{t('public.hatedPost')}
</h3>
<ul className="divide-y divide-line">
{hated.map((i) => (
<Row key={i.id} item={i} scale={scale} />
))}
</ul>
</div>
)}
{!loved.length && !hated.length && <p className="mt-3 text-sm text-ink-3">{t('public.allAgree')}</p>}
</>
)}
</>
)
}
-90
View File
@@ -1,90 +0,0 @@
import type { MediaInput, MediaItem } from '../types'
import { getAniListPublicRatings, getTmdbPublicRating } from './catalogApi'
import { isSafeExternalId, readStorage } from './security'
/**
* Récupère la note moyenne du public (TMDB / AniList) pour les fiches qui n'en ont pas.
* Les titres sans note fiable (trop peu de votes) sont mémorisés pour ne pas être redemandés à chaque fois.
*/
const CHECKED_KEY = 'azuucine:public-checked'
const RECHECK_MS = 30 * 24 * 3600 * 1000
function loadChecked(): Record<string, number> {
const raw = readStorage(CHECKED_KEY, {})
const out: Record<string, number> = {}
if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
for (const [k, v] of Object.entries(raw as Record<string, unknown>)) if (typeof v === 'number') out[k] = v
}
return out
}
function saveChecked(c: Record<string, number>) {
try {
localStorage.setItem(CHECKED_KEY, JSON.stringify(c))
} catch {
/* ignore */
}
}
/** Fiches notées par moi, reliées à une base, sans note publique (et pas vérifiées récemment). */
export function missingPublic(items: MediaItem[], tmdbKey?: string): MediaItem[] {
const checked = loadChecked()
const now = Date.now()
return items.filter(
(i) =>
i.publicRating == null &&
isSafeExternalId(i.externalId) &&
(i.externalId.startsWith('anilist:') || !!tmdbKey) &&
!(checked[i.id] && now - checked[i.id] < RECHECK_MS),
)
}
export async function fetchPublicRatings(
items: MediaItem[],
tmdbKey: string | undefined,
onProgress?: (done: number, total: number) => void,
): Promise<{ id: string; patch: Partial<MediaInput> }[]> {
const todo = missingPublic(items, tmdbKey).slice(0, 400)
const patches: { id: string; patch: Partial<MediaInput> }[] = []
const checked = loadChecked()
let done = 0
const total = todo.length
const ani = todo.filter((i) => i.externalId!.startsWith('anilist:'))
if (ani.length) {
try {
const map = await getAniListPublicRatings(ani.map((i) => Number(i.externalId!.split(':')[1])))
for (const i of ani) {
const r = map.get(Number(i.externalId!.split(':')[1]))
if (r) patches.push({ id: i.id, patch: { publicRating: r } })
checked[i.id] = Date.now()
}
} catch {
/* réseau : on réessaiera */
}
done += ani.length
onProgress?.(done, total)
}
if (tmdbKey) {
const tmdb = todo.filter((i) => i.externalId!.startsWith('tmdb:'))
for (let k = 0; k < tmdb.length; k += 4) {
await Promise.all(
tmdb.slice(k, k + 4).map(async (i) => {
try {
const r = await getTmdbPublicRating(i.externalId!, tmdbKey)
if (r) patches.push({ id: i.id, patch: { publicRating: r } })
checked[i.id] = Date.now()
} catch {
/* ignore ce titre */
}
}),
)
done += tmdb.slice(k, k + 4).length
onProgress?.(done, total)
}
}
saveChecked(checked)
return patches
}
+7 -422
View File
@@ -1,429 +1,14 @@
import { genreLabel } from '../lib/genres' import { t } from '../i18n'
import { locale, t } from '../i18n' import { PageHeader } from '../components/ui'
import { Star } from 'lucide-react'
import { useMemo, useState, type ReactNode } from 'react'
import Disagreements from '../components/Disagreements'
import Poster from '../components/Poster'
import { EmptyState, PageHeader, SectionTitle } from '../components/ui'
import { MEDIA_TYPES, STATUSES } from '../lib/constants'
import { availableYears, computeStats, countries, itemsForPeriod, monthly, records, watchMinutes } from '../lib/stats'
import { cx, formatDuration, formatRating } from '../lib/utils'
import { useMedia } from '../store'
import type { MediaItem, MediaType } from '../types'
/** Couleurs des types (palette catégorielle validée pour fond sombre, ordre fixe). */
const TYPE_COLORS: Record<MediaType, string> = {
film: '#3987e5',
serie: '#d95926',
anime: '#199e70',
kdrama: '#c98500',
cdrama: '#d55181',
autre: '#008300',
}
type Tab = 'overview' | 'habits' | 'tastes'
const TABS: { value: Tab; readonly label: string }[] = [
{ value: 'overview', get label() { return t('stats.overview') } },
{ value: 'habits', get label() { return t('stats.habits') } },
{ value: 'tastes', get label() { return t('stats.tastes') } },
]
const fmtInt = (n: number) => n.toLocaleString(locale())
/** Colonnes verticales d'une seule couleur ; toucher une colonne affiche sa valeur. */
function Columns({
data,
format,
height = 140,
selected,
onSelect,
}: {
data: { key: string; label: string; value: number }[]
format: (v: number) => string
height?: number
selected?: string
onSelect: (key: string) => void
}) {
const max = Math.max(1, ...data.map((d) => d.value))
return (
<div>
<div className="flex items-end gap-1.5" style={{ height }}>
{data.map((d) => {
const on = d.key === selected
return (
<button
key={d.key}
onClick={() => onSelect(d.key)}
className="group relative flex h-full flex-1 items-end"
aria-label={`${d.label} : ${format(d.value)}`}
title={`${d.label} : ${format(d.value)}`}
>
<span
className={cx('w-full rounded-t-[4px] transition-colors', on ? 'bg-accent' : 'bg-accent/45')}
style={{ height: `${(d.value / max) * 100}%`, minHeight: d.value ? 3 : 0 }}
/>
</button>
)
})}
</div>
<div className="mt-2 flex gap-1.5 border-t border-line pt-1.5">
{data.map((d) => (
<span key={d.key} className={cx('flex-1 text-center text-[10px]', d.key === selected ? 'font-semibold text-ink' : 'text-ink-3')}>
{d.label}
</span>
))}
</div>
</div>
)
}
function Tile({ label, value, hint }: { label: string; value: ReactNode; hint?: string }) {
return (
<div className="card p-4">
<div className="eyebrow">{label}</div>
<div className="mt-2 text-2xl font-bold leading-none tabular-nums">{value}</div>
{hint && <div className="mt-1.5 text-xs text-ink-3">{hint}</div>}
</div>
)
}
function MiniPoster({ item, caption }: { item: MediaItem; caption: string }) {
return (
<div className="flex items-center gap-3">
<div className="w-12 shrink-0">
<Poster src={item.poster} title={item.title} />
</div>
<div className="min-w-0">
<p className="truncate text-sm font-semibold">{item.title}</p>
<p className="text-xs text-ink-3">{caption}</p>
</div>
</div>
)
}
/** Statistiques : en cours de refonte complète. */
export default function StatsPage() { export default function StatsPage() {
const { items, settings, loading } = useMedia()
const scale = settings.ratingScale
const years = useMemo(() => availableYears(items), [items])
const [year, setYear] = useState('')
const [tab, setTab] = useState<Tab>('overview')
const [metric, setMetric] = useState<'count' | 'minutes'>('count')
const [month, setMonth] = useState<string>()
const [ratingBin, setRatingBin] = useState<string>()
const scoped = useMemo(() => itemsForPeriod(items, year), [items, year])
const s = useMemo(() => computeStats(scoped), [scoped])
const months = useMemo(() => monthly(items, year), [items, year])
const geo = useMemo(() => countries(scoped), [scoped])
const rec = useMemo(() => records(scoped), [scoped])
if (loading) return <PageHeader title={t('stats.pageTitle')} accent={t('stats.pageAccent')} />
if (items.length === 0) {
return ( return (
<> <>
<PageHeader title={t('stats.pageTitle')} accent={t('stats.pageAccent')} /> <PageHeader title={t('nav.stats')} />
<EmptyState title={t('stats.emptyTitle')} text={t('stats.emptyText')} /> <div className="grid min-h-[50dvh] place-items-center">
</> <p className="text-5xl font-bold tracking-tight text-ink-3 lg:text-7xl">Soon</p>
) </div>
}
const hours = Math.round(s.totalMinutes / 60)
const days = s.totalMinutes / 1440
const typeTotal = s.byType.reduce((sum, bt) => sum + bt.minutes, 0)
const typeRows = s.byType.filter((bt) => bt.value > 0).sort((a, b) => b.minutes - a.minutes)
// Mois sélectionné par défaut : le plus chargé
const busiest = months.reduce((best, m) => (m[metric] > best[metric] ? m : best), months[0])
const shownMonth = months.find((m) => m.key === month) ?? busiest
// Histogramme des notes
const ratingCols =
scale === '5'
? s.ratingBuckets.map((v, i) => ({ key: String(i), label: formatRating(i + 1, '5'), value: v }))
: s.ratingBuckets.map((v, i) => ({ key: String(i), label: String(i + 1), value: v }))
const shownRating = ratingCols.find((c) => c.key === ratingBin) ?? ratingCols.reduce((a, b) => (b.value > a.value ? b : a), ratingCols[0])
const maxGenre = Math.max(1, ...s.topGenres.map((g) => g.value))
const maxCountry = Math.max(1, ...geo.list.map((c) => c.count))
const periodLabel = year || t('stats.sinceStart')
return (
<>
<PageHeader title={t('stats.pageTitle')} accent={t('stats.pageAccent')} subtitle={year ? t('stats.subtitleYear', { count: s.total, year }) : t('stats.subtitle', { count: s.total })} />
{/* Période + onglets, collants en haut */}
<div className="sticky top-0 z-20 -mx-4 space-y-2.5 bg-bg/95 px-4 pb-3 pt-[max(0.5rem,env(safe-area-inset-top))] backdrop-blur-md">
<div className="no-scrollbar -mx-4 flex gap-2 overflow-x-auto px-4">
{['', ...years].map((y) => (
<button key={y || 'all'} onClick={() => setYear(y)} className={cx('chip py-1! text-[13px]', year === y && 'chip-on')}>
{y || t('common.all')}
</button>
))}
</div>
<div className="grid grid-cols-3 gap-1 rounded-full border border-line p-1">
{TABS.map((tb) => (
<button
key={tb.value}
onClick={() => setTab(tb.value)}
className={cx('rounded-full py-2 text-xs font-semibold transition-colors', tab === tb.value ? 'bg-ink text-bg' : 'text-ink-3')}
>
{tb.label}
</button>
))}
</div>
</div>
{tab === 'overview' && (
<>
{/* Le grand chiffre */}
<div className="card mt-3 p-5">
<span className="eyebrow">{t('home.screenTime')} · {periodLabel}</span>
<div className="mt-2 flex items-baseline gap-2">
<span className="text-5xl font-bold tabular-nums leading-none">{fmtInt(hours)}</span>
<span className="text-xl font-semibold text-accent">{t('stats.hours', { count: hours })}</span>
</div>
<p className="mt-2 text-sm text-ink-2">
{t('stats.nonStopPre')}
<span className="font-semibold text-ink">{days >= 1 ? t('stats.days', { count: Math.round(days) }) : formatDuration(s.totalMinutes)}</span>
{t('stats.nonStopPost')}
{' · '}
{t('stats.finishedN', { count: s.completed })} · {t('stats.episodesN', { count: s.episodesWatched })}
</p>
</div>
{/* Répartition par type : barre empilée + légende */}
<SectionTitle>{t('stats.timeByType')}</SectionTitle>
{typeTotal > 0 ? (
<>
<div className="flex h-4 gap-[2px] overflow-hidden rounded-full">
{typeRows.map((row) =>
row.minutes > 0 ? (
<span key={row.type} style={{ flexGrow: row.minutes, background: TYPE_COLORS[row.type] }} title={`${row.label} : ${formatDuration(row.minutes)}`} />
) : null,
)}
</div>
<ul className="mt-4 space-y-2.5">
{typeRows.map((row) => (
<li key={row.type} className="flex items-center gap-3 text-sm">
<span className="size-3 shrink-0 rounded-full" style={{ background: TYPE_COLORS[row.type] }} />
<span className="flex-1 text-ink-2">{row.label}</span>
<span className="text-xs text-ink-3">{t('journal.seen', { count: row.completed })}</span>
<span className="w-16 text-end text-xs font-semibold tabular-nums">{formatDuration(row.minutes)}</span>
<span className="w-10 text-end text-xs tabular-nums text-ink-3">{Math.round((row.minutes / typeTotal) * 100)} %</span>
</li>
))}
</ul>
</>
) : (
<p className="text-sm text-ink-3">{t('stats.noTime')}</p>
)}
<div className="mt-8 grid grid-cols-2 gap-3">
<Tile
label={t('stats.avgRating')}
value={
s.avgRating != null ? (
<span className="flex items-center gap-1.5">
<Star size={20} className="fill-accent text-accent" />
{formatRating(Math.round(s.avgRating * 10) / 10, scale)}
<span className="text-sm font-normal text-ink-3">/{scale}</span>
</span>
) : (
'—'
)
}
hint={t('stats.rated', { count: s.ratedCount })}
/>
<Tile label={t('home.completed')} value={fmtInt(s.completed)} hint={year ? t('stats.inYear', { year }) : t('home.thisYear', { count: s.completedThisYear })} />
</div>
{/* Statuts en pastilles */}
<SectionTitle>{t('stats.statuses')}</SectionTitle>
<div className="grid grid-cols-5 gap-2 text-center">
{s.byStatus.map((st) => (
<div key={st.status} className="rounded-2xl border border-line py-3">
<div className="text-lg font-bold tabular-nums">{st.value}</div>
<div className="mt-0.5 text-[10px] leading-tight text-ink-3">{STATUSES.find((x) => x.value === st.status)?.label}</div>
</div>
))}
</div>
</>
)}
{tab === 'habits' && (
<>
<SectionTitle
action={
<div className="flex rounded-full border border-line p-0.5">
{(['count', 'minutes'] as const).map((m) => (
<button
key={m}
onClick={() => setMetric(m)}
className={cx('rounded-full px-2.5 py-0.5 text-[11px] font-semibold', metric === m ? 'bg-ink text-bg' : 'text-ink-3')}
>
{m === 'count' ? t('catalog.titles') : t('stats.hoursTab')}
</button>
))}
</div>
}
>
{year ? t('stats.monthByMonth', { year }) : t('stats.last12')}
</SectionTitle>
<div className="card p-4">
<p className="mb-4 text-sm">
<span className="font-semibold capitalize">{new Date(`${shownMonth.key}-15T12:00:00`).toLocaleDateString(locale(), { month: 'long', year: 'numeric' })}</span>
<span className="text-ink-2">
{' · '}
{t('stats.monthFinished', { count: shownMonth.count })} · {formatDuration(shownMonth.minutes)}
</span>
</p>
<Columns
data={months.map((m) => ({ key: m.key, label: m.initial, value: metric === 'count' ? m.count : m.minutes }))}
format={(v) => (metric === 'count' ? t('account.nTitles', { count: v }) : formatDuration(v))}
selected={shownMonth.key}
onSelect={setMonth}
/>
{busiest[metric] > 0 && (
<p className="mt-3 text-xs text-ink-3">
{t('stats.busiest')} <span className="text-ink">{new Date(`${busiest.key}-15T12:00:00`).toLocaleDateString(locale(), { month: 'long', year: 'numeric' })}</span>
</p>
)}
</div>
<SectionTitle>{t('stats.records')}</SectionTitle>
<div className="space-y-3">
{rec.marathon && (
<div className="card p-3.5">
<span className="eyebrow text-accent">{t('stats.marathon')}</span>
<div className="mt-2">
<MiniPoster item={rec.marathon.item} caption={`${t('stats.episodesN', { count: rec.marathon.episodes })} · ${formatDuration(watchMinutes(rec.marathon.item))}`} />
</div>
</div>
)}
{rec.longestFilm && (
<div className="card p-3.5">
<span className="eyebrow text-accent">{t('stats.longestFilm')}</span>
<div className="mt-2">
<MiniPoster item={rec.longestFilm} caption={formatDuration(rec.longestFilm.duration ?? 0)} />
</div>
</div>
)}
{!rec.marathon && !rec.longestFilm && <p className="text-sm text-ink-3">{t('stats.noRecords')}</p>}
</div>
{s.topPlatforms.length > 0 && (
<>
<SectionTitle>{t('stats.platforms')}</SectionTitle>
<div className="flex flex-wrap gap-2">
{s.topPlatforms.map((p, i) => (
<span key={p.label} className={cx('chip', i === 0 && 'chip-on')}>
{p.label}
<span className="text-xs opacity-60">{p.value}</span>
</span>
))}
</div>
</>
)}
</>
)}
{tab === 'tastes' && (
<>
{rec.bestRated && rec.bestRated.length > 0 && (
<>
<SectionTitle>{t('stats.bestRated')} · {periodLabel}</SectionTitle>
<div className="no-scrollbar -mx-4 flex gap-3 overflow-x-auto px-4 pb-1">
{rec.bestRated.map((item) => (
<div key={item.id} className="w-24 shrink-0">
<Poster src={item.poster} title={item.title} />
<p className="mt-1.5 truncate text-xs font-medium text-ink-2">{item.title}</p>
<p className="flex items-center gap-1 text-[11px] text-ink-3">
<Star size={10} className="fill-accent text-accent" />
{formatRating(item.rating, scale)}
</p>
</div>
))}
</div>
</>
)}
<SectionTitle>{t('stats.myRatings')}</SectionTitle>
{s.ratedCount > 0 ? (
<div className="card p-4">
<p className="mb-4 text-sm">
<span className="font-semibold">{t('account.nTitles', { count: shownRating.value })}</span>
<span className="text-ink-2"> {t('stats.ratedAs', { count: shownRating.value, rating: `${shownRating.label}${scale === '5' ? ' ★' : '/10'}` })}</span>
</p>
<Columns data={ratingCols} format={(v) => t('account.nTitles', { count: v })} height={110} selected={shownRating.key} onSelect={setRatingBin} />
</div>
) : (
<p className="text-sm text-ink-3">{t('stats.noRatings')}</p>
)}
<Disagreements scoped={scoped} />
<SectionTitle>{t('stats.favGenres')}</SectionTitle>
{s.topGenres.length ? (
<div className="flex flex-wrap items-baseline gap-x-4 gap-y-2">
{s.topGenres.map((g, i) => {
const r = g.value / maxGenre
return (
<span
key={g.label}
className={cx('font-bold leading-tight', i === 0 ? 'text-accent' : r > 0.6 ? 'text-ink' : 'text-ink-2')}
style={{ fontSize: `${0.85 + r * 1.15}rem` }}
title={t('account.nTitles', { count: g.value })}
>
{genreLabel(g.label)}
<sup className="ms-0.5 text-[10px] font-medium text-ink-3">{g.value}</sup>
</span>
)
})}
</div>
) : (
<p className="text-sm text-ink-3">{t('stats.noGenres')}</p>
)}
<SectionTitle>{t('stats.countries')}</SectionTitle>
{geo.list.length ? (
<ul className="space-y-3">
{geo.list.slice(0, 8).map((c) => (
<li key={c.code} className="flex items-center gap-3 text-sm">
<span className="w-7 text-center text-xl leading-none">{c.flag}</span>
<span className="w-28 truncate text-ink-2">{c.name}</span>
<span className="h-2 flex-1 overflow-hidden rounded-full bg-surface-2">
<span className="block h-full rounded-full bg-accent" style={{ width: `${(c.count / maxCountry) * 100}%` }} />
</span>
<span className="w-8 text-end text-xs font-semibold tabular-nums">{c.count}</span>
</li>
))}
</ul>
) : null}
{geo.missing > 0 && (
<p className="mt-3 text-xs text-ink-3">
{geo.list.length === 0 ? t('stats.noCountryLegacy', { count: geo.missing }) : t('stats.noCountry', { count: geo.missing })}
</p>
)}
<SectionTitle>{t('stats.byType')}</SectionTitle>
<div className="grid grid-cols-3 gap-2">
{MEDIA_TYPES.map((mt) => {
const row = s.byType.find((b) => b.type === mt.value)!
return (
<div key={mt.value} className="rounded-2xl border border-line p-3">
<span className="mb-2 block h-1 w-6 rounded-full" style={{ background: TYPE_COLORS[mt.value] }} />
<div className="text-xl font-bold tabular-nums">{row.value}</div>
<div className="text-[11px] text-ink-3">{mt.label}</div>
</div>
)
})}
</div>
</>
)}
<p className="mt-8 text-xs text-ink-3">
{t('stats.footnote')}
</p>
</> </>
) )
} }