"use client"; import useSWRInfinite from "swr/infinite"; import { Spinner } from "#/components/Spinner/Spinner"; import { useState, useEffect } from "react"; import { useScrollPosition } from "#/hooks/useScrollPosition"; import { useUserStore } from "../store/auth"; import { ENDPOINTS } from "#/api/config"; import { useSWRfetcher } from "#/api/utils"; import { Card } from "flowbite-react"; import { Poster } from "#/components/ReleasePoster/Poster"; import { ReleaseChips } from "#/components/ReleasePoster/Chips"; import { PosterWithStuff } from "#/components/ReleasePoster/PosterWithStuff"; import Link from "next/link"; const profile_lists = { // 0: "Не смотрю", 1: { name: "Смотрю", bg_color: "bg-green-500" }, 2: { name: "В планах", bg_color: "bg-purple-500" }, 3: { name: "Просмотрено", bg_color: "bg-blue-500" }, 4: { name: "Отложено", bg_color: "bg-yellow-500" }, 5: { name: "Брошено", bg_color: "bg-red-500" }, }; const YearSeason = ["_", "Зима", "Весна", "Лето", "Осень"]; export function RelatedPage(props: { id: number | string; title: string }) { const token = useUserStore((state) => state.token); const getKey = (pageIndex: number, previousPageData: any) => { if (previousPageData && !previousPageData.content.length) return null; if (token) { return `${ENDPOINTS.release.related}/${props.id}/${pageIndex}?token=${token}&API-Version=v2`; } return `${ENDPOINTS.release.related}/${props.id}/${pageIndex}?API-Version=v2`; }; const { data, error, isLoading, size, setSize } = useSWRInfinite( getKey, useSWRfetcher, { initialSize: 1 } ); const [content, setContent] = useState(null); useEffect(() => { if (data) { let allReleases = []; for (let i = 0; i < data.length; i++) { allReleases.push(...data[i].content); } setContent(allReleases); } }, [data]); const scrollPosition = useScrollPosition(); useEffect(() => { if (scrollPosition >= 98 && scrollPosition <= 99) { setSize(size + 1); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [scrollPosition]); return ( <>
{release.title_ru}
)} {release.title_original && ({release.title_original}
)} {settings.showDescription && release.description && ({release.description}
)}В франшизе пока ничего нет...