import {storage} from '@/utils/storage'

export default {
    namespaced: true,
    state: {
        userInfo: storage.getUserInfo(),
        campus: storage.getData("campus", [])
    },
    getters: {
        userInfo: state => state.userInfo,
        campus: state => state.campus,
    },
    mutations: {
        SET_USER_INFO: (state, userInfo) => {
            state.userInfo = userInfo;
            storage.setUserInfo(userInfo);
        },

        SET_DEFAULT_CAMPUS: (state, {defaultCampusId, defaultCampusName}) => {
            state.userInfo.defaultCampusId = defaultCampusId;
            state.userInfo.defaultCampusName = defaultCampusName;
            storage.setUserInfo(state.userInfo);
        },

        SET_CAMPUS: (state, campus) => {
            state.campus = campus;
            storage.setData("campus", campus);
        },
    },
    actions: {}
}
