X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fhelpers%2FParticipant.js;h=eb943401f6074057b4e6fc625c0d7385c4d15042;hb=920f11ddfeb2175e4e1556886773dcd044c6085b;hp=a44d465a4e57609b0e45ff5e756fde2344a1a8e2;hpb=7016f4b28fa1324269ae9e2a8aad28dd562927d4;p=alttp.git diff --git a/resources/js/helpers/Participant.js b/resources/js/helpers/Participant.js index a44d465..eb94340 100644 --- a/resources/js/helpers/Participant.js +++ b/resources/js/helpers/Participant.js @@ -40,6 +40,18 @@ export const findResult = (participant, round) => { return round.results.find(result => result.user_id === participant.user_id); }; +export const patchUser = (participant, user) => { + if (!participant || !user) return participant; + if (participant.user_id != user.id) return participant; + return { + ...participant, + user: { + ...participant.user, + ...user, + }, + }; +}; + export const sortByResult = (participants, round) => { if (!participants || !participants.length) return participants; if (!round || !round.results || !round.results.length) return participants; @@ -50,5 +62,6 @@ export default { compareResult, compareUsername, findResult, + patchUser, sortByResult, };