diff --git a/app/create/tournament/page.js b/app/create/tournament/page.js
index ef210bf..078bc87 100644
--- a/app/create/tournament/page.js
+++ b/app/create/tournament/page.js
@@ -1,460 +1,495 @@
-"use client"
-import { useEffect, useState } from 'react';
-import axios from 'axios';
-import { platforms, timezones } from './tournament/data';
+"use client";
+import { useEffect, useState } from "react";
+import axios from "axios";
+import { platforms, timezones } from "./tournament/data";
+import { Button } from "../../../@/components/ui/button";
export default function Page() {
- const [selectedPlatform, setSelectedPlatform] = useState("");
- const [participantType, setParticipantType] = useState("");
- const [selectedTimezone, setSelectedTimezone] = useState("");
- const [tournamentName, setTournamentName] = useState("");
- const [size, setSize] = useState("");
- const [isSubmitting, setIsSubmitting] = useState(false);
- const [successMessage, setSuccessMessage] = useState("");
- const [errorMessage, setErrorMessage] = useState("");
- const [games, setGames] = useState([]);
-
- // Add new state variables for additional fields
- const [tournamentFormat, setTournamentFormat] = useState("");
- const [registrationEndDate, setRegistrationEndDate] = useState("");
- const [tournamentStartDate, setTournamentStartDate] = useState("");
- const [tournamentEndDate, setTournamentEndDate] = useState("");
- const [maxTeamMembers, setMaxTeamMembers] = useState("");
- const [minTeamMembers, setMinTeamMembers] = useState("");
- const [maxTeams, setMaxTeams] = useState("");
- const [minTeams, setMinTeams] = useState("");
- const [tournamentVisibility, setTournamentVisibility] = useState("");
- const [inviteCode, setInviteCode] = useState("");
-
- const [prizeConfig, setPrizeConfig] = useState([]);
- const [rules, setRules] = useState([]);
- const [sponsors, setSponsors] = useState([]);
- const [gameParameter, setGameParameter] = useState("");
- const [parameterPoints, setParameterPoints] = useState("");
- const [roundType, setRoundType] = useState("");
- const [numberOfMatches, setNumberOfMatches] = useState("");
- const [qualifyingTeamsPerGroup, setQualifyingTeamsPerGroup] = useState("1");
- const [wildcardPlayers, setWildcardPlayers] = useState("");
- const [teamsPerGroup, setTeamsPerGroup] = useState("");
- const [roundName, setRoundName] = useState("");
- const [tournamentIcon, setTournamentIcon] = useState(null);
- const [tournamentBanner, setTournamentBanner] = useState(null);
-
-
- useEffect(() => {
- const fetchGames = async () => {
- try {
- const response = await axios.get('/api/games');
- setGames(response.data);
- } catch (error) {
- console.error("Error while fetching game data: ", error);
- }
- };
- fetchGames();
- }, []);
-
- const handleSubmit = async (e) => {
- e.preventDefault();
- setIsSubmitting(true);
- setSuccessMessage("");
- setErrorMessage("");
-
- if (
- !tournamentName ||
- !selectedPlatform ||
- !participantType ||
- !selectedTimezone ||
- !size
- ) {
- setErrorMessage("Please fill out all fields.");
- setIsSubmitting(false);
- return;
- }
-
- const formData = {
- tournamentName,
- selectedPlatform,
- participantType,
- selectedTimezone,
- size,
- };
-
- try {
- const response = await axios.post("/api/tournaments", formData);
- setSuccessMessage(response.data.message);
- setTournamentName("");
- setSelectedPlatform("");
- setParticipantType("");
- setSelectedTimezone("");
- setSize("");
- } catch (error) {
- if (error.response) {
- setErrorMessage(error.response.data.message);
- } else {
- setErrorMessage("An error occurred. Please try again.");
- }
- } finally {
- setIsSubmitting(false);
- }
- };
-
- const handleReset = () => {
- setTournamentName("");
- setSelectedPlatform("");
- setParticipantType("");
- setSelectedTimezone("");
- setSize("");
- setSuccessMessage("");
- setErrorMessage("");
- };
-
- const handleIconUpload = (event) => {
- const file = event.target.files[0];
- if (file && file.type.substr(0, 5) === "image") {
- setTournamentIcon(URL.createObjectURL(file));
- } else {
- alert("Please select an image file");
- }
+ const [selectedPlatform, setSelectedPlatform] = useState("");
+ const [participantType, setParticipantType] = useState("");
+ const [selectedTimezone, setSelectedTimezone] = useState("");
+ const [tournamentName, setTournamentName] = useState("");
+ const [size, setSize] = useState("");
+ const [isSubmitting, setIsSubmitting] = useState(false);
+ const [successMessage, setSuccessMessage] = useState("");
+ const [errorMessage, setErrorMessage] = useState("");
+ const [games, setGames] = useState([]);
+
+ // Add new state variables for additional fields
+ const [tournamentFormat, setTournamentFormat] = useState("");
+ const [registrationEndDate, setRegistrationEndDate] = useState("");
+ const [tournamentStartDate, setTournamentStartDate] = useState("");
+ const [tournamentEndDate, setTournamentEndDate] = useState("");
+ const [maxTeamMembers, setMaxTeamMembers] = useState("");
+ const [minTeamMembers, setMinTeamMembers] = useState("");
+ const [maxTeams, setMaxTeams] = useState("");
+ const [minTeams, setMinTeams] = useState("");
+ const [tournamentVisibility, setTournamentVisibility] = useState("");
+ const [inviteCode, setInviteCode] = useState("");
+
+ const [prizeConfig, setPrizeConfig] = useState([]);
+ const [rules, setRules] = useState([]);
+ const [sponsors, setSponsors] = useState([]);
+ const [gameParameter, setGameParameter] = useState("");
+ const [parameterPoints, setParameterPoints] = useState("");
+ const [roundType, setRoundType] = useState("");
+ const [numberOfMatches, setNumberOfMatches] = useState("");
+ const [qualifyingTeamsPerGroup, setQualifyingTeamsPerGroup] = useState("1");
+ const [wildcardPlayers, setWildcardPlayers] = useState("");
+ const [teamsPerGroup, setTeamsPerGroup] = useState("");
+ const [roundName, setRoundName] = useState("");
+ const [tournamentIcon, setTournamentIcon] = useState(null);
+ const [tournamentBanner, setTournamentBanner] = useState(null);
+
+ useEffect(() => {
+ const fetchGames = async () => {
+ try {
+ const response = await axios.get("/api/games");
+ setGames(response.data);
+ } catch (error) {
+ console.error("Error while fetching game data: ", error);
+ }
};
-
- const handleBannerUpload = (event) => {
- const file = event.target.files[0];
- if (file && file.type.substr(0, 5) === "image") {
- setTournamentBanner(URL.createObjectURL(file));
- } else {
- alert("Please select an image file");
- }
+ fetchGames();
+ }, []);
+
+ const handleSubmit = async (e) => {
+ e.preventDefault();
+ setIsSubmitting(true);
+ setSuccessMessage("");
+ setErrorMessage("");
+
+ if (
+ !tournamentName ||
+ !selectedPlatform ||
+ !participantType ||
+ !selectedTimezone ||
+ !size
+ ) {
+ setErrorMessage("Please fill out all fields.");
+ setIsSubmitting(false);
+ return;
+ }
+
+ const formData = {
+ tournamentName,
+ selectedPlatform,
+ participantType,
+ selectedTimezone,
+ size,
};
- return (
-
-
-
Create New Tournament
-
-
-
-
-
-
-
-
-
-
-
-
-
- {/* Prize Configuration */}
-
-
Prize Configuration ⓘ
-
-
-
- {/* Rules */}
-
-
Rules ⓘ
-
-
-
-
- {/* Sponsors */}
-
-
Sponsors
-
-
+ try {
+ const response = await axios.post("/api/tournaments", formData);
+ setSuccessMessage(response.data.message);
+ setTournamentName("");
+ setSelectedPlatform("");
+ setParticipantType("");
+ setSelectedTimezone("");
+ setSize("");
+ } catch (error) {
+ if (error.response) {
+ setErrorMessage(error.response.data.message);
+ } else {
+ setErrorMessage("An error occurred. Please try again.");
+ }
+ } finally {
+ setIsSubmitting(false);
+ }
+ };
+
+ const handleReset = () => {
+ setTournamentName("");
+ setSelectedPlatform("");
+ setParticipantType("");
+ setSelectedTimezone("");
+ setSize("");
+ setSuccessMessage("");
+ setErrorMessage("");
+ };
+
+ const handleIconUpload = (event) => {
+ const file = event.target.files[0];
+ if (file && file.type.substr(0, 5) === "image") {
+ setTournamentIcon(URL.createObjectURL(file));
+ } else {
+ alert("Please select an image file");
+ }
+ };
+
+ const handleBannerUpload = (event) => {
+ const file = event.target.files[0];
+ if (file && file.type.substr(0, 5) === "image") {
+ setTournamentBanner(URL.createObjectURL(file));
+ } else {
+ alert("Please select an image file");
+ }
+ };
+
+ return (
+
+
+
Create New Tournament
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* Prize Configuration */}
+
+
+ Prize Configuration{" "}
+ ⓘ
+
+
+
- {/* Game Configuration */}
-
-
Game Configuration ⓘ
-
-
-
-
-
-
-
- setParameterPoints(e.target.value)}
- placeholder="Enter Parameter Points"
- />
-
-
-
-
+ {/* Rules */}
+
+
+ Rules ⓘ
+
+
+
+
- {/* Tournament Configuration */}
-
-
Tournament Configuration
-
Round 1
-
-
-
+ {/* Sponsors */}
+
+
Sponsors
+
+
- {/* Create Tournament Button */}
-
-
-
+ {/* Game Configuration */}
+
+
+ Game Configuration{" "}
+ ⓘ
+
+
+
+
+
+
+
+
+ setParameterPoints(e.target.value)}
+ placeholder="Enter Parameter Points"
+ />
+
+
+
+
- {/* Success and Error Messages */}
- {successMessage && (
-
- {successMessage}
-
- )}
- {errorMessage && (
-
- {errorMessage}
-
- )}
+ {/* Tournament Configuration */}
+
+
+ Tournament Configuration
+
+
Round 1
+
+
- );
+
+ {/* Create Tournament Button */}
+
+
+
+
+ {/* Success and Error Messages */}
+ {successMessage && (
+
+ {successMessage}
+
+ )}
+ {errorMessage && (
+
+ {errorMessage}
+
+ )}
+
+
+ );
}
diff --git a/components/Footer.jsx b/components/Footer.jsx
index 158573a..ee197f7 100644
--- a/components/Footer.jsx
+++ b/components/Footer.jsx
@@ -93,7 +93,7 @@ export default function Footer() {
-
+
Built and maintained by Sanity Gaming - © 2024