Add a 'no jobs available' if not jobs in breezy.

This commit is contained in:
Thomas Smith 2023-05-04 14:44:34 +02:00
parent 353ac32766
commit 722cf08c35

View file

@ -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>