From d8b0af04613d3e27da79e8c9b7540d062f456e1d Mon Sep 17 00:00:00 2001 From: Arek Date: Fri, 17 Jun 2022 13:45:32 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20:sparkles:=20Wy=C5=9Bwietlanie=20usuwan?= =?UTF-8?q?ia=20tylko=20dla=20organizatora=20danego=20turnieju?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_main page/pojedynczy_turniej/app.js | 24 ++++----- .../_main page/pojedynczy_turniej/index.html | 4 +- frontend/normal_user/app.js | 51 +++++++++++++++++-- frontend/normal_user/index.html | 6 +-- 4 files changed, 63 insertions(+), 22 deletions(-) diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/app.js b/frontend/normal_user/_main page/pojedynczy_turniej/app.js index dd8b14d..ab12e2b 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/app.js +++ b/frontend/normal_user/_main page/pojedynczy_turniej/app.js @@ -10,23 +10,20 @@ async function showTournaments() { } } -// async function renderTournaments() { -// let tournaments = await showTournaments(); -// let html = ''; -// tournaments[1]; (tournament => { -// let htmlSegment = `

${tournament.id}

`; -// html += htmlSegment; -// }); - -// let container = document.querySelector('.form'); -// container.innerHTML = html; -// } - async function renderTournaments() { let tournaments = await showTournaments(); let html = ''; + let htmlDate = ''; tournaments.forEach(tournament => { if (`${tournament.id}` == localStorage.getItem("tournamentId")) { + + htmlDate = ` +

${tournament.name}

+

${tournament.places}
+ ${tournament.from} do ${tournament.to}

` + + + let htmlSegment = `

${tournament.name}

${tournament.places}

@@ -57,6 +54,9 @@ async function renderTournaments() { } }); + let date = document.querySelector('.tournamentData') + date.innerHTML = htmlDate; + let container = document.querySelector('.form'); container.innerHTML = html; } diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/index.html b/frontend/normal_user/_main page/pojedynczy_turniej/index.html index fdafce7..104778b 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/index.html +++ b/frontend/normal_user/_main page/pojedynczy_turniej/index.html @@ -35,9 +35,7 @@
-

Turniej majowy 2022

-

Propadel, Warszawa
- 13/05/2022 do 15/05/2022

+
diff --git a/frontend/normal_user/app.js b/frontend/normal_user/app.js index 2f88ff9..3947a24 100644 --- a/frontend/normal_user/app.js +++ b/frontend/normal_user/app.js @@ -12,11 +12,30 @@ function saveIdTournament(id) { localStorage.setItem('tournamentId', id); } -async function renderTournaments() { +function checkRoleCreator() { + fetch('https://dragonmaster.pl/inz/user', { + headers: { + Authorization: ("Bearer " + localStorage.getItem("token")) + } + }) + .then(res => res.json()) + .then(json => { + let test = (json['id']) + renderTournaments(test) + }) +} + + +async function renderTournaments(test) { let tournaments = await showTournaments(); let html = ''; tournaments.forEach(tournament => { - let htmlSegment = `
+ // console.log(test) + organiser = `${tournament.creator}`; + console.log(organiser) + // console.log(organiser) + if (organiser == test) { + let htmlSegment = `
@@ -31,16 +50,40 @@ async function renderTournaments() {
- +
`; - html += htmlSegment; + html += htmlSegment; + } + else { + let htmlSegment = `
+
+ +
+
+
+

${tournament.name}

+ ${tournament.place} + ${tournament.from} do ${tournament.to} + + +
+ +
+
+ `; + html += htmlSegment; + } }); let container = document.querySelector('.tournament-list'); container.innerHTML = html; } +function checkRoleforDelete() { + +} + function logout() { localStorage.clear(); location.reload(); diff --git a/frontend/normal_user/index.html b/frontend/normal_user/index.html index d3df9ee..ca42c54 100644 --- a/frontend/normal_user/index.html +++ b/frontend/normal_user/index.html @@ -10,15 +10,15 @@ - +