2016-03-18 08:55:35 -04:00
|
|
|
define [
|
|
|
|
"base"
|
2016-04-04 11:05:42 -04:00
|
|
|
"libs/platform"
|
|
|
|
], (App, platform) ->
|
2017-11-27 07:49:12 -05:00
|
|
|
App.controller 'UniverstiesContactController', ($scope, $modal, $http) ->
|
2016-03-18 08:55:35 -04:00
|
|
|
|
|
|
|
$scope.form = {}
|
|
|
|
$scope.sent = false
|
|
|
|
$scope.sending = false
|
2017-11-27 13:03:42 -05:00
|
|
|
$scope.error = false
|
2016-03-18 08:55:35 -04:00
|
|
|
$scope.contactUs = ->
|
|
|
|
if !$scope.form.email?
|
|
|
|
console.log "email not set"
|
|
|
|
return
|
|
|
|
$scope.sending = true
|
|
|
|
ticketNumber = Math.floor((1 + Math.random()) * 0x10000).toString(32)
|
2017-11-27 07:49:12 -05:00
|
|
|
data =
|
|
|
|
_csrf : window.csrfToken
|
2016-03-18 08:55:35 -04:00
|
|
|
name: $scope.form.name || $scope.form.email
|
|
|
|
email: $scope.form.email
|
2016-03-21 07:41:05 -04:00
|
|
|
labels: "#{$scope.form.source} accounts"
|
2016-03-18 08:55:35 -04:00
|
|
|
message: "Please contact me with more details"
|
2017-11-27 08:52:31 -05:00
|
|
|
subject: "#{$scope.form.name} - General Enquiry - #{$scope.form.position} - #{$scope.form.university}"
|
2017-11-27 07:49:12 -05:00
|
|
|
inbox: "accounts"
|
2016-03-18 08:55:35 -04:00
|
|
|
|
2017-11-27 07:49:12 -05:00
|
|
|
request = $http.post "/support", data
|
2017-11-28 05:13:54 -05:00
|
|
|
|
|
|
|
request.catch ()->
|
|
|
|
$scope.error = true
|
|
|
|
$scope.$apply()
|
|
|
|
|
2017-11-27 07:49:12 -05:00
|
|
|
request.then (response)->
|
2016-03-18 08:55:35 -04:00
|
|
|
$scope.sent = true
|
2018-03-15 12:21:17 -04:00
|
|
|
event_tracking.send 'subscription-funnel', 'plans-page', 'group-inquiry-sent'
|
2017-11-27 13:03:42 -05:00
|
|
|
$scope.error = (response.status != 200)
|
2016-03-18 08:55:35 -04:00
|
|
|
$scope.$apply()
|