diff --git a/src/components/pages/Statistics.js b/src/components/pages/Statistics.js index d3129d663b8f87297a16628f0df954357441cd81..44a4cdde14ce51f9060973b59c3967c4d96f170d 100644 --- a/src/components/pages/Statistics.js +++ b/src/components/pages/Statistics.js @@ -1,6 +1,7 @@ import React, { Component } from 'react'; import { Container, Menu } from 'semantic-ui-react'; import Events from './Events' +import Trainees from './Trainees' export default class Statistics extends Component { state = { activeItem: 'events' } @@ -35,6 +36,7 @@ export default class Statistics extends Component { </Menu.Item> </Menu> { activeItem === 'events' ? <Events /> : '' } + { activeItem === 'trainees' ? <Trainees /> : '' } </Container> </div> ); diff --git a/src/components/pages/Trainees.js b/src/components/pages/Trainees.js new file mode 100644 index 0000000000000000000000000000000000000000..ea165892f2e84e04cb6bf94a5853f08f592a3e0b --- /dev/null +++ b/src/components/pages/Trainees.js @@ -0,0 +1,47 @@ +import React, { Component } from 'react'; +import { Link } from 'react-router-dom'; +import { Container, Table } from 'semantic-ui-react'; +import { connect } from 'react-redux'; +import { getTrainees } from '../../actions/statistics'; + +class Trainees extends Component { + componentWillMount() { + this.props.getTrainees(); + } + + renderTrainees() { + return this.props.trainees.map((trainee) => + { return ( + <Table.Row> + <Table.Cell> + <Link to={`trainees/${trainee.id}`}> + {trainee.full_name} + </Link> + </Table.Cell> + </Table.Row> + ); + }); + } + + render() { + return ( + <Container textAlign='center'> + <Table color='blue' celled selectable compact> + <Table.Header> + <Table.Row> + <Table.HeaderCell>KĂŠpzĹdĹk</Table.HeaderCell> + </Table.Row> + </Table.Header> + + <Table.Body> + {this.props.trainees ? this.renderTrainees() : 'Nincsenek kĂŠpzĹdĹk'} + </Table.Body> + </Table> + </Container> + ); + } +} + +const mapStateToProps = ({ trainees: { trainees }, user }) => ({ trainees, user }); + +export default connect(mapStateToProps, { getTrainees })(Trainees);