import {createStore} from "vuex";
import {appUser} from "@mocks/users.js";

class AdapterOfUsers {
  constructor() {
  }

  getUsersList() {
    return [appUser]
  }

  getUsersByServiceId() {
    return [appUser]
  }
}

const users = {
  namespaced: true,
  state: {
    siteUsers: [],
    usersWithoutSite: [],
  },
  mutations: {
    setSiteUsers(state, users) {
      state.siteUsers = users
    },
    setUsersWithoutSite(state, users) {
      state.usersWithoutSite = users
    },
  },
  getters: {
    siteUsers: state => {
      return state.siteUsers
    },
    usersWithoutSite: state => {
      return state.usersWithoutSite
    }
  },
  actions: {
    resetStore({state}) {
      state.siteUsers = []
    },
    saveSiteUsers({commit}, users) {
      commit('setSiteUsers', users)
    },
    saveUsersWithoutSite({commit}, users) {
      commit('setUsersWithoutSite', users)
    }
  },
}


const services = {
  namespaced: true,
  getters: {
    selectedService: () => {
      return {id: 1, name: 'service1'}
    }
  },
}

const store = createStore({
  modules: {
    users,
    services
  },
})

const adapterOfUsers = new AdapterOfUsers()

export {adapterOfUsers, store}