@@ -19,7 +19,7 @@
-
+
diff --git a/frontend/panel_organizatora/dodawanie turnieju/app.js b/frontend/panel_organizatora/dodawanie turnieju/app.js
index 421c62a..d3700b5 100644
--- a/frontend/panel_organizatora/dodawanie turnieju/app.js
+++ b/frontend/panel_organizatora/dodawanie turnieju/app.js
@@ -53,43 +53,60 @@ function createTournament() {
let rankingChecker = checkRankingBox();
console.log(rankingChecker)
let checker = checkCheckBox();
- console.log(checker)
- fetch('https://dragonmaster.pl/inz/tournament', {
- method: "PUT",
- headers: {
- 'Content-type': 'application/json',
- Authorization: ("Bearer " + localStorage.getItem("token"))
- },
- body: JSON.stringify(
- {
- "name": document.getElementById("name").value,
- "typeOfLadder": "string",
- "pointsForTournament": "1",
- "places": "12",
- "roles": "role",
- "ranked": rankingChecker,
- "place": document.getElementById("place").value,
- "from": document.getElementById("term_from").value,
- "to": document.getElementById("term_to").value,
- "rang": document.getElementById("rank").value,
- "entryFee": document.getElementById("entry-fee").value,
- "director": document.getElementById("director").value,
- "phone": document.getElementById("phone").value,
- "entriesTo": document.getElementById("entries").value,
- "additionalInformations": document.getElementById("add-info").value,
- "categotry": document.getElementById("category").value,
- "visibility": checker
- }
- )
- }
- )
+ let name = document.getElementById("name").value
+ let place = document.getElementById("place").value
+ let from = document.getElementById("term_from").value
+ let to = document.getElementById("term_to").value
+ let rang = document.getElementById("rank").value
+ let entryFee = document.getElementById("entry-fee").value
+ let director = document.getElementById("director").value
+ let phone = document.getElementById("phone").value
+ let entriesTo = document.getElementById("entries").value
+ let additionalInformations = document.getElementById("add-info").value
+ let category = document.getElementById("category").value
- .then(res => res.json())
- .then(data => {
- console.log(data)
- window.location.href = '../../normal_user/index.html'
- })
- .catch(error => console.log(error))
+ console.log(checker)
+ if (name == null || name == "", place == null || place == "", from == null || from == "", to == null || to == "", rang == null || rang == "", entryFee == null || entryFee == "", director == null || director == "", phone == null || phone == "", entriesTo == null || entriesTo == "", additionalInformations == null || additionalInformations == "", category == null || category == "") {
+ alert("Nie można utowrzyć turnieju! Proszę wypełnić wszystkie pola!")
+ }
+ else {
+ fetch('https://dragonmaster.pl/inz/tournament', {
+ method: "PUT",
+ headers: {
+ 'Content-type': 'application/json',
+ Authorization: ("Bearer " + localStorage.getItem("token"))
+ },
+ body: JSON.stringify(
+ {
+ "name": name,
+ "typeOfLadder": "string",
+ "pointsForTournament": "1",
+ "places": "12",
+ "roles": "role",
+ "ranked": rankingChecker,
+ "place": place,
+ "from": from,
+ "to": to,
+ "rang": rang,
+ "entryFee": entryFee,
+ "director": director,
+ "phone": phone,
+ "entriesTo": entriesTo,
+ "additionalInformations": additionalInformations,
+ "categotry": category,
+ "visibility": checker
+ }
+ )
+ }
+ )
+
+ .then(res => res.json())
+ .then(data => {
+ console.log(data)
+ window.location.href = '../../normal_user/index.html'
+ })
+ .catch(error => console.log(error))
+ }
}
function logout() {
diff --git a/frontend/panel_organizatora/dodawanie turnieju/index.html b/frontend/panel_organizatora/dodawanie turnieju/index.html
index 5dbf393..3ad87d3 100644
--- a/frontend/panel_organizatora/dodawanie turnieju/index.html
+++ b/frontend/panel_organizatora/dodawanie turnieju/index.html
@@ -23,7 +23,7 @@
-
+
@@ -82,7 +82,7 @@
-
Zapisy
+
Zapisy do
diff --git a/frontend/panel_organizatora/edycja turnieju/app.js b/frontend/panel_organizatora/edycja turnieju/app.js
index 3b3cb10..986a2f9 100644
--- a/frontend/panel_organizatora/edycja turnieju/app.js
+++ b/frontend/panel_organizatora/edycja turnieju/app.js
@@ -66,7 +66,7 @@ function createTournament() {
"name": document.getElementById("name").value,
"typeOfLadder": "string",
"pointsForTournament": "1",
- "places": document.getElementById("place").value,
+ "place": document.getElementById("place").value,
"roles": document.getElementById("category").value,
"from": document.getElementById("term_from").value,
"to": document.getElementById("term_to").value,
@@ -114,3 +114,46 @@ function loginVisibility() {
}
}
+
+async function showTournaments() {
+ let url = 'https://dragonmaster.pl/inz/tournaments';
+ try {
+ let res = await fetch(url);
+ return await res.json();
+ } catch (error) {
+ console.log(error);
+ }
+}
+
+async function renderTournaments() {
+ let tournaments = await showTournaments();
+ tournaments.forEach(tournament => {
+ let rank = 0
+ if (`${tournament.approved}` == 0) {
+ rank = "Nie"
+ }
+ else if (`${tournament.approved}` == 1) {
+ rank = "Tak, ale niezatwierdzony"
+ }
+ else {
+ rank = "Tak"
+ }
+
+
+ if (`${tournament.id}` == localStorage.getItem("tournamentId")) {
+
+ console.log(`${tournament.rang}`)
+ document.getElementById("name").placeholder = `${tournament.name}`
+ document.getElementById("term_from").placeholder = `${tournament.from}`
+ document.getElementById("term_to").placeholder = `${tournament.to}`
+ document.getElementById("place").placeholder = `${tournament.place}`
+ document.getElementById("category").placeholder = `${tournament.roles}`
+ document.getElementById("rank").placeholder = `${tournament.rang}`
+ document.getElementById("entry-fee").placeholder = `${tournament.entryFee}`
+ document.getElementById("director").placeholder = `${tournament.director}`
+ document.getElementById("phone").placeholder = `${tournament.phone}`
+ document.getElementById("entries").placeholder = `${tournament.entriesTo}`
+ document.getElementById("add-info").placeholder = `${tournament.additionalInformations}`
+ }
+ });
+}
diff --git a/frontend/panel_organizatora/edycja turnieju/index.html b/frontend/panel_organizatora/edycja turnieju/index.html
index 0534bb8..7d7aa1b 100644
--- a/frontend/panel_organizatora/edycja turnieju/index.html
+++ b/frontend/panel_organizatora/edycja turnieju/index.html
@@ -12,7 +12,7 @@
-
+