2018-11-05 10:06:39 +00:00
|
|
|
/* eslint-disable
|
|
|
|
max-len,
|
|
|
|
no-return-assign,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
2020-05-19 09:02:56 +00:00
|
|
|
import App from '../base'
|
2018-11-05 10:06:39 +00:00
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
export default App.controller(
|
|
|
|
'AnnualUpgradeController',
|
|
|
|
function ($scope, $http, $modal) {
|
|
|
|
const MESSAGES_URL = '/user/subscription/upgrade-annual'
|
2020-05-19 09:02:56 +00:00
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
$scope.upgradeComplete = false
|
|
|
|
const savings = {
|
|
|
|
student: '19.2',
|
2021-04-27 07:52:58 +00:00
|
|
|
collaborator: '36',
|
2018-11-05 10:06:39 +00:00
|
|
|
}
|
2021-04-14 13:17:21 +00:00
|
|
|
$scope.$watch($scope.planName, function () {
|
|
|
|
$scope.yearlySaving = savings[$scope.planName]
|
|
|
|
if ($scope.planName === 'annual') {
|
|
|
|
return ($scope.upgradeComplete = true)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return ($scope.completeAnnualUpgrade = function () {
|
|
|
|
const body = {
|
|
|
|
planName: $scope.planName,
|
2021-04-27 07:52:58 +00:00
|
|
|
_csrf: window.csrfToken,
|
2021-04-14 13:17:21 +00:00
|
|
|
}
|
2018-11-05 10:06:39 +00:00
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
$scope.inflight = true
|
2018-11-05 10:06:39 +00:00
|
|
|
|
2021-04-14 13:17:21 +00:00
|
|
|
return $http
|
|
|
|
.post(MESSAGES_URL, body)
|
|
|
|
.then(() => ($scope.upgradeComplete = true))
|
|
|
|
.catch(() => console.log('something went wrong changing plan'))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|