diff --git a/TODO.md b/TODO.md
index 92ff8e3..0273c61 100644
--- a/TODO.md
+++ b/TODO.md
@@ -17,7 +17,6 @@
### Коллекции
- [ ] Добавление \ Удаление аниме в\из коллекции
-- [ ] Просмотр комментариев и комментирование
### Страница аниме тайтла
diff --git a/app/components/CollectionInfo/CollectionInfo.Basics.tsx b/app/components/CollectionInfo/CollectionInfo.Basics.tsx
index 6513735..5e6432f 100644
--- a/app/components/CollectionInfo/CollectionInfo.Basics.tsx
+++ b/app/components/CollectionInfo/CollectionInfo.Basics.tsx
@@ -15,32 +15,34 @@ export const CollectionInfoBasics = (props: {
}) => {
return (
-
-
-
создана: {unixToDate(props.creationDate, "full")}
-
обновлена: {unixToDate(props.updateDate, "full")}
+
+
+
+
создана: {unixToDate(props.creationDate, "full")}
+
обновлена: {unixToDate(props.updateDate, "full")}
+
+
+
+
+
{props.authorLogin}
+
Автор
+
+
+
+
+
+

+
+
+
{props.title}
+
{props.description}
-
-
-
-
{props.authorLogin}
-
Автор
-
-
-
-
-
-

-
-
-
{props.title}
-
{props.description}
);
diff --git a/app/components/Comments/Comments.Add.tsx b/app/components/Comments/Comments.Add.tsx
index b275ddb..66ffee8 100644
--- a/app/components/Comments/Comments.Add.tsx
+++ b/app/components/Comments/Comments.Add.tsx
@@ -13,6 +13,7 @@ export const CommentsAddModal = (props: {
token: string;
setShouldRender?: any;
setCommentSend?: any;
+ type?: "release" | "collection";
}) => {
const [message, setMessage] = useState(
props.isReply ? `${props.parentProfile.login}, ` : ""
@@ -31,13 +32,18 @@ export const CommentsAddModal = (props: {
};
async function _send() {
- const res = await fetch(
- `${ENDPOINTS.release.info}/comment/add/${props.release_id}?token=${props.token}`,
- {
- method: "POST",
- body: JSON.stringify(data),
- }
- );
+ let url;
+
+ if (props.type == "collection") {
+ url = `${ENDPOINTS.collection.base}/comment/add/${props.release_id}?token=${props.token}`;
+ } else {
+ url = `${ENDPOINTS.release.info}/comment/add/${props.release_id}?token=${props.token}`;
+ }
+
+ const res = await fetch(url, {
+ method: "POST",
+ body: JSON.stringify(data),
+ });
if (props.isReply && props.setShouldRender && props.setCommentSend) {
props.setShouldRender(true);
diff --git a/app/components/Comments/Comments.Comment.tsx b/app/components/Comments/Comments.Comment.tsx
index 02b3707..0788d2a 100644
--- a/app/components/Comments/Comments.Comment.tsx
+++ b/app/components/Comments/Comments.Comment.tsx
@@ -27,6 +27,7 @@ export const CommentsComment = (props: {
parentComment?: any;
setShouldRender?: (shouldRender: boolean) => void;
setCommentSend?: (commentSend: boolean) => void;
+ type?: "release" | "collection";
}) => {
const [replies, setReplies] = useState([]);
const [likes, setLikes] = useState(props.comment.likes_count);
@@ -49,7 +50,12 @@ export const CommentsComment = (props: {
async function _deleteComment() {
if (props.token) {
- let url = `${ENDPOINTS.release.info}/comment/delete/${props.comment.id}?token=${props.token}`;
+ let url;
+ if (props.type == "collection") {
+ url = `${ENDPOINTS.collection.base}/comment/delete/${props.comment.id}?token=${props.token}`;
+ } else {
+ url = `${ENDPOINTS.release.info}/comment/delete/${props.comment.id}?token=${props.token}`;
+ }
await fetch(url);
if (props.setShouldRender && props.setCommentSend) {
@@ -62,9 +68,17 @@ export const CommentsComment = (props: {
useEffect(() => {
async function _fetchReplies() {
setReplies([]);
- let url = `${ENDPOINTS.release.info}/comment/replies/${
- parentCommentId || props.comment.id
- }/0?sort=2`;
+ let url;
+ if (props.type == "collection") {
+ url = `${ENDPOINTS.collection.base}/comment/replies/${
+ parentCommentId || props.comment.id
+ }/0?sort=2`;
+ } else {
+ url = `${ENDPOINTS.release.info}/comment/replies/${
+ parentCommentId || props.comment.id
+ }/0?sort=2`;
+ }
+
if (props.token) {
url += `&token=${props.token}`;
}
@@ -88,7 +102,13 @@ export const CommentsComment = (props: {
async function _sendVote(action: number) {
if (props.token) {
- let url = `${ENDPOINTS.release.info}/comment/vote/${props.comment.id}/${action}?token=${props.token}`;
+ let url;
+
+ if (props.type == "collection") {
+ url = `${ENDPOINTS.collection.base}/comment/vote/${props.comment.id}/${action}?token=${props.token}`;
+ } else {
+ url = `${ENDPOINTS.release.info}/comment/vote/${props.comment.id}/${action}?token=${props.token}`;
+ }
fetch(url);
}
}
@@ -126,7 +146,7 @@ export const CommentsComment = (props: {
<>
@@ -300,6 +322,7 @@ export const CommentsComment = (props: {
parentProfile={props.profile}
setShouldRender={props.setShouldRender || setShouldRender}
setCommentSend={props.setCommentSend || setCommentSend}
+ type={props.type}
/>
{props.token && (
)}
>
diff --git a/app/components/Comments/Comments.Edit.tsx b/app/components/Comments/Comments.Edit.tsx
index 67faca0..2108d02 100644
--- a/app/components/Comments/Comments.Edit.tsx
+++ b/app/components/Comments/Comments.Edit.tsx
@@ -9,6 +9,7 @@ export const CommentsEditModal = (props: {
token: string;
setShouldRender?: any;
setCommentSend?: any;
+ type?: "release" | "collection";
}) => {
const [message, setMessage] = useState(props.parentComment.message);
const [isSpoiler, setIsSpoiler] = useState(props.parentComment.isSpoiler);
@@ -23,13 +24,16 @@ export const CommentsEditModal = (props: {
};
async function _send() {
- const res = await fetch(
- `${ENDPOINTS.release.info}/comment/edit/${props.parentComment.id}?token=${props.token}`,
- {
- method: "POST",
- body: JSON.stringify(data),
- }
- );
+ let url;
+ if (props.type == "collection") {
+ url = `${ENDPOINTS.collection.base}/comment/edit/${props.parentComment.id}?token=${props.token}`;
+ } else {
+ url = `${ENDPOINTS.release.info}/comment/edit/${props.parentComment.id}?token=${props.token}`;
+ }
+ const res = await fetch(url, {
+ method: "POST",
+ body: JSON.stringify(data),
+ });
if (props.setShouldRender && props.setCommentSend) {
props.setShouldRender(true);
diff --git a/app/components/Comments/Comments.Main.tsx b/app/components/Comments/Comments.Main.tsx
index 6a4bfda..7987fe7 100644
--- a/app/components/Comments/Comments.Main.tsx
+++ b/app/components/Comments/Comments.Main.tsx
@@ -9,9 +9,11 @@ export const CommentsMain = (props: {
release_id: number;
token: string | null;
comments: any;
+ type?: "release" | "collection";
}) => {
const [isAllCommentsOpen, setIsAllCommentsOpen] = useState(false);
const [isAddCommentsOpen, setIsAddCommentsOpen] = useState(false);
+ const type = props.type || "release";
return (
<>
@@ -55,6 +57,8 @@ export const CommentsMain = (props: {
isDeleted: comment.is_deleted,
}}
token={props.token}
+ isSubComment={type != "release"}
+ type={type}
/>
))}
@@ -65,13 +69,15 @@ export const CommentsMain = (props: {
setIsOpen={setIsAllCommentsOpen}
release_id={props.release_id}
token={props.token}
+ type={props.type}
/>
+ type={props.type}
+ />
>
);
};
@@ -95,6 +101,7 @@ const CommentsAllModal = (props: {
setIsOpen: any;
release_id: number;
token: string | null;
+ type?: "release" | "collection";
}) => {
const [isLoadingEnd, setIsLoadingEnd] = useState(false);
const [currentRef, setCurrentRef] = useState
(null);
@@ -102,9 +109,16 @@ const CommentsAllModal = (props: {
setCurrentRef(ref);
}, []);
+ const type = props.type || "release";
+
const getKey = (pageIndex: number, previousPageData: any) => {
if (previousPageData && !previousPageData.content.length) return null;
- let url = `${ENDPOINTS.release.info}/comment/all/${props.release_id}/${pageIndex}?sort=1`;
+ let url;
+ if (type == "release") {
+ url = `${ENDPOINTS.release.info}/comment/all/${props.release_id}/${pageIndex}?sort=1`;
+ } else if (type == "collection") {
+ url = `${ENDPOINTS.collection.base}/comment/all/${props.release_id}/${pageIndex}?sort=1`;
+ }
if (props.token) {
url += `&token=${props.token}`;
}
@@ -184,7 +198,8 @@ const CommentsAllModal = (props: {
isDeleted: comment.is_deleted,
}}
token={props.token}
- />
+ type={type}
+ />
))
) : (
diff --git a/app/components/ReleaseInfo/ReleaseInfo.UserList.tsx b/app/components/ReleaseInfo/ReleaseInfo.UserList.tsx
index 139ec98..fa0b419 100644
--- a/app/components/ReleaseInfo/ReleaseInfo.UserList.tsx
+++ b/app/components/ReleaseInfo/ReleaseInfo.UserList.tsx
@@ -100,7 +100,7 @@ export const ReleaseInfoUserList = (props: {
>
) : (
-
Войдите что-бы добавить список, избранное или коллекцию
+ Войдите что-бы добавить в список, избранное или коллекцию
)}
diff --git a/app/pages/ViewCollection.tsx b/app/pages/ViewCollection.tsx
index 94bc989..2460862 100644
--- a/app/pages/ViewCollection.tsx
+++ b/app/pages/ViewCollection.tsx
@@ -12,6 +12,7 @@ import { ReleaseSection } from "#/components/ReleaseSection/ReleaseSection";
import { CollectionInfoBasics } from "#/components/CollectionInfo/CollectionInfo.Basics";
import { InfoLists } from "#/components/InfoLists/InfoLists";
import { CollectionInfoControls } from "#/components/CollectionInfo/CollectionInfoControls";
+import { CommentsMain } from "#/components/Comments/Comments.Main";
const fetcher = async (url: string) => {
const res = await fetch(url);
@@ -32,11 +33,17 @@ export const ViewCollectionPage = (props: { id: number }) => {
const [isLoadingEnd, setIsLoadingEnd] = useState(false);
const router = useRouter();
- function useFetchCollectionInfo() {
- let url: string = `${ENDPOINTS.collection.base}/${props.id}`;
+ function useFetchCollectionInfo(type: "info" | "comments") {
+ let url: string;
+
+ if (type == "info") {
+ url = `${ENDPOINTS.collection.base}/${props.id}`;
+ } else if (type == "comments") {
+ url = `${ENDPOINTS.collection.base}/comment/all/${props.id}/0?sort=3`;
+ }
if (userStore.token) {
- url += `?token=${userStore.token}`;
+ url += `${type != "info" ? "&" : "?"}token=${userStore.token}`;
}
const { data, isLoading } = useSWR(url, fetcher);
@@ -51,7 +58,10 @@ export const ViewCollectionPage = (props: { id: number }) => {
return url;
};
- const [collectionInfo, collectionInfoIsLoading] = useFetchCollectionInfo();
+ const [collectionInfo, collectionInfoIsLoading] =
+ useFetchCollectionInfo("info");
+ const [collectionComments, collectionCommentsIsLoading] =
+ useFetchCollectionInfo("comments");
const { data, error, isLoading, size, setSize } = useSWRInfinite(
getKey,
@@ -87,7 +97,7 @@ export const ViewCollectionPage = (props: { id: number }) => {
) : (
collectionInfo && (
<>
-
+
{
creationDate={collectionInfo.collection.creation_date}
updateDate={collectionInfo.collection.last_update_date}
/>
- {userStore.token && !isLoading && (
-
-
+ {collectionComments && !collectionCommentsIsLoading && (
+
-
-
- )}
+ )}
+ {userStore.token && !isLoading && (
+ <>
+
+
+ >
+ )}
+
{isLoading || !content || !isLoadingEnd ? (