28 lines
1 KiB
TypeScript
28 lines
1 KiB
TypeScript
import {apiClient} from "../apiClient";
|
|
import type {UserDto} from "../dtos/UserDto";
|
|
import type {CreateUserRequest} from "../dtos/CreateUserRequest.ts";
|
|
import type {ChangeUserPasswordRequest} from "../dtos/ChangeUserPasswordRequest.ts";
|
|
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_URL}/me`);
|
|
}
|
|
|
|
export async function fetchAllUsers(): Promise<UserListResponse> {
|
|
return apiClient.get(`${USER_URL}/all`);
|
|
}
|
|
|
|
export async function createUser(dto: CreateUserRequest): Promise<CreateUserResponse> {
|
|
return apiClient.post(`${USER_URL}/create`, dto);
|
|
}
|
|
|
|
export async function updateUser(dto: UserDto): Promise<UserDto> {
|
|
return apiClient.post(`${USER_URL}/update`, dto);
|
|
}
|
|
|
|
export async function changePassword(dto: ChangeUserPasswordRequest) {
|
|
return apiClient.post(`${USER_URL}/change-password`, dto);
|
|
}
|