X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fhelpers%2FParticipant.js;h=7d649526924a35c0812938a07b85aa4bd978f901;hb=43da6b2ec78774e7b045a09c68af39717b5f5dbc;hp=d7bdd7c4a41055a8f7d067c2f44c1f02ffc1a5b2;hpb=9bc03c27b90df8f8acfdecc5cfbcbf8226485abc;p=alttp.git diff --git a/resources/js/helpers/Participant.js b/resources/js/helpers/Participant.js index d7bdd7c..7d64952 100644 --- a/resources/js/helpers/Participant.js +++ b/resources/js/helpers/Participant.js @@ -43,8 +43,8 @@ export const compareResult = round => (a, b) => { }; export const compareUsername = (a, b) => { - const a_name = a && a.user ? User.getUserName(a.user) : ''; - const b_name = b && b.user ? User.getUserName(b.user) : ''; + const a_name = getUserName(a); + const b_name = getUserName(b); return a_name.localeCompare(b_name); }; @@ -54,6 +54,9 @@ export const findResult = (participant, round) => { return round.results.find(result => result.user_id === participant.user_id); }; +export const getUserName = participant => + participant.user ? User.getUserName(participant.user) : ''; + export const isRunner = participant => participant && participant.roles && participant.roles.includes('runner'); @@ -101,6 +104,7 @@ export default { compareResult, compareUsername, findResult, + getUserName, isRunner, isTournamentAdmin, isTournamentCrew,