text: import { Client } from '../../services/api'
  
  const state = {
    unities: [],
    services: [],
    departments: []
  }
  
  const getters = {
  
  }
  
  const mutations = {
    updateUnities (state, unities) {
      state.unities = unities
    },
  
    updateServices (state, services) {
      state.services = services
    },
  
    updateDepartments (state, departments) {
      state.departments = departments
    }
  }
  
  const actions = {
    fetchUnities ({ state, commit, rootState }) {
      return new Promise((resolve, reject) => {
        const api = new Client(rootState.config.server)
  
        api
          .unities(rootState.auth.accessToken)
          .then(data => {
            commit('updateUnities', data)
            resolve()
          }, error => {
            reject(error)
          })
      })
    },
  
    fetchServices ({ state, commit, rootState }, unityId) {
      commit('updateServices', [])
  
      if (!unityId) {
        return Promise.resolve([])
      }
  
      return new Promise((resolve, reject) => {
        const api = new Client(rootState.config.server)
        api
          .services(rootState.auth.accessToken, unityId)
          .then(data => {
            commit('updateServices', data)
            resolve(data)
          }, error => {
            reject(error)
          })
      })
    },
  
    fetchDepartments ({ state, commit, rootState }) {
      commit('updateDepartments', [])
  
      return new Promise((resolve, reject) => {
        const api = new Client(rootState.config.server)
        api
          .departments(rootState.auth.accessToken)
          .then(data => {
            commit('updateDepartments', data)
            resolve(data)
          }, error => {
            reject(error)
          })
      })
    }
  }
  
  export default {
    state,
    getters,
    actions,
    mutations
  }
  