42 lines
1.1 KiB
JavaScript
Executable File
42 lines
1.1 KiB
JavaScript
Executable File
const Component = require(`${appPath}/core/component`);
|
|
const db = require(`${appPath}/core/database`);
|
|
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 db.findOne(
|
|
`SELECT
|
|
c.dueDay,
|
|
c.iban,
|
|
pm.name,
|
|
pm.code
|
|
FROM client c
|
|
JOIN payMethod pm ON pm.id = c.payMethodFk
|
|
WHERE c.id = :clientId`, {clientId: clientId});
|
|
}
|
|
},
|
|
components: {
|
|
'email-header': emailHeader.build(),
|
|
'email-footer': emailFooter.build()
|
|
},
|
|
props: {
|
|
recipientId: {
|
|
required: true
|
|
}
|
|
}
|
|
};
|