import { axios } from "@/requests/axios.config";

const prefix = "/user";

function loginAPI(data) {
  return axios.post(`${prefix}/login`, data);
}

function registerAPI(data) {
  return axios.post(`${prefix}/register`, data);
}

function sendMessageAPI(data) {
  return axios.post(`${prefix}/sendMessage`, data);
}

function resetAPI(data) {
  return axios.post(`${prefix}/resetPassword`, data);
}

function getUserAPI(data){
  return axios.get(`${prefix}/findUserById`, {
    params: {
      id: data,
    }
  });
}

function getNameByUsernameAPI(data) {
  return axios.get(`${prefix}/findNameByUserName`, {
    params: {
      username: data,
    }
  });
}

function saveNameAPI(data) {
  return axios.post(`${prefix}/saveName`, data);
}

function saveEmailAPI(data) {
  return axios.post(`${prefix}/saveEmail`, data);
}

function saveSignatureAPI(data) {
  return axios.post(`${prefix}/saveSignature`, data);
}

function findUserIdByPhone(phone){
  return axios.get(`${prefix}/findIdByPhone/${phone}`);
}

const userAPIs = {
  loginAPI,
  registerAPI,
  sendMessageAPI,
  resetAPI,
  getUserAPI,
  saveNameAPI,
  saveEmailAPI,
  saveSignatureAPI,
  getNameByUsernameAPI,
  findUserIdByPhone
};

export default userAPIs;