]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/results/List.js
hide round placement
[alttp.git] / resources / js / components / results / List.js
index f4d4ff10ee502130f44f65a9e03762347100d692..14c70968cd5324823c558732df049e3a2fd715ea 100644 (file)
@@ -2,19 +2,26 @@ import PropTypes from 'prop-types';
 import React from 'react';
 
 import Item from './Item';
-import { sortByResult } from '../../helpers/Participant';
+import { sortByFinished, sortByResult } from '../../helpers/Participant';
+import { maySeeResults } from '../../helpers/permissions';
 import { getRunners } from '../../helpers/Tournament';
+import { withUser } from '../../helpers/UserContext';
 
-const List = ({ round, tournament }) => <div className="results d-flex flex-wrap">
-       {sortByResult(getRunners(tournament), round).map(participant =>
-               <Item
-                       key={participant.id}
-                       participant={participant}
-                       round={round}
-                       tournament={tournament}
-               />
-       )}
-</div>;
+const List = ({ round, tournament, user }) => {
+       const runners = maySeeResults(user, tournament, round)
+               ? sortByResult(getRunners(tournament), round)
+               : sortByFinished(getRunners(tournament), round);
+       return <div className="results d-flex flex-wrap">
+               {runners.map(participant =>
+                       <Item
+                               key={participant.id}
+                               participant={participant}
+                               round={round}
+                               tournament={tournament}
+                       />
+               )}
+       </div>;
+};
 
 List.propTypes = {
        round: PropTypes.shape({
@@ -23,6 +30,8 @@ List.propTypes = {
                participants: PropTypes.arrayOf(PropTypes.shape({
                })),
        }),
+       user: PropTypes.shape({
+       }),
 };
 
-export default List;
+export default withUser(List);