import React, { useMemo, useRef, useState } from 'react' import { Head, Link, router, useForm } from '@inertiajs/react' import AdminLayout from '../../../Layouts/AdminLayout' import DateTimePicker from '../../../components/ui/DateTimePicker' import NovaSelect from '../../../components/ui/NovaSelect' import ShareToast from '../../../components/ui/ShareToast' import WorldMediaUploadField from '../../../components/worlds/editor/WorldMediaUploadField' const CHALLENGE_EDITOR_TABS = [ { id: 'overview', label: 'Overview', description: 'Title, slug, access, and the compact summary shown in academy challenge lists.', icon: 'fa-compass-drafting', sections: ['challenge-identity'], }, { id: 'brief', label: 'Brief', description: 'Write the creative objective, rules, prizes, required tags, and eligible categories.', icon: 'fa-bullseye', sections: ['challenge-brief', 'challenge-rules'], }, { id: 'media', label: 'Media', description: 'Upload the hero cover and tune the visual used on challenge cards.', icon: 'fa-image', sections: ['challenge-media'], }, { id: 'timeline', label: 'Timeline', description: 'Manage submission and voting windows without mixing them into editorial copy.', icon: 'fa-calendar-days', sections: ['challenge-timeline'], }, { id: 'publish', label: 'Publish', description: 'Control status, visibility, featured placement, and the final public preview.', icon: 'fa-rocket-launch', sections: ['challenge-publishing', 'challenge-preview'], }, ] const CHALLENGE_FIELD_TAB_MAP = { title: 'overview', slug: 'overview', excerpt: 'overview', access_level: 'overview', description: 'brief', brief: 'brief', rules: 'brief', prize_text: 'brief', required_tags: 'brief', allowed_categories: 'brief', cover_image: 'media', starts_at: 'timeline', ends_at: 'timeline', voting_starts_at: 'timeline', voting_ends_at: 'timeline', status: 'publish', featured: 'publish', active: 'publish', } function getField(fields, name) { return fields.find((field) => field.name === name) || null } function FieldError({ message }) { if (!message) return null return

{message}

} function SectionCard({ id, eyebrow, title, description, actions, children, tone = 'default', className = '' }) { const toneClass = tone === 'feature' ? 'bg-[radial-gradient(circle_at_top_left,rgba(56,189,248,0.15),transparent_38%),linear-gradient(180deg,rgba(15,23,42,0.96),rgba(2,6,23,0.92))] shadow-[0_24px_70px_rgba(2,6,23,0.28)]' : 'bg-white/[0.03]' return (
{eyebrow ?

{eyebrow}

: null}

{title}

{description ?

{description}

: null}
{actions ?
{actions}
: null}
{children}
) } function EditorWorkspaceTabs({ activeTab, onChange, errorCounts }) { const activeMeta = CHALLENGE_EDITOR_TABS.find((tab) => tab.id === activeTab) || CHALLENGE_EDITOR_TABS[0] return (
{CHALLENGE_EDITOR_TABS.map((tab) => { const isActive = tab.id === activeTab const errorCount = Number(errorCounts?.[tab.id] || 0) return ( ) })}

{activeMeta.description}

{activeMeta.sections.map((section) => ( {section.replace('challenge-', '').replace(/-/g, ' ')} ))}
) } function TextField({ label, value, onChange, error, hint, ...rest }) { return ( ) } function TextAreaField({ label, value, onChange, error, rows = 4, hint, placeholder }) { return (