mirror of
https://github.com/Radiquum/AniX.git
synced 2025-09-05 22:15:36 +05:00
anix/feat: add new stats
anix/fix: search links from release page
This commit is contained in:
parent
b93aeeed04
commit
c636c843ed
3 changed files with 102 additions and 44 deletions
|
@ -3,12 +3,21 @@ import Link from "next/link";
|
||||||
import ApexCharts from "apexcharts";
|
import ApexCharts from "apexcharts";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { minutesToTime } from "#/api/utils";
|
import { minutesToTime } from "#/api/utils";
|
||||||
|
import { ReleaseInfoSearchLink } from "../ReleaseInfo/ReleaseInfo.SearchLink";
|
||||||
|
|
||||||
|
type preferredItem = {
|
||||||
|
name: string;
|
||||||
|
percentage: number;
|
||||||
|
};
|
||||||
|
|
||||||
export const ProfileStats = (props: {
|
export const ProfileStats = (props: {
|
||||||
lists: Array<number>;
|
lists: Array<number>;
|
||||||
watched_count: number;
|
watched_count: number;
|
||||||
watched_time: number;
|
watched_time: number;
|
||||||
profile_id: number
|
profile_id: number;
|
||||||
|
preferred_genres: Array<preferredItem>;
|
||||||
|
preferred_audiences: Array<preferredItem>;
|
||||||
|
preferred_themes: Array<preferredItem>;
|
||||||
}) => {
|
}) => {
|
||||||
const getChartOptions = () => {
|
const getChartOptions = () => {
|
||||||
return {
|
return {
|
||||||
|
@ -81,41 +90,95 @@ export const ProfileStats = (props: {
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<div>
|
<div>
|
||||||
<p className="align-center whitespace-nowrap">
|
<div className="grid grid-cols-2 gap-y-2 gap-x-4">
|
||||||
<span className="inline-block rounded w-4 h-4 bg-[#66bb6c]"></span>{" "}
|
<p className="align-center whitespace-nowrap">
|
||||||
Смотрю <span className="font-bold">{props.lists[0]}</span>
|
<span className="inline-block rounded w-4 h-4 bg-[#66bb6c]"></span>{" "}
|
||||||
</p>
|
Смотрю <span className="font-bold">{props.lists[0]}</span>
|
||||||
<p className="align-center whitespace-nowrap">
|
</p>
|
||||||
<span className="inline-block rounded w-4 h-4 bg-[#b566bb]"></span>{" "}
|
<p className="align-center whitespace-nowrap">
|
||||||
В планах <span className="font-bold">{props.lists[1]}</span>
|
<span className="inline-block rounded w-4 h-4 bg-[#b566bb]"></span>{" "}
|
||||||
</p>
|
В планах <span className="font-bold">{props.lists[1]}</span>
|
||||||
<p className="align-center whitespace-nowrap">
|
</p>
|
||||||
<span className="inline-block rounded w-4 h-4 bg-[#5c6cc0]"></span>{" "}
|
<p className="align-center whitespace-nowrap">
|
||||||
Просмотрено <span className="font-bold">{props.lists[2]}</span>
|
<span className="inline-block rounded w-4 h-4 bg-[#5c6cc0]"></span>{" "}
|
||||||
</p>
|
Просмотрено <span className="font-bold">{props.lists[2]}</span>
|
||||||
<p className="align-center whitespace-nowrap">
|
</p>
|
||||||
<span className="inline-block rounded w-4 h-4 bg-[#ffca28]"></span>{" "}
|
<p className="align-center whitespace-nowrap">
|
||||||
Отложено <span className="font-bold">{props.lists[3]}</span>
|
<span className="inline-block rounded w-4 h-4 bg-[#ffca28]"></span>{" "}
|
||||||
</p>
|
Отложено <span className="font-bold">{props.lists[3]}</span>
|
||||||
<p className="align-center whitespace-nowrap">
|
</p>
|
||||||
<span className="inline-block rounded w-4 h-4 bg-[#ef5450]"></span>{" "}
|
<p className="align-center whitespace-nowrap">
|
||||||
Брошено <span className="font-bold">{props.lists[4]}</span>
|
<span className="inline-block rounded w-4 h-4 bg-[#ef5450]"></span>{" "}
|
||||||
</p>
|
Брошено <span className="font-bold">{props.lists[4]}</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="mt-4">
|
||||||
|
<p>
|
||||||
|
Жанры:{" "}
|
||||||
|
<span>
|
||||||
|
{props.preferred_genres.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<div key={`preferred-genres-${item.name}`} className="inline">
|
||||||
|
{index > 0 && ", "}
|
||||||
|
<ReleaseInfoSearchLink
|
||||||
|
title={item.name}
|
||||||
|
searchBy={"tag"}
|
||||||
|
/>{" "}
|
||||||
|
<span className="text-sm text-gray-700 dark:text-gray-300">{item.percentage}%</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Аудитория:{" "}
|
||||||
|
<span>
|
||||||
|
{props.preferred_audiences.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<div key={`preferred-audiences-${item.name}`} className="inline">
|
||||||
|
{index > 0 && ", "}
|
||||||
|
<ReleaseInfoSearchLink
|
||||||
|
title={item.name}
|
||||||
|
searchBy={"tag"}
|
||||||
|
/>{" "}
|
||||||
|
<span className="text-sm text-gray-700 dark:text-gray-300">{item.percentage}%</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Тематика:{" "}
|
||||||
|
<span>
|
||||||
|
{props.preferred_themes.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<div key={`preferred-themes-${item.name}`} className="inline">
|
||||||
|
{index > 0 && ", "}
|
||||||
|
<ReleaseInfoSearchLink
|
||||||
|
title={item.name}
|
||||||
|
searchBy={"tag"}
|
||||||
|
/>{" "}
|
||||||
|
<span className="text-sm text-gray-700 dark:text-gray-300">{item.percentage}%</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Просмотрено серий:{" "}
|
||||||
|
<span className="font-bold">{props.watched_count}</span>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Время просмотра:{" "}
|
||||||
|
<span className="font-bold">
|
||||||
|
~{minutesToTime(props.watched_time)}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="donut-chart"></div>
|
<div id="donut-chart"></div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<p>
|
|
||||||
Просмотрено серий:{" "}
|
|
||||||
<span className="font-bold">{props.watched_count}</span>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Время просмотра:{" "}
|
|
||||||
<span className="font-bold">
|
|
||||||
~{minutesToTime(props.watched_time)}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,19 +1,11 @@
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
|
||||||
// const searchBy = {
|
|
||||||
// title: 0,
|
|
||||||
// studio: 1,
|
|
||||||
// director: 2,
|
|
||||||
// author: 3,
|
|
||||||
// genre: 4
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TODO: сделать какую-нибудь анимацию на ссылке при наведении и фокусе
|
// TODO: сделать какую-нибудь анимацию на ссылке при наведении и фокусе
|
||||||
export const ReleaseInfoSearchLink = (props: { title: string, searchBy: string | number | null }) => {
|
export const ReleaseInfoSearchLink = (props: { title: string, searchBy: string }) => {
|
||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
className="underline"
|
className="text-gray-700 transition-colors duration-300 hover:text-black dark:text-gray-300 hover:dark:text-white"
|
||||||
href={`/search?q=${props.title}&searchBy=${props.searchBy}`}
|
href={`/search?query=${props.title}¶ms={"where"%3A"releases"%2C"searchBy"%3A"${props.searchBy}"}`}
|
||||||
>
|
>
|
||||||
{props.title}
|
{props.title}
|
||||||
</Link>
|
</Link>
|
||||||
|
|
|
@ -164,6 +164,9 @@ export const ProfilePage = (props: any) => {
|
||||||
watched_count={user.watched_episode_count}
|
watched_count={user.watched_episode_count}
|
||||||
watched_time={user.watched_time}
|
watched_time={user.watched_time}
|
||||||
profile_id={user.id}
|
profile_id={user.id}
|
||||||
|
preferred_genres={user.preferred_genres || []}
|
||||||
|
preferred_audiences={user.preferred_audiences || []}
|
||||||
|
preferred_themes={user.preferred_themes || []}
|
||||||
/>
|
/>
|
||||||
<ProfileWatchDynamic watchDynamic={user.watch_dynamics || []} />
|
<ProfileWatchDynamic watchDynamic={user.watch_dynamics || []} />
|
||||||
<div className="flex flex-col gap-2 lg:hidden">
|
<div className="flex flex-col gap-2 lg:hidden">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue