jobs - add check if jobs are available

This commit is contained in:
LinuxSquare 2024-03-09 14:34:31 +01:00
parent e57625adc9
commit f6c545a946
2 changed files with 54 additions and 45 deletions

View file

@ -21,7 +21,7 @@
<label for="experience">Your experience in this is position *</label> <label for="experience">Your experience in this is position *</label>
<textarea class="rounded-md" name="experience" id="experience" cols="30" rows="5"></textarea> <textarea class="rounded-md" name="experience" id="experience" cols="30" rows="5"></textarea>
<label for="references">Your references *</label> <label for="references">Your references *</label>
<textarea class="rounded-md" name="" id="" cols="30" rows="5"></textarea> <textarea class="rounded-md" name="references" id="" cols="30" rows="5"></textarea>
</div> </div>
</div> </div>
<div class="apply-section -docs"> <div class="apply-section -docs">

View file

@ -3,52 +3,61 @@ let jobsContainer = document.getElementById("jobsContainer")
fetch('/json/jobs.json') fetch('/json/jobs.json')
.then((response) => response.json()) .then((response) => response.json())
.then((json) => { .then((json) => {
json.forEach((job) => { if(json.length <= 0) {
const jobContainer = document.createElement("div"); const jobContainer = document.createElement("div");
jobContainer.classList.add("flex-auto"); jobContainer.classList.add("flex-auto");
jobContainer.appendChild(document.createElement("h2")).innerHTML = "There are currently no open jobs to apply for"
jobContainer.appendChild(document.createElement("p")).innerHTML = "Please try again to a different time"
const jobTitle = document.createElement("h2"); jobsContainer.appendChild(jobContainer);
jobTitle.innerHTML = job.title; } else {
jobContainer.appendChild(jobTitle) json.forEach((job) => {
if(job.sub.length > 0) { const jobContainer = document.createElement("div");
const jobIcons = document.createElement("div"); jobContainer.classList.add("flex-auto");
jobIcons.classList.add("flex", "flex-row", "text-2xl");
job.sub.forEach((icon) => { const jobTitle = document.createElement("h2");
let iconObject jobTitle.innerHTML = job.title;
switch(icon.source) { jobContainer.appendChild(jobTitle)
case "mdi": if(job.sub.length > 0) {
iconObject = document.createElement("span"); const jobIcons = document.createElement("div");
iconObject.classList.add("iconify"); jobIcons.classList.add("flex", "flex-row", "text-2xl");
iconObject.setAttribute("data-icon", "mdi-"+icon.icon+""); job.sub.forEach((icon) => {
break; let iconObject
case "simpleicons": switch(icon.source) {
case "mdi":
iconObject = document.createElement("span"); iconObject = document.createElement("span");
iconObject.classList.add("icon"); iconObject.classList.add("iconify");
const iconImg = document.createElement("img"); iconObject.setAttribute("data-icon", "mdi-"+icon.icon+"");
iconImg.height = 20;
iconImg.width = 20;
iconImg.src = "https://cdn.jsdelivr.net/npm/simple-icons@v10/icons/"+icon.icon+".svg"
iconObject.appendChild(iconImg);
break; break;
} case "simpleicons":
jobIcons.appendChild(iconObject); iconObject = document.createElement("span");
}); iconObject.classList.add("icon");
jobContainer.appendChild(jobIcons); const iconImg = document.createElement("img");
} iconImg.height = 20;
iconImg.width = 20;
iconImg.src = "https://cdn.jsdelivr.net/npm/simple-icons@v10/icons/"+icon.icon+".svg"
iconObject.appendChild(iconImg);
break;
}
jobIcons.appendChild(iconObject);
});
jobContainer.appendChild(jobIcons);
}
const jobDescription = document.createElement("p"); const jobDescription = document.createElement("p");
jobDescription.innerHTML = job.description; jobDescription.innerHTML = job.description;
jobContainer.appendChild(jobDescription); jobContainer.appendChild(jobDescription);
const applyButton = document.createElement("button"); const applyButton = document.createElement("button");
applyButton.type = "button" applyButton.type = "button"
applyButton.classList.add("text-white", "bg-blue-700", "hover:bg-blue-800", "focus:outline-none", "focus:ring-4", "focus:ring-blue-300", "font-medium", "rounded-full", "text-sm", "px-5", "py-2.5", "text-center", "me-2", "mb-2", "dark:bg-blue-600", "dark:hover:bg-blue-700", "dark:focus:ring-blue-800", "max-w-2xs"); applyButton.classList.add("text-white", "bg-blue-700", "hover:bg-blue-800", "focus:outline-none", "focus:ring-4", "focus:ring-blue-300", "font-medium", "rounded-full", "text-sm", "px-5", "py-2.5", "text-center", "me-2", "mb-2", "dark:bg-blue-600", "dark:hover:bg-blue-700", "dark:focus:ring-blue-800", "max-w-2xs");
applyButton.addEventListener("click", () => { applyButton.addEventListener("click", () => {
openApplyForm(job.title) openApplyForm(job.title)
}) })
applyButton.innerHTML = "Apply" applyButton.innerHTML = "Apply"
jobsContainer.appendChild(jobContainer) jobsContainer.appendChild(jobContainer)
jobContainer.appendChild(applyButton) jobsContainer.appendChild(applyButton)
}); });
}); }
});