Remove hand written API objects.

This commit is contained in:
Dan Albert 2022-03-06 23:31:43 -08:00
parent 6ee235545f
commit 4b4336391a
22 changed files with 37 additions and 101 deletions

View File

@ -1,6 +1,6 @@
import { RootState } from "../app/store"; import { RootState } from "../app/store";
import { gameLoaded, gameUnloaded } from "./actions"; import { gameLoaded, gameUnloaded } from "./actions";
import { ControlPoint } from "./controlpoint"; import { ControlPoint } from "./liberationApi";
import { PayloadAction, createSlice } from "@reduxjs/toolkit"; import { PayloadAction, createSlice } from "@reduxjs/toolkit";
interface ControlPointsState { interface ControlPointsState {

View File

@ -1,11 +0,0 @@
import { LatLng } from "leaflet";
export interface ControlPoint {
id: number;
name: string;
blue: boolean;
position: LatLng;
mobile: boolean;
destination: LatLng | null;
sidc: string;
}

View File

@ -4,8 +4,6 @@ import backend from "./backend";
import Combat from "./combat"; import Combat from "./combat";
import { endCombat, newCombat, updateCombat } from "./combatSlice"; import { endCombat, newCombat, updateCombat } from "./combatSlice";
import { updateControlPoint } from "./controlPointsSlice"; import { updateControlPoint } from "./controlPointsSlice";
import { ControlPoint } from "./controlpoint";
import { Flight } from "./flight";
import { import {
deselectFlight, deselectFlight,
registerFlight, registerFlight,
@ -19,11 +17,15 @@ import {
deleteFrontLine, deleteFrontLine,
updateFrontLine, updateFrontLine,
} from "./frontLinesSlice"; } from "./frontLinesSlice";
import FrontLine from "./frontline";
import reloadGameState from "./gamestate"; import reloadGameState from "./gamestate";
import { liberationApi } from "./liberationApi"; import {
liberationApi,
ControlPoint,
Flight,
FrontLine,
Tgo,
} from "./liberationApi";
import { navMeshUpdated } from "./navMeshSlice"; import { navMeshUpdated } from "./navMeshSlice";
import Tgo from "./tgo";
import { updateTgo } from "./tgosSlice"; import { updateTgo } from "./tgosSlice";
import { threatZonesUpdated } from "./threatZonesSlice"; import { threatZonesUpdated } from "./threatZonesSlice";
import { LatLng } from "leaflet"; import { LatLng } from "leaflet";

View File

@ -1,10 +0,0 @@
import { Waypoint } from "./waypoint";
import { LatLng } from "leaflet";
export interface Flight {
id: string;
blue: boolean;
position: LatLng | null;
sidc: string;
waypoints: Waypoint[] | null;
}

View File

@ -1,6 +1,6 @@
import { RootState } from "../app/store"; import { RootState } from "../app/store";
import { gameLoaded, gameUnloaded } from "./actions"; import { gameLoaded, gameUnloaded } from "./actions";
import { Flight } from "./flight"; import { Flight } from "./liberationApi";
import { PayloadAction, createSlice } from "@reduxjs/toolkit"; import { PayloadAction, createSlice } from "@reduxjs/toolkit";
import { LatLng } from "leaflet"; import { LatLng } from "leaflet";

View File

@ -1,6 +1,6 @@
import { RootState } from "../app/store"; import { RootState } from "../app/store";
import { gameLoaded, gameUnloaded } from "./actions"; import { gameLoaded, gameUnloaded } from "./actions";
import FrontLine from "./frontline"; import { FrontLine } from "./liberationApi";
import { PayloadAction, createSlice } from "@reduxjs/toolkit"; import { PayloadAction, createSlice } from "@reduxjs/toolkit";
interface FrontLinesState { interface FrontLinesState {

View File

@ -1,8 +0,0 @@
import { LatLng } from "leaflet";
export interface FrontLine {
id: string;
extents: LatLng[];
}
export default FrontLine;

View File

@ -1,9 +1,12 @@
import { ControlPoint } from "./controlpoint"; import {
import { Flight } from "./flight"; ControlPoint,
import FrontLine from "./frontline"; Flight,
import { NavMeshes, ThreatZoneContainer } from "./liberationApi"; FrontLine,
import SupplyRoute from "./supplyroute"; NavMeshes,
import Tgo from "./tgo"; SupplyRoute,
Tgo,
ThreatZoneContainer,
} from "./liberationApi";
import { LatLngLiteral } from "leaflet"; import { LatLngLiteral } from "leaflet";
export default interface Game { export default interface Game {

View File

@ -1,6 +1,6 @@
import { RootState } from "../app/store"; import { RootState } from "../app/store";
import { gameLoaded, gameUnloaded } from "./actions"; import { gameLoaded, gameUnloaded } from "./actions";
import SupplyRoute from "./supplyroute"; import { SupplyRoute } from "./liberationApi";
import { createSlice } from "@reduxjs/toolkit"; import { createSlice } from "@reduxjs/toolkit";
interface SupplyRoutesState { interface SupplyRoutesState {

View File

@ -1,11 +0,0 @@
import { LatLng } from "leaflet";
export interface SupplyRoute {
points: LatLng[];
front_active: boolean;
is_sea: boolean;
blue: boolean;
active_transports: string[];
}
export default SupplyRoute;

View File

@ -1,17 +0,0 @@
import { LatLng } from "leaflet";
export interface Tgo {
id: string;
name: string;
control_point_name: string;
category: string;
blue: boolean;
position: LatLng;
units: string[];
threat_ranges: number[];
detection_ranges: number[];
dead: boolean;
sidc: string;
}
export default Tgo;

View File

@ -1,6 +1,6 @@
import { RootState } from "../app/store"; import { RootState } from "../app/store";
import { gameLoaded, gameUnloaded } from "./actions"; import { gameLoaded, gameUnloaded } from "./actions";
import { Tgo } from "./tgo"; import { Tgo } from "./liberationApi";
import { PayloadAction, createSlice } from "@reduxjs/toolkit"; import { PayloadAction, createSlice } from "@reduxjs/toolkit";
interface TgosState { interface TgosState {

View File

@ -1,12 +0,0 @@
import { LatLng } from "leaflet";
export interface Waypoint {
name: string;
position: LatLng;
altitude_ft: number;
altitude_reference: string;
is_movable: boolean;
should_mark: boolean;
include_in_path: boolean;
timing: string;
}

View File

@ -1,4 +1,4 @@
import { Flight } from "../../api/flight"; import { Flight } from "../../api/liberationApi";
import { Icon, Point } from "leaflet"; import { Icon, Point } from "leaflet";
import { Symbol } from "milsymbol"; import { Symbol } from "milsymbol";
import { Marker } from "react-leaflet"; import { Marker } from "react-leaflet";

View File

@ -1,4 +1,4 @@
import Tgo from "../../api/tgo"; import { Tgo } from "../../api/liberationApi";
import { selectTgos } from "../../api/tgosSlice"; import { selectTgos } from "../../api/tgosSlice";
import { useAppSelector } from "../../app/hooks"; import { useAppSelector } from "../../app/hooks";
import { Circle, LayerGroup } from "react-leaflet"; import { Circle, LayerGroup } from "react-leaflet";

View File

@ -1,5 +1,5 @@
import backend from "../../api/backend"; import backend from "../../api/backend";
import { ControlPoint as ControlPointModel } from "../../api/controlpoint"; import { ControlPoint as ControlPointModel } from "../../api/liberationApi";
import { import {
useClearControlPointDestinationMutation, useClearControlPointDestinationMutation,
useSetControlPointDestinationMutation, useSetControlPointDestinationMutation,
@ -10,6 +10,7 @@ import {
Point, Point,
Marker as LMarker, Marker as LMarker,
Polyline as LPolyline, Polyline as LPolyline,
LatLngLiteral,
} from "leaflet"; } from "leaflet";
import { Symbol as MilSymbol } from "milsymbol"; import { Symbol as MilSymbol } from "milsymbol";
import { import {
@ -64,7 +65,7 @@ function formatLatLng(latLng: LatLng) {
function destinationTooltipText( function destinationTooltipText(
cp: ControlPointModel, cp: ControlPointModel,
destinationish: LatLng, destinationish: LatLngLiteral,
inRange: boolean inRange: boolean
) { ) {
const destination = new LatLng(destinationish.lat, destinationish.lng); const destination = new LatLng(destinationish.lat, destinationish.lng);
@ -93,12 +94,12 @@ function PrimaryMarker(props: ControlPointProps) {
const [hasDestination, setHasDestination] = useState<boolean>( const [hasDestination, setHasDestination] = useState<boolean>(
props.controlPoint.destination != null props.controlPoint.destination != null
); );
const [pathDestination, setPathDestination] = useState<LatLng>( const [pathDestination, setPathDestination] = useState<LatLngLiteral>(
props.controlPoint.destination props.controlPoint.destination
? props.controlPoint.destination ? props.controlPoint.destination
: props.controlPoint.position : props.controlPoint.position
); );
const [position, setPosition] = useState<LatLng>( const [position, setPosition] = useState<LatLngLiteral>(
props.controlPoint.destination props.controlPoint.destination
? props.controlPoint.destination ? props.controlPoint.destination
: props.controlPoint.position : props.controlPoint.position
@ -189,8 +190,7 @@ function PrimaryMarker(props: ControlPointProps) {
dragend: async (event) => { dragend: async (event) => {
const currentPosition = new LatLng( const currentPosition = new LatLng(
pathDestination.lat, pathDestination.lat,
pathDestination.lng, pathDestination.lng
pathDestination.alt
); );
const destination = event.target.getLatLng(); const destination = event.target.getLatLng();
setDestination(destination); setDestination(destination);
@ -225,7 +225,7 @@ function PrimaryMarker(props: ControlPointProps) {
interface SecondaryMarkerProps { interface SecondaryMarkerProps {
controlPoint: ControlPointModel; controlPoint: ControlPointModel;
destination: LatLng | null; destination: LatLngLiteral | undefined;
} }
function SecondaryMarker(props: SecondaryMarkerProps) { function SecondaryMarker(props: SecondaryMarkerProps) {

View File

@ -1,4 +1,4 @@
import { Flight } from "../../api/flight"; import { Flight } from "../../api/liberationApi";
import { useGetCommitBoundaryForFlightQuery } from "../../api/liberationApi"; import { useGetCommitBoundaryForFlightQuery } from "../../api/liberationApi";
import WaypointMarker from "../waypointmarker"; import WaypointMarker from "../waypointmarker";
import { ReactElement } from "react"; import { ReactElement } from "react";

View File

@ -1,5 +1,5 @@
import { Flight } from "../../api/flight";
import { selectFlights, selectSelectedFlight } from "../../api/flightsSlice"; import { selectFlights, selectSelectedFlight } from "../../api/flightsSlice";
import { Flight } from "../../api/liberationApi";
import { useAppSelector } from "../../app/hooks"; import { useAppSelector } from "../../app/hooks";
import FlightPlan from "../flightplan"; import FlightPlan from "../flightplan";
import { LayerGroup } from "react-leaflet"; import { LayerGroup } from "react-leaflet";

View File

@ -1,4 +1,4 @@
import { FrontLine as FrontLineModel } from "../../api/frontline"; import { FrontLine as FrontLineModel } from "../../api/liberationApi";
import { Polyline } from "react-leaflet"; import { Polyline } from "react-leaflet";
interface FrontLineProps { interface FrontLineProps {

View File

@ -1,4 +1,4 @@
import { SupplyRoute as SupplyRouteModel } from "../../api/supplyroute"; import { SupplyRoute as SupplyRouteModel } from "../../api/liberationApi";
import SplitLines from "../splitlines/SplitLines"; import SplitLines from "../splitlines/SplitLines";
import { Polyline as LPolyline } from "leaflet"; import { Polyline as LPolyline } from "leaflet";
import { useEffect, useRef } from "react"; import { useEffect, useRef } from "react";

View File

@ -2,7 +2,7 @@ import {
useOpenNewTgoPackageDialogMutation, useOpenNewTgoPackageDialogMutation,
useOpenTgoInfoDialogMutation, useOpenTgoInfoDialogMutation,
} from "../../api/liberationApi"; } from "../../api/liberationApi";
import { Tgo as TgoModel } from "../../api/tgo"; import { Tgo as TgoModel } from "../../api/liberationApi";
import SplitLines from "../splitlines/SplitLines"; import SplitLines from "../splitlines/SplitLines";
import { Icon, Point } from "leaflet"; import { Icon, Point } from "leaflet";
import { Symbol as MilSymbol } from "milsymbol"; import { Symbol as MilSymbol } from "milsymbol";

View File

@ -1,6 +1,6 @@
import backend from "../../api/backend"; import backend from "../../api/backend";
import { Flight } from "../../api/flight"; import { Flight } from "../../api/liberationApi";
import { Waypoint } from "../../api/waypoint"; import { Waypoint } from "../../api/liberationApi";
import { Icon } from "leaflet"; import { Icon } from "leaflet";
import { Marker as LMarker } from "leaflet"; import { Marker as LMarker } from "leaflet";
import icon from "leaflet/dist/images/marker-icon.png"; import icon from "leaflet/dist/images/marker-icon.png";