<i18n>
{
  "en": {
    "title": "Delete this hook?"
  },
  "de": {
    "title": "Diesen Hook löschen?"
  }
}
</i18n>

<template>
  <v-card>
    <v-card-title primary-title class="dialog-title elevation-3">
      <div class="headline">{{ $t('title') }}</div>
    </v-card-title>
    <v-card-text>
      {{ dialog.info.type }} {{ dialog.info.name }}
    </v-card-text>
    <v-divider></v-divider>
    <v-card-actions>
      <v-spacer></v-spacer>
      <v-btn flat="flat" @click="setDialog({ show: false })">{{ $t('cancel') }}</v-btn>
      <v-btn color="error" @click="deleteItems">{{ $t('delete') }}</v-btn>
    </v-card-actions>
  </v-card>
</template>

<script>
import axios from 'axios'
import { mapState } from 'vuex'

export default {
  name: 'RegistrationModuleDelete',
  data () {
    return {
    }
  },
  computed: {
    ...mapState('registration', ['dialog'])
  },
  methods: {
    setDialog (data) {
      this.$store.commit('registration/setDialog', data)
    },
    async deleteItems () {
      await axios.delete('/api/registration/hooks/' + this.dialog.info.id)
      this.$store.dispatch('registration/loadHooks')
      this.setDialog({ show: false })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.dialog-title {
  z-index: 1;
}
.selected-list {
  padding: 30px;
}
</style>
