export const state = () => ({
  user: {},
  token: null
});

export const getters = {

}

export const mutations = {
  saveUser(state, user){
    state.user = user;
  },
  saveToken(state, token) {
    state.token = token;
  }
}

export const actions = {
  nuxtServerInit({ commit}, { req, app }) {
    const token = app.$cookies.get('token');
    const user = app.$cookies.get('user');
    if (user){
      commit('saveUser', user)
    }
    if(token){
      commit('saveToken', token);
    }
  }
};
