diff --git a/frontend/src/api/fragments.ts b/frontend/src/api/fragments.ts index 718df05b..5b79c5f1 100644 --- a/frontend/src/api/fragments.ts +++ b/frontend/src/api/fragments.ts @@ -42,6 +42,7 @@ export const EVALUATION_DASHBOARD_FIELDS_FRAGMENT = gql` status projectId indicatorActivityDate + workshopCompleteDate project { fusionProjectId indicatorEvaluationId diff --git a/frontend/src/views/Project/Dashboard/Components/TablesAndTitles.tsx b/frontend/src/views/Project/Dashboard/Components/TablesAndTitles.tsx index 1d4bb71b..514be717 100644 --- a/frontend/src/views/Project/Dashboard/Components/TablesAndTitles.tsx +++ b/frontend/src/views/Project/Dashboard/Components/TablesAndTitles.tsx @@ -47,34 +47,33 @@ const TablesAndTitles = ({ let followUpScore = null Object.entries(evaluations).forEach((evaluation) => { - if (evaluation[1].projectId !== projectId) { - projectId = evaluation[1].projectId + const evalData = evaluation[1] + if (evalData.projectId !== projectId) { + projectId = evalData.projectId } - if (projectIndicators.findIndex(pi => pi.evaluationId === evaluation[1].id) > -1 && evaluation[1].project.indicatorEvaluationId === evaluation[1].id) { - if (evaluation[1].indicatorActivityDate && evaluation[1].progression === Progression.FollowUp) { - activityDate = evaluation[1].indicatorActivityDate - } - } - else if (evaluation[1].project.indicatorEvaluationId === evaluation[1].id) { - if (evaluation[1].indicatorActivityDate && evaluation[1].progression === Progression.FollowUp) { - activityDate = evaluation[1].indicatorActivityDate + const isFollowUp = evalData.progression === Progression.FollowUp + const isIndicatorEvaluation = evalData.project.indicatorEvaluationId === evalData.id + const isProjectIndicator = projectIndicators.findIndex(pi => pi.evaluationId === evalData.id) > -1 + + if ((isProjectIndicator || isIndicatorEvaluation) && isFollowUp) { + if (evalData.indicatorActivityDate) { + activityDate = evalData.indicatorActivityDate + } else if (evalData.workshopCompleteDate) { + activityDate = evalData.workshopCompleteDate } } }) if (projectBMTScores.length > 0) { - projectBMTScores.forEach((score: any, index: any) => { - if (score.projectId === projectId) { - followUpScore = score.bmtScore - } - }) - } - else if (generatedBMTScores) { - generatedBMTScores.generateBMTScores.forEach((score: any, index: any) => { - if (score.projectId === projectId) { - followUpScore = score.followUpScore - } - }) + const score = projectBMTScores.find((score: any) => score.projectId === projectId) + if (score) { + followUpScore = score.bmtScore + } + } else if (generatedBMTScores) { + const score = generatedBMTScores.generateBMTScores.find((score: any) => score.projectId === projectId) + if (score) { + followUpScore = score.followUpScore + } } return (