--- /dev/null
+import Round from './Round';
+
+export const findParticipant = (tournament, user) => {
+ if (!tournament || !tournament.participants || !tournament.participants.length) return null;
+ if (!user || !user.id) return null;
+ return tournament.participants.find(p => p.user_id == user.id);
+};
+
+export const patchResult = (tournament, result) => {
+ if (!tournament || !tournament.rounds) return tournament;
+ return {
+ ...tournament,
+ rounds: tournament.rounds.map(round =>
+ round.id === result.round_id
+ ? Round.patchResult(round, result)
+ : round
+ ),
+ };
+};
+
+export default {
+ findParticipant,
+ patchResult,
+};