Renamed directories

This commit is contained in:
2023-09-22 16:56:57 -04:00
parent 02a4d840e0
commit 9cf92b8c1f
66 changed files with 11 additions and 28 deletions

38
ui/src/api/airport.ts Normal file
View File

@@ -0,0 +1,38 @@
import { Bounds, GetAirportResponse, GetAirportsResponse } from './airport.types';
import { getRequest } from '.';
interface GetAirportProps {
icao: string;
}
export async function getAirport({ icao }: GetAirportProps): Promise<GetAirportResponse> {
const response = await getRequest(`airports/${icao}`, {});
return response?.data || { data: undefined };
}
interface GetAirportsProps {
bounds?: Bounds;
category?: string;
filter?: string;
page?: number;
limit?: number;
}
export async function getAirports({
bounds,
category,
filter,
limit = 10,
page = 1
}: GetAirportsProps): Promise<GetAirportsResponse> {
const response = await getRequest('airports', {
bounds: bounds
? `${bounds?.northEast.lat},${bounds?.northEast.lon},${bounds?.southWest.lat},${bounds?.southWest.lon}`
: undefined,
category: category ?? undefined,
filter: filter ?? undefined,
limit,
page
});
return response?.data || { data: [] };
}