<script setup lang="ts">
import {Flight} from "@/Types/types";
import InlineBadge from "@/Components/FlightsGoneBy/InlineBadge.vue";

const props = defineProps<{
    flight: Flight
}>();

type BadgeVariant = 'first' | 'business' | 'premium' | 'economy' | 'private' | 'unspecified';

function classVariant(name?: string | null): BadgeVariant {
    const n = name?.toLowerCase() ?? '';
    if (n.includes('private'))  return 'private';
    if (n.includes('first'))    return 'first';
    if (n.includes('business')) return 'business';
    if (n.includes('premium'))  return 'premium';
    if (n.includes('economy'))  return 'economy';
    return 'unspecified';
}
</script>

<template>
    <InlineBadge :variant="classVariant(flight.flight_class?.name)">
        {{ flight.flight_class?.name }}
    </InlineBadge>
</template>
