2018-05-30 10:29:21 +00:00
|
|
|
define [
|
|
|
|
"base"
|
|
|
|
], (App) ->
|
|
|
|
App.controller "TeamInviteController", ($scope, $http) ->
|
|
|
|
|
|
|
|
$scope.inflight = false
|
|
|
|
|
|
|
|
if hasPersonalSubscription
|
|
|
|
$scope.view = "personalSubscription"
|
|
|
|
else
|
|
|
|
$scope.view = "teamInvite"
|
|
|
|
|
|
|
|
$scope.keepPersonalSubscription = ->
|
|
|
|
$scope.view = "teamInvite"
|
|
|
|
|
|
|
|
$scope.cancelPersonalSubscription = ->
|
|
|
|
$scope.inflight = true
|
|
|
|
request = $http.post "/user/subscription/cancel", {_csrf:window.csrfToken}
|
|
|
|
request.then ()->
|
|
|
|
$scope.inflight = false
|
|
|
|
$scope.view = "teamInvite"
|
|
|
|
request.catch ()->
|
|
|
|
console.log "the request failed"
|
|
|
|
|
|
|
|
$scope.joinTeam = ->
|
|
|
|
$scope.inflight = true
|
2018-05-31 10:54:50 +00:00
|
|
|
request = $http.put "/subscription/invites/#{window.inviteToken}/", {_csrf:window.csrfToken}
|
2018-05-30 10:29:21 +00:00
|
|
|
request.then (response)->
|
|
|
|
{ status } = response
|
|
|
|
$scope.inflight = false
|
2018-05-31 10:54:50 +00:00
|
|
|
$scope.view = "inviteAccepted"
|
2018-05-30 10:29:21 +00:00
|
|
|
if status != 200 # assume request worked
|
|
|
|
$scope.requestSent = false
|
|
|
|
request.catch ()->
|
|
|
|
console.log "the request failed"
|