<template>
  <b-container fluid="xl">
    <page-title :description="$t('pageTransfer.description')" />
    <snmp />
    <hr />
    <smtp />
    <hr />
    <syslog />
    <hr />
    <modal-snmp @ok="saveSnmp" />
    <modal-smtp @ok="saveSmtp" />
  </b-container>
</template>

<script>
import BVToastMixin from '@/components/_sila/Mixins/BVToastMixin';
import LoadingBarMixin, {
  loading,
} from '@/components/_sila/Mixins/LoadingBarMixin';

import PageTitle from '@/components/_sila/Global/PageTitle';
import Snmp from './Snmp';
import Smtp from './Smtp';
import ModalSnmp from './ModalSnmp.vue';
import ModalSmtp from './ModalSmtp.vue';
import Syslog from './Syslog';

export default {
  name: 'PowerRestorePolicy',
  components: {
    PageTitle,
    Snmp,
    ModalSnmp,
    Smtp,
    ModalSmtp,
    Syslog,
  },
  mixins: [BVToastMixin, LoadingBarMixin],
  data() {
    return {
      loading,
    };
  },
  methods: {
    saveSnmp(modalFormData) {
      this.startLoader();
      this.$store
        .dispatch('snmpStore/addSubscriber', modalFormData)
        .then((message) => this.successToast(message))
        .catch(({ message }) => this.errorToast(message))
        .finally(() => this.endLoader());
    },

    saveSmtp(modalFormData) {
      this.startLoader();
      this.$store
        .dispatch('smtpStore/addSubscriber', modalFormData)
        .then((message) => this.successToast(message))
        .catch(({ message }) => this.errorToast(message))
        .finally(() => this.endLoader());
    },
  },
};
</script>
