@@ -95,17 +95,20 @@ function EvaluatedList({ projects }) {
9595
9696 const filteredProjects = newProjects . filter ( ( project ) => {
9797 if ( filter === 0 ) {
98- return project . status === 1 && project . project_evaluation !== 0 ;
98+ // return project.status === 1 && project.project_evaluation !== 0;
99+ return projects && project . project_evaluation !== 0 ;
99100 } else if ( filter === 1 ) {
100101 return (
101102 project . categorization . infrastructure === true &&
102- project . status === 1 &&
103+ // project.status === 1 &&
104+ projects &&
103105 project . project_evaluation !== 0
104106 ) ;
105107 } else if ( filter === 2 ) {
106108 return (
107109 project . categorization . infrastructure === false &&
108- project . status === 1 &&
110+ // project.status === 1 &&
111+ projects &&
109112 project . project_evaluation !== 0
110113 ) ;
111114 }
@@ -116,6 +119,22 @@ function EvaluatedList({ projects }) {
116119 ( a , b ) => b . project_evaluation - a . project_evaluation
117120 ) ;
118121
122+ const rankedProjects = sortedProjects . map ( ( project , index ) => {
123+ if ( index === 0 ) {
124+ project . rank = 1 ;
125+ } else if (
126+ project . project_evaluation ===
127+ sortedProjects [ index - 1 ] . project_evaluation
128+ ) {
129+ // same score = same rank
130+ project . rank = sortedProjects [ index - 1 ] . rank ;
131+ } else {
132+ // new score = +1 rank
133+ project . rank = sortedProjects [ index - 1 ] . rank + 1 ;
134+ }
135+ return project ;
136+ } ) ;
137+
119138 return (
120139 < motion . div
121140 initial = { { y : "200vh" } }
@@ -143,11 +162,14 @@ function EvaluatedList({ projects }) {
143162 < Table id = "header-fixed" >
144163 < TableHead className = { classes . tableHead } >
145164 < TableRow >
165+ < TableCell className = { classes . tableFont } align = "center" >
166+ Rank
167+ </ TableCell >
146168 < TableCell className = { classes . tableFont } align = "center" >
147169 Implementing Office
148170 </ TableCell >
149171 < TableCell className = { classes . tableFont } >
150- Project Title ({ sortedProjects . length } Projects)
172+ Project Title ({ rankedProjects . length } Projects)
151173 </ TableCell >
152174 < TableCell className = { classes . tableFont } align = "center" >
153175 Evaluator
@@ -167,7 +189,7 @@ function EvaluatedList({ projects }) {
167189 </ TableRow >
168190 </ TableHead >
169191 < TableBody >
170- { sortedProjects . map ( ( project ) => {
192+ { rankedProjects . map ( ( project ) => {
171193 const projectCost = project . investment_req
172194 . map ( ( item ) => parseFloat ( item . value ) )
173195 . reduce ( ( a , b ) => a + b , 0 ) ;
@@ -204,6 +226,9 @@ function EvaluatedList({ projects }) {
204226 )
205227 }
206228 >
229+ < TableCell className = { classes . tableFont } align = "center" >
230+ { project . rank }
231+ </ TableCell >
207232 < TableCell className = { classes . tableFont } align = "center" >
208233 < Avatar src = { institute . logo } /> { institute . title }
209234 </ TableCell >
0 commit comments