<template>
  <main id="main" style="margin-top: 200px; padding-bottom: 50px;">
    <div class="container">
      <div class="form">
        <div class="row">
          <div class="col">
            <div class="section-header">
              <h2>Email Recipients</h2>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col">
            <listView
              :items="recipients"
              :showNew="true"
              :editable="true"
              :deleteable="true"
              :hideSearch="true"
              :showColumnChooser="false"
              :displayColumns="columns"
              :sortKey="'description'"
              @onEdit="Edit"
              @onDelete="Delete"
              @onNew="New"
            />
          </div>
        </div>
      </div>
    </div>
  </main>
</template>

<script>
/* eslint-disable */
import { mapActions, mapState } from 'vuex'
import listView from '../shared/listView'

export default {
  name: 'MailRecipients',
  components: {
    listView,
  },
  data() {
    return {
      columns: ['recipientName', 'recipientMail', 'recipientUsage'],
    }
  },
  created() {
    this.getMailRecipients()
  },
  computed: {
    ...mapState('template', ['recipients']),
  },
  methods: {
    ...mapActions('template', ['getMailRecipients', 'deleteMailRecipient']),
    New() {
      this.$router.push('/emailRecipient/new')
    },
    Edit(item) {
      this.$router.push({
        path: `/emailRecipient/Edit/${item.id}`,
      })
    },
    Delete(item) {
      this.deleteMailRecipient(item.id)
    },
  },
}
</script>

<style lang="scss" scoped></style>
