feat: Selecting one Tournament

Now you can choose one tournament from tournaments calendar
This commit is contained in:
Arek 2022-06-14 08:46:41 +02:00
parent 7a8ec95791
commit 5ce2883a53
4 changed files with 66 additions and 48 deletions

View File

@ -1,4 +1,6 @@
function showTournaments() {
let tourId = localStorage.getItem("myElement")
async function showTournaments() {
let url = 'https://dragonmaster.pl/inz/tournaments';
try {
let res = await fetch(url);
@ -6,6 +8,55 @@ function showTournaments() {
} catch (error) {
console.log(error);
}
let tournaments = await showTournaments();
console.log(tournaments[1])
}
// 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() {
let tournaments = await showTournaments();
let html = '';
tournaments.forEach(tournament => {
if (`${tournament.id}` == localStorage.getItem("tournamentId")) {
let htmlSegment = `
<h1> ${tournament.name}</h1>
<h2>${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>
${tournament.rang}
<h3 class="descriptor">Dyrektor turnieju:</h3>
${tournament.director}
<h3 class="descriptor">Dodatkowe informacje</h3>
${tournament.additionalInformations}
`;
html += htmlSegment;
}
});
let container = document.querySelector('.form');
container.innerHTML = html;
}

View File

@ -7,16 +7,19 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Padel Tournaments System</title>
<link href="style.css" rel="stylesheet">
<script type="text/javascript" src="app.js"></script>
</head>
<body>
<body onload="renderTournaments()">
<header>
<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 class="linkBox">
<!-- <span class="dot">JM</span>-->
<button class="loginButton" type="submit" onclick="window.location.href='../../panel_organizatora/logowanie/index.html'">LOGOWANIE</button>
<button class="loginButton" type="submit"
onclick="window.location.href='../../panel_organizatora/logowanie/index.html'">LOGOWANIE</button>
<a class="header_link" href="../../kontakt/index.html">Kontakt</a>
<a class="header_link" href="../../ranking/index.html">Ranking</a>
<a class="header_link" href="../../index.html">Kalendarz turniejów</a>
@ -56,45 +59,6 @@
<div class="form">
<h1> Turniej Majowy 2022</h1>
<h2>Propadel, Warszawa</h2>
<h3 class="descriptor">Wpisowe:</h3>
<label>
<input>
</label>
<h3 class="descriptor">Ranga:</h3>
<label>
<input>
</label>
<h3 class="descriptor">Kategorie:</h3>
<label>
<input>
</label>
<h3 class="descriptor">Zapisy do:</h3>
<label>
<input>
</label>
<h3 class="descriptor">Czy rankingowy:</h3>
<label>
<input>
</label>
<h3 class="descriptor">Dyrektor turnieju:</h3>
<label>
<input>
</label>
<h3 class="descriptor">Dodatkowe informacje</h3>
<label>
<textarea name="Text1" cols="40" rows="5"></textarea>
</label>
</div>
</div>
</body>

View File

@ -8,12 +8,15 @@ async function showTournaments() {
}
}
function saveIdTournament(id) {
localStorage.setItem('tournamentId', id);
}
async function renderTournaments() {
let tournaments = await showTournaments();
let html = '';
console.log(tournaments[1])
tournaments.forEach(tournament => {
let htmlSegment = `<div class = "tournamentBox" onclick="window.location.href='_main page/pojedynczy_turniej/index.html';loca">
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>

View File

@ -10,7 +10,7 @@
<script type="text/javascript" src="app.js"></script>
</head>
<body onload="renderTournaments();logoutVisibility(); loginVisibility(); creatorVisibility()">
<body onload="renderTournaments();logoutVisibility(); loginVisibility(); creatorVisibility();">
<header>
<div class="logoBox">
<a class="header_link" href="./index.html"><img class="logo" src="./_global/logo.svg" alt="Logo error"></a>