24 lines
823 B
TypeScript
24 lines
823 B
TypeScript
import { apiGet, apiPatch, apiPost } from "./axios";
|
|
import type { ApiListResponse, UserInfo } from "../types/api";
|
|
import { apiDelete } from "./axios";
|
|
|
|
export const fetchUsers = (params?: Record<string, any>) =>
|
|
apiGet<ApiListResponse<UserInfo>>("/api/v1/users/", { params });
|
|
|
|
export const createUser = (payload: {
|
|
email: string;
|
|
password: string;
|
|
full_name: string;
|
|
clinical_department: string;
|
|
}) =>
|
|
apiPost<UserInfo>("/api/v1/users/", payload);
|
|
|
|
export const updateUser = (
|
|
userId: string,
|
|
payload: Partial<{ status: string; password: string; full_name: string; clinical_department: string; is_active: boolean }>
|
|
) =>
|
|
apiPatch<UserInfo>(`/api/v1/users/${userId}`, payload);
|
|
|
|
export const deleteUser = (userId: string) =>
|
|
apiDelete<void>(`/api/v1/users/${userId}`, { suppressErrorMessage: true });
|