(function () {
        'use strict';

        angular
            .module("app")
            .controller("ReportAbuseController", ReportAbuseController);

        ReportAbuseController.$inject = ["$rootScope", "$scope"];

        function ReportAbuseController($rootScope, $scope) {
            var vm = this;
            vm.showLoading = false;
            vm.notification = null;
            vm.isSuccess = false;

            $('#modal-abuse-report').on('hidden.bs.modal', function (e) {
                vm.notification = null;
                $scope.$applyAsync();
            });

            vm.sendReportAbuse = function (form) {
                if (!form.$valid) {
                    return false;
                }

                vm.showLoading = true;
                window.intgrtn.sendContactUsRequest({
                    clickID: window.intgrtn.lookup("clickID", true),
                    type: 3,//spam/gdpr
                    firstName: vm.firstName,
                    lastName: vm.lastName,
                    email: vm.email,
                    subject: vm.subject,
                    message: vm.message,
                }, function (response, statusCode) {
                    vm.showLoading = false;
                    vm.notification = "Your message has been received!";
                    vm.firstName = null;
                    vm.lastName = null;
                    vm.email = null;
                    vm.subject = null;
                    vm.message = null;
                    vm.terms = null;
                    vm.isSuccess = true;
                    $scope.$applyAsync();
                }, function (response, statusCode) {
                    vm.showLoading = false;
                    vm.notification = "There was an error receiving your message! Please, try again later...";
                    $scope.$applyAsync();
                });
            };

        }
    }()
)
;