From 041b579d3eae358b63bbb24cf27c18f1ba0f38e2 Mon Sep 17 00:00:00 2001 From: Christos Nasikas Date: Fri, 22 Mar 2019 14:53:53 +0200 Subject: [PATCH] [APP]: Create HallOfFame page --- app/src/routes/app.js | 11 ++++- app/src/views/Stats/HallOfFame.js | 73 +++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 app/src/views/Stats/HallOfFame.js diff --git a/app/src/routes/app.js b/app/src/routes/app.js index ef53ad3..87ce322 100644 --- a/app/src/routes/app.js +++ b/app/src/routes/app.js @@ -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 = [ @@ -48,6 +50,13 @@ const appRoutes = [ { path: '/loginCallback', component: LoginCallback + }, + { + path: '/hall-of-fame', + sidebarName: 'Hall of Fame', + icon: Poll, + component: HallOfFame, + show: true } ] diff --git a/app/src/views/Stats/HallOfFame.js b/app/src/views/Stats/HallOfFame.js new file mode 100644 index 0000000..165d060 --- /dev/null +++ b/app/src/views/Stats/HallOfFame.js @@ -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 ( +
+ + + + Username + Total Assignments Solved + + + + {this.props.stats.topUsers.map(user => ( + + + {user.username} + + {user.solved} + + ))} + +
+
+ ) + } +} + +const mapStateToProps = (state, ownProps) => { + return { + stats: state.stats + } +} + +const mapDispatchToProps = dispatch => { + return { + actions: bindActionCreators({ topUsers }, dispatch) + } +} + +export default connect(mapStateToProps, mapDispatchToProps)(withStyles(styles)(HallOfFame))