import api from "./axios";

export const getAllUsers = () => api.get("/admin/users");
export const updateRole = (id, role) => api.put(`/admin/users`, { id, role });
export const deleteUser = (id) => api.delete(`/admin/users/${id}`);
export const checkIfUserExists = (username) => api.get(`/users/exists`, { params: { username: username } });

export const getCurrentUser = async () => {
  return api.get("/users/me");
};

export const updateCurrentUser = async (display_name) => {
  return api.patch("/users/me", { display_name });
};

export const changePassword = async (current_password, new_password) => {
  return api.post("/users/me/change-password", { current_password, new_password });
};