import { createStore } from 'vuex';

export default createStore({
  state: {
    modelApp: {
      id: 0
    },
  },
  mutations: {
    setId(state, payload) { 
        state.modelApp.id = payload; 
    }
  },
  actions: {
    async fetchUser({ commit }) {
        const user = await api.getUser();
        commit('setId', user.id);
    }
  },
  getters: {
    id: (state) => state.modelApp.id
  }
});