<script setup lang="ts">
import MainLayout from "@/Layouts/MainLayout.vue";
import {Achievement, Flight, Region, User} from "@/Types/types";
import Panel from "@/Components/FlightsGoneBy/Panels/Panel.vue";
import PanelHeader from "@/Components/FlightsGoneBy/Panels/PanelHeader.vue";
import {computed} from "vue";
import PanelSubHeader from "@/Components/FlightsGoneBy/Panels/PanelSubHeader.vue";

import FlightRegionTable from "@/Components/FlightsGoneBy/FlightRegionTable.vue";
import {useRegionFlights} from "@/Composables/useRegionFlights";
import RegionLegend from "@/Components/FlightsGoneBy/Panels/RegionLegend.vue";
import Brazil from "@/Components/Maps/Brazil.vue";


defineOptions({ layout: MainLayout })
const props = defineProps<{
    achievement: Achievement
    user: User
    isFollowing: boolean
    flights: Flight[]
    regions: Region[]
}>()

const countryCode = 'BR'
const stateLocalCodes = ['AC','AL','AP','AM','BA','CE','DF','ES','GO','MA','MT','MS','MG','PA','PB','PR','PE','PI','RJ','RN','RS','RO','RR','SC','SP','SE','TO']

const { flightsByRegion, visitedRegions, regionNames } = useRegionFlights(
    computed(() => props.flights),
    stateLocalCodes,
    countryCode,
    computed(() => props.regions)
)

</script>

<template>
    <Panel>
        <PanelHeader centered>The Challenge</PanelHeader>
        <p>
            Either take off or land from an airport in each Brazilian State plus the Distrito Federal (Brasilia).
        </p>
    </Panel>
    <Panel style="display:flex; flex-direction: column; align-items: center; justify-content: center;">
        <PanelHeader centered>Progress</PanelHeader>
        <Brazil :visitedStates="visitedRegions" :flights="flightsByRegion" style="width: 100%;"/>
        <RegionLegend :regionNames="regionNames" :visitedRegions="visitedRegions" :stateLocalCodes="stateLocalCodes"/>
        <br/>
        <PanelHeader center>Flights By State</PanelHeader>
        <FlightRegionTable
            :regionCodes="stateLocalCodes"
            :regionNames="regionNames"
            :flightsByRegion="flightsByRegion"
        />
    </Panel>
    <Panel>
        <PanelHeader centered>Difficulty</PanelHeader>
        <p>
            This is a very difficult challenge - Brazil is a reasonably mature aviation market by South American standards, but flights can still be expensive and the major
            hubs tend to be in the south so you can expect a lot of doubling back. Brasilia might not be a bad base as it's quite central and well connected, but if you're trying
            to achieve this trophy organically, it's unlikely to just happen!
        </p>
    </Panel>
</template>

<style scoped>

</style>
