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