import { Link } from 'react-router-dom'
import StatusBadge from './StatusBadge'
interface Post {
id: string
title: string
excerpt?: string
type: 'feature' | 'bug' | 'general'
status: string
voteCount: number
commentCount: number
authorName: string
createdAt: string
boardSlug: string
hasVoted?: boolean
}
export default function PostCard({
post,
onVote,
}: {
post: Post
onVote?: (id: string) => void
}) {
const timeAgo = formatTimeAgo(post.createdAt)
return (
{/* Vote column */}
{/* Content zone */}
{post.type}
{post.authorName} - {timeAgo}
{post.title}
{post.excerpt && (
{post.excerpt}
)}
{/* Status + comments */}
)
}
function formatTimeAgo(date: string): string {
const seconds = Math.floor((Date.now() - new Date(date).getTime()) / 1000)
if (seconds < 60) return 'just now'
const minutes = Math.floor(seconds / 60)
if (minutes < 60) return `${minutes}m ago`
const hours = Math.floor(minutes / 60)
if (hours < 24) return `${hours}h ago`
const days = Math.floor(hours / 24)
if (days < 30) return `${days}d ago`
const months = Math.floor(days / 30)
return `${months}mo ago`
}