"use client"; import { useUserStore } from "#/store/auth"; import { useEffect, useState } from "react"; import { Spinner } from "../components/Spinner/Spinner"; import { fetchDataViaGet } from "../api/utils"; import { ENDPOINTS } from "#/api/config"; 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"; export const ProfilePage = (props: any) => { const authUser = useUserStore((state) => state); const [user, setUser] = useState(null); const [isMyProfile, setIsMyProfile] = useState(false); useEffect(() => { async function _getData() { let url = `${ENDPOINTS.user.profile}/${props.id}`; if (authUser.token) { url += `?token=${authUser.token}`; } const data = await fetchDataViaGet(url); setUser(data.profile); setIsMyProfile(data.is_my_profile); } _getData(); // eslint-disable-next-line react-hooks/exhaustive-deps }, [authUser]); if (!user) { 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 && (
)}
); };