import ngModule from '../../module';
import Dialog from '../dialog';

export default class Controller extends Dialog {
    constructor($element, $, $transclude) {
        super($element, $, $transclude);
    }

    responseHandler(response) {
        if (response !== 'accept')
            return super.responseHandler(response);

        this.$http.post('Ostickets/send-to-support', {
            reason: this.reason,
            additionalData: this.additionalData
        })
            .then(() => super.responseHandler(response))
            .then(() => this.vnApp.showSuccess(this.$t('Email sended!')));
    }
}

Controller.$inject = ['$element', '$scope', '$transclude'];

ngModule.vnComponent('vnSupportDialog', {
    slotTemplate: require('./index.html'),
    controller: Controller,
    bindings: {
        additionalData: '<?'
    }
});