diff --git a/app/api/utils.ts b/app/api/utils.ts index a4c0f3f..0c27799 100644 --- a/app/api/utils.ts +++ b/app/api/utils.ts @@ -114,9 +114,10 @@ const months = [ "дек.", ]; -export function unixToDate(unix: number) { +export function unixToDate(unix: number, type: string = "short") { const date = new Date(unix * 1000); - return date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear(); + if (type === "short") return date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear(); + if (type === "full") return date.getDate() + " " + months[date.getMonth()] + " " + date.getFullYear() + ", " + date.getHours() + ":" + date.getMinutes(); } export const getSeasonFromUnix = (unix: number) => { diff --git a/app/components/Comments/Comments.Comment.tsx b/app/components/Comments/Comments.Comment.tsx new file mode 100644 index 0000000..c99adf7 --- /dev/null +++ b/app/components/Comments/Comments.Comment.tsx @@ -0,0 +1,97 @@ +import { unixToDate } from "#/api/utils"; +import { useEffect, useState } from "react"; +import { ENDPOINTS } from "#/api/config"; + +export const CommentsComment = (props: { + profile: { login: string; avatar: string; id: number }; + comment: { + id: number; + timestamp: number; + message: string; + likes: number; + reply_count: number; + }; + isSubComment?: boolean; +}) => { + const [replies, setReplies] = useState([]); + useEffect(() => { + async function _fetchReplies() { + await fetch( + `${ENDPOINTS.release.info}/comment/replies/${props.comment.id}/0?sort=2` + ) + .then((res) => res.json()) + .then((data) => { + setReplies(data.content); + }); + } + if (!props.isSubComment && props.comment.reply_count > 0) { + _fetchReplies(); + } + }, []); + + return ( +
+ +

+ {props.comment.message} +

+
+ +
+ {replies.length > 0 && + replies.map((comment: any) => ( + + ))} +
+ ); +}; diff --git a/app/components/Comments/Comments.Main.tsx b/app/components/Comments/Comments.Main.tsx new file mode 100644 index 0000000..76f7ad7 --- /dev/null +++ b/app/components/Comments/Comments.Main.tsx @@ -0,0 +1,64 @@ +import { Card, Button } from "flowbite-react"; +import { CommentsComment } from "./Comments.Comment"; +export const CommentsMain = (props: { + release_id: number; + token: string | null; + comments: any; +}) => { + return ( + +
+
+
+

+ Комментарии +

+

+ Популярные и актуальные +

+
+ +
+
+
+ + +
+ +
+ {props.comments.map((comment: any) => ( + + ))} +
+
+ ); +}; diff --git a/app/components/ReleasePlayer/ReleasePlayer.tsx b/app/components/ReleasePlayer/ReleasePlayer.tsx index f855dab..bd799ce 100644 --- a/app/components/ReleasePlayer/ReleasePlayer.tsx +++ b/app/components/ReleasePlayer/ReleasePlayer.tsx @@ -97,7 +97,7 @@ export const ReleasePlayer = (props: { id: number }) => { return ( {!voiceoverInfo || !sourcesInfo || !episodeInfo ? ( -
+
) : ( diff --git a/app/pages/Release.tsx b/app/pages/Release.tsx index a367118..1db0b0b 100644 --- a/app/pages/Release.tsx +++ b/app/pages/Release.tsx @@ -14,6 +14,7 @@ import { ReleaseInfoUserList } from "#/components/ReleaseInfo/ReleaseInfo.UserLi import { ReleaseInfoRating } from "#/components/ReleaseInfo/ReleaseInfo.Rating"; import { ReleaseInfoRelated } from "#/components/ReleaseInfo/ReleaseInfo.Related"; import { ReleaseInfoScreenshots } from "#/components/ReleaseInfo/ReleaseInfo.Screenshots"; +import { CommentsMain } from "#/components/Comments/Comments.Main"; export const ReleasePage = (props: any) => { const token = useUserStore((state) => state.token); @@ -46,7 +47,7 @@ export const ReleasePage = (props: any) => { return data ? (
-
+
{ note={data.release.note} />
-
+
{ genres={data.release.genres} />
-
+
{ />
{data.release.status.name.toLowerCase() != "анонс" && ( -
+
)} {data.release.status.name.toLowerCase() != "анонс" && ( -
+
{
)} {data.release.screenshot_images.length > 0 && ( -
+
)} + +
+ +
+ {data.release.related_releases.length > 0 && ( -
+