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 { withUser } from '../../helpers/UserContext';
10 const List = ({ round, tournament, user }) => {
11 if (tournament.type === 'open-async') {
12 const results = round.results || [];
13 return <div className="results d-flex flex-wrap">
14 {results.map(result =>
18 tournament={tournament}
24 const runners = maySeeResults(user, tournament, round)
25 ? sortByResult(getRunners(tournament), round)
26 : sortByFinished(getRunners(tournament), round);
27 return <div className="results d-flex flex-wrap">
28 {runners.map(participant =>
32 tournament={tournament}
33 user={participant.user}
40 round: PropTypes.shape({
41 results: PropTypes.arrayOf(PropTypes.shape({
44 tournament: PropTypes.shape({
45 participants: PropTypes.arrayOf(PropTypes.shape({
47 type: PropTypes.string,
48 users: PropTypes.arrayOf(PropTypes.shape({
51 user: PropTypes.shape({
55 export default withUser(List);