const Component = require(`vn-print/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.id); this.sales = await this.fetchSales(this.id, this.from, this.to); if (!this.client) throw new Error('Something went wrong'); }, methods: { fetchClient(id) { return this.findOneFromDef('client', [id]); }, fetchSales(id, from, to) { return this.rawSqlFromDef('sales', [id, from, to]); }, }, components: { 'report-header': reportHeader.build(), 'report-footer': reportFooter.build() }, props: { id: { type: Number, required: true, description: 'The client id' }, from: { required: true }, to: { required: true } } };