diff --git a/src/components/media/PopupModal.tsx b/src/components/media/PopupModal.tsx index 3274c31d..a9d9bc1b 100644 --- a/src/components/media/PopupModal.tsx +++ b/src/components/media/PopupModal.tsx @@ -20,6 +20,29 @@ interface PopupModalProps { media: MediaItem; } +interface MediaData { + backdrop_path?: string; + title?: string; + name?: string; + runtime?: number; + release_date?: string; + first_air_date?: string; + vote_average?: number; + genres?: Array<{ name: string }>; + overview?: string; +} + +interface MediaInfo { + results?: Array<{ + iso_3166_1: string; + rating?: string; + release_dates?: Array<{ + certification: string; + release_date: string; + }>; + }>; +} + type StyleState = { opacity: number; visibility: "visible" | "hidden" | undefined; @@ -46,11 +69,10 @@ export function PopupModal({ opacity: 0, visibility: "hidden", }); - const [data, setData] = useState(null); - const [mediaInfo, setMediaInfo] = useState(null); + const [data, setData] = useState(null); + const [mediaInfo, setMediaInfo] = useState(null); const [error, setError] = useState(null); - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const [menuOpen, setMenuOpen] = useState(false); // Added definition for menuOpen + // const [menuOpen, setMenuOpen] = useState(false); const navigate = useNavigate(); useEffect(() => { @@ -62,7 +84,6 @@ export function PopupModal({ onClose(); } } - document.addEventListener("mousedown", handleClickOutside); return () => { document.removeEventListener("mousedown", handleClickOutside); @@ -83,7 +104,7 @@ export function PopupModal({ try { const mediaTypePath = media.type === "show" ? "tv" : media.type; - const result = await get(`/${mediaTypePath}/${media.id}`, { + const result = await get(`/${mediaTypePath}/${media.id}`, { api_key: conf().TMDB_READ_API_KEY, language: "en-US", }); @@ -107,7 +128,7 @@ export function PopupModal({ const mediaTypeForAPI = media.type === "show" ? "tv" : media.type; const endpointSuffix = media.type === "show" ? "content_ratings" : "release_dates"; - const result = await get( + const result = await get( `/${mediaTypeForAPI}/${media.id}/${endpointSuffix}`, { api_key: conf().TMDB_READ_API_KEY, @@ -126,10 +147,7 @@ export function PopupModal({ }, [media.id, media.type, isVisible]); if (!isVisible && style.visibility === "hidden") return null; - - if (error) { - return
Error: {error}
; - } + if (error) return
Error: {error}
; const isTVShow = media.type === "show"; const usReleaseInfo = mediaInfo?.results?.find( @@ -158,11 +176,7 @@ export function PopupModal({
@@ -172,9 +186,7 @@ export function PopupModal({ alt={media.poster ? "" : "failed to fetch :("} className="rounded-xl object-cover w-full h-full" loading="lazy" - style={{ - maxHeight: "60vh", - }} + style={{ maxHeight: "60vh" }} /> ) : ( @@ -239,19 +251,17 @@ export function PopupModal({
- {Array.from({ length: 5 }, (_, index) => { - return ( - - {index < Math.round(Number(data?.vote_average) / 2) ? ( - - ) : ( - - )} - - ); - })} + {Array.from({ length: 5 }, (_, index) => ( + + {index < Math.round(Number(data?.vote_average) / 2) ? ( + + ) : ( + + )} + + ))}
- {data?.genres?.length > 0 + {data?.genres && data.genres.length > 0 ? data.genres.map((genre: { name: string }) => (
@@ -259,8 +269,9 @@ export function PopupModal({
)) - : Array.from({ length: 3 }).map((_) => ( -
+ : Array.from({ length: 3 }).map((_, idx) => ( + // eslint-disable-next-line react/no-array-index-key +
))}