Replace api.ts with auto-generated API.

All the slices will come later.
This commit is contained in:
Dan Albert
2022-03-06 17:40:28 -08:00
parent 2310ef0f80
commit 30aebf2546
4 changed files with 35 additions and 57 deletions

View File

@@ -1,6 +1,7 @@
import { useGetCommitBoundaryForFlightQuery } from "../../api/api";
import { Flight } from "../../api/flight";
import { useGetCommitBoundaryForFlightQuery } from "../../api/liberationApi";
import WaypointMarker from "../waypointmarker";
import { LatLng } from "leaflet";
import { ReactElement } from "react";
import { Polyline } from "react-leaflet";
@@ -66,14 +67,31 @@ interface CommitBoundaryProps {
}
function CommitBoundary(props: CommitBoundaryProps) {
const { data, error, isLoading } = useGetCommitBoundaryForFlightQuery(
props.flightId
);
if (isLoading || error || !data) {
const { data, error, isLoading } = useGetCommitBoundaryForFlightQuery({
flightId: props.flightId,
});
if (isLoading) {
return <></>;
}
if (error) {
console.error(`Error loading commit boundary for ${props.flightId}`, error);
return <></>;
}
if (!data) {
console.log(
`Null response data when loading commit boundary for ${props.flightId}`
);
return <></>;
}
// TODO: Fix the response model and clean up.
const positions = data.map(([lat, lng]) => new LatLng(lat, lng));
return (
<Polyline positions={data} color="#ffff00" weight={1} interactive={false} />
<Polyline
positions={positions}
color="#ffff00"
weight={1}
interactive={false}
/>
);
}