import { sessionStorage } from '../utils/storage';

const mutations = {
  SET_USER (state, user) {
    state.user = user;
    sessionStorage.setItem('user', user);
  },
  SET_USERNAME (state, userName) {
    state.userName = userName;
    sessionStorage.setItem('userName',JSON.stringify(userName) );
  },
  SET_USERROLE (state, userRole) {
    state.userRole = userRole;
    sessionStorage.setItem('userRole',userRole?JSON.stringify(userRole):'');
  },
  // SET_USERAvatar (state, userAvatar) {
  //   state.userAvatar = userAvatar;
  //   sessionStorage.setItem('userAvatar',JSON.stringify(userAvatar));
  // },
  SET_TOKEN (state, token) {
    state.token = token;
    sessionStorage.setItem('token', token);
  },
  SET_companyList (state, companyList) {
    state.companyList = companyList;
    sessionStorage.setItem('companyList',JSON.stringify(companyList));
  },
  SET_mtCompanyId(state, mtCompanyId){
    state.mtCompanyId = mtCompanyId;
    sessionStorage.setItem('mtCompanyId',mtCompanyId);
  },
  SET_menus (state, menus) {
    state.menus = menus;
    sessionStorage.setItem('menus',JSON.stringify(menus));
  },
  SET_MOBILE(state, mobile) {
    state.mobile = mobile;
    console.log('mobile', mobile)
    sessionStorage.setItem('mobile', mobile);
  },
  SET_USERAvatar(state, avatarUrl) {
    state.avatarUrl = avatarUrl;
    console.log('avatarUrl', avatarUrl)
    sessionStorage.setItem('avatarUrl', avatarUrl);
  },
  
};

export default mutations;

