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

module.exports = {
    name: 'claim-pickup-order',
    components: {
        'email-body': emailBody.build(),
    },
    async serverPrefetch() {
        this.ticket = await this.fetchTicket(this.id);

        if (!this.ticket)
            throw new Error('Something went wrong');

        this.instructions = this.$t('description.instructions', [this.id, this.ticket.id]);
    },
    methods: {
        fetchTicket(id) {
            return this.findOneFromDef('ticket', [id]);
        }
    },
    props: {
        id: {
            type: Number,
            required: true
        }
    }
};