const state = {
  token: null,
  isLogin: false,
  isErrorPage: false,
  isAuthChk: false,
  userId: null,
  userNm: null,
  pwd: null,
  rootUrl: null,
  menuUrls: [],
  authToken: null,
  beforeUrl: null,
  isLoading: false,
};

const getters = {
  getToken: (state) => state.token,
  isLogin: (state) => state.isLogin,
  isErrorPage: (state) => state.isErrorPage,
  isAuthChk: (state) => state.isAuthChk,
  userId: (state) => state.userId,
  userNm: (state) => state.userNm,
  getPwd: (state) => state.pwd,
  getRootUrl: (state) => state.rootUrl,
  getMenuUrls: (state) => state.menuUrls,
  getAuthToken: (state) => state.authToken,
  getBeforeUrl: (state) => state.beforeUrl,
  isLoading: (state) => state.isLoading,
};

const mutations = {
  saveToken: (state, token) => {
    state.token = token;
  },
  removeToken: (state) => {
    state.token = null;
  },
  isLogin: (state, value) => {
    // console.log("isLogin mutation : " + value);
    state.isLogin = value;
  },
  isErrorPage: (state, value) => {
    // console.log("isErrorPage mutation : " + value);
    state.isErrorPage = value;
  },
  isAuthChk: (state, value) => {
    // console.log("isAuthChk mutation : "+ value);
    state.isAuthChk = value;
  },
  savePwd: (state, value) => {
    state.pwd = value;
  },
  userId: (state, value) => {
    state.userId = value;
  },
  userNm: (state, value) => {
    state.userNm = value;
  },
  rootUrl: (state, value) => {
    state.rootUrl = value;
  },
  setMenuUrls: (state, value) => {
    state.menuUrls = value;
  },
  saveAuthToken: (state, token) => {
    state.authToken = token;
  },
  saveBeforeUrl: (state, value) => {
    state.beforeUrl = value;
  },
  isLoading: (state, value) => {
    state.isLoading = value;
  },
};

const actions = {};

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions,
};
