"use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import Image from "next/image"; import "./movie.css"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faPlay, faBookmark as faBookmarkSolid, } from "@fortawesome/free-solid-svg-icons"; import { faBookmark as faBookmarkRegular } from "@fortawesome/free-regular-svg-icons"; import apiClient from "@/api/apiClient"; import { Spinner } from "@/components/Spinner"; import CastSection from "@/components/CastSection"; import NotFound from "@/app/not-found"; export default function MovieDetailsPage({ params }) { const [metadata, setMetadata] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { async function fetchData() { try { const decodedTitle = decodeURIComponent(params.title); const data = await apiClient.getMovieMetadataByTitle(decodedTitle); if (data) { setMetadata(data); } else { setError("Movie metadata not found."); } } catch (err) { setError("An error occurred while fetching movie metadata."); } finally { setLoading(false); } } fetchData(); }, [params.title]); if (loading) { return (
); } if (error) { return ; } const englishTitle = metadata?.data?.translations?.nameTranslations?.find( (translation) => translation.language === "eng" )?.name || metadata?.data?.name || "Title not available"; const englishOverview = metadata?.data?.translations?.overviewTranslations?.find( (translation) => translation.language === "eng" )?.overview || "Overview not available"; const backdropImage = metadata?.data?.artworks?.find( (artwork) => artwork.type === 15 )?.image; const genres = metadata?.data?.genres || []; const cast = metadata?.data?.characters || []; return (

{englishTitle} {"(" + metadata?.data?.year + ")" || ""}

{`${englishTitle}

Director / Writer: Jon Watts, Steve Ditko, Stan Lee, Chris McKenna, Erik Sommers

Stars: Tom Holland, Angourie Rice, Samuel L. Jackson, Zendaya, Jon Favreau, Jake Gyllenhaal, Marisa Tomei

Release Year: {metadata?.data?.year || "N/A"}

Runtime:{" "} {metadata?.data?.runtime ? `${metadata.data.runtime} minutes` : "N/A"}

Storyline

{englishOverview}

Content Rating:{" "} {metadata?.data?.contentRatings?.[0]?.fullname || "Not Rated"}

); }