const vnReport = require('../../../core/mixins/vn-report.js');

module.exports = {
    name: 'campaign-metrics',
    mixins: [vnReport],
    async serverPrefetch() {
        this.client = await this.findOneFromDef('client', [this.id]);
        this.checkMainEntity(this.client);
        this.sales = await this.rawSqlFromDef('sales', [this.id, this.from, this.to]);
    },
    props: {
        id: {
            type: Number,
            required: true,
            description: 'The client id'
        },
        from: {
            required: true
        },
        to: {
            required: true
        }
    }
};