Add the API Client to all rest resources

This commit is contained in:
araemer 2026-02-22 13:15:48 +01:00
parent 0dc3264a22
commit 709cb23f3d
6 changed files with 29 additions and 53 deletions

View file

@ -5,22 +5,24 @@ import type {ChangeUserPasswordRequest} from "../dtos/ChangeUserPasswordRequest.
import type {CreateUserResponse} from "../dtos/CreateUserResponse.ts";
import type {UserListResponse} from "../dtos/UserListResponse.ts";
const USER_URL = "/user"
export async function fetchCurrentUser(): Promise<UserDto> {
return apiClient.get("/user/me");
return apiClient.get(`${USER_URL}/me`);
}
export async function fetchAllUsers(): Promise<UserListResponse> {
return apiClient.get("/user/all");
return apiClient.get(`${USER_URL}/all`);
}
export async function createUser(dto: CreateUserRequest): Promise<CreateUserResponse> {
return apiClient.post("/user/create", dto);
return apiClient.post(`${USER_URL}/create`, dto);
}
export async function updateUser(dto: UserDto): Promise<UserDto> {
return apiClient.post("/user/update", dto);
return apiClient.post(`${USER_URL}/update`, dto);
}
export async function changePassword(dto: ChangeUserPasswordRequest) {
return apiClient.post("/user/change-password", dto);
return apiClient.post(`${USER_URL}/change-password`, dto);
}