const userInfoKey = "admin_user_info"

export function getAdminUserInfoCache() {
    return window.sessionStorage.getItem(userInfoKey)
}

export function cacheAdminUserInfo(infoJSONStr) {
    window.sessionStorage.setItem(userInfoKey, infoJSONStr)
}

export function removeAdminUserInfoCache() {
    window.sessionStorage.removeItem(userInfoKey)
}

const loginInfoKey = "login_info"
export function getLoginInfoCache() {
    var jsonStr = window.localStorage.getItem(loginInfoKey)
    if (jsonStr == null || jsonStr.length == 0) {
        return {
            mobile: "",
            password: "",
        }
    } else {
        var infoJSON = JSON.parse(jsonStr)
        return {
            mobile: infoJSON.mobile,
            password: infoJSON.password,
        }
    }
}

export function cacheLoginInfo(mobile, password) {
    var info = {
        mobile: mobile,
        // password: password,
        password: "",
    }
    var infoJSONStr = JSON.stringify(info)
    window.localStorage.setItem(loginInfoKey, infoJSONStr)
}