import { Check, X } from 'lucide-react' import { useMemo, useState } from 'react' import { locale, t } from '../../i18n' import { useBackToClose } from '../../lib/backNav' import { useEscape } from '../../lib/escape' import { useScrollLock } from '../../lib/scrollLock' import { availableYears, monthly } from '../../lib/stats' import { cx, formatDuration } from '../../lib/utils' import { useMedia } from '../../store' import { Columns } from './Charts' /** * Paramètres des stats : la courbe mois par mois, et en dessous une case par mois pour l'afficher ou non * (ex. le mois où toute la bibliothèque a été ajoutée d'un coup). Les mois masqués suivent le compte (réglages synchronisés). */ export default function StatsSettings({ onClose, initialYear }: { onClose: () => void; initialYear: string }) { const { items, settings, updateSettings } = useMedia() useScrollLock() useEscape(onClose) useBackToClose(onClose) const years = useMemo(() => availableYears(items), [items]) const [year, setYear] = useState(initialYear && years.includes(initialYear) ? initialYear : '') const months = useMemo(() => monthly(items, year), [items, year]) const hidden = new Set(settings.statsHiddenMonths ?? []) const setShown = (key: string, shown: boolean) => { const next = new Set(hidden) if (shown) next.delete(key) else next.add(key) updateSettings({ statsHiddenMonths: next.size ? [...next].sort() : undefined }) } const label = (key: string) => new Date(`${key}-15T12:00:00`).toLocaleDateString(locale(), { month: 'long', year: 'numeric' }) return (
{t('stats.hideMonthsHint')}
{/* Une case par mois : cochée = affiché dans la courbe */}