diff --git a/app/timetracking/frontend/wizard.html b/app/timetracking/frontend/wizard.html index f676384..ab6a11a 100644 --- a/app/timetracking/frontend/wizard.html +++ b/app/timetracking/frontend/wizard.html @@ -385,6 +385,7 @@ // Load a specific time entry async function loadSpecificEntry(timeId) { + console.log('๐ŸŽฏ Loading specific entry:', timeId); document.getElementById('loading-state').classList.remove('d-none'); document.getElementById('time-entry-container').classList.add('d-none'); document.getElementById('completion-state').classList.add('d-none'); @@ -397,6 +398,7 @@ } const entry = await response.json(); + console.log('๐Ÿ“ฅ Loaded entry:', entry.id, 'Status:', entry.status, 'Date:', entry.worked_date); currentEntry = entry; currentCaseId = entry.case_id; @@ -404,19 +406,26 @@ // Only fetch other case entries if this entry is pending // Otherwise just show this single entry if (entry.status === 'pending' && entry.case_id) { + console.log('๐Ÿ” Fetching other pending entries for case:', entry.case_id); const caseResponse = await fetch(`/api/v1/timetracking/wizard/case/${entry.case_id}/entries`); if (caseResponse.ok) { const caseEntries = await caseResponse.json(); + console.log('๐Ÿ“‹ Got', caseEntries.length, 'pending entries for case'); // Make sure our entry is in the list (it should be since it's pending) window.currentCaseEntries = caseEntries; } else { + console.log('โš ๏ธ Could not fetch case entries, showing single entry'); window.currentCaseEntries = [entry]; } } else { + console.log('โ„น๏ธ Entry is not pending or has no case - showing single entry only'); // Entry is not pending - just show this one entry window.currentCaseEntries = [entry]; } + console.log('โœจ Current entry to display:', currentEntry.id); + console.log('๐Ÿ“ฆ All entries:', window.currentCaseEntries.map(e => e.id)); + // Show the entry displayCaseEntries({ time_entry: entry, @@ -431,7 +440,7 @@ document.getElementById('time-entry-container').classList.remove('d-none'); } catch (error) { - console.error('Error loading specific entry:', error); + console.error('โŒ Error loading specific entry:', error); showToast('Kunne ikke indlรฆse tidsregistrering', 'danger'); // Fall back to loading next entry setTimeout(() => loadNextEntry(), 1000); @@ -498,6 +507,9 @@ const entries = window.currentCaseEntries || []; const container = document.getElementById('time-entries-list'); + console.log('๐Ÿ–ผ๏ธ displayCaseEntries called with', entries.length, 'entries'); + console.log('๐ŸŽฏ currentEntry.id:', currentEntry?.id); + if (entries.length === 0) { container.innerHTML = '
Ingen pending tidsregistreringer
'; return; @@ -507,10 +519,14 @@ let entry; if (currentEntry && currentEntry.id) { entry = entries.find(e => e.id === currentEntry.id) || entries[0]; + console.log('๐Ÿ”Ž Looking for entry', currentEntry.id, '- Found:', entry.id); } else { entry = entries[0]; + console.log('โ„น๏ธ No currentEntry set, using first entry:', entry.id); } + console.log('โœ… Displaying entry:', entry.id, 'Date:', entry.worked_date); + // Update header document.getElementById('case-header-title').textContent = entry.case_title || 'Ingen case'; document.getElementById('case-header-customer').textContent = entry.customer_name || '-';