Improve display of Bunny.net CDN statistics on admin page

Update BunnyAdminPage to safely render CDN statistics (total videos, total views, storage, bandwidth) by ensuring fallback values of 0 are used when data is not yet available, preventing potential rendering errors.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: d7424866-83d1-4486-a212-ac12b4c7becf
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/d7424866-83d1-4486-a212-ac12b4c7becf/VMZ5vW0
This commit is contained in:
sebastjanartic 2025-08-08 21:26:05 +00:00
parent 756a77ca57
commit d8fa916902

View File

@ -70,8 +70,8 @@ export default function BunnyAdminPage() {
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),
totalVideos: 0,
totalViews: 0,
totalStorage: 0,
bandwidth: 0
};
@ -131,7 +131,7 @@ export default function BunnyAdminPage() {
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-white" data-testid="text-total-videos">
{stats.totalVideos}
{stats?.totalVideos || 0}
</div>
</CardContent>
</Card>
@ -143,7 +143,7 @@ export default function BunnyAdminPage() {
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-white" data-testid="text-total-views">
{formatViews(stats.totalViews)}
{formatViews(stats?.totalViews || 0)}
</div>
</CardContent>
</Card>
@ -155,7 +155,7 @@ export default function BunnyAdminPage() {
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-white" data-testid="text-storage">
{formatFileSize(stats.totalStorage)}
{formatFileSize(stats?.totalStorage || 0)}
</div>
</CardContent>
</Card>
@ -167,7 +167,7 @@ export default function BunnyAdminPage() {
</CardHeader>
<CardContent>
<div className="text-2xl font-bold text-white" data-testid="text-bandwidth">
{formatFileSize(stats.bandwidth)}
{formatFileSize(stats?.bandwidth || 0)}
</div>
</CardContent>
</Card>