feat: sessions API

This commit is contained in:
2025-06-15 18:09:48 +02:00
parent 97ffcbdaa4
commit cc497b6016

View File

@ -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<FetchUserSessionsResponse> => {
const response = await axios.get<FetchUserSessionsResponse>(
"/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<FetchServiceSessionsResponse> => {
const response = await axios.get<FetchServiceSessionsResponse>(
"/api/v1/admin/service-sessions",
{
params: req,
},
);
if (response.status !== 200 && response.status !== 201)
throw await handleApiError(response);
return response.data;
};