salix/print/templates/email/payment-update/payment-update.js

33 lines
854 B
JavaScript
Executable File

const Component = require(`${appPath}/core/component`);
const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer');
module.exports = {
name: 'payment-update',
async serverPrefetch() {
this.payMethod = await this.fetchPayMethod(this.recipientId);
if (!this.payMethod)
throw new Error('Something went wrong');
},
computed: {
accountAddress: function() {
return this.payMethod.iban.slice(-4);
},
},
methods: {
fetchPayMethod(clientId) {
return this.findOneFromDef('payMethod', {clientId: clientId});
}
},
components: {
'email-header': emailHeader.build(),
'email-footer': emailFooter.build()
},
props: {
recipientId: {
required: true
}
}
};