1 export const isComplete = (tournament, round) => {
2 if (!tournament || !tournament.participants) return false;
3 if (!round || !round.results) return false;
4 return tournament.participants.length === round.results.length &&
5 round.results.filter(r => !r.has_finished).length === 0;
8 export const patchResult = (round, result) => {
9 if (!round) return round;
10 if (!round.results || !round.results.length) {
11 return { ...round, results: [result] };
13 if (!round.results.find(r => r.id === result.id)) {
14 return { ...round, results: [...round.results, result] };
18 results: round.results.map(r => r.id === result.id ? result : r),