X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fhelpers%2FTournament.js;h=a3f97cc22b47a6e4a3f135a8bbb506ebf9134b0b;hb=920f11ddfeb2175e4e1556886773dcd044c6085b;hp=ff1a06349424f7567e9de29df8a07f2b3d2a4e30;hpb=7016f4b28fa1324269ae9e2a8aad28dd562927d4;p=alttp.git diff --git a/resources/js/helpers/Tournament.js b/resources/js/helpers/Tournament.js index ff1a063..a3f97cc 100644 --- a/resources/js/helpers/Tournament.js +++ b/resources/js/helpers/Tournament.js @@ -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, };