From f9ced3f4a134ca926469b86504c3b9aaa5b4b12c Mon Sep 17 00:00:00 2001 From: saurabhchaddha6 Date: Sat, 10 Aug 2024 09:45:09 +0530 Subject: [PATCH] update form --- app/tournaments/[id]/register/page.js | 178 ++++++++++++++------------ 1 file changed, 93 insertions(+), 85 deletions(-) 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 ( -
-

Register for Tournament

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
+
+
+

Register for Tournament

+
+
+ + setTeamName(e.target.value)} + className="w-full p-3 rounded-lg bg-gray-700 text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder="Enter your team name" + required + /> +
+
+ + setMembers(e.target.value)} + className="w-full p-3 rounded-lg bg-gray-700 text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder="Enter team members" + required + /> +
+
+ + setEmail(e.target.value)} + className="w-full p-3 rounded-lg bg-gray-700 text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder="Enter your email" + required + /> +
+
+ + setSelectedPlatform(e.target.value)} + className="w-full p-3 rounded-lg bg-gray-700 text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder="Enter the platform (e.g., PC, Console)" + /> +
+
+ + setParticipantType(e.target.value)} + className="w-full p-3 rounded-lg bg-gray-700 text-white border border-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder="Enter the participant type (e.g., Player, Coach)" + /> +
+ +
+
); -} \ No newline at end of file +}