import user from '@/core/models/user'

export default {
    namespaced: true,
    state: {
        showLoginModal: false,
        userInfo: null,
    },
    getters: {
        showLoginModal(state) {
            return state.showLoginModal;
        },
        userInfo(state) {
            return state.userInfo;
        },
    },
    mutations: {
        showLoginModal(state, data) {
            state.showLoginModal = data;
        },
        userInfo(state, data) {
            state.userInfo = data;
        }
    },
    actions: {
        logout(context) {
            context.commit('userInfo', null);
        },
        userInfo(context) {
            user.getInfo().then(info => {
                context.commit('userInfo', info);
            });
        }
    }
}
