import Keys from '@/constant/key'
import Cookies from 'js-cookie'
import { UserInfoModel } from '@/model/userModel'

export const setLanguage = (language: string) => Cookies.set(Keys.languageKey, language)
export const setSize = (size: string) => Cookies.set(Keys.sizeKey, size)
export const getToken = () => Cookies.get(Keys.tokenKey)
export const getProjectId = () => Cookies.get(Keys.projectId)
export const setProjectId = (projectId: any) => Cookies.set(Keys.projectId, projectId)
export const setToken = (token: string) => Cookies.set(Keys.tokenKey, token)
export const removeToken = () => Cookies.remove(Keys.tokenKey)
export const setCookieUserInfo = (userInfo: any) => Cookies.set(Keys.userInfoKey, userInfo)
export const setCookieMac = (mac: any) => Cookies.set(Keys.macKey, mac)
export const getCookieMac = () => {
  return Cookies.get(Keys.macKey)
}
export const getCookieUserInfo = () => {
  let userInfo: any = Cookies.get(Keys.userInfoKey)
  if (userInfo) {
    return JSON.parse(userInfo)
  } else {
    return ''
  }
}

export const getSessionUserInfo = () => {
  let userInfo: any = sessionStorage.getItem(Keys.userInfoKey)
  if (userInfo) {
    return JSON.parse(userInfo)
  } else {
    return ''
  }
}
export const setSessionUserInfo = (userInfo: any) => sessionStorage.setItem(Keys.userInfoKey, userInfo)


