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 { withUser } from '../../helpers/UserContext';
11 const List = ({ round, tournament, user }) => {
12 if (tournament.type === 'open-async') {
13 const results = maySeeResults(user, tournament, round)
14 ? (round.results || []).sort(compareResult)
15 : round.results || [];
16 return <div className="results d-flex flex-wrap">
17 {results.map(result =>
21 tournament={tournament}
27 const runners = maySeeResults(user, tournament, round)
28 ? sortByResult(getRunners(tournament), round)
29 : sortByFinished(getRunners(tournament), round);
30 return <div className="results d-flex flex-wrap">
31 {runners.map(participant =>
35 tournament={tournament}
36 user={participant.user}
43 round: PropTypes.shape({
44 results: PropTypes.arrayOf(PropTypes.shape({
47 tournament: PropTypes.shape({
48 participants: PropTypes.arrayOf(PropTypes.shape({
50 type: PropTypes.string,
51 users: PropTypes.arrayOf(PropTypes.shape({
54 user: PropTypes.shape({
58 export default withUser(List);