Ошибка
Произошла ошибка при загрузке коллекций. Попробуйте обновить страницу или зайдите позже.
"use client"; import useSWRInfinite from "swr/infinite"; import { CollectionsSection } from "#/components/CollectionsSection/CollectionsSection"; import { Spinner } from "#/components/Spinner/Spinner"; import { useState, useEffect } from "react"; import { useScrollPosition } from "#/hooks/useScrollPosition"; import { useUserStore } from "../store/auth"; import { Button } from "flowbite-react"; import { ENDPOINTS } from "#/api/config"; import { useRouter } from "next/navigation"; import { useSWRfetcher } from "#/api/utils"; export function CollectionsFullPage(props: { type: "favorites" | "profile" | "release"; title: string; profile_id?: number; release_id?: number; }) { const userStore = useUserStore(); const router = useRouter(); const getKey = (pageIndex: number, previousPageData: any) => { if (previousPageData && !previousPageData.content.length) return null; let url: string; if (props.type == "favorites") { url = `${ENDPOINTS.collection.favoriteCollections}/all/${pageIndex}`; } else if (props.type == "profile") { url = `${ENDPOINTS.collection.userCollections}/${props.profile_id}/${pageIndex}`; } else if (props.type == "release") { url = `${ENDPOINTS.collection.releaseInCollections}/${props.release_id}/${pageIndex}`; } if (userStore.token) { url += `?token=${userStore.token}`; } return url; }; const { data, error, isLoading, size, setSize } = useSWRInfinite( getKey, useSWRfetcher, { initialSize: 2 } ); 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]); useEffect(() => { if ( userStore.state === "finished" && !userStore.token && props.type == "favorites" ) { router.push(`/login?redirect=/collections/favorites`); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [userStore.state, userStore.token]); if (isLoading) { return (
Произошла ошибка при загрузке коллекций. Попробуйте обновить страницу или зайдите позже.
Тут пока ничего нет...