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";

export async function fetchCurrentUser(): Promise<UserDto> {
    return apiClient.get("/user/me");
}

export async function fetchAllUsers(): Promise<UserListResponse> {
    return apiClient.get("/user/all");
}

export async function createUser(dto: CreateUserRequest): Promise<CreateUserResponse> {
    return apiClient.post("/user/create", dto);
}

export async function updateUser(dto: UserDto): Promise<UserDto> {
    return apiClient.post("/user/update", dto);
}

export async function changePassword(dto: ChangeUserPasswordRequest) {
    return apiClient.post("/user/change-password", dto);
}
