// js/jobListings.js document.addEventListener('DOMContentLoaded', function() { // Fetch job listings from API fetch('/positions') .then(response => response.json()) .then(data => { const jobListingsContainer = document.getElementById('job-listings'); // Clear the placeholder content jobListingsContainer.innerHTML = ''; // Check if there are positions if (data.positions && data.positions.length > 0) { data.positions.forEach(position => { const jobCard = document.createElement('div'); jobCard.className = 'job-card'; jobCard.innerHTML = `
${position.company || 'TSYS Group'} • ${position.location || 'Location'}
${position.description || 'No description available.'}
Salary Range: ${parseInt(position.salary_min).toLocaleString()} - ${parseInt(position.salary_max).toLocaleString()}
View Details `; jobListingsContainer.appendChild(jobCard); }); } else { jobListingsContainer.innerHTML = 'No job positions available at this time. Please check back later.
'; } }) .catch(error => { console.error('Error fetching job listings:', error); const jobListingsContainer = document.getElementById('job-listings'); jobListingsContainer.innerHTML = 'Error loading job listings. Please try again later.
'; }); });