import React from 'react' import { usePage } from '@inertiajs/react' import StudioLayout from '../../Layouts/StudioLayout' import { studioSurface, trackStudioEvent } from '../../utils/studioEvents' const kpiConfig = [ { key: 'total_content', label: 'Total content', icon: 'fa-solid fa-table-cells-large' }, { key: 'views_30d', label: 'Views', icon: 'fa-solid fa-eye' }, { key: 'appreciation_30d', label: 'Reactions', icon: 'fa-solid fa-heart' }, { key: 'shares_30d', label: 'Shares / Saves', icon: 'fa-solid fa-share-nodes' }, { key: 'comments_30d', label: 'Comments', icon: 'fa-solid fa-comments' }, { key: 'followers', label: 'Followers', icon: 'fa-solid fa-user-group' }, ] function KpiCard({ config, value }) { return (
{config.label}

{typeof value === 'number' ? value.toLocaleString() : value}

) } function QuickCreateCard({ item }) { return ( trackStudioEvent('studio_quick_create_used', { surface: studioSurface(), module: item.key, meta: { href: item.url, label: item.label, }, })} className="rounded-[24px] border border-sky-300/20 bg-sky-300/10 p-4 text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/15" >
New {item.label}

Jump straight into the dedicated {item.label.toLowerCase()} creation workflow.

) } function RecentPublishCard({ item }) { return (

{item.module_label}

{item.title}

Published {new Date(item.published_at || item.updated_at).toLocaleDateString()}

) } function ContinueWorkingCard({ item }) { return (

{item.module_label}

{item.title}

Updated {new Date(item.updated_at || item.created_at).toLocaleDateString()}

) } function ScheduledItemCard({ item }) { return (

{item.module_label}

{item.title}

Scheduled {new Date(item.scheduled_at || item.published_at).toLocaleString()}

) } function ActivityRow({ item }) { return (

{item.title}

{item.module_label}

{item.body}

) } function GrowthHint({ item }) { return (

{item.title}

{item.body}

{item.label}
) } function ChallengeWidget({ challenge }) { return (

{challenge.official ? 'Official challenge' : 'Community challenge'}

{challenge.title}

{challenge.status}

{challenge.prompt || challenge.description}

{Number(challenge.entries_count || 0).toLocaleString()} entries {challenge.is_joined ? `${challenge.submission_count} submitted` : 'Not joined'}
) } function FeaturedStatusCard({ item }) { return (

{item.module_label}

{item.title}

{item.subtitle || item.visibility || 'Selected for profile presentation'}

) } function CommandCenterColumn({ title, items = [], empty, renderItem }) { return (

{title}

{items.length > 0 ? items.map(renderItem) :
{empty}
}
) } function InsightBlock({ item }) { const toneClasses = { positive: 'border-emerald-400/20 bg-emerald-400/10 text-emerald-100', warning: 'border-amber-400/20 bg-amber-400/10 text-amber-100', action: 'border-sky-400/20 bg-sky-400/10 text-sky-100', neutral: 'border-white/10 bg-white/[0.03] text-slate-200', } return ( trackStudioEvent('studio_insight_clicked', { surface: studioSurface(), module: 'overview', meta: { insight_key: item.key, href: item.href, }, })} className={`block rounded-[24px] border p-4 transition hover:border-white/20 ${toneClasses[item.tone] || toneClasses.neutral}`} >

{item.title}

{item.body}

{item.cta}
) } function TopPerformerCard({ item }) { return (
{item.image_url && ( {item.title} )}

{item.module_label}

{item.title}

{item.subtitle || item.visibility}

{Number(item.metrics?.views || 0).toLocaleString()} views {Number(item.metrics?.appreciation || 0).toLocaleString()} reactions {Number(item.metrics?.comments || 0).toLocaleString()} comments
) } function RecentComment({ comment }) { return (

{comment.author_name} {' '}on{' '} {comment.item_title}

{comment.body}

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

) } export default function StudioDashboard() { const { props } = usePage() const overview = props.overview || {} const analytics = props.analytics || {} const kpis = overview.kpis || {} const widgetVisibility = overview.preferences?.widget_visibility || {} const showWidget = (key) => widgetVisibility[key] !== false return (
{kpiConfig.map((config) => ( ))}

Command center

Open calendar
} /> } /> } />

Readable insights

{(overview.insight_blocks || []).map((item) => ( ))}
{showWidget('module_summaries') &&

Module health

Open content queue
{(overview.module_summaries || []).map((item) => (
{item.label}
{Number(item.count || 0).toLocaleString()}
{Number(item.published_count || 0).toLocaleString()} published
{Number(item.trend_value || 0).toLocaleString()} {item.trend_label || 'recent'}
{Number(item.draft_count || 0).toLocaleString()} drafts
{Number(item.archived_count || 0).toLocaleString()} archived
))}
}

Quick create

Start with any module
{(overview.quick_create || []).map((item) => ( ))}
{showWidget('active_challenges') &&
{(overview.active_challenges?.items || []).map((item) => )}
} {showWidget('featured_status') &&

Featured status

Manage featured
{overview.featured_status?.selected_count || 0}/{overview.featured_status?.target_count || 4}
modules have a selected featured item
{(overview.featured_status?.missing_modules || []).length} missing
{(overview.featured_status?.items || []).slice(0, 3).map((item) => )}
} {showWidget('creator_health') &&

Creator health

Open growth
{overview.creator_health?.score || 0}
blended workflow health score
{(overview.creator_health?.checkpoints || []).map((item) => (

{item.label}

{item.detail}

{item.score}
))}
}
{showWidget('continue_working') &&

Continue working

Open drafts
{(overview.continue_working || []).map((item) => )}
} {showWidget('scheduled_items') &&

Upcoming schedule

Open calendar
{(overview.scheduled_items || []).slice(0, 4).map((item) => )}
}

Top performers

Open insights
{overview.top_performers?.length > 0 ? (
{overview.top_performers.map((item) => ( ))}
) : (
Nothing has enough activity yet to rank here.
)}
{showWidget('draft_reminders') &&

Draft reminders

}
{showWidget('recent_activity') &&

Recent activity

Open inbox

Recent publishes

{(overview.recent_publishes || []).slice(0, 4).map((item) => ( ))}

Recent followers

{(overview.recent_followers || []).map((follower) => ( {follower.avatar_url ? ( {follower.username} ) : (
)}
{follower.name}
@{follower.username}
))}

Inbox feed

{(overview.recent_activity || []).slice(0, 4).map((item) => ( ))}
}

Growth hints

{(overview.growth_hints || []).map((item) => ( ))}

Recent comments

View all
{(overview.recent_comments || []).length > 0 ? ( overview.recent_comments.map((comment) => ) ) : (

No comments yet

)}

Momentum

{[ ['Views', analytics.totals?.views], ['Reactions', analytics.totals?.appreciation], ['Shares', analytics.totals?.shares], ['Comments', analytics.totals?.comments], ].map(([label, value]) => (
{label} {Number(value || 0).toLocaleString()}
))}
{showWidget('stale_drafts') &&

Stale drafts

Filter stale work
{(overview.stale_drafts || []).map((item) => )}
}
) }