Made Aircrafts fetch from Server. Added OSM Objects to mission
This commit is contained in:
25
apps/dispatch/app/querys/aircrafts.ts
Normal file
25
apps/dispatch/app/querys/aircrafts.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { ConnectedAircraft, Prisma, Station } from "@repo/db";
|
||||
import axios from "axios";
|
||||
import { serverApi } from "helpers/axios";
|
||||
|
||||
export const getConnectedAircraftsAPI = async () => {
|
||||
const res =
|
||||
await axios.get<(ConnectedAircraft & { Station: Station })[]>(
|
||||
"/api/aircrafts",
|
||||
); // return only connected aircrafts
|
||||
if (res.status !== 200) {
|
||||
throw new Error("Failed to fetch stations");
|
||||
}
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const editConnectedAircraftAPI = async (
|
||||
id: number,
|
||||
mission: Prisma.ConnectedAircraftUpdateInput,
|
||||
) => {
|
||||
const respone = await serverApi.patch<ConnectedAircraft>(
|
||||
`/aircrafts/${id}`,
|
||||
mission,
|
||||
);
|
||||
return respone.data;
|
||||
};
|
||||
Reference in New Issue
Block a user