annual-upgrade.js 1.2 KB

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