import { createStore } from "vuex";
import createPersistedState from "vuex-persistedstate";

const store = createStore({
  plugins: [createPersistedState()],
  state: () => ({
    token: "",
    userData: {},
  }),
  getters: {
    getToken(state) {
      return state.token;
    },
    getUserData(state) {
      return state.userData;
    },
  },
  mutations: {
    setToken(state, token: string) {
      state.token = token;
    },
    setUserData(state, userData: object) {
      state.userData = userData;
    },
  },
});

export default store;
