X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fhelpers%2FParticipant.js;h=1a24f8efef9ee242be68ec7e0af9a271fda6010a;hb=9b15396c4363a92796cd555f629dffd48fae7ae7;hp=d7bdd7c4a41055a8f7d067c2f44c1f02ffc1a5b2;hpb=9bc03c27b90df8f8acfdecc5cfbcbf8226485abc;p=alttp.git diff --git a/resources/js/helpers/Participant.js b/resources/js/helpers/Participant.js index d7bdd7c..1a24f8e 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,10 +104,13 @@ export default { compareResult, compareUsername, findResult, + getUserName, isRunner, isTournamentAdmin, isTournamentCrew, isTournamentMonitor, patchUser, + sortByFinished, sortByResult, + sortByUsername, };