1 import PropTypes from 'prop-types';
2 import React from 'react';
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 { compareResult } from '../../helpers/Result';
9 import { useUser } from '../../hooks/user';
11 const List = ({ round, tournament }) => {
12 const { user } = useUser();
14 if (tournament.type === 'open-async') {
15 const results = maySeeResults(user, tournament, round)
16 ? (round.results || []).sort(compareResult)
17 : round.results || [];
18 return <div className="results d-flex flex-wrap">
19 {results.map(result =>
23 tournament={tournament}
29 const runners = maySeeResults(user, tournament, round)
30 ? sortByResult(getRunners(tournament), round)
31 : sortByFinished(getRunners(tournament), round);
32 return <div className="results d-flex flex-wrap">
33 {runners.map(participant =>
37 tournament={tournament}
38 user={participant.user}
45 round: PropTypes.shape({
46 results: PropTypes.arrayOf(PropTypes.shape({
49 tournament: PropTypes.shape({
50 participants: PropTypes.arrayOf(PropTypes.shape({
52 type: PropTypes.string,
53 users: PropTypes.arrayOf(PropTypes.shape({