@@ -16,9 +16,11 @@ import type { PostType } from "../_services/query";
1616import PostUpvote from "../_components/PostUpvote" ;
1717import { getUserRole } from "../_services/action" ;
1818
19- export default function PostPage ( ) {
20- const { postId } = useParams ( ) as { postId : string } ;
19+ interface PostViewProps {
20+ postId : string ;
21+ }
2122
23+ export default function PostView ( { postId } : PostViewProps ) {
2224 const [ supabase , setSupabase ] = useState < any > ( null ) ;
2325
2426 useEffect ( ( ) => {
@@ -92,48 +94,42 @@ export default function PostPage() {
9294
9395 return (
9496 < >
95- < div className = "mx-auto flex w-full max-w-[50rem] flex-col gap-4" >
96- < Box className = "mx-auto w-full rounded-lg bg-white p-8 shadow-xl dark:bg-gray-800" >
97- < div className = "container mx-auto flex flex-col gap-4 px-4 py-6 sm:px-6 lg:px-8" >
98- < h1 className = "text-3xl font-bold" > { post . title } </ h1 >
99- < div className = "flex items-center" >
100- < Image
101- src = { post . author_id ?. image_url || defaultAvatar }
102- alt = { `${ post . author_id ?. first_name || "User" } 's profile` }
103- className = "mr-4 h-10 w-10 rounded-full object-cover"
104- width = { 40 }
105- height = { 40 }
106- />
107- < div className = "flex-1" >
108- < h2 className = "font-semibold text-gray-800 dark:text-gray-100" >
109- { post . author_id
110- ? `${ post . author_id . first_name } ${ post . author_id . last_name } `
111- : "Codebility" }
112- </ h2 >
113- </ div >
114- < p className = "text-sm text-gray-500 dark:text-gray-400" >
115- { format ( new Date ( post . created_at ) , "MMM d, yyyy" ) }
116- </ p >
117- </ div >
118-
119- < PostUpvote post = { post } />
120-
121- < img
122- src = { post . image_url || "/assets/images/bg-certificate.png" }
123- alt = "Post image"
124- className = "h-full w-full object-cover"
125- />
126- < p className = "mb-4 mt-4 text-justify text-gray-600 dark:text-gray-400" >
127- { post . content }
128- </ p >
129- { isMentor && (
130- < Button className = "mb-4 mt-4 w-auto" onClick = { openModal } >
131- Edit Post
132- </ Button >
133- ) }
134- </ div >
135- </ Box >
97+ < h1 className = "text-3xl font-bold" > { post . title } </ h1 >
98+ < div className = "flex items-center" >
99+ < Image
100+ src = { post . author_id ?. image_url || defaultAvatar }
101+ alt = { `${ post . author_id ?. first_name || "User" } 's profile` }
102+ className = "mr-4 h-10 w-10 rounded-full object-cover"
103+ width = { 40 }
104+ height = { 40 }
105+ />
106+ < div className = "flex-1" >
107+ < h2 className = "font-semibold text-gray-800 dark:text-gray-100" >
108+ { post . author_id
109+ ? `${ post . author_id . first_name } ${ post . author_id . last_name } `
110+ : "Codebility" }
111+ </ h2 >
112+ </ div >
113+ < p className = "text-sm text-gray-500 dark:text-gray-400" >
114+ { format ( new Date ( post . created_at ) , "MMM d, yyyy" ) }
115+ </ p >
136116 </ div >
117+
118+ < PostUpvote post = { post } />
119+
120+ < img
121+ src = { post . image_url || "/assets/images/bg-certificate.png" }
122+ alt = "Post image"
123+ className = "h-full w-full object-cover"
124+ />
125+ < p className = "mb-4 mt-4 text-justify text-gray-600 dark:text-gray-400" >
126+ { post . content }
127+ </ p >
128+ { isMentor && (
129+ < Button className = "mb-4 mt-4 w-auto" onClick = { openModal } >
130+ Edit Post
131+ </ Button >
132+ ) }
137133 < EditPostModal
138134 post = { post }
139135 isOpen = { isModalOpen }
0 commit comments