Skip to content

Commit b3ea0ce

Browse files
Robert MiddletonRobert Middleton
authored andcommitted
Sprout method applied to genObjectiveGroup.
1 parent eee8865 commit b3ea0ce

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Components/StudentOverview/SelectedLTStudentViewTable.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,30 @@ import {
1717
useClassTargetMasteryQuery,
1818
} from '../../__generated__/types';
1919

20+
function getUniqueObjectives(objectives: Objective[]): Objective[] {
21+
const uniqueObjectives: Objective[] = [];
22+
const objectiveNameSet = new Set();
23+
objectives.forEach((objective) => {
24+
if (!objectiveNameSet.has(objective.objectiveName)) {
25+
objectiveNameSet.add(objective.objectiveName);
26+
uniqueObjectives.push(objective);
27+
}
28+
});
29+
30+
return uniqueObjectives;
31+
}
32+
2033
function genObjectiveGroup(targetMasteryData: any): any {
2134
const objectiveGorup: any = {
2235
Header: 'Objectives',
2336
columns: [],
2437
};
2538

26-
targetMasteryData.classTargetMastery.target.objectives.map((objective: any) => {
39+
const uniqueObjectives = getUniqueObjectives(
40+
targetMasteryData.classTargetMastery.target.objectives
41+
);
42+
43+
uniqueObjectives.forEach((objective) => {
2744
objectiveGorup.columns.push({
2845
Header: objective.objectiveName,
2946
accessor: `row.${objective.objectiveId}`,

0 commit comments

Comments
 (0)