"use client";
import { useUserStore } from "#/store/auth";
import { useEffect, useState } from "react";
import { Spinner } from "../components/Spinner/Spinner";
import { ENDPOINTS } from "#/api/config";
import useSWR from "swr";
import { useSWRfetcher } from "#/api/utils";
import { ProfileUser } from "#/components/Profile/Profile.User";
import { ProfileBannedBanner } from "#/components/Profile/ProfileBannedBanner";
import { ProfilePrivacyBanner } from "#/components/Profile/Profile.PrivacyBanner";
import { ProfileActivity } from "#/components/Profile/Profile.Activity";
import { ProfileStats } from "#/components/Profile/Profile.Stats";
import { ProfileWatchDynamic } from "#/components/Profile/Profile.WatchDynamic";
import { ProfileActions } from "#/components/Profile/Profile.Actions";
import { ProfileReleaseRatings } from "#/components/Profile/Profile.ReleaseRatings";
import { ProfileReleaseHistory } from "#/components/Profile/Profile.ReleaseHistory";
import { ProfileEditModal } from "#/components/Profile/Profile.EditModal";
export const ProfilePage = (props: any) => {
const authUser = useUserStore();
const [user, setUser] = useState(null);
const [isMyProfile, setIsMyProfile] = useState(false);
const [isOpen, setIsOpen] = useState(false);
let url = `${ENDPOINTS.user.profile}/${props.id}`;
if (authUser.token) {
url += `?token=${authUser.token}`;
}
const { data, error } = useSWR(url, useSWRfetcher);
useEffect(() => {
if (data) {
setUser(data.profile);
setIsMyProfile(data.is_my_profile);
}
}, [data]);
if (!user && !error) {
return (
Произошла ошибка при загрузке профиля. Попробуйте обновить страницу
или зайдите позже.
Ошибка