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

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

export default store;
