2018-11-05 05:06:39 -05:00
|
|
|
/* eslint-disable
|
|
|
|
max-len,
|
|
|
|
no-return-assign,
|
|
|
|
no-undef,
|
|
|
|
*/
|
|
|
|
// 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-04-06 07:45:56 -04:00
|
|
|
define(['../../base'], App =>
|
2018-11-05 05:06:39 -05:00
|
|
|
App.controller('TeamInviteController', function($scope, $http) {
|
|
|
|
$scope.inflight = false
|
|
|
|
|
2019-02-25 11:24:03 -05:00
|
|
|
if (hasIndividualRecurlySubscription) {
|
|
|
|
$scope.view = 'hasIndividualRecurlySubscription'
|
2018-11-05 05:06:39 -05:00
|
|
|
} else {
|
|
|
|
$scope.view = 'teamInvite'
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.keepPersonalSubscription = () => ($scope.view = 'teamInvite')
|
|
|
|
|
|
|
|
$scope.cancelPersonalSubscription = function() {
|
|
|
|
$scope.inflight = true
|
|
|
|
const request = $http.post('/user/subscription/cancel', {
|
|
|
|
_csrf: window.csrfToken
|
|
|
|
})
|
|
|
|
request.then(function() {
|
|
|
|
$scope.inflight = false
|
|
|
|
return ($scope.view = 'teamInvite')
|
|
|
|
})
|
2019-02-25 05:24:33 -05:00
|
|
|
return request.catch(() => {
|
|
|
|
$scope.inflight = false
|
|
|
|
$scope.cancel_error = true
|
|
|
|
console.log('the request failed')
|
|
|
|
})
|
2018-11-05 05:06:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return ($scope.joinTeam = function() {
|
|
|
|
$scope.inflight = true
|
|
|
|
const request = $http.put(
|
|
|
|
`/subscription/invites/${window.inviteToken}/`,
|
|
|
|
{ _csrf: window.csrfToken }
|
|
|
|
)
|
|
|
|
request.then(function(response) {
|
|
|
|
const { status } = response
|
|
|
|
$scope.inflight = false
|
|
|
|
$scope.view = 'inviteAccepted'
|
|
|
|
if (status !== 200) {
|
|
|
|
// assume request worked
|
|
|
|
return ($scope.requestSent = false)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return request.catch(() => console.log('the request failed'))
|
|
|
|
})
|
|
|
|
}))
|