import { Link } from 'react-router-dom'; import { FaFire } from 'react-icons/fa'; // Changed FaStar to FaFire import { getFileUrl } from '../../services/pocketbaseService'; // Corrected import path import { useEffect } from 'react'; // Import useEffect for logging import { useAuth } from '../../contexts/AuthContext'; // Import useAuth // MediaCard component displays a card for a media item. // It now accepts averageRating and reviewCount props from the parent. // Added userProfile prop to check admin/critic role function MediaCard({ media, userProfile }) { // Destructure media properties, including the new ones from Supabase // Use 'path' for the link instead of 'id' // Используем 'poster' вместо 'poster_url' для имени файла const { id, title, poster, average_rating, review_count, release_date, type, path, is_published } = media; // Added is_published // Используем getFileUrl для получения URL постера const posterUrl = getFileUrl(media, 'poster'); // Используем имя поля 'poster' const releaseDate = release_date; const averageRating = average_rating; // This is the 10-point average from Supabase const reviewCount = review_count; // Use the 'path' field for the link const mediaLink = path ? `/media/${path}` : `/media/${id}`; // Fallback to id if path is missing (for old data) // Check if the current user is admin or critic const isAdminOrCritic = userProfile && (userProfile.role === 'admin' || userProfile.is_critic === true); // Add log to check average_rating and review_count here when component mounts or media prop changes useEffect(() => { console.log(`MediaCard for "${title}" rendered with media prop:`, media); console.log(`MediaCard for "${title}" stats:`, { average_rating: averageRating, review_count: reviewCount, is_published: is_published }); }, [media]); return (