import { useMemo } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { useTmdbDiscoverMovies, useTmdbDiscoverTv } from '../../hooks/use-tmdb' import { useLibraryByTmdbId } from '../../hooks/use-jellyfin' import { usePreferencesStore } from '../../stores/preferences-store' import { mapTmdbToJf } from '../../lib/tmdb-mapping' import { DISCOVER_MOODS, type DiscoverMood } from '../../lib/discover-moods' import { filterToMissing } from '../../pages/discover/helpers' import ContentRow from '../ui/ContentRow' interface Props { activeId: string | null onChange: (id: string | null) => void kind: 'movie' | 'tv' } export function MoodChips({ activeId, onChange, kind }: Props) { return (
In the mood for
) } function MoodChipButton({ mood, active, disabled, onClick, }: { mood: DiscoverMood active: boolean disabled: boolean onClick: () => void }) { const Icon = mood.icon return (
  • {mood.label}
  • ) } /** * The row that materialises beneath the chip strip when a mood is picked. * Movie-only moods show just one row; the few that have TV recipes show * two rows (movies then shows). */ export function MoodRow({ moodId, kind }: { moodId: string; kind: 'movie' | 'tv' }) { const mood = DISCOVER_MOODS.find(m => m.id === moodId) if (!mood) return null return ( {kind === 'movie' && } {kind === 'tv' && mood.tvParams && } ) } function MoodMovieRow({ mood }: { mood: DiscoverMood }) { const movies = useTmdbDiscoverMovies(mood.movieParams) const lib = useLibraryByTmdbId() const hideAdult = usePreferencesStore(s => s.hideAdult) const items = useMemo(() => { let raw = (movies.data?.results || []).map(m => ({ ...m, media_type: 'movie' as const })) if (mood.extra) raw = raw.filter(mood.extra) return mapTmdbToJf(filterToMissing(raw, lib.data, hideAdult, m => !!m.adult), lib.data) }, [movies.data, lib.data, hideAdult, mood]) if (items.length === 0) return null return ( ) } function MoodTvRow({ mood }: { mood: DiscoverMood }) { const tv = useTmdbDiscoverTv(mood.tvParams || {}) const lib = useLibraryByTmdbId() const items = useMemo(() => { const raw = (tv.data?.results || []).map(m => ({ ...m, media_type: 'tv' })) return mapTmdbToJf(filterToMissing(raw, lib.data), lib.data) }, [tv.data, lib.data]) if (items.length === 0) return null return ( ) }