diff --git a/frontend/panel_organizatora/dodawanie turnieju/app.js b/frontend/panel_organizatora/dodawanie turnieju/app.js index 8b48717..8269ff2 100644 --- a/frontend/panel_organizatora/dodawanie turnieju/app.js +++ b/frontend/panel_organizatora/dodawanie turnieju/app.js @@ -1,29 +1,57 @@ -document.getElementById("tournamentSubmit").addEventListener("click", function () { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function () { - if (this.readyState == 4 && this.status == 200) { - alert("Dodano turniej"); - } else if (this.readyState == 4) { - alert("something not work :( " + this.status); - } +// document.getElementById("tournamentSubmit").addEventListener("click", function () { +// var xhttp = new XMLHttpRequest(); +// xhttp.onreadystatechange = function () { +// if (this.readyState == 4 && this.status == 200) { +// alert("Dodano turniej"); +// } else if (this.readyState == 4) { +// alert("something not work :( " + this.status); +// } +// } +// xhttp.open("PUT", "dragonmaster.pl/inz/tournament"); +// xhttp.setRequestHeader("Authorization", "Bearer " + token); +// xhttp.send('{"name":"' + document.getElementById("tournamentName").value + +// '","typeOfLadder":"' + document.getElementById("ladderType").value + +// '","pointsForTournament":"' + document.getElementById("tournamentPoints").value + +// '","places":"' + document.getElementById("tournamentPlace").value + +// '","roles":"' + document.getElementById("tournamentRole").value + +// '","ranked":"' + document.getElementById("isRanked").value + +// '","place":"' + document.getElementById("tournamentPlace").value + +// '","from":"' + document.getElementById("tournamentFrom").value + +// '","to":"' + document.getElementById("tournamentTo").value + +// '","rang":"' + document.getElementById("tournamentRang").value + +// '","entyFee":"' + document.getElementById("tournamentEntyFee").value + +// '","director":"' + document.getElementById("tournamentDirector").value + +// '","phone":"' + document.getElementById("directorphone").value + +// '","entriesTo":"' + document.getElementById("tournamentEntriesTo").value + +// '","additionalInformations":"' + document.getElementById("tournamentAddInfo").value + +// '","category":"' + "cat1" + +// '","}'); +// }); + +function createTournament() { + 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, + "place": document.getElementById("place").value, + "ranked": document.getElementById("rank").value, + "roles": document.getElementById("category").value, + "phone": document.getElementById("phone").value, + "director": document.getElementById("director").value, + "phone": document.getElementById("regphone").value, + "entryFee": document.getElementById("entry-fee").value, + "additionalInformations": document.getElementById("add-info").value + } + ) } - xhttp.open("PUT", "dragonmaster.pl/inz/tournament"); - xhttp.setRequestHeader("Authorization", "Bearer " + token); - xhttp.send('{"name":"' + document.getElementById("tournamentName").value + - '","typeOfLadder":"' + document.getElementById("ladderType").value + - '","pointsForTournament":"' + document.getElementById("tournamentPoints").value + - '","places":"' + document.getElementById("tournamentPlace").value + - '","roles":"' + document.getElementById("tournamentRole").value + - '","ranked":"' + document.getElementById("isRanked").value + - '","place":"' + document.getElementById("tournamentPlace").value + - '","from":"' + document.getElementById("tournamentFrom").value + - '","to":"' + document.getElementById("tournamentTo").value + - '","rang":"' + document.getElementById("tournamentRang").value + - '","entyFee":"' + document.getElementById("tournamentEntyFee").value + - '","director":"' + document.getElementById("tournamentDirector").value + - '","phone":"' + document.getElementById("directorphone").value + - '","entriesTo":"' + document.getElementById("tournamentEntriesTo").value + - '","additionalInformations":"' + document.getElementById("tournamentAddInfo").value + - '","category":"' + "cat1" + - '","}'); -}); \ No newline at end of file + ) + + .then(res => res.json()) + .then(data => console.log(data)) + .catch(error => console.log(error)) +} diff --git a/frontend/panel_organizatora/dodawanie turnieju/index.html b/frontend/panel_organizatora/dodawanie turnieju/index.html index 36ed585..d48b34a 100644 --- a/frontend/panel_organizatora/dodawanie turnieju/index.html +++ b/frontend/panel_organizatora/dodawanie turnieju/index.html @@ -31,57 +31,57 @@