@@ -6,7 +6,7 @@ import util from '../../util';
66
77module . exports = [
88 ( req , res , next ) => {
9- const canAccessAllApplications = util . hasRoles ( req , ADMIN_ROLES ) || util . hasProjectManagerRole ( req ) ;
9+ const isAdminOrPM = util . hasRoles ( req , ADMIN_ROLES ) || util . hasProjectManagerRole ( req ) ;
1010 const opportunityId = _ . parseInt ( req . params . id ) ;
1111
1212 let sort = req . query . sort ? decodeURIComponent ( req . query . sort ) : 'createdAt desc' ;
@@ -50,7 +50,7 @@ module.exports = [
5050 req . log . debug ( `Fetched existing active members ${ JSON . stringify ( members ) } ` ) ;
5151 req . log . debug ( `Applications ${ JSON . stringify ( copilotApplications ) } ` ) ;
5252 const enrichedApplications = copilotApplications . map ( ( application ) => {
53- const m = members . find ( member => member . userId === application . userId ) ;
53+ const member = members . find ( memberItem => memberItem . userId === application . userId ) ;
5454
5555 // Using spread operator fails in lint check
5656 // While Object.assign fails silently during run time
@@ -70,16 +70,16 @@ module.exports = [
7070 copilotOpportunity : application . copilotOpportunity ,
7171 } ;
7272
73- if ( m ) {
74- enriched . existingMembership = m ;
73+ if ( member ) {
74+ enriched . existingMembership = member ;
7575 }
7676
7777 req . log . debug ( `Existing member to application ${ JSON . stringify ( enriched ) } ` ) ;
7878
7979 return enriched ;
8080 } ) ;
8181
82- const response = canAccessAllApplications
82+ const response = isAdminOrPM
8383 ? enrichedApplications
8484 : enrichedApplications . map ( app => ( {
8585 userId : app . userId ,
0 commit comments