File tree Expand file tree Collapse file tree 2 files changed +82
-1
lines changed Expand file tree Collapse file tree 2 files changed +82
-1
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,12 @@ import AssignmentList from 'views/Assignments/AssignmentList'
6
6
import SingleAssignment from 'views/Assignments/Assignment'
7
7
import LoginCallback from 'views/Callbacks/LoginCallback.js'
8
8
import Home from 'views/Home/Home.js'
9
+ import HallOfFame from 'views/Stats/HallOfFame'
9
10
10
11
import {
11
12
Class ,
12
- Assignment
13
+ Assignment ,
14
+ Poll
13
15
} from '@material-ui/icons/'
14
16
15
17
const appRoutes = [
@@ -48,6 +50,13 @@ const appRoutes = [
48
50
{
49
51
path : '/loginCallback' ,
50
52
component : LoginCallback
53
+ } ,
54
+ {
55
+ path : '/hall-of-fame' ,
56
+ sidebarName : 'Hall of Fame' ,
57
+ icon : Poll ,
58
+ component : HallOfFame ,
59
+ show : true
51
60
}
52
61
]
53
62
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { bindActionCreators } from 'redux'
3
+ import { connect } from 'react-redux'
4
+ import { withStyles } from '@material-ui/core/styles'
5
+ import Table from '@material-ui/core/Table'
6
+ import TableBody from '@material-ui/core/TableBody'
7
+ import TableCell from '@material-ui/core/TableCell'
8
+ import TableHead from '@material-ui/core/TableHead'
9
+ import TableRow from '@material-ui/core/TableRow'
10
+
11
+ import {
12
+ statsActions
13
+ } from '../../actions'
14
+
15
+ const topUsers = statsActions . topUsers
16
+
17
+ const styles = theme => ( {
18
+ jumbotron : {
19
+ fontSize : '100%'
20
+ } ,
21
+ button : {
22
+ margin : theme . spacing . unit
23
+ } ,
24
+ buttonFirst : {
25
+ marginLeft : 0
26
+ }
27
+ } )
28
+
29
+ class HallOfFame extends React . Component {
30
+ componentDidMount ( ) {
31
+ this . props . actions . topUsers ( ) . catch ( e => console . log ( e ) )
32
+ }
33
+
34
+ render ( ) {
35
+ return (
36
+ < div >
37
+ < Table >
38
+ < TableHead >
39
+ < TableRow >
40
+ < TableCell > Username</ TableCell >
41
+ < TableCell > Total Assignments Solved</ TableCell >
42
+ </ TableRow >
43
+ </ TableHead >
44
+ < TableBody >
45
+ { this . props . stats . topUsers . map ( user => (
46
+ < TableRow key = { user . id } >
47
+ < TableCell component = 'th' scope = 'row' >
48
+ { user . username }
49
+ </ TableCell >
50
+ < TableCell > { user . solved } </ TableCell >
51
+ </ TableRow >
52
+ ) ) }
53
+ </ TableBody >
54
+ </ Table >
55
+ </ div >
56
+ )
57
+ }
58
+ }
59
+
60
+ const mapStateToProps = ( state , ownProps ) => {
61
+ return {
62
+ stats : state . stats
63
+ }
64
+ }
65
+
66
+ const mapDispatchToProps = dispatch => {
67
+ return {
68
+ actions : bindActionCreators ( { topUsers } , dispatch )
69
+ }
70
+ }
71
+
72
+ export default connect ( mapStateToProps , mapDispatchToProps ) ( withStyles ( styles ) ( HallOfFame ) )
You can’t perform that action at this time.
0 commit comments