Padel-Tournaments-System/frontend/normal_user/_main page/pojedynczy_turniej/app.js

87 lines
2.2 KiB
JavaScript
Raw Normal View History

let tourId = localStorage.getItem("myElement")
async function showTournaments() {
2022-06-10 15:33:05 +02:00
let url = 'https://dragonmaster.pl/inz/tournaments';
try {
let res = await fetch(url);
return await res.json();
} catch (error) {
console.log(error);
}
}
2022-06-19 09:34:23 +02:00
function loginVisibility() {
if (localStorage.getItem("token") !== null) {
document.getElementById("login").style.display = "none";
}
else {
document.getElementById("login").style.display = "";
}
}
async function renderTournaments() {
2022-06-10 15:33:05 +02:00
let tournaments = await showTournaments();
let html = '';
let htmlDate = '';
tournaments.forEach(tournament => {
2022-06-19 09:34:23 +02:00
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")) {
2022-06-18 14:35:43 +02:00
console.log(`${tournament.rang}`)
htmlDate = `
<h1 class="tournamentInfo">${tournament.name}</h1>
2022-06-19 09:34:23 +02:00
<h2 class="tournamentInfo">Miejsc: ${tournament.places}</br>
${tournament.from} do ${tournament.to}</h2>`
let htmlSegment = `
<h1> ${tournament.name}</h1>
2022-06-19 09:34:23 +02:00
<h2>Miejsca: ${tournament.places}</h2>
<h3 class="descriptor">Wpisowe:</h3>
${tournament.entryFee}
<h3 class="descriptor">Ranga:</h3>
${tournament.rang}
<h3 class="descriptor">Kategorie:</h3>
${tournament.categotry}
<h3 class="descriptor">Zapisy do:</h3>
${tournament.to}
<h3 class="descriptor">Czy rankingowy:</h3>
2022-06-19 09:34:23 +02:00
${rank}
<h3 class="descriptor">Dyrektor turnieju:</h3>
${tournament.director}
<h3 class="descriptor">Dodatkowe informacje</h3>
${tournament.additionalInformations}
`;
html += htmlSegment;
}
});
let date = document.querySelector('.tournamentData')
date.innerHTML = htmlDate;
let container = document.querySelector('.form');
container.innerHTML = html;
}