feat: ✨ Wyświetlanie usuwania tylko dla organizatora danego turnieju
This commit is contained in:
parent
411a03501c
commit
d8b0af0461
@ -10,23 +10,20 @@ async function showTournaments() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// async function renderTournaments() {
|
|
||||||
// let tournaments = await showTournaments();
|
|
||||||
// let html = '';
|
|
||||||
// tournaments[1]; (tournament => {
|
|
||||||
// let htmlSegment = `<h1>${tournament.id}</h2>`;
|
|
||||||
// html += htmlSegment;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// let container = document.querySelector('.form');
|
|
||||||
// container.innerHTML = html;
|
|
||||||
// }
|
|
||||||
|
|
||||||
async function renderTournaments() {
|
async function renderTournaments() {
|
||||||
let tournaments = await showTournaments();
|
let tournaments = await showTournaments();
|
||||||
let html = '';
|
let html = '';
|
||||||
|
let htmlDate = '';
|
||||||
tournaments.forEach(tournament => {
|
tournaments.forEach(tournament => {
|
||||||
if (`${tournament.id}` == localStorage.getItem("tournamentId")) {
|
if (`${tournament.id}` == localStorage.getItem("tournamentId")) {
|
||||||
|
|
||||||
|
htmlDate = `
|
||||||
|
<h1 class="tournamentInfo">${tournament.name}</h1>
|
||||||
|
<h2 class="tournamentInfo">${tournament.places}</br>
|
||||||
|
${tournament.from} do ${tournament.to}</h2>`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let htmlSegment = `
|
let htmlSegment = `
|
||||||
<h1> ${tournament.name}</h1>
|
<h1> ${tournament.name}</h1>
|
||||||
<h2>${tournament.places}</h2>
|
<h2>${tournament.places}</h2>
|
||||||
@ -57,6 +54,9 @@ async function renderTournaments() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let date = document.querySelector('.tournamentData')
|
||||||
|
date.innerHTML = htmlDate;
|
||||||
|
|
||||||
let container = document.querySelector('.form');
|
let container = document.querySelector('.form');
|
||||||
container.innerHTML = html;
|
container.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,7 @@
|
|||||||
|
|
||||||
<div class="tournamentDataBox">
|
<div class="tournamentDataBox">
|
||||||
<div class="tournamentData">
|
<div class="tournamentData">
|
||||||
<h1 class="tournamentInfo">Turniej majowy 2022</h1>
|
|
||||||
<h2 class="tournamentInfo">Propadel, Warszawa </br>
|
|
||||||
13/05/2022 do 15/05/2022</h2>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -12,10 +12,29 @@ function saveIdTournament(id) {
|
|||||||
localStorage.setItem('tournamentId', 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 tournaments = await showTournaments();
|
||||||
let html = '';
|
let html = '';
|
||||||
tournaments.forEach(tournament => {
|
tournaments.forEach(tournament => {
|
||||||
|
// console.log(test)
|
||||||
|
organiser = `${tournament.creator}`;
|
||||||
|
console.log(organiser)
|
||||||
|
// console.log(organiser)
|
||||||
|
if (organiser == test) {
|
||||||
let htmlSegment = `<div class = "tournamentBox" onclick="window.location.href='_main page/pojedynczy_turniej/index.html'; saveIdTournament(${tournament.id});">
|
let htmlSegment = `<div class = "tournamentBox" onclick="window.location.href='_main page/pojedynczy_turniej/index.html'; saveIdTournament(${tournament.id});">
|
||||||
<div class="tournamentIconBox">
|
<div class="tournamentIconBox">
|
||||||
<img class="tournamentIcon" src="_main%20page/cup.svg" alt="">
|
<img class="tournamentIcon" src="_main%20page/cup.svg" alt="">
|
||||||
@ -31,16 +50,40 @@ async function renderTournaments() {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<img class="dots" src="src/trash.svg">
|
<img class="dots" id="deleteMatch" src="src/trash.svg">
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
html += htmlSegment;
|
html += htmlSegment;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let htmlSegment = `<div class = "tournamentBox" onclick="window.location.href='_main page/pojedynczy_turniej/index.html'; saveIdTournament(${tournament.id});">
|
||||||
|
<div class="tournamentIconBox">
|
||||||
|
<img class="tournamentIcon" src="_main%20page/cup.svg" alt="">
|
||||||
|
</div>
|
||||||
|
<div class="tournamentDataBox">
|
||||||
|
<div class="tournamentData">
|
||||||
|
<h4>${tournament.name}</h4>
|
||||||
|
${tournament.place}
|
||||||
|
${tournament.from} do ${tournament.to}
|
||||||
|
|
||||||
|
<button class="tournamentOpen">OPEN</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
html += htmlSegment;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let container = document.querySelector('.tournament-list');
|
let container = document.querySelector('.tournament-list');
|
||||||
container.innerHTML = html;
|
container.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkRoleforDelete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function logout() {
|
function logout() {
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
location.reload();
|
location.reload();
|
||||||
|
@ -10,15 +10,15 @@
|
|||||||
<script type="text/javascript" src="app.js"></script>
|
<script type="text/javascript" src="app.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="renderTournaments();logoutVisibility(); loginVisibility(); checkRole();">
|
<body onload="renderTournaments();logoutVisibility(); loginVisibility(); checkRole(); checkRoleCreator();">
|
||||||
<header>
|
<header>
|
||||||
<div class="logoBox">
|
<div class="logoBox">
|
||||||
<a class="header_link" href="./index.html"><img class="logo" src="../_global/logo.svg" alt="Logo error"></a>
|
<a class="header_link" href="./index.html"><img class="logo" src="../_global/logo.svg" alt="Logo error"></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="linkBox">
|
<div class="linkBox">
|
||||||
<!-- <span class="dot">JM</span>-->
|
<!-- <span class="dot">JM</span>-->
|
||||||
<button class="loginButton" type="submit"
|
<button class="loginButton" type="submit" onclick="window.location.href='logowanie/index.html'"
|
||||||
onclick="window.location.href='logowanie/index.html'" id="login">LOGOWANIE</button>
|
id="login">LOGOWANIE</button>
|
||||||
<button class="loginButton" id="logout" onclick="logout()">Wyloguj</button>
|
<button class="loginButton" id="logout" onclick="logout()">Wyloguj</button>
|
||||||
|
|
||||||
<a class="header_link" href="kontakt/index.html">Kontakt</a>
|
<a class="header_link" href="kontakt/index.html">Kontakt</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user