annual-upgrade.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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(
  14. 'AnnualUpgradeController',
  15. function ($scope, $http, $modal) {
  16. const MESSAGES_URL = '/user/subscription/upgrade-annual'
  17. $scope.upgradeComplete = false
  18. const savings = {
  19. student: '19.2',
  20. collaborator: '36',
  21. }
  22. $scope.$watch($scope.planName, function () {
  23. $scope.yearlySaving = savings[$scope.planName]
  24. if ($scope.planName === 'annual') {
  25. return ($scope.upgradeComplete = true)
  26. }
  27. })
  28. return ($scope.completeAnnualUpgrade = function () {
  29. const body = {
  30. planName: $scope.planName,
  31. _csrf: window.csrfToken,
  32. }
  33. $scope.inflight = true
  34. return $http
  35. .post(MESSAGES_URL, body)
  36. .then(() => ($scope.upgradeComplete = true))
  37. .catch(() => console.log('something went wrong changing plan'))
  38. })
  39. }
  40. )