Ошибка
Произошла ошибка при загрузке коллекций. Попробуйте обновить страницу или зайдите позже.
"use client"; import useSWR from "swr"; import { CollectionCourusel } from "#/components/CollectionCourusel/CollectionCourusel"; import { Spinner } from "#/components/Spinner/Spinner"; import { useSWRfetcher } from "#/api/utils"; import { useUserStore } from "#/store/auth"; import { ENDPOINTS } from "#/api/config"; import { useRouter } from "next/navigation"; import { useEffect, useState } from "react"; export function CollectionsPage() { const userStore = useUserStore(); const router = useRouter(); const [searchVal, setSearchVal] = useState(""); function useFetchReleases(section: string) { let url: string; if (userStore.token && userStore.user) { if (section == "userCollections") { url = `${ENDPOINTS.collection.userCollections}/${userStore.user.id}/0?token=${userStore.token}`; } else if (section == "userFavoriteCollections") { url = `${ENDPOINTS.collection.favoriteCollections}/all/0?token=${userStore.token}`; } } const { data, error } = useSWR(url, useSWRfetcher); return [data, error]; } const [userCollections, userCollectionsError] = useFetchReleases("userCollections"); const [favoriteCollections, favoriteCollectionsError] = useFetchReleases( "userFavoriteCollections" ); useEffect(() => { if (userStore.state === "finished" && !userStore.token) { router.push("/login?redirect=/collections"); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [userStore.state, userStore.token]); return ( <> {userStore.state === "loading" && (!userCollections || !favoriteCollections) && (
Произошла ошибка при загрузке коллекций. Попробуйте обновить страницу или зайдите позже.