X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fjs%2Fcomponents%2Fresults%2FList.js;h=3d1bdfa8f27c9ff0147832934ce81975a8bee2c0;hb=537b998e8059c56e3a20ee2a89d42c3bbfbb80b8;hp=448736a97bef7ee787ba6b7987f66ec9f370ced8;hpb=14bee4bbb112ddab53914fa777be6004debeb5c4;p=alttp.git diff --git a/resources/js/components/results/List.js b/resources/js/components/results/List.js index 448736a..3d1bdfa 100644 --- a/resources/js/components/results/List.js +++ b/resources/js/components/results/List.js @@ -2,26 +2,54 @@ 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 }) =>
- {sortByResult(tournament.participants, round).map(participant => - - )} -
; +const List = ({ round, tournament, user }) => { + if (tournament.type === 'open-async') { + const results = round.results || []; + return
+ {results.map(result => + + )} +
; + } + const runners = maySeeResults(user, tournament, round) + ? sortByResult(getRunners(tournament), round) + : sortByFinished(getRunners(tournament), round); + return
+ {runners.map(participant => + + )} +
; +}; List.propTypes = { round: PropTypes.shape({ + results: PropTypes.arrayOf(PropTypes.shape({ + })), }), tournament: PropTypes.shape({ participants: PropTypes.arrayOf(PropTypes.shape({ })), + type: PropTypes.string, + users: PropTypes.arrayOf(PropTypes.shape({ + })), + }), + user: PropTypes.shape({ }), }; -export default List; +export default withUser(List);