]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/results/List.js
hide round placement
[alttp.git] / resources / js / components / results / List.js
1 import PropTypes from 'prop-types';
2 import React from 'react';
3
4 import Item from './Item';
5 import { sortByFinished, sortByResult } from '../../helpers/Participant';
6 import { maySeeResults } from '../../helpers/permissions';
7 import { getRunners } from '../../helpers/Tournament';
8 import { withUser } from '../../helpers/UserContext';
9
10 const List = ({ round, tournament, user }) => {
11         const runners = maySeeResults(user, tournament, round)
12                 ? sortByResult(getRunners(tournament), round)
13                 : sortByFinished(getRunners(tournament), round);
14         return <div className="results d-flex flex-wrap">
15                 {runners.map(participant =>
16                         <Item
17                                 key={participant.id}
18                                 participant={participant}
19                                 round={round}
20                                 tournament={tournament}
21                         />
22                 )}
23         </div>;
24 };
25
26 List.propTypes = {
27         round: PropTypes.shape({
28         }),
29         tournament: PropTypes.shape({
30                 participants: PropTypes.arrayOf(PropTypes.shape({
31                 })),
32         }),
33         user: PropTypes.shape({
34         }),
35 };
36
37 export default withUser(List);