import React from 'react' import StudioLayout from '../../Layouts/StudioLayout' import { usePage } from '@inertiajs/react' import { studioSurface, trackStudioEvent } from '../../utils/studioEvents' const summaryCards = [ ['active_challenges', 'Active challenges', 'fa-bolt'], ['joined_challenges', 'Joined challenges', 'fa-trophy'], ['entries_submitted', 'Entries submitted', 'fa-paper-plane'], ['featured_entries', 'Featured entries', 'fa-star'], ['winner_entries', 'Winner entries', 'fa-crown'], ['cards_available', 'Challenge-ready cards', 'fa-layer-group'], ] function formatDate(value) { if (!value) return 'TBD' const date = new Date(value) if (Number.isNaN(date.getTime())) return value return date.toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) } export default function StudioChallenges() { const { props } = usePage() const { summary, spotlight, activeChallenges, recentEntries, cardLeaders, reminders } = props return (
{summaryCards.map(([key, label, icon]) => (
{label}
{Number(summary?.[key] || 0).toLocaleString()}
))}
{spotlight ? (

Challenge spotlight

{spotlight.title}

{spotlight.prompt || spotlight.description || 'A featured challenge run is active in Nova Cards right now.'}

{spotlight.status} {spotlight.official ? 'Official' : 'Community'} {spotlight.entries_count} entries {spotlight.is_joined ? `${spotlight.submission_count} submitted` : 'Not joined yet'}
trackStudioEvent('studio_challenge_action_taken', { surface: studioSurface(), module: 'challenges', meta: { action: 'open_spotlight', challenge_id: spotlight.id, }, })} className="inline-flex items-center gap-2 rounded-full border border-sky-300/20 bg-sky-300/10 px-4 py-2 text-sm font-semibold text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/15" > Open challenge Review cards
) : null}

Open and recent challenge runs

Public archive
{(activeChallenges || []).map((challenge) => ( trackStudioEvent('studio_challenge_action_taken', { surface: studioSurface(), module: 'challenges', meta: { action: 'open_challenge', challenge_id: challenge.id, }, })} className="block rounded-[22px] border border-white/10 bg-black/20 p-4 transition hover:border-white/20" >
{challenge.title}
{challenge.status} • {challenge.official ? 'official' : 'community'} • {challenge.entries_count} entries

{challenge.prompt || challenge.description || 'Challenge details are available in the public challenge view.'}

{formatDate(challenge.starts_at)} start
{formatDate(challenge.ends_at)} end
{challenge.is_joined ? `${challenge.submission_count} submitted` : 'Not joined'} {challenge.featured ? Featured run : null}
))}

Workflow reminders

{(reminders || []).map((item) => (

{item.title}

{item.body}

{item.cta}
))}

Recent submissions

Cards with challenge traction

{(cardLeaders || []).map((card) => (
{card.title}
{card.status} • {card.challenge_entries_count} challenge entries
Open
Views
{Number(card.views_count || 0).toLocaleString()}
Comments
{Number(card.comments_count || 0).toLocaleString()}
))}
) }