import Cookies from 'js-cookie'
import axios, { axiosErrorToast } from '../config/axios'

export default function logout() {
  axios({
    method: 'POST',
    baseURL: process.env.REACT_APP_API_HOST,
    url: '/auth-server/auth/logout',
  })
    .then((res) => {
      Cookies.remove('campx_tenant')
      Cookies.remove('campx_session_key')
      Cookies.remove('campx_institution')
      window.location.href = '/'
    })
    .catch((err) => {
      axiosErrorToast('Unable To Logout.')
    })
}
