Skip to content

Commit 2cf4d65

Browse files
committed
[APP]: Create HallOfFame page
1 parent 918aa32 commit 2cf4d65

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

app/src/routes/app.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import AssignmentList from 'views/Assignments/AssignmentList'
66
import SingleAssignment from 'views/Assignments/Assignment'
77
import LoginCallback from 'views/Callbacks/LoginCallback.js'
88
import Home from 'views/Home/Home.js'
9+
import HallOfFame from 'views/Stats/HallOfFame'
910

1011
import {
1112
Class,
12-
Assignment
13+
Assignment,
14+
Poll
1315
} from '@material-ui/icons/'
1416

1517
const appRoutes = [
@@ -48,6 +50,13 @@ const appRoutes = [
4850
{
4951
path: '/loginCallback',
5052
component: LoginCallback
53+
},
54+
{
55+
path: '/hall-of-fame',
56+
sidebarName: 'Hall of Fame',
57+
icon: Poll,
58+
component: HallOfFame,
59+
show: true
5160
}
5261
]
5362

app/src/views/Stats/HallOfFame.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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))

0 commit comments

Comments
 (0)