]> git.localhorst.tv Git - alttp.git/blob - resources/js/helpers/User.js
highlight "todo" rounds
[alttp.git] / resources / js / helpers / User.js
1 export const findResult = (user, round) => {
2         if (!user || !user.id) return null;
3         if (!round || !round.results || !round.results.length) return null;
4         return round.results.find(result => result.user_id == user.id);
5 };
6
7 export const getAvatarUrl = user => user.avatar
8         ? `//cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png`
9         : '/default-avatar.png';
10
11 export const hasFinishedRound = (user, round) => {
12         const result = findResult(user, round);
13         return result && result.has_finished;
14 };
15
16 export default {
17         findResult,
18         getAvatarUrl,
19         hasFinishedRound,
20 };