Edited {formatTimeAgo(editedAt)}
)} {/* Attachments */} {post?.attachments?.length > 0 && (import React, { useState } from 'react'
import AuthorBadge from './AuthorBadge'
export default function PostCard({ post, thread, isOp = false, isAuthenticated = false, canModerate = false }) {
const [reported, setReported] = useState(false)
const [reporting, setReporting] = useState(false)
const author = post?.user
const content = post?.rendered_content ?? post?.content ?? ''
const postedAt = post?.created_at
const editedAt = post?.edited_at
const isEdited = post?.is_edited
const postId = post?.id
const threadId = thread?.id
const threadSlug = thread?.slug
const handleReport = async () => {
if (reporting || reported) return
setReporting(true)
try {
const res = await fetch(`/forum/post/${postId}/report`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': getCsrf(),
'Accept': 'application/json',
},
credentials: 'same-origin',
})
if (res.ok) setReported(true)
} catch { /* silent */ }
setReporting(false)
}
return (
Edited {formatTimeAgo(editedAt)}
Attachments