Description
The Prisma schema has a Comment model with postId, userId, content, parentId (for replies), and createdAt. The CommentsSection component exists and renders comments, but it reads from local context state (which is never populated from the database). There are no API endpoints for CRUD operations on comments.
More info
Endpoints needed:
GET /api/posts/[id]/comments — paginated list of comments for a post (with nested replies).
POST /api/posts/[id]/comments — authenticated, create a comment.
DELETE /api/comments/[id] — authenticated, owner-only delete.
The CommentsSection component in components/comments-section.tsx currently uses the context addReply action and stores replies in memory. It should be refactored to:
- Fetch comments from
GET /api/posts/[id]/comments on mount.
- Submit new comments via
POST /api/posts/[id]/comments.
- Support threaded replies using the
parentId field.
Description
The Prisma schema has a
Commentmodel withpostId,userId,content,parentId(for replies), andcreatedAt. TheCommentsSectioncomponent exists and renders comments, but it reads from local context state (which is never populated from the database). There are no API endpoints for CRUD operations on comments.More info
Endpoints needed:
GET /api/posts/[id]/comments— paginated list of comments for a post (with nested replies).POST /api/posts/[id]/comments— authenticated, create a comment.DELETE /api/comments/[id]— authenticated, owner-only delete.The
CommentsSectioncomponent incomponents/comments-section.tsxcurrently uses the contextaddReplyaction and stores replies in memory. It should be refactored to:GET /api/posts/[id]/commentson mount.POST /api/posts/[id]/comments.parentIdfield.