// assets/js/tracking.js
function refreshTracking(trackingCode) {
    if (!trackingCode) return;
    
    fetch('ajax/tracking.php?code=' + encodeURIComponent(trackingCode))
        .then(response => response.json())
        .then(data => {
            if (data.success) {
                location.reload();
            } else {
                alert('Unable to refresh. Please try again.');
            }
        })
        .catch(error => console.error('Error:', error));
}

// Auto-refresh tracking every 60 seconds on orders page
if (window.location.pathname.includes('dashboard.php') && 
    document.querySelector('.tracking-card')) {
    setInterval(() => {
        location.reload();
    }, 60000);
}