Skip to content

Commit

Permalink
[APP]: Create HallOfFame page
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Mar 22, 2019
1 parent aa58a72 commit 041b579
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/src/routes/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import AssignmentList from 'views/Assignments/AssignmentList'
import SingleAssignment from 'views/Assignments/Assignment'
import LoginCallback from 'views/Callbacks/LoginCallback.js'
import Home from 'views/Home/Home.js'
import HallOfFame from 'views/Stats/HallOfFame'

import {
Class,
Assignment
Assignment,
Poll
} from '@material-ui/icons/'

const appRoutes = [
Expand Down Expand Up @@ -48,6 +50,13 @@ const appRoutes = [
{
path: '/loginCallback',
component: LoginCallback
},
{
path: '/hall-of-fame',
sidebarName: 'Hall of Fame',
icon: Poll,
component: HallOfFame,
show: true
}
]

Expand Down
73 changes: 73 additions & 0 deletions app/src/views/Stats/HallOfFame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React from 'react'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { withStyles } from '@material-ui/core/styles'
import Typography from '@material-ui/core/Typography'
import Table from '@material-ui/core/Table'
import TableBody from '@material-ui/core/TableBody'
import TableCell from '@material-ui/core/TableCell'
import TableHead from '@material-ui/core/TableHead'
import TableRow from '@material-ui/core/TableRow'

import {
statsActions
} from '../../actions'

const topUsers = statsActions.topUsers

const styles = theme => ({
jumbotron: {
fontSize: '100%'
},
button: {
margin: theme.spacing.unit
},
buttonFirst: {
marginLeft: 0
}
})

class HallOfFame extends React.Component {
componentDidMount () {
this.props.actions.topUsers().catch(e => console.log(e))
}

render () {
return (
<div>
<Table>
<TableHead>
<TableRow>
<TableCell>Username</TableCell>
<TableCell>Total Assignments Solved</TableCell>
</TableRow>
</TableHead>
<TableBody>
{this.props.stats.topUsers.map(user => (
<TableRow key={user.id}>
<TableCell component='th' scope='row'>
{user.username}
</TableCell>
<TableCell>{user.solved}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
)
}
}

const mapStateToProps = (state, ownProps) => {
return {
stats: state.stats
}
}

const mapDispatchToProps = dispatch => {
return {
actions: bindActionCreators({ topUsers }, dispatch)
}
}

export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(HallOfFame))

0 comments on commit 041b579

Please sign in to comment.