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 (
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 )} > )}