2018-11-05 05:06:39 -05: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 05:02:56 -04:00
|
|
|
import App from '../base'
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
export default App.controller(
|
|
|
|
'AnnualUpgradeController',
|
|
|
|
function ($scope, $http, $modal) {
|
|
|
|
const MESSAGES_URL = '/user/subscription/upgrade-annual'
|
2020-05-19 05:02:56 -04:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.upgradeComplete = false
|
|
|
|
const savings = {
|
|
|
|
student: '19.2',
|
|
|
|
collaborator: '36'
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
2021-04-14 09:17:21 -04: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,
|
|
|
|
_csrf: window.csrfToken
|
|
|
|
}
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
$scope.inflight = true
|
2018-11-05 05:06:39 -05:00
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
return $http
|
|
|
|
.post(MESSAGES_URL, body)
|
|
|
|
.then(() => ($scope.upgradeComplete = true))
|
|
|
|
.catch(() => console.log('something went wrong changing plan'))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
)
|