import React, { useState } from 'react'; import { Heart, MessageCircle } from 'lucide-react'; import { CommunityPost } from '../types'; interface CommunityCardProps { post: CommunityPost; index: number; } export const CommunityCard: React.FC = ({ post, index }) => { const [isLiked, setIsLiked] = useState(post.isLiked); const [likeCount, setLikeCount] = useState(post.likeCount); const handleLike = () => { // Optimistic UI update const newLikedState = !isLiked; setIsLiked(newLikedState); setLikeCount(prev => newLikedState ? prev + 1 : prev - 1); }; // Format time strictly relative or simple (e.g., "10 min ago" or "Evening") const getTimeString = (timestamp: number) => { const diff = Date.now() - timestamp; const minutes = Math.floor(diff / 60000); if (minutes < 60) return `${minutes}m ago`; const hours = Math.floor(minutes / 60); if (hours < 24) return `${hours}h ago`; return new Date(timestamp).toLocaleDateString([], { month: 'short', day: 'numeric' }); }; return (
{/* Top Row: User info (Anonymous) - very subtle */}
{post.user.name}
{/* Content */}

{post.content}

{/* Footer: Interactions + Time */}
{/* Like Button */} {/* Comment Button (Visual only for now) */}
{/* Timestamp */} {getTimeString(post.createdAt)}
); };