]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/Tournament.js
show tournament participation in profile
[alttp.git] / resources / js / helpers / Tournament.js
index 2c145a83cc5aa48bf6e3b0c4688ae9c4e5967aa4..a3f97cc22b47a6e4a3f135a8bbb506ebf9134b0b 100644 (file)
@@ -64,7 +64,16 @@ export const patchRound = (tournament, round) => {
        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)),
        };
 };
 
@@ -83,5 +92,7 @@ export default {
        compareScore,
        findParticipant,
        patchResult,
+       patchRound,
+       patchUser,
        sortParticipants,
 };