import React from 'react' import { usePage, Link } from '@inertiajs/react' import StudioLayout from '../../Layouts/StudioLayout' const kpiItems = [ { key: 'views', label: 'Total Views', icon: 'fa-eye', color: 'text-emerald-400', bg: 'bg-emerald-500/10' }, { key: 'favourites', label: 'Total Favourites', icon: 'fa-heart', color: 'text-pink-400', bg: 'bg-pink-500/10' }, { key: 'shares', label: 'Total Shares', icon: 'fa-share-nodes', color: 'text-amber-400', bg: 'bg-amber-500/10' }, { key: 'downloads', label: 'Total Downloads', icon: 'fa-download', color: 'text-purple-400', bg: 'bg-purple-500/10' }, { key: 'comments', label: 'Total Comments', icon: 'fa-comment', color: 'text-blue-400', bg: 'bg-blue-500/10' }, ] const performanceItems = [ { key: 'avg_ranking', label: 'Avg Ranking Score', icon: 'fa-trophy', color: 'text-yellow-400', bg: 'bg-yellow-500/10' }, { key: 'avg_heat', label: 'Avg Heat Score', icon: 'fa-fire', color: 'text-orange-400', bg: 'bg-orange-500/10' }, ] const contentTypeIcons = { skins: 'fa-layer-group', wallpapers: 'fa-desktop', photography: 'fa-camera', other: 'fa-folder-open', members: 'fa-users', } const contentTypeColors = { skins: 'text-emerald-400 bg-emerald-500/10', wallpapers: 'text-blue-400 bg-blue-500/10', photography: 'text-amber-400 bg-amber-500/10', other: 'text-slate-400 bg-slate-500/10', members: 'text-purple-400 bg-purple-500/10', } export default function StudioAnalytics() { const { props } = usePage() const { totals, topArtworks, contentBreakdown, recentComments } = props const totalArtworksCount = (contentBreakdown || []).reduce((sum, ct) => sum + ct.count, 0) return ( {/* KPI Cards */}
{kpiItems.map((item) => (
{item.label}

{(totals?.[item.key] ?? 0).toLocaleString()}

))}
{/* Performance Averages */}
{performanceItems.map((item) => (
{item.label}

{(totals?.[item.key] ?? 0).toFixed(1)}

))}
{/* Content Breakdown */}

Content Breakdown

{contentBreakdown?.length > 0 ? (
{contentBreakdown.map((ct) => { const pct = totalArtworksCount > 0 ? Math.round((ct.count / totalArtworksCount) * 100) : 0 const iconClass = contentTypeIcons[ct.slug] || 'fa-folder' const colorClass = contentTypeColors[ct.slug] || 'text-slate-400 bg-slate-500/10' const [textColor, bgColor] = colorClass.split(' ') return (
{ct.name} {ct.count}
) })}
) : (

No artworks categorised yet

)}
{/* Recent Comments */}

Recent Comments

{recentComments?.length > 0 ? (
{recentComments.map((c) => (

{c.author_name} {' '}on{' '} {c.artwork_title}

{c.body}

{new Date(c.created_at).toLocaleDateString()}

))}
) : (

No comments yet

)}
{/* Top Performers Table */}

Top 10 Artworks

{topArtworks?.length > 0 ? (
{topArtworks.map((art, i) => ( ))}
# Artwork Views Favs Shares Downloads Ranking Heat
{i + 1} {art.thumb_url && ( {art.title} )} {art.title} {art.views.toLocaleString()} {art.favourites.toLocaleString()} {art.shares.toLocaleString()} {art.downloads.toLocaleString()} {art.ranking_score.toFixed(1)} 5 ? 'text-orange-400' : 'text-slate-400'}`}> {art.heat_score.toFixed(1)} {art.heat_score > 5 && ( )}
) : (

No published artworks with stats yet

)}
) }