import { useMemo } from 'react' import { useNavigate } from 'react-router-dom' import { motion } from 'framer-motion' import { ArrowRight, Star } from '../../lib/icons' import { useTmdbTrending } from '../../hooks/use-tmdb' import { useLibraryByTmdbId } from '../../hooks/use-jellyfin' import { usePreferencesStore } from '../../stores/preferences-store' import { filterToMissing } from '../../pages/discover/helpers' const TMDB_IMG = 'https://image.tmdb.org/t/p' /** * Editorial pick at the top of Discover. Picks the highest-ranked * trending-today item the user doesn't already own, with a backdrop + * synopsis available. If nothing qualifies, the hero hides itself so * the page falls back to the chips + rows beneath. * * Visual: 21:9 backdrop, left-side gradient ramp to bg-void so the * copy stays legible against any image. The DNA borrows the hero pattern * from DetailPage's hero but in a smaller, contained card. */ export function SpotlightHero({ kind = 'all' }: { kind?: 'all' | 'movie' | 'tv' }) { const navigate = useNavigate() const trending = useTmdbTrending(kind, 'day') const lib = useLibraryByTmdbId() const hideAdult = usePreferencesStore(s => s.hideAdult) const pick = useMemo(() => { const list = trending.data?.results || [] const filtered = filterToMissing(list, lib.data, hideAdult, m => !!m.adult) return filtered.find(m => m.backdrop_path && m.overview) || null }, [trending.data, lib.data, hideAdult]) if (!pick) return null const title: string = pick.title || pick.name || 'Untitled' const overview: string = pick.overview || '' const backdrop = `${TMDB_IMG}/w1280${pick.backdrop_path}` const year = (pick.release_date || pick.first_air_date || '').slice(0, 4) const rating = typeof pick.vote_average === 'number' ? pick.vote_average.toFixed(1) : null const mediaType: 'movie' | 'tv' = pick.media_type === 'tv' || pick.first_air_date ? 'tv' : 'movie' function open() { if (!pick) return navigate(`/item/tmdb-${mediaType}-${pick.id}`) } return (
) }