]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/Tournament.js
allow users to set their stream link
[alttp.git] / resources / js / helpers / Tournament.js
index ff1a06349424f7567e9de29df8a07f2b3d2a4e30..a3f97cc22b47a6e4a3f135a8bbb506ebf9134b0b 100644 (file)
@@ -68,6 +68,15 @@ export const patchRound = (tournament, round) => {
        };
 };
 
+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)),
+       };
+};
+
 export const sortParticipants = tournament => {
        if (!tournament || !tournament.participants || !tournament.participants.length) {
                return tournament;
@@ -83,5 +92,7 @@ export default {
        compareScore,
        findParticipant,
        patchResult,
+       patchRound,
+       patchUser,
        sortParticipants,
 };