--- import AdminLayout from '../../layouts/AdminLayout.astro'; import { txasupabase } from '../../lib/txasupabase.js'; // Fetch real statistics from Supabase const localMovies = await txasupabase.getLocalMovies(); const totalMovies = Object.keys(localMovies).length; const users = await txasupabase.getUsers(); const totalUsers = users.length; // Fetch real count for comments const { count: commentsCount } = await txasupabase.supabase .from('comments') .select('*', { count: 'exact', head: true }); // Fetch real count for email logs (báo lỗi/gửi mail) const { count: emailLogsCount } = await txasupabase.supabase .from('email_logs') .select('*', { count: 'exact', head: true }); const stats = [ { label: 'Tổng số phim (Cục bộ)', value: String(totalMovies), icon: 'fas fa-film', color: 'text-blue-500' }, { label: 'Tổng thành viên', value: String(totalUsers), icon: 'fas fa-user-plus', color: 'text-green-500' }, { label: 'Tổng bình luận', value: String(commentsCount || 0), icon: 'fas fa-comments', color: 'text-purple-500' }, { label: 'Lịch sử gửi Email', value: String(emailLogsCount || 0), icon: 'fas fa-envelope-open-text', color: 'text-red-500' }, ]; // Phim mới cập nhật từ Database cục bộ const newestMovies = Object.values(localMovies) .sort((a: any, b: any) => { const timeA = new Date(a.movie.modified?.time || a.movie.created?.time || 0).getTime(); const timeB = new Date(b.movie.modified?.time || b.movie.created?.time || 0).getTime(); return timeB - timeA; }) .slice(0, 5); const formatImageUrl = (url: string) => { if (!url) return '/placeholder-poster.jpg'; if (url.startsWith('http')) return url; const cleanUrl = url.startsWith('/') ? url : `/${url}`; return `https://phimimg.com${cleanUrl}`; }; ---

Bảng điều khiển

Chào mừng bạn trở lại, hệ thống đang hoạt động ổn định.

{stats.map(stat => (

{stat.label}

{stat.value}

))}

Phim mới cập nhật

Xem tất cả
{newestMovies.length > 0 ? newestMovies.map((m: any) => { const movie = m.movie; const poster = formatImageUrl(movie.poster_url || movie.thumb_url); const genres = movie.category ? movie.category.map((c: any) => c.name).join(', ') : 'Chưa phân loại'; const modifiedTime = movie.modified?.time || movie.created?.time || new Date().toISOString(); const views = movie.view || 0; return ( ); }) : ( )}
Phim Ngày cập nhật Lượt xem Hành động
{movie.name}
{movie.name} {genres}
Chưa có phim nào trong cơ sở dữ liệu cục bộ.

Báo cáo gần đây

{[1,2,3,4].map(i => (
Lỗi không xem được tập {i} Phim: Trục Ngọc
))}