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 @@ - +