import { MutationTree } from "vuex";
import { State, Mutations, MutationType } from "./_type";

const mutations: MutationTree<State> & Mutations = {
  [MutationType.setRoles](state, roles) {
    state.roles = roles;
  },
  [MutationType.setCollapsed](state, collapsed) {
    state.collapsed = collapsed;
    state.store.setItem("collapsed", `${collapsed}`);
  },
  [MutationType.setRoutes](state, routes) {
    state.routes = routes;
  },
  [MutationType.setSelectTime](state, time) {
    state.selectTime = time;
  },
  [MutationType.setUser](state, user) {
    state.user = user;
    state.store.setItem("user", JSON.stringify(user));
  },
  [MutationType.setOfficial](state, officials) {
    if (!state.officials.length) state.officials = officials;
  },
  [MutationType.setPlatforms](state, platforms) {
    if (!state.platforms.length) state.platforms = platforms;
  },
  [MutationType.setTemStepOne](state, setTemStepOne) {
    state.setTemStepOne = setTemStepOne;
  },
};

export default mutations;
