if (b_forfeit) {
return 1;
}
- return 0;
+ return compareUsername(a, b);
};
export const compareUsername = (a, b) => {
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;
compareResult,
compareUsername,
findResult,
+ patchUser,
sortByResult,
};