Skip to content

Implement comments API endpoints and connect CommentsSection component #186

@3m1n3nc3

Description

@3m1n3nc3

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:

  1. Fetch comments from GET /api/posts/[id]/comments on mount.
  2. Submit new comments via POST /api/posts/[id]/comments.
  3. Support threaded replies using the parentId field.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions