added MEasurement-tool, added Dispatch-name auto change
This commit is contained in:
37
apps/dispatch/app/_querys/dispatcher.ts
Normal file
37
apps/dispatch/app/_querys/dispatcher.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { ConnectedAircraft, ConnectedDispatcher, Prisma } from "@repo/db";
|
||||
import { serverApi } from "_helpers/axios";
|
||||
import axios from "axios";
|
||||
|
||||
export const changeDispatcherAPI = async (
|
||||
id: number,
|
||||
data: Prisma.ConnectedDispatcherUpdateInput,
|
||||
) => {
|
||||
const res = await serverApi.patch<ConnectedDispatcher>(`/dispatcher/${id}`, data);
|
||||
if (res.status !== 200) {
|
||||
throw new Error("Failed to update Connected Dispatcher");
|
||||
}
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const getConnectedDispatcherAPI = async (filter?: Prisma.ConnectedDispatcherWhereInput) => {
|
||||
const res = await axios.get<ConnectedDispatcher[]>("/api/dispatcher", {
|
||||
params: {
|
||||
filter: JSON.stringify(filter),
|
||||
},
|
||||
});
|
||||
if (res.status !== 200) {
|
||||
throw new Error("Failed to fetch Connected Dispatcher");
|
||||
}
|
||||
return res.data;
|
||||
};
|
||||
|
||||
export const kickDispatcherAPI = async ({ id, bann }: { id: number; bann?: boolean }) => {
|
||||
const res = await serverApi.delete(`/dispatcher/${id}`, {
|
||||
data: { bann },
|
||||
});
|
||||
console.log(res.status);
|
||||
if (res.status != 204) {
|
||||
throw new Error("Failed to kick aircraft");
|
||||
}
|
||||
return res.data;
|
||||
};
|
||||
Reference in New Issue
Block a user