"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 (
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"}
{englishOverview}
Content Rating:{" "} {metadata?.data?.contentRatings?.[0]?.fullname || "Not Rated"}