1 import Participant from './Participant';
2 import Tournament from './Tournament';
4 export const isComplete = (tournament, round) => {
5 if (!tournament || !tournament.participants) return false;
6 if (!round || !round.results) return false;
7 const runners = Tournament.getRunners(tournament);
8 if (!runners.length) return false;
9 for (let i = 0; i < runners.length; ++i) {
10 const result = Participant.findResult(runners[i], round);
11 if (!result || !result.has_finished) return false;
16 export const patchResult = (round, result) => {
17 if (!round) return round;
18 if (!round.results || !round.results.length) {
19 return { ...round, results: [result] };
21 if (!round.results.find(r => r.id === result.id)) {
22 return { ...round, results: [...round.results, result] };
26 results: round.results.map(r => r.id === result.id ? result : r),