const state = {
    user: null,
    userStatus: null,
}

const getters = {
    authUser: state => {
        return state.user
    }
}

const actions = {
    // eslint-disable-next-line no-unused-vars
    fetchAuthUser({commit, state}) {
        // eslint-disable-next-line no-undef
        axios.get('/api/auth-user')
            .then(res => {
                commit('setAuthUser', res.data)
            })
            .catch(error => {
                console.log('Unable to fetch auth user' + error)
            })
    }
}

const mutations = {
    setAuthUser(state, user) {
        state.user = user
    }
}

export default {
    state, getters, actions, mutations,
}
