"use client";
import useSWR from "swr";
import { Spinner } from "#/components/Spinner/Spinner";
import { useSWRfetcher } from "#/api/utils";
import { useUserStore } from "#/store/auth";
import { useEffect, useState } from "react";
import { ReleaseInfoBasics } from "#/components/ReleaseInfo/ReleaseInfo.Basics";
import { ReleaseInfoInfo } from "#/components/ReleaseInfo/ReleaseInfo.Info";
import { ReleasePlayer } from "#/components/ReleasePlayer/ReleasePlayer";
import { ReleasePlayerCustom } from "#/components/ReleasePlayer/ReleasePlayerCustom";
import { ReleaseInfoUserList } from "#/components/ReleaseInfo/ReleaseInfo.UserList";
import { ReleaseInfoRating } from "#/components/ReleaseInfo/ReleaseInfo.Rating";
import { ReleaseInfoRelated } from "#/components/ReleaseInfo/ReleaseInfo.Related";
import { ReleaseInfoScreenshots } from "#/components/ReleaseInfo/ReleaseInfo.Screenshots";
import { CommentsMain } from "#/components/Comments/Comments.Main";
import { InfoLists } from "#/components/InfoLists/InfoLists";
import { ENDPOINTS } from "#/api/config";
import { usePreferencesStore } from "#/store/preferences";
export const ReleasePage = (props: any) => {
const userStore = useUserStore();
const preferenceStore = usePreferencesStore();
const [userList, setUserList] = useState(0);
const [userFavorite, setUserFavorite] = useState(false);
function useFetch(id: number) {
let url: string;
url = `${ENDPOINTS.release.info}/${id}`;
if (userStore.token) {
url += `?token=${userStore.token}`;
}
const { data, isLoading, error } = useSWR(url, useSWRfetcher);
return [data, isLoading, error];
}
const [data, isLoading, error] = useFetch(props.id);
useEffect(() => {
if (data) {
const el = document.getElementById("note");
if (el) {
el.innerHTML = data.release.note;
}
setUserList(data.release.profile_list_status || 0);
setUserFavorite(data.release.is_favorite);
}
}, [data]);
if (isLoading) {
return (
Произошла ошибка при загрузке релиза. Попробуйте обновить страницу
или зайдите позже.
Ошибка