import ngModule from '../module';
import Component from 'core/lib/component';
import './style.scss';

class Controller extends Component {
    addStowaway(stowaway) {
        let params = {id: stowaway.id, shipFk: this.ticket.id};
        this.$http.post(`Stowaways/`, params)
            .then(() => this.cardReload())
            .then(() => {
                this.vnApp.showSuccess(this.$t('Data saved!'));
                this.$.dialog.hide();
            });
    }

    show() {
        this.$.dialog.show();
    }

    hide() {
        this.$.dialog.hide();
    }
}

ngModule.vnComponent('vnAddStowaway', {
    template: require('./addStowaway.html'),
    controller: Controller,
    bindings: {
        ticket: '<',
        cardReload: '&?'
    }
});