import { default as axios } from 'axios'
import { getHeaderInfo } from '../helpers/tokenCreator'

// const API_URL = `${__VITE_BACKEND_URL__}`
const API_URL = import.meta.env.VITE_BACKEND_URL + 'api/'

const login = async (formData: { email: string; password: string }) => {
  return await axios.post(API_URL + 'v1/admin/login', {
    ...formData,
  })
}

const logout = async () => {
  const headers = await getHeaderInfo()
  return await axios.get(API_URL + 'v1/admin/logout', headers)
}

export const authAPI = {
  login,
  logout,
}
