feat: pagination + revoke session API
This commit is contained in:
@ -2,11 +2,15 @@ import type { ServiceSession, UserSession } from "@/types";
|
|||||||
import { axios, handleApiError } from "..";
|
import { axios, handleApiError } from "..";
|
||||||
|
|
||||||
export interface FetchUserSessionsRequest {
|
export interface FetchUserSessionsRequest {
|
||||||
limit: number;
|
page: number;
|
||||||
offset: number;
|
size: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FetchUserSessionsResponse = UserSession[];
|
export interface FetchUserSessionsResponse {
|
||||||
|
items: UserSession[];
|
||||||
|
page: number;
|
||||||
|
total_pages: number;
|
||||||
|
}
|
||||||
|
|
||||||
export const adminGetUserSessionsApi = async (
|
export const adminGetUserSessionsApi = async (
|
||||||
req: FetchUserSessionsRequest,
|
req: FetchUserSessionsRequest,
|
||||||
@ -24,6 +28,17 @@ export const adminGetUserSessionsApi = async (
|
|||||||
return response.data;
|
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 {
|
export interface FetchServiceSessionsRequest {
|
||||||
limit: number;
|
limit: number;
|
||||||
offset: number;
|
offset: number;
|
||||||
|
Reference in New Issue
Block a user