1 import Participant from './Participant';
2 import Round from './Round';
4 export const findParticipant = (tournament, user) => {
5 if (!tournament || !tournament.participants || !tournament.participants.length) return null;
6 if (!user || !user.id) return null;
7 return tournament.participants.find(p => p.user_id == user.id);
10 export const patchResult = (tournament, result) => {
11 if (!tournament || !tournament.rounds) return tournament;
14 rounds: tournament.rounds.map(round =>
15 round.id === result.round_id
16 ? Round.patchResult(round, result)
22 export const patchRound = (tournament, round) => {
23 if (!tournament) return tournament;
26 rounds: tournament.rounds.map(r => r.id === round.id ? round : r),
30 export const sortParticipants = tournament => {
31 if (!tournament || !tournament.participants || !tournament.participants.length) {
36 participants: tournament.participants.sort(Participant.compareUsername),