38 lines
1.0 KiB
JavaScript
Executable File
38 lines
1.0 KiB
JavaScript
Executable File
const Component = require(`${appPath}/core/component`);
|
|
const reportHeader = new Component('report-header');
|
|
const reportFooter = new Component('report-footer');
|
|
|
|
module.exports = {
|
|
name: 'campaign-metrics',
|
|
async serverPrefetch() {
|
|
this.client = await this.fetchClient(this.recipientId);
|
|
this.sales = await this.fetchSales(this.recipientId, this.from, this.to);
|
|
|
|
if (!this.client)
|
|
throw new Error('Something went wrong');
|
|
},
|
|
methods: {
|
|
fetchClient(clientId) {
|
|
return this.findOneFromDef('client', [clientId]);
|
|
},
|
|
fetchSales(clientId, from, to) {
|
|
return this.rawSqlFromDef('sales', [clientId, from, to]);
|
|
},
|
|
},
|
|
components: {
|
|
'report-header': reportHeader.build(),
|
|
'report-footer': reportFooter.build()
|
|
},
|
|
props: {
|
|
recipientId: {
|
|
required: true
|
|
},
|
|
from: {
|
|
required: true
|
|
},
|
|
to: {
|
|
required: true
|
|
}
|
|
}
|
|
};
|