const KEY_TOKEN = 'KEY_TOKEN'
const KEY_USER = 'KEY_USER'


function setToken(token: string) {
    localStorage.setItem(KEY_TOKEN, token)
}

function getToken(): string | null {
    return localStorage.getItem(KEY_TOKEN)
}

export const token = {
    setToken,
    getToken
}

function setUserMsg(user: object) {
    localStorage.setItem(KEY_USER, JSON.stringify(user))
}

function getUserMsg(): object | null {
    const userStr = localStorage.getItem(KEY_USER)
    return userStr ? JSON.parse(userStr) : null
}

export const userMsg = {
    setUserMsg,
    getUserMsg
}