overleaf/services/web/public/coffee/main/contact-us.coffee

37 lines
1 KiB
CoffeeScript
Raw Normal View History

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