import { useEffect, useState } from "react"; import { useAniList } from "../../../lib/anilist/useAnilist"; import Skeleton from "react-loading-skeleton"; import DisqusComments from "../../disqus"; import { AniListInfoTypes } from "types/info/AnilistInfoTypes"; import { SessionTypes } from "pages/en"; import Link from "next/link"; import Image from "next/image"; type DetailsProps = { info: AniListInfoTypes; session: SessionTypes; epiNumber: number; description: string; id: string; onList: boolean; setOnList: (value: boolean) => void; handleOpen: () => void; disqus: string; }; export default function Details({ info, session, epiNumber, description, id, onList, setOnList, handleOpen, disqus }: DetailsProps) { const [showComments, setShowComments] = useState(false); const { markPlanning } = useAniList(session); const [showDesc, setShowDesc] = useState(false); const truncatedDesc = truncateText(description, 420); function handlePlan() { if (onList === false) { markPlanning(info.id); setOnList(true); } } useEffect(() => { const isMobile = window.matchMedia("(max-width: 768px)").matches; if (isMobile) { setShowComments(false); } else { setShowComments(true); } return () => { setShowComments(false); setShowDesc(false); }; }, [id]); return (
{/*
*/}
{info ? ( Anime Cover ) : ( )}

Studios

{info ? ( info.studios?.edges[0].node.name ) : ( )}
{ session ? handlePlan() : handleOpen(); }} className={`w-8 h-8 hover:fill-white text-white hover:cursor-pointer ${ onList ? "fill-white" : "" }`} >

Status

{info ? info.status : }

Titles

{info ? ( <>
{info.title?.romaji || ""}
{info.title?.english || ""}
{info.title?.native || ""}
) : ( )}
{/*
*/}
{info && info.genres?.map((item, index) => (
{item}
))}
{/*
*/}
{info && ( <>

420 ? truncatedDesc : description }} className={`p-5 text-sm font-light font-roboto text-[#e4e4e4] `} /> {!showDesc && description?.length > 120 && ( setShowDesc((prev) => !prev)} className="flex justify-center items-end rounded-md pb-5 font-semibold font-karla cursor-pointer w-full h-full bg-gradient-to-t from-secondary hover:from-20% to-transparent absolute inset-0" > Read More )} )}

{/* {
} */} {!showComments && (
)} {showComments && (
{info && (
)}
)}
); } function truncateText(txt: string, length: number) { const text = txt.replace(/(<([^>]+)>)/gi, ""); return text.length > length ? text.slice(0, length) + "..." : text; }