import { TemplatesApi } from '@openapi/notifier-registry';
const templatesApi = new TemplatesApi();

export default {
  name: 'notification-template',
  data() {
    return {
      template: {
        id: '',
        name: '',
        body: '',
      },
      loading: false,
    };
  },
  methods: {
    async init() {
      this.loading = true;
      try {
        const template = await templatesApi.getMessageTemplate(
          this.$route.params.id
        );
        this.template.id = template.data.id;
        this.template.name = template.data.name;
        this.template.body = template.data.body;
      } catch (e) {}
      this.loading = false;
    },
  },
  mounted() {
    this.init();
  },
};
