"use client"; import { useUserStore } from "#/store/auth"; import { useEffect, useState } from "react"; import { fetchDataViaGet } from "../api/utils"; import { Spinner } from "../components/Spinner/Spinner"; import { Avatar, Card, Button, Table } from "flowbite-react"; import { Chip } from "../components/Chip/Chip"; import { unixToDate, minutesToTime } from "../api/utils"; import { ReleaseCourusel } from "#/components/ReleaseCourusel/ReleaseCourusel"; 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 = `/api/profile/${props.id}`; if (authUser.token) { url += `?token=${authUser.token}`; } const data = await fetchDataViaGet(url); setUser(data.profile); setIsMyProfile(data.is_my_profile); } _getData(); }, [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", }, ]; return (
{isMyProfile && } {user.is_banned && ( )} {user.is_verified && ( )} {/* {user.is_banned && } */} {/* */} {/* */}
{user.login}
{user.status}
{hasSocials && ( {socials.map((social) => { if (!social.nickname) return null; if (social.name == "discord") return ( ); return ( ); })} )}

Активность

Регистрация {unixToDate(user.register_date)} Был(а) в сети {unixToDate(user.last_activity_time)} Комментарий {user.comment_count} друзей {user.friend_count} видео {user.video_count} коллекций {user.collection_count}

Статистика

Просмотрено серий {user.watched_episode_count} Время просмотра {minutesToTime(user.watched_time)} {minutesToTime(user.watched_time)} Смотрю {user.watching_count} В Планах {user.plan_count} Просмотрено {user.completed_count} Отложено {user.hold_on_count} Брошено {user.dropped_count}
); };