diff --git a/service/airport-codes.json b/service/airport-codes.json index 5ae0fc5..7c82757 100644 --- a/service/airport-codes.json +++ b/service/airport-codes.json @@ -1458,7 +1458,7 @@ "local_code": "0R1" }, { - "icao": "K0R3", + "icao": "KIYA", "category": "small_airport", "full_name": "Abbeville Chris Crusta Memorial Airport", "point": diff --git a/ui/src/api/airport.ts b/ui/src/api/airport.ts index 590569b..5a84ca0 100644 --- a/ui/src/api/airport.ts +++ b/ui/src/api/airport.ts @@ -21,11 +21,6 @@ interface GetAirportsProps { limit?: number; } -export async function getAirportsCount() { - const response = await getRequest('airports/count'); - return response?.json() || { data: 0 }; -} - export async function getAirports({ bounds, category, diff --git a/ui/src/api/airport.types.ts b/ui/src/api/airport.types.ts index 4461edd..93d20e4 100644 --- a/ui/src/api/airport.types.ts +++ b/ui/src/api/airport.types.ts @@ -7,6 +7,17 @@ export enum AirportCategory { LARGE = 'large_airport' } +export function airportCategoryToText(category: AirportCategory): string { + switch (category) { + case AirportCategory.SMALL: + return 'Small'; + case AirportCategory.MEDIUM: + return 'Medium'; + case AirportCategory.LARGE: + return 'Large'; + } +} + export enum AirportOrderField { ICAO = 'icao', NAME = 'name', diff --git a/ui/src/components/Admin/AirportTablePanel.tsx b/ui/src/components/Admin/AirportTablePanel.tsx index b797b08..1d48f54 100644 --- a/ui/src/components/Admin/AirportTablePanel.tsx +++ b/ui/src/components/Admin/AirportTablePanel.tsx @@ -1,6 +1,7 @@ import { getAirports, importAirports, removeAirport } from "@/api/airport"; -import { Airport } from "@/api/airport.types"; -import { Text, Button, Card, Group, Pagination, ScrollArea, Table, TextInput, rem } from "@mantine/core"; +import { Airport, AirportCategory, AirportOrderField, airportCategoryToText } from "@/api/airport.types"; +import { Text, Button, Card, Group, Pagination, ScrollArea, Table, TextInput, rem, UnstyledButton, Center } from "@mantine/core"; +import { HiChevronUp, HiChevronDown, HiSelector } from "react-icons/hi"; import { useEffect, useState } from "react"; import { CiSearch } from "react-icons/ci"; @@ -31,15 +32,12 @@ export default function AirportTablePanel({ setAirport }: { setAirport: (airport const rows = airports.map((airport) => ( { - console.log('here'); - setAirport(airport); - }} + onClick={() => setAirport(airport)} style={{ cursor: 'pointer' }} > {airport.icao} {airport.full_name} - {airport.category} + {airportCategoryToText(airport.category)} {airport.continent} {airport.iso_country} {airport.iso_region} @@ -61,7 +59,7 @@ export default function AirportTablePanel({ setAirport }: { setAirport: (airport onChange={handleSearchChange} /> - +
ICAO @@ -114,4 +112,22 @@ function PanelButton({ children, color = 'blue', onClick }: {children: any, colo > {children} -} \ No newline at end of file +} + +function Th({ children, asc, sorted, onSort }: { children: any, asc: boolean, sorted: boolean, onSort: () => void }) { + const Icon = sorted ? (asc ? HiChevronUp : HiChevronDown) : HiSelector; + return ( + + + + + {children} + +
+ +
+
+
+
+ ); +}