Files
hspguard/web/src/api/admin/users.ts
2025-06-04 19:33:07 +02:00

32 lines
811 B
TypeScript

import type { UserProfile } from "@/types";
import { axios, handleApiError } from "..";
export interface FetchUsersResponse {
items: UserProfile[];
count: number;
}
export const adminGetUsersApi = async (): Promise<FetchUsersResponse> => {
const response = await axios.get<FetchUsersResponse>("/api/v1/admin/users");
if (response.status !== 200 && response.status !== 201)
throw await handleApiError(response);
return response.data;
};
export type FetchUserResponse = UserProfile;
export const adminGetUserApi = async (
id: string,
): Promise<FetchUserResponse> => {
const response = await axios.get<FetchUserResponse>(
`/api/v1/admin/users/${id}`,
);
if (response.status !== 200 && response.status !== 201)
throw await handleApiError(response);
return response.data;
};