feat: sessions API
This commit is contained in:
48
web/src/api/admin/sessions.ts
Normal file
48
web/src/api/admin/sessions.ts
Normal 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;
|
||||||
|
};
|
Reference in New Issue
Block a user