import React from 'react' import { useForm, usePage } from '@inertiajs/react' import StudioLayout from '../../Layouts/StudioLayout' export default function StudioGroupChallengeEditor() { const { props } = usePage() const challenge = props.challenge || null const form = useForm({ title: challenge?.title || '', summary: challenge?.summary || '', description: challenge?.description || '', visibility: challenge?.visibility || props.visibilityOptions?.[0]?.value || 'public', participation_scope: challenge?.participation_scope || props.participationScopeOptions?.[0]?.value || 'group_only', status: challenge?.status || props.statusOptions?.[0]?.value || 'draft', start_at: challenge?.start_at ? challenge.start_at.slice(0, 16) : '', end_at: challenge?.end_at ? challenge.end_at.slice(0, 16) : '', rules_text: challenge?.rules_text || '', submission_instructions: challenge?.submission_instructions || '', judging_mode: challenge?.judging_mode || '', linked_collection_id: challenge?.linked_collection?.id || '', linked_project_id: challenge?.linked_project?.id || '', featured_artwork_id: challenge?.featured_artwork?.id || '', cover_file: null, }) const attachForm = useForm({ artwork_id: '' }) const submit = (event) => { event.preventDefault() const options = { forceFormData: true, preserveScroll: true } if (props.updateUrl) { form.post(props.updateUrl, { ...options, _method: 'patch' }) return } form.post(props.storeUrl, options) } return (
form.setData('title', event.target.value)} placeholder="Challenge title" className="rounded-2xl border border-white/10 bg-black/20 px-4 py-3 text-white outline-none" />