text: import types from '@/types/complex';
  import globalTypes from '@/types/global';
  import Vue from 'vue';
  import { authHttp } from '@/utils/http';
  
  const state = {
  
  };
  
  const actions = {
      
      // create complex
      [types.actions.createComplex]: ({ commit}, data) => {
          commit(globalTypes.mutations.startProcessing);
          return new Promise((resolve, reject) =>  {
              authHttp.post('/complex/', data)
                  .then(complex => {
                      resolve(complex);
                  })
                  .catch(err => {
                      console.log(err)
                      reject(err);
                  })
                  .finally(() => {
                      commit(globalTypes.mutations.stopProcessing);
                  })
          })
      },
  
      // get all complexes
      [types.actions.getComplexes]: ({ commit }) => {
          commit(globalTypes.mutations.startProcessing);
          return new Promise((resolve, reject) =>  {
              authHttp.get('/complex/findall')
                  .then(complexes => {
                      resolve(complexes);
                  })
                  .catch(err => {
                      console.log(err)
                      reject(err);
                  })
                  .finally(() => {
                      commit(globalTypes.mutations.stopProcessing);
                  })
          })
      },
  
      // get one complex
      [types.actions.getComplex]: ({ commit}, idComplex) => {
          commit(globalTypes.mutations.startProcessing);
          return new Promise((resolve, reject) =>  {
              authHttp.get(`/complex/${idComplex}`)
                  .then(complex => {
                      resolve(complex);
                  })
                  .catch(err => {
                      console.log(err)
                      reject(err);
                  })
                  .finally(() => {
                      commit(globalTypes.mutations.stopProcessing);
                  })
          })
      },
  
      // update complex
      [types.actions.updateComplex]: ({ commit}, data) => {
          commit(globalTypes.mutations.startProcessing);
          return new Promise((resolve, reject) =>  {
              authHttp.put(`/complex/${data.id}`, data)
                  .then(complex => {
                      resolve(complex);
                  })
                  .catch(err => {
                      console.log(err)
                      reject(err);
                  })
                  .finally(() => {
                      commit(globalTypes.mutations.stopProcessing);
                  })
          })
      },
  
      // delete complex
      [types.actions.deleteComplex]: ({ commit}, data) => {
          commit(globalTypes.mutations.startProcessing);
          return new Promise((resolve, reject) =>  {
              authHttp.put(`/complex/delete/${data.id}`)
                  .then(complex => {
                      resolve(complex);
                  })
                  .catch(err => {
                      console.log(err)
                      reject(err);
                  })
                  .finally(() => {
                      commit(globalTypes.mutations.stopProcessing);
                  })
          })
      }
  };
  
  const getters = {
     
  };
  
  const mutations = {
  
  };
  
  export default {
      state,
      actions,
      getters,
      mutations
  };