import React from 'react' import { usePage } from '@inertiajs/react' import SeoHead from '../../components/seo/SeoHead' function csrfToken() { return document.querySelector('meta[name="csrf-token"]')?.getAttribute('content') || '' } export default function GroupPostShow() { const { props } = usePage() const group = props.group || {} const post = props.post || {} const recentPosts = Array.isArray(props.recentPosts) ? props.recentPosts : [] const submitReport = async () => { if (!props.reportEndpoint || !post.id) return const reason = window.prompt('Reason for reporting this post?') if (!reason) return await fetch(props.reportEndpoint, { method: 'POST', credentials: 'same-origin', headers: { Accept: 'application/json', 'Content-Type': 'application/json', 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-TOKEN': csrfToken(), }, body: JSON.stringify({ target_type: 'group_post', target_id: post.id, reason }), }) } return (
← Back to {group.name} {props.reportEndpoint ? : null}
{post.type ? {post.type} : null} {post.is_pinned ? Pinned : null}

{post.title}

{post.author?.name || post.author?.username || group.name} • {post.published_at ? new Date(post.published_at).toLocaleString() : 'Recently'}
{post.excerpt ?

{post.excerpt}

: null}
{post.content || ''}
{recentPosts.length > 0 ? (

More from {group.name}

{recentPosts.filter((item) => item.id !== post.id).map((item) => (
{item.type}
{item.title}

{item.excerpt || 'Read the full post.'}

))}
) : null}
) }