"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 (
); } if (error) { return (

Ошибка

Произошла ошибка при загрузке профиля. Попробуйте обновить страницу или зайдите позже.

); } const hasSocials = user.vk_page != "" || user.tg_page != "" || user.tt_page != "" || user.inst_page != "" || user.discord_page != "" || false; const socials = [ { name: "vk", nickname: user.vk_page, icon: "fa6-brands--vk", urlPrefix: "https://vk.com/", }, { name: "telegram", nickname: user.tg_page, icon: "fa6-brands--telegram", urlPrefix: "https://t.me/", }, { name: "discord", nickname: user.discord_page, icon: "fa6-brands--discord", }, { name: "tiktok", nickname: user.tt_page, icon: "fa6-brands--tiktok", urlPrefix: "https://tiktok.com/@", }, { name: "instagram", nickname: user.inst_page, icon: "fa6-brands--instagram", urlPrefix: "https://instagram.com/", }, ]; const hasChips = user.is_verified || user.is_blocked || (user.roles && user.roles.length > 0) || isMyProfile; const isPrivacy = user.is_stats_hidden || user.is_counts_hidden || user.is_social_hidden; return ( <>
{!user.is_counts_hidden && ( )} {!user.is_stats_hidden && (
{user.votes && user.votes.length > 0 && ( )} {user.history && user.history.length > 0 && ( )}
)}
{authUser.token && ( )} {!user.is_stats_hidden && ( <>
{user.votes && user.votes.length > 0 && ( )} {user.history && user.history.length > 0 && ( )}
)}
); };