annual-upgrade.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* eslint-disable
  2. max-len,
  3. no-return-assign,
  4. */
  5. // TODO: This file was created by bulk-decaffeinate.
  6. // Fix any style issues and re-enable lint.
  7. /*
  8. * decaffeinate suggestions:
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. import App from '../base'
  13. export default App.controller('AnnualUpgradeController', function(
  14. $scope,
  15. $http,
  16. $modal
  17. ) {
  18. const MESSAGES_URL = '/user/subscription/upgrade-annual'
  19. $scope.upgradeComplete = false
  20. const savings = {
  21. student: '19.2',
  22. collaborator: '36'
  23. }
  24. $scope.$watch($scope.planName, function() {
  25. $scope.yearlySaving = savings[$scope.planName]
  26. if ($scope.planName === 'annual') {
  27. return ($scope.upgradeComplete = true)
  28. }
  29. })
  30. return ($scope.completeAnnualUpgrade = function() {
  31. const body = {
  32. planName: $scope.planName,
  33. _csrf: window.csrfToken
  34. }
  35. $scope.inflight = true
  36. return $http
  37. .post(MESSAGES_URL, body)
  38. .then(() => ($scope.upgradeComplete = true))
  39. .catch(() => console.log('something went wrong changing plan'))
  40. })
  41. })