'use strict'

angular.module('pathwayApp')
.controller('ProjectController', function ($scope, $http, $stateParams, $state) {
  $http({method: 'GET',
         url: '/api/pathways/' + $stateParams.pathway_id + '/projects/' + $stateParams.id
  }).success(function(data, status){
    $scope.project = data
  })
  $scope.projects = $http({method: 'GET',
         url: '/api/projects'
  }).success(function(data, status){
    $scope.allProjects = data
  })
  $scope.create = function() {
    $http({method: 'POST',
      url: '/api/projects',
      data: {project: $scope.project } 
    }).success(function(data, status){
      console.log("hello from create()")
      $state.go('home')
    }).error(function(data){
      console.log(data)
    })
  }
  $scope.addProject = function(project, donated_weight) {
    $http({method: 'POST',
      url: '/api/pathways/' + $stateParams.id + '/projects',
      data: {projects: project, weight: donated_weight } 
    }).success(function(data, status){
      console.log("hello from create()")
      $state.go('home')
    }).error(function(data){
      console.log(data)
    })
  }
});
'use strict'

angular.module('pathwayApp')
.controller('ProjectController', function ($scope, $http, $stateParams, $state) {
  $http({method: 'GET',
         url: '/api/pathways/' + $stateParams.pathway_id + '/projects/' + $stateParams.id
  }).success(function(data, status){
    $scope.project = data
  })
  $scope.projects = $http({method: 'GET',
         url: '/api/projects'
  }).success(function(data, status){
    $scope.allProjects = data
  })
  $scope.create = function() {
    $http({method: 'POST',
      url: '/api/projects',
      data: {project: $scope.project } 
    }).success(function(data, status){
      console.log("hello from create()")
      $state.go('home')
    }).error(function(data){
      console.log(data)
    })
  }
  var projects = 0 
  $scope.addProject = function(project, donated_weight) {
    $http({method: 'POST',
      url: '/api/pathways/' + $stateParams.id + '/projects',
      data: {projects: project, weight: donated_weight } 
    }).success(function(data, status){
      projects += 1
      if (projects == 3) {$state.go('showPathway', {'id': data.pathway_id })} 
    }).error(function(data){
      console.log(data)
    })
  }
});
Add functionality for pathway owner to choose 3 projects then be redirected to pathway
Add functionality for pathway owner to choose 3 projects then be redirected to pathway
