import { NewsItem } from '@/types/news'; import { Card, CardContent, CardHeader } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Clock, Pin, ExternalLink, Eye, Trash2 } from 'lucide-react'; import { cn } from '@/lib/utils'; import { useAuth } from '@/hooks/useAuth'; interface NewsCardProps { news: NewsItem; onTogglePin: (id: string) => void; onMarkAsRead: (id: string) => void; onDelete: (id: string) => void; onOpenArticle: (article: NewsItem) => void; } const NewsCard = ({ news, onTogglePin, onMarkAsRead, onDelete, onOpenArticle }: NewsCardProps) => { const { user } = useAuth(); // Function to decode HTML entities const decodeHtmlEntities = (text: string) => { const textarea = document.createElement('textarea'); textarea.innerHTML = text; return textarea.value; }; const getSourceColor = (category: string) => { switch (category) { case 'rss': return 'bg-blue-500/10 text-blue-700 border-blue-200'; case 'youtube': return 'bg-red-500/10 text-red-700 border-red-200'; case 'steam': return 'bg-gray-500/10 text-gray-700 border-gray-200'; case 'actualites': return 'bg-green-500/10 text-green-700 border-green-200'; default: return 'bg-muted text-muted-foreground'; } }; const handleCardClick = () => { onOpenArticle(news); if (!news.isRead) { onMarkAsRead(news.id); } }; return
{news.source}

{decodeHtmlEntities(news.title)}

{decodeHtmlEntities(news.description)}

{new Date(news.publishedAt).toLocaleDateString('fr-FR', { day: 'numeric', month: 'long', hour: '2-digit', minute: '2-digit' })}
{!news.isRead && } {news.url && }
; }; export default NewsCard;