import Cookies from 'js-cookie'

const TOKEN_KEY = 'C_TOKEN', USER_ID_KEY = 'C_USER_ID', USER_NAME_KEY = 'C_USER_NAME'

export function getToken() {
    return Cookies.get(TOKEN_KEY)
}

export function setToken(token) {
    return Cookies.set(TOKEN_KEY, token)
}

export function removeToken() {
    return Cookies.remove(TOKEN_KEY)
}

export function getUserId() {
    return Cookies.get(USER_ID_KEY)
}

export function setUserId(userId) {
    return Cookies.set(USER_ID_KEY, userId)
}

export function removeUserId() {
    return Cookies.remove(USER_ID_KEY)
}

export function getUserName() {
    return Cookies.get(USER_NAME_KEY)
}

export function setUserName(userName) {
    return Cookies.set(USER_NAME_KEY, userName)
}

export function removeUserName() {
    return Cookies.remove(USER_NAME_KEY)
}

export function setUserInfo(user, token) {
    setUserId(user.userId)
    setUserName(user.userName)
    setToken(token)
}

export function clearUserInfo() {
    removeUserId()
    removeUserName()
    removeToken()
}