mirror of
https://github.com/ivabus/www
synced 2024-11-22 13:15:06 +03:00
Add a 'no jobs available' if not jobs in breezy.
This commit is contained in:
parent
353ac32766
commit
722cf08c35
1 changed files with 73 additions and 63 deletions
|
@ -27,11 +27,20 @@
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Fetch data from API
|
// Fetch data from API
|
||||||
fetch("https://tea.breezy.hr/json?verbose=true")
|
fetch("https://tea.breezy.hr/json?verbose=true")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
// Check if data is empty
|
||||||
|
if (data.length === 0) {
|
||||||
|
// Display message when no jobs are available
|
||||||
|
const container = document.getElementById("card-container");
|
||||||
|
const noJobsMessage = document.createElement("div");
|
||||||
|
noJobsMessage.classList.add("alert", "alert-info");
|
||||||
|
noJobsMessage.textContent = "No jobs available right now";
|
||||||
|
container.appendChild(noJobsMessage);
|
||||||
|
} else {
|
||||||
// Loop through data and create card for each item
|
// Loop through data and create card for each item
|
||||||
data.forEach(item => {
|
data.forEach(item => {
|
||||||
// Create card element
|
// Create card element
|
||||||
|
@ -92,9 +101,10 @@
|
||||||
row.appendChild(col);
|
row.appendChild(col);
|
||||||
container.appendChild(row);
|
container.appendChild(row);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(error => console.log(error));
|
.catch(error => console.log(error));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
Loading…
Reference in a new issue