import React, { useState } from 'react'; import { Card } from '../ui/card'; import { Button } from '../ui/button'; import { Badge } from '../ui/badge'; import { Post, Comment } from '../../types'; import { Heart, MessageSquare, Repeat, Share2, MoreHorizontal, Play, } from 'lucide-react'; import { CommentItem } from './CommentItem'; import { SharePostModal } from './SharePostModal'; import { useToast } from '../../context/ToastContext'; interface PostCardProps { post: Post; } export const PostCard: React.FC = ({ post }) => { const { addToast } = useToast(); const [isLiked, setIsLiked] = useState(post.isLiked || false); const [likesCount, setLikesCount] = useState(post.likes); const [showComments, setShowComments] = useState(false); const [showShareModal, setShowShareModal] = useState(false); // Mock comments const comments: Comment[] = post.recentComments || [ { id: 'c1', author: { name: 'Fan_01', handle: '@fan', avatar: 'https://picsum.photos/50', }, content: 'This is fire! 🔥', timestamp: '10m', likes: 2, }, { id: 'c2', author: { name: 'Producer_X', handle: '@pro_x', avatar: 'https://picsum.photos/51', }, content: 'What snare is that?', timestamp: '30m', likes: 5, replies: [], }, ]; const handleLike = () => { setIsLiked(!isLiked); setLikesCount((prev) => (isLiked ? prev - 1 : prev + 1)); if (!isLiked) addToast('Liked post'); }; const handleShareConfirm = (type: 'repost' | 'quote', _text?: string) => { addToast(type === 'repost' ? 'Reposted!' : 'Quote posted!', 'success'); }; return ( <> {/* Repost Header */} {post.isRepost && (
{post.repostAuthor} Reposted
)} {/* Post Header */}
{post.author.name} {post.author.isVerified && ( )}
{post.author.handle} • {post.timestamp}
{/* Content */}
{post.content} {post.tags && (
{post.tags.map((tag) => ( {tag} ))}
)}
{/* Media Rendering */} {post.type === 'image' && post.image && (
)} {post.type === 'audio' && post.audioTrack && (
{post.audioTrack.title}
{post.audioTrack.artist}
{Array.from({ length: 40 }).map((_, i) => (
))}
)} {post.type === 'poll' && post.pollOptions && (
{post.pollOptions.map((opt, i) => (
{opt.label} {opt.votes}%
))}
Total votes: 124 • 2 days left
)} {/* Footer Actions */}
{/* Comments Section */} {showComments && (
{comments.map((c) => ( addToast('Liked comment')} onReply={(handle) => addToast(`Replying to ${handle}`)} /> ))}
{post.comments > 2 && ( )}
)}
{showShareModal && ( setShowShareModal(false)} onConfirm={handleShareConfirm} /> )} ); };