Add threaded comment replies for admin and curator

- Add parentId field to LessonComment (self-referential FK, SetNull on delete)
- Show replies indented under parent comment with left border visual
- Add reply button (visible to admin/curator only) with inline textarea
- Only root comments shown in main list; replies nested below their parent
- Update comment count to include replies
- Server-side validation: only admin/curator can reply, parent must belong to same lesson

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-29 13:17:30 +05:00
parent 6b5bfc853e
commit c25369b766
6 changed files with 215 additions and 58 deletions
+5 -2
View File
@@ -301,9 +301,12 @@ model LessonComment {
text String
deleted Boolean @default(false)
createdAt DateTime @default(now())
parentId String?
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
lesson Lesson @relation(fields: [lessonId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
parent LessonComment? @relation("CommentReplies", fields: [parentId], references: [id], onDelete: SetNull)
replies LessonComment[] @relation("CommentReplies")
}
// ─────────────────────────────────────────────