diff --git a/app/tournaments/[id]/register/page.js b/app/tournaments/[id]/register/page.js index 4e3ec6a..586a7a0 100644 --- a/app/tournaments/[id]/register/page.js +++ b/app/tournaments/[id]/register/page.js @@ -3,31 +3,27 @@ import { useRouter } from 'next/router'; import axios from 'axios'; export default function RegisterPage() { - const [userData, setUserData] = useState({ - teamName: '', - members: '', - email: '', - selectedPlatform: '', - participantType: '', - }); + const [teamName, setTeamName] = useState(''); + const [members, setMembers] = useState(''); + const [email, setEmail] = useState(''); + const [selectedPlatform, setSelectedPlatform] = useState(''); + const [participantType, setParticipantType] = useState(''); const [isLoading, setIsLoading] = useState(false); const router = useRouter(); const { id: tournamentId } = router.query; - const handleChange = (e) => { - const { name, value } = e.target; - setUserData((prevData) => ({ ...prevData, [name]: value })); - }; - const handleSubmit = async (e) => { e.preventDefault(); setIsLoading(true); try { - const membersArray = userData.members.split(',').map(member => member.trim()); const response = await axios.post(`/api/register/${tournamentId}`, { - ...userData, - members: membersArray + teamName, + members, + email, + selectedPlatform, + participantType }); + if (response.status === 201) { alert('Registration successful!'); router.push(`/tournament/${tournamentId}`); @@ -43,75 +39,87 @@ export default function RegisterPage() { }; return ( -