import { getFollowList, getFollowAccount, getExpertInfo } from "@/api/copy";
const copy = {
  state: {
    followList: [],
    followAccount: {},
    expertInfo: {},
  },
  mutations: {
    setFollowList: (state, list) => {
      state.followList = list
    },
    setFollowAccount: (state, info) => {
      state.followAccount = info
    },
    setExpertInfo: (state, info) => {
      state.expertInfo = info
    },
  },
  actions: {
    getFollowList({ commit }, sign) {
      return new Promise((resolve, reject) => {
        getFollowList({
          status: 1
        }).then(res => {
          commit('setFollowList', res.list || [])
          resolve(res)
        }).catch(error => {
        })
      })
    },
    getExpertInfo({ commit }, sign) {
      return new Promise((resolve, reject) => {
        getExpertInfo().then(res => {
          var list = res.list || []
          commit('setExpertInfo', list[0] || {})
          resolve(list[0] || {})
        }).catch(error => {
        })
      })
    },
    getFollowAccount({ commit }, sign) {
      return new Promise((resolve, reject) => {
        getFollowAccount().then(res => {
          commit('setFollowAccount', {
            ...res,
            server: 'copy',
            market: 'copy',
          } || {})
          resolve(res)
        }).catch(error => {
        })
      })
    },
  }
}

export default copy
