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 for (let i = 0; i < runners.length; ++i) {
9 const result = Participant.findResult(runners[i], round);
10 if (!result || !result.has_finished) return false;
15 export const patchResult = (round, result) => {
16 if (!round) return round;
17 if (!round.results || !round.results.length) {
18 return { ...round, results: [result] };
20 if (!round.results.find(r => r.id === result.id)) {
21 return { ...round, results: [...round.results, result] };
25 results: round.results.map(r => r.id === result.id ? result : r),