const StoryCollectComponent = {
    templateUrl: "/app/activity/story-collect.component.html",
    bindings: {
        activity: '<'
    },
    controller: function ($stateParams, $state, $activity, api) {

        let $ctrl = this;

        $ctrl.text = "";
        $ctrl.min = 50;
        $ctrl.count = 0;

        $ctrl.getCount = function () {
            $ctrl.count = $ctrl.text.length;
            return $ctrl.count;
        }

        $ctrl.submit = function () {

            //console.log($ctrl.text);

            $activity.submitStory($ctrl.text).then(function (response){
                
                if (response==true) {
                    //$activity.completeCurrentActivity(); //this action was moved to the goNextActivity in Sprint 2
                    $activity.gotoNextActivity();
                } else {
                    alert("There was an error submitting your story. Please try again.");
                }
            });
        };

    }
};