contact-us.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* eslint-disable
  2. max-len,
  3. no-return-assign,
  4. no-undef,
  5. no-unused-vars,
  6. */
  7. // TODO: This file was created by bulk-decaffeinate.
  8. // Fix any style issues and re-enable lint.
  9. /*
  10. * decaffeinate suggestions:
  11. * DS102: Remove unnecessary code created because of implicit returns
  12. * DS207: Consider shorter variations of null checks
  13. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  14. */
  15. define(['base'], App =>
  16. App.controller('GroupPlanContactController', function($scope, $modal, $http) {
  17. $scope.form = {}
  18. $scope.sent = false
  19. $scope.sending = false
  20. $scope.error = false
  21. return ($scope.contactUs = function() {
  22. if ($scope.form.email == null) {
  23. console.log('email not set')
  24. return
  25. }
  26. $scope.sending = true
  27. const ticketNumber = Math.floor((1 + Math.random()) * 0x10000).toString(
  28. 32
  29. )
  30. const data = {
  31. _csrf: window.csrfToken,
  32. name: $scope.form.name || $scope.form.email,
  33. email: $scope.form.email,
  34. labels: `${$scope.form.source} accounts`,
  35. message: 'Please contact me with more details',
  36. subject: `${$scope.form.name} - Group Enquiry - ${
  37. $scope.form.position
  38. } - ${$scope.form.university}`,
  39. inbox: 'accounts'
  40. }
  41. const request = $http.post('/support', data)
  42. request.catch(function() {
  43. $scope.error = true
  44. return $scope.$apply()
  45. })
  46. return request.then(function(response) {
  47. $scope.sent = true
  48. eventTracking.send(
  49. 'subscription-funnel',
  50. 'plans-page',
  51. 'group-inquiry-sent'
  52. )
  53. $scope.error = response.status !== 200
  54. return $scope.$apply()
  55. })
  56. })
  57. }))