Skip to content

Commit a53a64b

Browse files
committed
updated graphql
1 parent 9eaff8c commit a53a64b

File tree

5 files changed

+135
-147
lines changed

5 files changed

+135
-147
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
query ClassMissionMastery {
2+
classMissionMastery(missionId: "4df2cfa5710") {
3+
mission {
4+
...CMMissionFields
5+
}
6+
studentMissionMasteryList {
7+
...CMStudentFields
8+
}
9+
}
10+
}
11+
12+
fragment CMMissionFields on Mission {
13+
name
14+
description
15+
}
16+
17+
fragment CMStudentFields on StudentMissionMastery {
18+
student {
19+
studentId
20+
lastName
21+
firstName
22+
email
23+
team
24+
}
25+
currentTaskId
26+
currentTaskName
27+
level
28+
progress
29+
}

src/Components/CourseHome/ListView.tsx

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,43 @@
1111
import React from 'react';
1212
import { useHistory } from 'react-router-dom';
1313
import TableComponent from '../TableComponent/TableComponent';
14+
import { CmStudentFieldsFragment } from '../../__generated__/types';
15+
16+
interface MissionMasteryRow {
17+
row: {
18+
name: string;
19+
recent: string;
20+
masteryLevel: string;
21+
lastLogOn: string;
22+
studentId: string;
23+
};
24+
}
1425

1526
function ListView(classMissionMasterydata: any) {
1627
const history = useHistory();
17-
const rowClicked = (userName: string) => {
28+
const rowClicked = (row: MissionMasteryRow) => {
29+
console.log(row);
1830
history.push({
19-
pathname: '/singleStudentOverview',
20-
state: { id: '', firstName: userName, lastName: ' ' },
31+
pathname: `/singleStudentOverview/${row.row.studentId}`,
2132
});
2233
};
2334

24-
const data: any[] = [];
25-
classMissionMasterydata.classMissionMasterydata.studentMissionMasteryList.map(
26-
(studentMissionMastery: any) =>
27-
data.push({
35+
const data: MissionMasteryRow[] = classMissionMasterydata.classMissionMasterydata.studentMissionMasteryList.map(
36+
(studentMissionMastery: CmStudentFieldsFragment) => {
37+
return {
2838
row: {
2939
name: `${studentMissionMastery.student.lastName} ${studentMissionMastery.student.firstName}`,
3040
recent: studentMissionMastery.currentTaskName,
3141
masteryLevel: studentMissionMastery.level,
3242
lastLogOn: 'Jan. 7, 2021',
43+
studentId: studentMissionMastery.student.studentId,
3344
},
34-
})
45+
};
46+
}
3547
);
3648

3749
// TODO remove when names are populated
38-
data.forEach((dataEntry) => {
50+
data.forEach((dataEntry: MissionMasteryRow) => {
3951
if (dataEntry.row.name.indexOf('null') !== -1) {
4052
dataEntry.row.name = 'Mary Lee';
4153
}

src/Components/TableComponent/TableComponent.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ function TableComponent({ columns, data, rowClickFunction }: any) {
4141
className={rowClickFunction !== undefined ? 'hoverRow' : ''}
4242
{...row.getRowProps()}
4343
onClick={() =>
44-
rowClickFunction !== undefined
45-
? rowClickFunction(row.values['row.name'])
46-
: undefined
44+
rowClickFunction !== undefined ? rowClickFunction(row.original) : undefined
4745
}
4846
>
4947
{row.cells.map((cell) => {

src/__generated__/types.ts

Lines changed: 84 additions & 105 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hooks/ClassMissionMastery.graphql

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)