import Image from "next/image"; import { ReleaseCard } from "../ReleaseCard/ReleaseCard"; import { getData } from "@/app/api/api-utils"; import { endpoints } from "@/app/api/config"; import { useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faTiktok, faVk, faInstagram, faTelegram, } from "@fortawesome/free-brands-svg-icons"; function getNoun(number, one, two, five) { let n = Math.abs(number); n %= 100; if (n >= 5 && n <= 20) { return five; } n %= 10; if (n === 1) { return one; } if (n >= 2 && n <= 4) { return two; } return five; } function convertMinutes(min) { const d = Math.floor(min / 1440); // 60*24 const h = Math.floor((min - d * 1440) / 60); const m = Math.round(min % 60); var dDisplay = d > 0 ? `${d} ${getNoun(d, "день", "дня", "дней")}, ` : ""; var hDisplay = h > 0 ? `${h} ${getNoun(h, "час", "часа", "часов")}, ` : ""; var mDisplay = m > 0 ? `${m} ${getNoun(m, "минута", "минуты", "минут")}` : ""; return dDisplay + hDisplay + mDisplay; } export const UserProfile = (props) => { const [lastWatched, setLastWatched] = useState(); const router = useRouter(); useEffect(() => { async function _getData() { const data = await getData( `${endpoints.user.profile}/${props.profile.id}`, ); setLastWatched(data.profile.history); } _getData(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const hasSocials = props.profile.vk_page != "" || props.profile.tg_page != "" || props.profile.tt_page != "" || props.profile.inst_page != "" || false; const socials = [ { name: "vk", nickname: props.profile.vk_page, icon: faVk, urlPrefix: "https://vk.com", }, { name: "telegram", nickname: props.profile.tg_page, icon: faTelegram, urlPrefix: "https://t.me", }, { name: "tiktok", nickname: props.profile.tt_page, icon: faTiktok, urlPrefix: "https://tiktok.com", }, { name: "instagram", nickname: props.profile.inst_page, icon: faInstagram, urlPrefix: "https://instagram.com", }, ]; return ( <>
account_circle
{props.profile.login}

{props.profile.status}

{hasSocials ? (
workspaces
{socials.map((item) => { return item.nickname != "" ? ( ) : ( "" ); })}
) : ( "" )}
avg_pace
Активность
{props.profile.comment_count}

коммент

{props.profile.video_count}

видео

{props.profile.collection_count}

коллекций

{props.profile.friend_count}

друзей

show_chart
Статистика

Просмотрено серий:{" "} {props.profile.watched_episode_count}

Время просмотра:{" "} {convertMinutes(props.profile.watched_time)}

play_arrow Смотрю:{" "} {props.profile.watching_count}

note_stack В Планах:{" "} {props.profile.plan_count}

done Просмотрено:{" "} {props.profile.completed_count}

schedule Отложено:{" "} {props.profile.hold_on_count}

backspace Брошено:{" "} {props.profile.dropped_count}

{lastWatched ? (
tab_recent
Недавно просмотрено
) : ( )} ); };