import Cookies from 'js-cookie'

const TokenKey = 'patrol_wzgl_token'
const UserInfo = 'patrol_wzgl_user'


export function getToken() {
  //return Cookies.get(TokenKey)

  if (Cookies.get(TokenKey)) {
    return Cookies.get(TokenKey)
  } else {
    return sessionStorage.getItem(TokenKey);
  }
}

export function setToken(token) {
  sessionStorage.setItem(TokenKey, token);
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  sessionStorage.clear();
  return Cookies.remove(TokenKey)

}

export function getWzglUser() {
  //return Cookies.get(TokenKey)

  if (Cookies.get(UserInfo)) {
    return Cookies.get(UserInfo)
  } else {
    return sessionStorage.getItem(UserInfo);
  }
}

export function setWzglUser(User) {
  sessionStorage.setItem(UserInfo, User);
  return Cookies.set(UserInfo, User)
}

export function removeWzglUser() {
  sessionStorage.clear();
  return Cookies.remove(UserInfo)

}
