import { GetterTree, MutationTree, Module } from 'vuex';

interface State {
  needToUpdate: boolean;
  selectedRecruits: string[];
  recruits: Record<string, string>[];
  summoningList: Record<string, string>[];
}

export const state: State = {
  needToUpdate: false,
  recruits: [],
  selectedRecruits: [],
  summoningList: [],
};

export const getters: GetterTree<State, State> = {
  needToUpdate(state) {
    return state.needToUpdate;
  },
  recruits(state) {
    return state.recruits;
  },
  selectedRecruits(state) {
    return state.selectedRecruits;
  },
};

export const mutations: MutationTree<State> = {
  recruits(state, list) {
    state.recruits = list;
  },
  selectedRecruits(state, list) {
    state.selectedRecruits = list;
  },
  summoningList(state, list) {
    state.summoningList = list;
  },
};

const recruits: Module<State, State> = {
  state,
  getters,
  mutations,
};

export default recruits;
