feat: add variant scoring controls to EditTournamentForm
This commit is contained in:
@@ -19,16 +19,19 @@ export default function EditTournamentForm({ tournament }: EditTournamentFormPro
|
||||
format: tournament.format,
|
||||
status: tournament.status,
|
||||
maxParticipants: tournament.maxParticipants?.toString() || "",
|
||||
targetScore: tournament.targetScore?.toString() || "",
|
||||
allowTies: tournament.allowTies || false,
|
||||
})
|
||||
const [error, setError] = useState("")
|
||||
const [success, setSuccess] = useState("")
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>) => {
|
||||
const { name, value } = e.target
|
||||
const { name, value, type } = e.target
|
||||
const checked = (e.target as HTMLInputElement).checked
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
[name]: value,
|
||||
[name]: type === 'checkbox' ? checked : value,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -48,6 +51,7 @@ export default function EditTournamentForm({ tournament }: EditTournamentFormPro
|
||||
...formData,
|
||||
maxParticipants: formData.maxParticipants ? parseInt(formData.maxParticipants) : null,
|
||||
eventDate: formData.eventDate ? new Date(formData.eventDate).toISOString() : null,
|
||||
targetScore: formData.targetScore ? parseInt(formData.targetScore) : null,
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -186,6 +190,7 @@ export default function EditTournamentForm({ tournament }: EditTournamentFormPro
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div>
|
||||
<label htmlFor="maxParticipants" className="block text-sm font-medium text-gray-700">
|
||||
Max Participants (optional)
|
||||
@@ -201,6 +206,36 @@ export default function EditTournamentForm({ tournament }: EditTournamentFormPro
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="targetScore" className="block text-sm font-medium text-gray-700">
|
||||
Target Score (optional)
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
id="targetScore"
|
||||
name="targetScore"
|
||||
min="1"
|
||||
value={formData.targetScore}
|
||||
onChange={handleChange}
|
||||
className="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-green-500 focus:ring-green-500 sm:text-sm"
|
||||
placeholder="Default: 5"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="flex items-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="allowTies"
|
||||
checked={formData.allowTies}
|
||||
onChange={handleChange}
|
||||
className="h-4 w-4 text-green-600 focus:ring-green-500 border-gray-300 rounded"
|
||||
/>
|
||||
<span className="ml-2 text-sm text-gray-700">Allow Ties</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end space-x-4">
|
||||
<Link
|
||||
href={`/admin/tournaments/${tournament.id}`}
|
||||
|
||||
Reference in New Issue
Block a user