const Component = require(`${appPath}/core/component`); const emailHeader = new Component('email-header'); const emailFooter = new Component('email-footer'); const attachment = new Component('attachment'); const attachments = require('./attachments.json'); module.exports = { name: 'letter-debtor-nd', async serverPrefetch() { this.debtor = await this.fetchDebtor(this.recipientId, this.companyId); if (!this.debtor) throw new Error('Something went wrong'); }, data() { return {attachments}; }, methods: { fetchDebtor(clientId, companyId) { return this.findOneFromDef('client', [clientId, companyId]); } }, components: { 'email-header': emailHeader.build(), 'email-footer': emailFooter.build(), 'attachment': attachment.build() }, props: { authorization: { required: true }, recipientId: { required: true }, companyId: { required: true } } };