import { get } from '@/store/utils/api'
import { PROCESSING_STARTED, PROCESSING_FINISHED } from '@/store/utils/types'
import { MISPACE_GET_ACCESS_CODE } from '@/store/utils/apiUrls'

const actions = {
  requestMiSpaceAccessCode: async ({ commit }) => {
    commit(PROCESSING_STARTED, 'requestMiSpaceAccessCode')
    return await get(MISPACE_GET_ACCESS_CODE)
      .then(res => res.data)
      .catch(() => false)
      .finally(() => {
        commit(PROCESSING_FINISHED, 'requestMiSpaceAccessCode')
      })
  },
}

export default {
  actions,
}
