diff --git a/web/admin.html b/web/admin.html index b01e83d..4c16c37 100644 --- a/web/admin.html +++ b/web/admin.html @@ -509,6 +509,14 @@ + + +
@@ -3266,6 +3274,16 @@ cancelBtn.style.display = (flight.status === 'BOOKED_OUT' || flight.status === 'DEPARTED') ? 'inline-block' : 'none'; document.getElementById('local-flight-edit-title').textContent = `${flight.registration} - ${flight.flight_type}`; + + // Load and display circuits if this is a CIRCUITS flight + const circuitsSection = document.getElementById('circuits-section'); + if (flight.flight_type === 'CIRCUITS') { + circuitsSection.style.display = 'block'; + loadCircuitsDisplay(flight.id); + } else { + circuitsSection.style.display = 'none'; + } + document.getElementById('localFlightEditModal').style.display = 'block'; } catch (error) { console.error('Error loading flight:', error); @@ -3273,6 +3291,39 @@ } } + async function loadCircuitsDisplay(localFlightId) { + try { + const response = await authenticatedFetch(`/api/v1/circuits/flight/${localFlightId}`); + if (!response.ok) throw new Error('Failed to load circuits'); + + const circuits = await response.json(); + displayCircuitsList(circuits); + } catch (error) { + console.error('Error loading circuits:', error); + document.getElementById('circuits-list').innerHTML = 'Error loading circuits
'; + } + } + + function displayCircuitsList(circuits) { + const circuitsList = document.getElementById('circuits-list'); + + if (circuits.length === 0) { + circuitsList.innerHTML = 'No touch & go records yet
'; + return; + } + + let html = `Total circuits: ${circuits.length}
`; + html += '