26 lines
707 B
TypeScript
26 lines
707 B
TypeScript
import { ConnectedAircraft, ConnectedDispatcher, Prisma } from "@repo/db";
|
|
import axios from "axios";
|
|
|
|
export const getConnectedUserAPI = async () => {
|
|
const res = await axios.get<(ConnectedAircraft | ConnectedDispatcher)[]>(
|
|
"/api/connected-user",
|
|
{},
|
|
);
|
|
if (res.status !== 200) {
|
|
throw new Error("Failed to fetch Connected User");
|
|
}
|
|
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;
|
|
};
|