import { Flight } from "../../api/flight";
import { useGetCommitBoundaryForFlightQuery } from "../../api/liberationApi";
import WaypointMarker from "../waypointmarker";
import { ReactElement } from "react";
import { Polyline } from "react-leaflet";
const BLUE_PATH = "#0084ff";
const RED_PATH = "#c85050";
const SELECTED_PATH = "#ffff00";
interface FlightPlanProps {
flight: Flight;
selected: boolean;
}
const pathColor = (props: FlightPlanProps) => {
if (props.selected) {
return SELECTED_PATH;
} else if (props.flight.blue) {
return BLUE_PATH;
} else {
return RED_PATH;
}
};
function FlightPlanPath(props: FlightPlanProps) {
const color = pathColor(props);
const waypoints = props.flight.waypoints;
if (waypoints == null) {
return <>>;
}
const points = waypoints
.filter((waypoint) => waypoint.include_in_path)
.map((waypoint) => waypoint.position);
return (
);
}
const WaypointMarkers = (props: FlightPlanProps) => {
if (!props.selected || props.flight.waypoints == null) {
return <>>;
}
var markers: ReactElement[] = [];
props.flight.waypoints?.forEach((p, idx) => {
markers.push(
);
});
return <>{markers}>;
};
interface CommitBoundaryProps {
flightId: string;
selected: boolean;
}
function CommitBoundary(props: CommitBoundaryProps) {
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 <>>;
}
return (
);
}
function CommitBoundaryIfSelected(props: CommitBoundaryProps) {
if (!props.selected) {
return <>>;
}
return ;
}
export default function FlightPlan(props: FlightPlanProps) {
return (
<>
>
);
}