import { api } from "src/boot/axios";

export const getUserById = async (id) => {
  const { data } = await api.get("/user/" + id);
  return data.payload;
};

export const getUsers = async () => {
  const { data } = await api.get("/user");
  return data.payload;
};

export const createUser = async (user) => {
  const { data } = await api.post("/user", user);
  return data.payload;
};

export const updateUser = async (user, id) => {
  const { data } = await api.put(`/user/${id}`, user);
  return data.payload;
};

export const deleteUser = async (id) => {
  const { data } = await api.delete(`/user/${id}`);
  return data.payload;
};

export const getUser = async () => {
  const { data } = await api.get("/user/me");
  return data.payload;
};

export const changePassword = async (payload) => {
  const { data } = await api.post("/user/change-password", payload);
  return data.payload;
};

export const countUsers = async () => {
  const { data } = await api.get("/user/count");
  return data.payload;
};

//

export const userTypes = async () => {
  const { data } = await api.get("/user-types");
  return data.payload;
};

export const createUserType = async (payload) => {
  const { data } = await api.post("/user-types", payload);
  return data.payload;
};
