feat: add comment replies and liking functionality

- Introduced support for nested comment replies in both frontend and backend.
- Added comment liking and unliking features, including like count and "isLiked" state tracking.
- Updated database schema with `parentId` and new `comment_likes` table.
- Enhanced UI for threaded comments and implemented display of like counts and reply actions.
- Refactored APIs and repositories to support replies, likes, and enriched comment data.
This commit is contained in:
Mathis HERRIOT
2026-01-29 15:26:54 +01:00
parent ed3ed66cab
commit 0976850c0c
11 changed files with 405 additions and 92 deletions

View File

@@ -3,6 +3,9 @@ import api from "@/lib/api";
export interface Comment {
id: string;
text: string;
parentId?: string;
likesCount: number;
isLiked: boolean;
createdAt: string;
updatedAt: string;
user: {
@@ -19,9 +22,14 @@ export const CommentService = {
return data;
},
async create(contentId: string, text: string): Promise<Comment> {
async create(
contentId: string,
text: string,
parentId?: string,
): Promise<Comment> {
const { data } = await api.post<Comment>(`/contents/${contentId}/comments`, {
text,
parentId,
});
return data;
},
@@ -29,4 +37,12 @@ export const CommentService = {
async remove(commentId: string): Promise<void> {
await api.delete(`/comments/${commentId}`);
},
async like(commentId: string): Promise<void> {
await api.post(`/comments/${commentId}/like`);
},
async unlike(commentId: string): Promise<void> {
await api.delete(`/comments/${commentId}/like`);
},
};