feat: pagination + revoke session API
This commit is contained in:
@ -2,11 +2,15 @@ import type { ServiceSession, UserSession } from "@/types";
|
||||
import { axios, handleApiError } from "..";
|
||||
|
||||
export interface FetchUserSessionsRequest {
|
||||
limit: number;
|
||||
offset: number;
|
||||
page: number;
|
||||
size: number;
|
||||
}
|
||||
|
||||
export type FetchUserSessionsResponse = UserSession[];
|
||||
export interface FetchUserSessionsResponse {
|
||||
items: UserSession[];
|
||||
page: number;
|
||||
total_pages: number;
|
||||
}
|
||||
|
||||
export const adminGetUserSessionsApi = async (
|
||||
req: FetchUserSessionsRequest,
|
||||
@ -24,6 +28,17 @@ export const adminGetUserSessionsApi = async (
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const adminRevokeUserSessionApi = async (
|
||||
sessionId: string,
|
||||
): Promise<void> => {
|
||||
const response = await axios.patch<FetchServiceSessionsResponse>(
|
||||
`/api/v1/admin/user-sessions/revoke/${sessionId}`,
|
||||
);
|
||||
|
||||
if (response.status !== 200 && response.status !== 201)
|
||||
throw await handleApiError(response);
|
||||
};
|
||||
|
||||
export interface FetchServiceSessionsRequest {
|
||||
limit: number;
|
||||
offset: number;
|
||||
|
Reference in New Issue
Block a user