123 lines
3.1 KiB
Vue
123 lines
3.1 KiB
Vue
<script setup lang="ts">
|
|
import { ref, computed } from "vue"
|
|
import axios from "axios"
|
|
import { MissingAirline } from "@/Types/types"
|
|
|
|
const props = defineProps<{
|
|
airline: MissingAirline
|
|
}>()
|
|
|
|
// Track ids we've dismissed locally (optimistic UI) and ones currently in-flight
|
|
const dismissedIds = ref<Set<number>>(new Set())
|
|
const pendingIds = ref<Set<number>>(new Set())
|
|
|
|
const visibleFlights = computed(() =>
|
|
props.airline.flights.filter(flight => !dismissedIds.value.has(flight.id))
|
|
)
|
|
|
|
async function dismissFlight(flightId: number) {
|
|
if (pendingIds.value.has(flightId)) return
|
|
|
|
pendingIds.value.add(flightId)
|
|
// Optimistically remove the pill
|
|
dismissedIds.value.add(flightId)
|
|
|
|
try {
|
|
await axios.post('/admin/ignore-missing-airline', {
|
|
flight_id: flightId,
|
|
})
|
|
} catch (error) {
|
|
// Revert on failure so the flight isn't silently lost from view
|
|
dismissedIds.value.delete(flightId)
|
|
console.error('Failed to ignore missing airline for flight', flightId, error)
|
|
} finally {
|
|
pendingIds.value.delete(flightId)
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="missing-airline-card">
|
|
<div class="card-header">
|
|
<span class="airline-code">{{ airline.code }}</span>
|
|
<span class="flight-count">{{ visibleFlights.length }} flight{{ visibleFlights.length === 1 ? '' : 's' }}</span>
|
|
</div>
|
|
|
|
<div class="flight-list">
|
|
<v-chip
|
|
v-for="flight in visibleFlights"
|
|
:key="flight.link"
|
|
class="flight-chip"
|
|
size="small"
|
|
closable
|
|
:disabled="pendingIds.has(flight.id)"
|
|
@click:close="dismissFlight(flight.id)"
|
|
>
|
|
<a :href="flight.link" class="flight-link" target="_blank" rel="noopener" @click.stop>
|
|
{{ flight.flight_number }}
|
|
</a>
|
|
</v-chip>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.missing-airline-card {
|
|
background: rgba(255, 255, 255, 0.03);
|
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
border-radius: 8px;
|
|
padding: 1rem 1.25rem;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.75rem;
|
|
}
|
|
|
|
.card-header {
|
|
display: flex;
|
|
align-items: baseline;
|
|
justify-content: space-between;
|
|
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
|
padding-bottom: 0.5rem;
|
|
}
|
|
|
|
.airline-code {
|
|
font-family: 'Share Tech Mono', monospace;
|
|
font-size: 1.1rem;
|
|
letter-spacing: 0.08em;
|
|
color: #ffc107;
|
|
font-weight: 700;
|
|
}
|
|
|
|
.flight-count {
|
|
font-family: 'Share Tech Mono', monospace;
|
|
font-size: 0.68rem;
|
|
letter-spacing: 0.1em;
|
|
text-transform: uppercase;
|
|
color: #778;
|
|
}
|
|
|
|
.flight-list {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.flight-chip {
|
|
font-family: 'Share Tech Mono', monospace;
|
|
font-size: 0.72rem;
|
|
letter-spacing: 0.06em;
|
|
background: rgba(255, 255, 255, 0.04) !important;
|
|
border: 1px solid rgba(255, 255, 255, 0.06);
|
|
}
|
|
|
|
.flight-link {
|
|
color: #9fb3c8;
|
|
text-decoration: none;
|
|
transition: color 0.15s ease;
|
|
}
|
|
|
|
.flight-link:hover {
|
|
color: #ffc107;
|
|
}
|
|
</style>
|