overleaf/services/web/frontend/js/main/project-list/left-hand-menu-promo-controller.js
Alasdair Smith 8f5270899f Merge pull request #2707 from overleaf/as-transform-esm
Transform frontend module format from AMD to ESM

GitOrigin-RevId: 9adbcdc95e819a54114010c6fd3521d8f58ef2fe
2020-05-20 03:21:38 +00:00

34 lines
1 KiB
JavaScript

import App from '../../base'
export default App.controller('LeftHandMenuPromoController', function(
$scope,
UserAffiliationsDataService,
eventTracking
) {
$scope.hasProjects = window.data.projects.length > 0
$scope.userHasNoSubscription = window.userHasNoSubscription
$scope.upgradeSubscription = function() {
eventTracking.send('subscription-funnel', 'project-page', 'upgrade')
}
$scope.share = function() {
eventTracking.send('subscription-funnel', 'project-page', 'sharing')
}
const _userHasNoAffiliation = function() {
$scope.userEmails = []
$scope.userAffiliations = []
return UserAffiliationsDataService.getUserEmails().then(function(emails) {
$scope.userEmails = emails
$scope.userAffiliations = emails
.filter(email => email.affiliation)
.map(email => email.affiliation)
$scope.userOnPayingUniversity = $scope.userAffiliations.some(
affiliation => affiliation.licence && affiliation.licence !== 'free'
)
})
}
_userHasNoAffiliation()
})