import pagination from '@/store/modules/pagination';
import { fetchSettingList } from '@/api/baseData/baseData';
import { GET_CAR_NUMBER_LIST } from './mutation-types';

const state = {
  list: [],
};
const getters = {
  list: state => state.list,
};
const actions = {
  fetchList({ dispatch, state, commit }, entity) {
    return fetchSettingList({
      ...state.pagination,
      ...entity,
    }).then(res => {
      const { list, ...pagination } = res.data;
      dispatch('updatePagination', pagination);
      commit(GET_CAR_NUMBER_LIST, list);
    });
  },
};
const mutations = {
  [GET_CAR_NUMBER_LIST](state, list) {
    state.list = list;
  },
};

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