X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fhelpers%2FTournament.js;h=a3f97cc22b47a6e4a3f135a8bbb506ebf9134b0b;hb=beccf752aafd468c3753c6d48ae30bccd946c3b9;hp=ff1a06349424f7567e9de29df8a07f2b3d2a4e30;hpb=09c1644b5f64d7423905ae1be8f79da0b482289a;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, };