diff --git a/client/src/pages/BunnyAdminPage.tsx b/client/src/pages/BunnyAdminPage.tsx index 568b50e..799a6f5 100644 --- a/client/src/pages/BunnyAdminPage.tsx +++ b/client/src/pages/BunnyAdminPage.tsx @@ -57,19 +57,19 @@ export default function BunnyAdminPage() { const queryClient = useQueryClient(); // Fetch videos from Bunny.net - const { data: videosData, isLoading } = useQuery<{ videos: Video[], total: number }>({ + const { data: videosData, isLoading } = useQuery({ queryKey: ['/api/videos', searchTerm], queryFn: () => apiRequest('GET', `/api/videos?search=${searchTerm}&limit=100`), }); // Fetch Bunny.net statistics - const { data: statsData } = useQuery({ + const { data: statsData } = useQuery({ queryKey: ['/api/bunny/stats'], queryFn: () => apiRequest('GET', '/api/bunny/stats'), }); - const videos: Video[] = videosData?.videos || []; - const stats: BunnyStats = statsData || { + const videos: Video[] = (videosData as any)?.videos || []; + const stats: BunnyStats = (statsData as any) || { totalVideos: videos.length, totalViews: videos.reduce((sum: number, v: Video) => sum + v.views, 0), totalStorage: 0, diff --git a/server/routes.ts b/server/routes.ts index a4673fe..3cf85bb 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -132,8 +132,9 @@ export async function registerRoutes(app: Express): Promise { // Bunny.net administration routes app.get("/api/bunny/stats", async (req, res) => { try { - const { videos } = await storage.getVideos(1, 1000); - const totalViews = videos.reduce((sum, video) => sum + video.views, 0); + const result = await storage.getVideos(1, 1000); + const videos = result?.videos || []; + const totalViews = videos.length > 0 ? videos.reduce((sum, video) => sum + video.views, 0) : 0; const stats = { totalVideos: videos.length,