X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FList.js;h=fb26fa56f264d94c2c393a6dc70af0e23dea91f3;hb=d2d1231d5cea49224df581aed9d9e77f9deb832b;hp=f4d4ff10ee502130f44f65a9e03762347100d692;hpb=d32516335ea2534e15256c948e9c38d3de40794b;p=alttp.git diff --git a/resources/js/components/results/List.js b/resources/js/components/results/List.js index f4d4ff1..fb26fa5 100644 --- a/resources/js/components/results/List.js +++ b/resources/js/components/results/List.js @@ -2,27 +2,57 @@ 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 { compareResult } from '../../helpers/Result'; +import { withUser } from '../../helpers/UserContext'; -const List = ({ round, tournament }) =>
- {sortByResult(getRunners(tournament), round).map(participant => - - )} -
; +const List = ({ round, tournament, user }) => { + if (tournament.type === 'open-async') { + const results = maySeeResults(user, tournament, round) + ? (round.results || []).sort(compareResult) + : 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);