const Component = require(`vn-print/core/component`);
const emailBody = new Component('email-body');
const attachment = new Component('attachment');
const attachments = require('./attachments.json');

module.exports = {
    name: 'printer-setup',
    async serverPrefetch() {
        this.client = await this.fetchClient(this.id);
    },
    data() {
        return {attachments};
    },
    methods: {
        fetchClient(id) {
            return this.findOneFromDef('client', [id]);
        }
    },
    components: {
        'email-body': emailBody.build(),
        'attachment': attachment.build()
    },
    props: {
        id: {
            type: Number,
            required: true
        }
    }
};