fix: null-safe icon selectors after table restructure (#4)

This commit is contained in:
Samuel Enocsson
2026-05-21 15:16:09 +02:00
parent 16d375ae10
commit 7af9d8d69e
+6 -10
View File
@@ -261,8 +261,8 @@ async function refreshRoundHistory(pdgaNumber) {
} }
async function refreshRatingHistory(pdgaNumber) { async function refreshRatingHistory(pdgaNumber) {
const icon = document.querySelector(`#history-${pdgaNumber} .chart-title .refresh-icon`); // No dedicated icon in the expanded row; spinner state not needed here
icon.classList.add('spinning'); const icon = null;
try { try {
const response = await fetch(`/api/refresh-rating-history/${pdgaNumber}`, { method: 'POST' }); const response = await fetch(`/api/refresh-rating-history/${pdgaNumber}`, { method: 'POST' });
@@ -277,8 +277,6 @@ async function refreshRatingHistory(pdgaNumber) {
} catch (error) { } catch (error) {
console.error('Error refreshing rating history:', error); console.error('Error refreshing rating history:', error);
alert('Failed to refresh rating history'); alert('Failed to refresh rating history');
} finally {
icon.classList.remove('spinning');
} }
} }
@@ -329,10 +327,9 @@ async function searchAndAddPlayer(event) {
return; return;
} }
const button = document.querySelector('.btn-add'); const button = document.querySelector('.add-bar button[type="submit"]');
const originalText = button.textContent; const originalText = button ? button.textContent : '';
button.disabled = true; if (button) { button.disabled = true; button.textContent = 'Searching...'; }
button.textContent = 'Searching...';
try { try {
const response = await fetch(`/api/search-player/${pdgaNumber}`); const response = await fetch(`/api/search-player/${pdgaNumber}`);
@@ -355,8 +352,7 @@ async function searchAndAddPlayer(event) {
console.error('Error searching for player:', error); console.error('Error searching for player:', error);
showErrorModal('Failed to search for player. Please try again.'); showErrorModal('Failed to search for player. Please try again.');
} finally { } finally {
button.disabled = false; if (button) { button.disabled = false; button.textContent = originalText; }
button.textContent = originalText;
} }
} }