X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fresults%2FList.js;h=911b6a53ba5526a70cb9073963190e6d0883949e;hb=31131fc56ecc52ba5ce8aa9854755b22620a7139;hp=9ad089632c5b6e035c9799646cf3a178fe5c4d8e;hpb=d920d896d4357289112e31d3b33d386ab754a12d;p=alttp.git diff --git a/resources/js/components/results/List.js b/resources/js/components/results/List.js index 9ad0896..911b6a5 100644 --- a/resources/js/components/results/List.js +++ b/resources/js/components/results/List.js @@ -2,25 +2,56 @@ 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 { useUser } from '../../hooks/user'; -const List = ({ round, tournament }) =>
- {sortByResult(tournament.participants, round).map(participant => - - )} -
; +const List = ({ round, tournament }) => { + const { user } = useUser(); + + 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({ + })), }), };