import { useContext } from 'react'
import { format } from 'date-fns'
import { ArrowRight } from 'lucide-react'
import { getInitials } from '../utils/api'
import { useLanguage } from '../i18n/LanguageContext'
import { AppContext } from '../App'
import BrandBadge from './BrandBadge'
import StatusBadge from './StatusBadge'
import { PlatformIcons } from './PlatformIcon'
export default function PostCard({ post, onClick, onMove, compact = false }) {
const { t } = useLanguage()
const { getBrandName } = useContext(AppContext)
const brandName = getBrandName(post.brand_id || post.brandId) || post.brand_name || post.brand
// Support both single platform and platforms array
const platforms = post.platforms?.length > 0
? post.platforms
: (post.platform ? [post.platform] : [])
const assigneeName = post.assignedToName || post.assignedName || post.assigned_name || (typeof post.assignedTo === 'object' ? post.assignedTo?.name : null)
if (compact) {
return (
{post.thumbnail_url && (
)}
{brandName && }
{assigneeName ? (
{getInitials(assigneeName)}
{assigneeName}
) : (
{t('common.unassigned')}
)}
{post.scheduledDate && (
{format(new Date(post.scheduledDate), 'MMM d')}
)}
{/* Quick move buttons */}
{onMove && (
{post.status === 'draft' && (
)}
{post.status === 'in_review' && (
)}
{post.status === 'approved' && (
)}
{post.status === 'scheduled' && (
)}
)}
)
}
// Table row view
return (
|
|
{brandName && } |
|
|
{assigneeName || '—'}
|
{post.scheduledDate ? format(new Date(post.scheduledDate), 'MMM d, yyyy') : '—'}
|
)
}