import Vue from 'vue';
import Vuex, { Store } from "vuex";
import Services from '../services';
Vue.use(Vuex);
const store = new Store({
  strict: true,
  state: {
    user: null,
  },
  getters: {
    user(state) {
      return state.user;
    }
  },
  mutations: {
    setUser: (state, user) => {
      state.user = user;
    }
  },
  actions: {
    getUser: async (ctx, userId?: number) => {
      const user = await Services.ApiService.getUser(userId);
      ctx.commit('setUser', user);
    },
  }
});
export default store;
