diff --git a/web/src/api/admin/sessions.ts b/web/src/api/admin/sessions.ts new file mode 100644 index 0000000..b5f9191 --- /dev/null +++ b/web/src/api/admin/sessions.ts @@ -0,0 +1,48 @@ +import type { ServiceSession, UserSession } from "@/types"; +import { axios, handleApiError } from ".."; + +export interface FetchUserSessionsRequest { + limit: number; + offset: number; +} + +export type FetchUserSessionsResponse = UserSession[]; + +export const adminGetUserSessionsApi = async ( + req: FetchUserSessionsRequest, +): Promise => { + const response = await axios.get( + "/api/v1/admin/user-sessions", + { + params: req, + }, + ); + + if (response.status !== 200 && response.status !== 201) + throw await handleApiError(response); + + return response.data; +}; + +export interface FetchServiceSessionsRequest { + limit: number; + offset: number; +} + +export type FetchServiceSessionsResponse = ServiceSession[]; + +export const adminGetServiceSessionsApi = async ( + req: FetchServiceSessionsRequest, +): Promise => { + const response = await axios.get( + "/api/v1/admin/service-sessions", + { + params: req, + }, + ); + + if (response.status !== 200 && response.status !== 201) + throw await handleApiError(response); + + return response.data; +};