import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";
import user from "./modules/user";
import invigilation from "./modules/invigilation";
import { keepAliveRoutesPairs } from "@/constant/constants";

Vue.use(Vuex);

export default new Vuex.Store({
  plugins: [createPersistedState({ storage: window.sessionStorage })],
  modules: {
    user,
    invigilation,
  },
  state: {
    isFullScreen: false,
    schoolLogo: "",
    keepAliveRoutes: keepAliveRoutesPairs.map((v) => v[0]),
  },
  mutations: {
    setIsFullScreen(state, isFullScreen) {
      state.isFullScreen = isFullScreen;
    },
    setSchoolLogo(state, schoolLogo) {
      state.schoolLogo = schoolLogo;
    },
    setEmptyKeepAliveRoutes(state) {
      state.keepAliveRoutes = [];
    },
    setRestoreKeepAliveRoutes(state) {
      state.keepAliveRoutes = keepAliveRoutesPairs.map((v) => v[0]);
    },
  },
  actions: {},
});
