@@ -17,6 +17,8 @@ import remarkGfm from "remark-gfm";
1717import type { PostType } from "../_services/query" ;
1818import PostUpvote from "../_components/PostUpvote" ;
1919import { getUserRole } from "../_services/action" ;
20+ import PostViewCommentList from "./PostViewCommentList" ;
21+ import PostViewCreateComment from "./PostViewCreateComment" ;
2022
2123interface PostViewProps {
2224 postId : string ;
@@ -36,6 +38,11 @@ export default function PostView({ postId }: PostViewProps) {
3638 const [ isAdmin , setIsAdmin ] = useState ( true ) ;
3739 const [ isAuthor , setIsAuthor ] = useState ( false ) ;
3840 const { user } = useUserStore ( ) ;
41+ const [ refreshComments , setRefreshComments ] = useState ( 0 ) ;
42+
43+ const triggerRefreshComments = ( ) => {
44+ setRefreshComments ( ( prev ) => prev + 1 ) ;
45+ } ;
3946
4047 useEffect ( ( ) => {
4148 const fetchRole = async ( ) => {
@@ -136,17 +143,31 @@ export default function PostView({ postId }: PostViewProps) {
136143
137144 < PostUpvote post = { post } />
138145
139- < div className = "prose prose-sm dark:prose-invert max-h-[800px] min-h-[160px] max-w-none overflow-y-auto p-4 text-sm" >
140- < ReactMarkdown remarkPlugins = { [ remarkGfm ] } >
141- { `\n\n${ post . content } ` }
142- </ ReactMarkdown >
146+ { /* Scrollable group */ }
147+ < div className = "max-h-[90vh] overflow-y-auto" >
148+ < div className = "prose prose-sm dark:prose-invert max-w-none text-sm" >
149+ < ReactMarkdown remarkPlugins = { [ remarkGfm ] } >
150+ { `\n\n${ post . content } ` }
151+ </ ReactMarkdown >
152+ </ div >
153+
154+ { ( isAdmin || isAuthor ) && (
155+ < Button className = "mb-4 mt-4 w-auto" onClick = { openModal } >
156+ Edit Post
157+ </ Button >
158+ ) }
159+ < div className = "mb-1 mt-1 border-t border-gray-200 dark:border-gray-700" />
160+ < PostViewCommentList
161+ postId = { postId }
162+ refresh = { refreshComments }
163+ hasDeleteCommentPrivilege = { isAdmin || isAuthor }
164+ />
143165 </ div >
166+ < PostViewCreateComment
167+ postId = { postId }
168+ onCommentCreated = { triggerRefreshComments }
169+ />
144170
145- { ( isAdmin || isAuthor ) && (
146- < Button className = "mb-4 mt-4 w-auto" onClick = { openModal } >
147- Edit Post
148- </ Button >
149- ) }
150171 < EditPostModal
151172 post = { post }
152173 isOpen = { isModalOpen }
0 commit comments