<template>
  <div class='admin_general'>
    <h1 class='admin_general__header'>Other</h1>
    <b-button @click='stopService' :loading="loading">Stop Kaverti Service</b-button>
  </div>
</template>

<script>
  import AjaxErrorHandler from "../../assets/js/errorHandler";

  export default {
    name: 'AdminOther',
    methods: {
      stopService() {
        this.loading = true

        this.axios.post(process.env.VUE_APP_APIENDPOINT + process.env.VUE_APP_APIVERSION + '/' + 'admin/service/stop', {
          action: "stop"
        }).then(() => {
          this.loading = false
        }).catch(e => {
          this.loading = false

          AjaxErrorHandler(this.$store)(e, (error, errors) => {
            let path = error.path

            if (this.errors[path] !== undefined) {
              this.errors[path] = error.message
            } else {
              errors.push(error.message)
            }
          })
        })
      }
    }
  }
</script>

<style lang='scss' scoped>
  @import '../../assets/scss/variables.scss';

  .admin_general {
    padding: 1rem 2rem;

    @at-root #{&}__header {
      margin: 0.5rem 0 1rem 0;
    }
  }
</style>
