diff --git a/app/listings/listings.controller.js b/app/listings/listings.controller.js index 9d0774758..6f42e1103 100755 --- a/app/listings/listings.controller.js +++ b/app/listings/listings.controller.js @@ -1,3 +1,4 @@ +import _ from 'lodash' import angular from 'angular' import { loadUser } from '../services/userv3.service.js' @@ -13,24 +14,91 @@ import { loadUser } from '../services/userv3.service.js' function ListingsCtrl(CONSTANTS, logger, $q, TcAuthService, UserService, UserStatsService, ProfileService, ChallengeService, ExternalAccountService, ngDialog, $anchorScroll, $scope) { + var vm = this + var handle + vm.neverParticipated = false + vm.loading = true + vm.userHasChallenges = true + vm.challengeView = 'tile' activate() function activate() { $scope.myChallenges = [] - $scope.userProps = { isAuth: false } + $scope.userProps = { isAuth: false, myChallenges: [] } logger.debug('Calling ListingsController activate()') - + vm.myChallenges = [] loadUser().then(function(token) { + handle = UserService.getUserIdentity().handle + // mock current user have this challenges + vm.myChallenges.push({'id':30056409}) + vm.myChallenges.push({'id':30056067}) + vm.myChallenges.push({'id':16870}) + // update auth flag if(TcAuthService.isAuthenticated()) { - $scope.userProps = { isAuth: true } + getChallenges(handle) + $scope.userProps = { isAuth: true, myChallenges: vm.myChallenges } } }, function(error) { // do nothing, just show non logged in state of navigation bar }) } + function getChallenges(handle) { + var marathonMatchParams = { + limit: 8, + filter: 'status=active' + } + + var challengeParams = { + limit: 8, + orderBy: 'submissionEndDate', + filter: 'status=active' + } + + $q.all([ + ChallengeService.getUserMarathonMatches(handle, marathonMatchParams), + ChallengeService.getUserChallenges(handle, challengeParams) + ]).then(function(challenges){ + var marathonMatches = challenges[0] + var devDesignChallenges = challenges[1] + + if (!marathonMatches.length && !devDesignChallenges.length) { + vm.userHasChallenges = false + _checkForParticipation().then(function() { + vm.loading = false + }) + } else { + ChallengeService.processActiveDevDesignChallenges(devDesignChallenges) + ChallengeService.processActiveMarathonMatches(marathonMatches) + var userChallenges = marathonMatches.concat(devDesignChallenges) + + userChallenges = _.sortBy(userChallenges, function(n) { + return n.registrationEndDate + }) + vm.myChallenges = userChallenges.reverse().slice(0, 8) + + // update myChallenges + $scope.userProps = { isAuth: true, myChallenges: vm.myChallenges } + + vm.userHasChallenges = true + vm.loading = false + } + }) + .catch(function(err) { + logger.error('Error getting challenges and marathon matches', err) + + vm.userHasChallenges = true + vm.loading = false + }) + } + + function _checkForParticipation() { + return ChallengeService.checkChallengeParticipation(handle, function(participated) { + vm.neverParticipated = !participated + }) + } } })() diff --git a/assets/css/directives/badge-tooltip.scss b/assets/css/directives/badge-tooltip.scss index fbcf074cf..dcbd83b98 100644 --- a/assets/css/directives/badge-tooltip.scss +++ b/assets/css/directives/badge-tooltip.scss @@ -438,7 +438,7 @@ background-position: 0px -672px; } .Predix-Community { - background-position: -50px -672px; + background-position: -47px -672px; } .iOS-Community { background-position: -95px -672px; diff --git a/package.json b/package.json index 3f2ab1635..63161ef11 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "appirio-styles": "0.x.x", "appirio-tech-ng-iso-constants": "^1.0.6", "appirio-tech-ng-ui-components": "^2.1.2", - "appirio-tech-react-components": "nomo-kazza/react-components.git#challenge-listings", + "appirio-tech-react-components": "appirio-tech/react-components.git#cl-misc-fixes-2", "auth0-angular": "^4.1.0", "auth0-js": "^6.8.0", "d3": "^3.5.14", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy