import axios from "../../../config/axios";
import {
  CheckUserNameType,
  UpdateEmailType,
  UpdatePhoneType,
  UpdateProfileType,
  VerifyPhoneType,
} from "../types/ProfileTypes";

export const getProfile = async () => {
  const { data } = await axios.get(`/users/me`);
  return data;
};

export const checkUserName = async (params: CheckUserNameType) => {
  const { data } = await axios.post(`/users/check-validity`, params);
  return data;
};

export const updateProfile = async (params: UpdateProfileType) => {
  const { data } = await axios.patch(`/users/profile`, params);
  return data;
};

export const updateEmail = async (params: UpdateEmailType) => {
  const { data } = await axios.patch(`/users/change-email`, params);
  return data;
};

export const updatePhone = async (params: UpdatePhoneType) => {
  const { data } = await axios.patch(`/users/change-phone`, params);
  return data;
};

export const verifyPhone = async (params: VerifyPhoneType) => {
  const { data } = await axios.patch(`/users/verify-phone`, params);
  return data;
};

export const singleUpload = async (params: FormData) => {
  const { data } = await axios.post(`/uploader/single-file`, params);
  return data;
};
