diff --git a/frontend/app/components/ReleaseCard/ReleaseCard.jsx b/frontend/app/components/ReleaseCard/ReleaseCard.jsx index b4bdc13..7f63022 100644 --- a/frontend/app/components/ReleaseCard/ReleaseCard.jsx +++ b/frontend/app/components/ReleaseCard/ReleaseCard.jsx @@ -3,10 +3,13 @@ import Image from "next/image"; export const ReleaseCard = (props) => { return ( - +
{/* eslint-disable-next-line @next/next/no-img-element */}
diff --git a/frontend/app/components/UserProfile/UserProfile.jsx b/frontend/app/components/UserProfile/UserProfile.jsx new file mode 100644 index 0000000..2b937ec --- /dev/null +++ b/frontend/app/components/UserProfile/UserProfile.jsx @@ -0,0 +1,170 @@ +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"; + +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(); + + 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 + }, []); + + return ( + <> +
+
+
+ account_circle +
+ Ваш профиль +
+
{props.profile.login}
+

{props.profile.status}

+
+
+
+
+
+
+ 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 +
Недавно просмотрено
+
+ +
+ ) : ( + "" + )} + + ); +}; diff --git a/frontend/app/login/page.js b/frontend/app/login/page.js index 13e76f5..52c3725 100644 --- a/frontend/app/login/page.js +++ b/frontend/app/login/page.js @@ -38,7 +38,7 @@ export default function LoginPage() { }, [userStore.user]); return ( -
+
login
Вход в аккаунт anixart.
diff --git a/frontend/app/profile/page.js b/frontend/app/profile/page.js new file mode 100644 index 0000000..2696919 --- /dev/null +++ b/frontend/app/profile/page.js @@ -0,0 +1,17 @@ +"use client"; +import { useUserStore } from "@/app/store/user-store"; +import { UserProfile } from "@/app/components/UserProfile/UserProfile"; + +export default function Profile() { + const userStore = useUserStore(); + + return ( + <> + {userStore.user ? ( + + ) : ( + + )} + + ); +} diff --git a/frontend/next.config.mjs b/frontend/next.config.mjs index 51b96fe..d37672a 100644 --- a/frontend/next.config.mjs +++ b/frontend/next.config.mjs @@ -1,5 +1,6 @@ /** @type {import('next').NextConfig} */ const nextConfig = { + reactStrictMode: false, images: { remotePatterns: [ {