Files
MOHPortalTest-AllAgents-All…/qwen/php/public/js/jobListings.js
2025-10-24 16:29:40 -05:00

35 lines
1.8 KiB
JavaScript

// 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 = `
<h4>${position.title || 'Untitled Position'}</h4>
<p>${position.company || 'TSYS Group'}${position.location || 'Location'}</p>
<p>${position.description || 'No description available.'}</p>
<p><strong>Salary Range:</strong> ${parseInt(position.salary_min).toLocaleString()} - ${parseInt(position.salary_max).toLocaleString()}</p>
<a href="/positions/${position.id || '#'}" class="btn">View Details</a>
`;
jobListingsContainer.appendChild(jobCard);
});
} else {
jobListingsContainer.innerHTML = '<p>No job positions available at this time. Please check back later.</p>';
}
})
.catch(error => {
console.error('Error fetching job listings:', error);
const jobListingsContainer = document.getElementById('job-listings');
jobListingsContainer.innerHTML = '<p>Error loading job listings. Please try again later.</p>';
});
});