a4a9c1c640
On main page now we can see all of tournaments from api
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
async function showTournaments() {
|
|
let url = 'https://dragonmaster.pl/inz/tournaments';
|
|
try {
|
|
let res = await fetch(url);
|
|
return await res.json();
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
}
|
|
|
|
async function renderTournaments() {
|
|
let tournaments = await showTournaments();
|
|
let html = '';
|
|
tournaments.forEach(tournament => {
|
|
let htmlSegment = `<div class = "tournamentBox">
|
|
<div class="tournamentIconBox">
|
|
<img class="tournamentIcon" src="_main%20page/cup.svg" alt="">
|
|
</div>
|
|
<div class="tournamentDataBox">
|
|
<div class="tournamentData">
|
|
<h4>${tournament.name}</h4>
|
|
Propadel, Warszawa
|
|
${tournament.from} do ${tournament.to}
|
|
<button class="tournamentOpen">OPEN</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`;
|
|
html += htmlSegment;
|
|
});
|
|
|
|
let container = document.querySelector('.tournament-list');
|
|
container.innerHTML = html;
|
|
}
|