import { BookOpenIcon, PlayIcon, PlusIcon, ShareIcon, } from "@heroicons/react/24/solid"; import Image from "next/image"; import { useRouter } from "next/router"; import { useEffect, useState } from "react"; import { convertSecondsToTime } from "@/utils/getTimes"; import Link from "next/link"; import InfoChip from "./reused/infoChip"; import Description from "./reused/description"; import { NewNavbar } from "@/components/shared/NavBar"; export default function DetailTop({ info, statuses, handleOpen, watchUrl, progress, color, }) { const router = useRouter(); const [readMore, setReadMore] = useState(false); const [showAll, setShowAll] = useState(false); const isAnime = info.type === "ANIME"; useEffect(() => { setReadMore(false); }, [info.id]); const handleShareClick = async () => { try { if (navigator.share) { await navigator.share({ title: `${isAnime ? "Watch" : "Read"} Now - ${info?.title?.english}`, // text: `Watch [${info?.title?.romaji}] and more on Moopa. Join us for endless anime entertainment"`, url: window.location.href, }); } else { // Web Share API is not supported, provide a fallback or show a message alert("Web Share API is not supported in this browser."); } } catch (error) { console.error("Error sharing:", error); } }; return (
{/* MAIN */}
poster anime

{info?.season?.toLowerCase() || getMonth(info?.startDate?.month)}{" "} {info.seasonYear || info?.startDate?.year}

{info?.title?.romaji || info?.title?.english}

{info.title?.english}

{info?.description && ( )}
See on AniList anilist_icon
{info.nextAiringEpisode?.timeUntilAiring && (

Episode {info.nextAiringEpisode.episode} in{" "} {convertSecondsToTime(info.nextAiringEpisode.timeUntilAiring)}{" "}

)} {info?.description && ( )} {info?.relations?.edges?.length > 0 && (
{info?.relations?.edges?.length > 0 && (
Relations
)} {info?.relations?.edges?.length > 3 && (
setShowAll(!showAll)} > {showAll ? "show less" : "show more"}
)}
{info?.relations?.edges .slice(0, showAll ? info?.relations?.edges.length : 3) .map((r, index) => { const rel = r.node; return (
{rel.id}
{r.relationType.replace(/_/g, " ")}
{rel.title.userPreferred}
{rel.format}
); })}
)}
); } function getMonth(month) { if (!month) return ""; const formattedMonth = new Date(0, month).toLocaleString("default", { month: "long", }); return formattedMonth; }