if (!tournament) return tournament;
return {
...tournament,
- rounds: tournament.rounds.map(r => r.id === round.id ? round : r),
+ rounds: tournament.rounds.map(r => r.id === round.id ? { ...r, ...round } : r),
+ };
+};
+
+export const patchUser = (tournament, user) => {
+ if (!tournament || !tournament.participants || !user) return tournament;
+ if (!tournament.participants.find(p => p.user_id == user.id)) return tournament;
+ return {
+ ...tournament,
+ participants: tournament.participants.map(p => Participant.patchUser(p, user)),
};
};
compareScore,
findParticipant,
patchResult,
+ patchRound,
+ patchUser,
sortParticipants,
};