import React from 'react'
import { Head, usePage } from '@inertiajs/react'
function MetricCard({ label, value, delta, icon }) {
return (
{Number(value || 0).toLocaleString()}
{Number(delta || 0).toLocaleString()} in the selected range
)
}
function TimelineChart({ timeline }) {
const safeTimeline = Array.isArray(timeline) ? timeline : []
const maxValue = safeTimeline.reduce((largest, item) => Math.max(largest, item.views || 0, item.likes || 0, item.saves || 0), 0) || 1
return (
Timeline
Engagement trend
{safeTimeline.length} days
{safeTimeline.length ? (
{safeTimeline.map((point) => (
{String(point.date || '').slice(5)}
))}
) : (
Analytics are enabled, but there are not enough daily snapshots yet to render a timeline.
)}
Views
Likes
Saves
)
}
export default function CollectionAnalytics() {
const { props } = usePage()
const collection = props.collection || {}
const analytics = props.analytics || {}
const totals = analytics.totals || {}
const range = analytics.range || {}
const topArtworks = Array.isArray(analytics.top_artworks) ? analytics.top_artworks : []
const seo = props.seo || {}
return (
<>
{seo.title || `${collection.title || 'Collection'} Analytics — Skinbase Nova`}
{seo.canonical ? : null}
{props.dashboardUrl ?
Dashboard : null}
{props.historyUrl ?
History : null}
{collection.manage_url ?
Manage : null}
Performance
{collection.title || 'Collection analytics'}
Review activity velocity, audience response, and the artworks carrying the most discovery value over the last {range.days || 30} days.
Artworks
Top artwork drivers
{topArtworks.length}
{topArtworks.length ? (
{topArtworks.map((artwork) => (
{artwork.thumb ?

:
}
{artwork.title}
Views: {Number(artwork.views || 0).toLocaleString()}
Favs: {Number(artwork.favourites || 0).toLocaleString()}
Shares: {Number(artwork.shares || 0).toLocaleString()}
Rank: {Number(artwork.ranking_score || 0).toFixed(1)}
))}
) : (
Attach or publish more artworks before artwork-level ranking can be surfaced here.
)}
>
)
}