From 63aa19863fbd4cf936dcdd6874b3dec124165735 Mon Sep 17 00:00:00 2001 From: Arek Date: Sun, 19 Jun 2022 13:14:20 +0200 Subject: [PATCH] fix: :bug: Fixing some bugs and made better tournament edition --- .../_main page/pojedynczy_turniej/app.js | 11 ++- .../pojedynczy_turniej/drabinka/index.html | 4 +- .../pojedynczy_turniej/drabinka/style.css | 5 ++ .../_main page/pojedynczy_turniej/index.html | 5 +- .../zapisy na turniej/app.js | 2 +- .../zapisy na turniej/index.html | 2 +- .../pojedynczy_turniej/zapisy/index.html | 10 +-- .../pojedynczy_turniej/zapisy/style.css | 11 ++- frontend/normal_user/index.html | 4 +- .../dodawanie turnieju/app.js | 89 +++++++++++-------- .../dodawanie turnieju/index.html | 4 +- .../panel_organizatora/edycja turnieju/app.js | 45 +++++++++- .../edycja turnieju/index.html | 8 +- 13 files changed, 138 insertions(+), 62 deletions(-) diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/app.js b/frontend/normal_user/_main page/pojedynczy_turniej/app.js index e0c178d..292d920 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/app.js +++ b/frontend/normal_user/_main page/pojedynczy_turniej/app.js @@ -11,17 +11,18 @@ async function showTournaments() { } function logout() { - localStorage.clear(); + localStorage.removeItem('token'); location.reload(); } function logoutVisibility() { if (localStorage.getItem("token") !== null) { document.getElementById("logout").style.display = ""; + document.getElementById("saverForTournament").style.display = ""; } else { document.getElementById("logout").style.display = "none"; - + document.getElementById("saverForTournament").style.display = "none"; } } @@ -30,9 +31,11 @@ function logoutVisibility() { function loginVisibility() { if (localStorage.getItem("token") !== null) { document.getElementById("login").style.display = "none"; + document.getElementById("saverForTournament").style.display = ""; } else { document.getElementById("login").style.display = ""; + document.getElementById("saverForTournament").style.display = "none"; } } @@ -61,14 +64,14 @@ async function renderTournaments() { htmlDate = `

${tournament.name}

-

Miejsc: ${tournament.places}
+

Miejsce: ${tournament.place}
${tournament.from} do ${tournament.to}

` let htmlSegment = `

${tournament.name}

-

Miejsca: ${tournament.places}

+

Miejsce: ${tournament.place}

Wpisowe:

${tournament.entryFee} diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/drabinka/index.html b/frontend/normal_user/_main page/pojedynczy_turniej/drabinka/index.html index 172bfdb..67a3af3 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/drabinka/index.html +++ b/frontend/normal_user/_main page/pojedynczy_turniej/drabinka/index.html @@ -22,7 +22,7 @@ - + Kontakt Ranking Kalendarz turniejów @@ -33,7 +33,7 @@
-
diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/app.js b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/app.js index 3d78fc6..761367c 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/app.js +++ b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/app.js @@ -67,7 +67,7 @@ function tournamentSave() { .then(res => { if (res.ok) { alert("Udało się zapisać!") - + window.location.href = '../index.html' } else { console.log("Coś poszło nie tak!") } return res diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/index.html b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/index.html index b3ee5de..0fab9bf 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/index.html +++ b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/index.html @@ -5,7 +5,7 @@ - Paddle tournament system + Padle tournament system diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy/index.html b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy/index.html index 399c9ee..7f83c6f 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy/index.html +++ b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy/index.html @@ -22,7 +22,7 @@ - + Kontakt Ranking Kalendarz turniejów @@ -33,7 +33,7 @@
- +
@@ -52,8 +52,8 @@
- Adrian Trela - Adam Kowalski + +
diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy/style.css b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy/style.css index 0abc9ad..22cc705 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy/style.css +++ b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy/style.css @@ -87,6 +87,7 @@ main { border: 1px solid #AFAFAF; padding: -2px; } + /*2'nd Layer*/ .partID { width: 6%; @@ -99,7 +100,8 @@ main { text-align: center; padding-bottom: 0; } -.partNames{ + +.partNames { width: 47%; height: 100%; float: left; @@ -111,7 +113,8 @@ main { line-height: 200%; } -.partParameters{ + +.partParameters { width: 47%; height: 100%; float: left; @@ -132,4 +135,8 @@ main { display: flex; flex-direction: column; line-height: 200%; +} + +.header-list { + display: flex; } \ No newline at end of file diff --git a/frontend/normal_user/index.html b/frontend/normal_user/index.html index 785a9e8..5b84b3b 100644 --- a/frontend/normal_user/index.html +++ b/frontend/normal_user/index.html @@ -9,7 +9,7 @@ - +
@@ -19,7 +19,7 @@ - + Kontakt Ranking 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 @@ - + Kontakt Ranking @@ -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 @@ - +
@@ -65,7 +65,7 @@ -

Miejsc

+

Miejsce

@@ -95,7 +95,7 @@ -

Zapisy

+

Zapisy do