X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Ftournament%2FScoreboard.js;h=cbc73a32620db88204b5fa81f669a5db18c79702;hb=5dacd7900839a5e270de87de8c4f51dea385c1f0;hp=008974b7cc76ce1b8f362707f0dfb6fdcead4ee0;hpb=1c3b922ba7143a548c8a7526f5e4384f336e2f1e;p=alttp.git diff --git a/resources/js/components/tournament/Scoreboard.js b/resources/js/components/tournament/Scoreboard.js index 008974b..cbc73a3 100644 --- a/resources/js/components/tournament/Scoreboard.js +++ b/resources/js/components/tournament/Scoreboard.js @@ -1,25 +1,67 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { Table } from 'react-bootstrap'; +import { Button, Table } from 'react-bootstrap'; import { withTranslation } from 'react-i18next'; +import Icon from '../common/Icon'; import Box from '../users/Box'; import { calculateScores } from '../../helpers/Tournament'; +import { withUser } from '../../helpers/UserContext'; import i18n from '../../i18n'; -const Scoreboard = ({ tournament }) => - +const getRowClassName = (tournament, score, user) => { + const classNames = ['score']; + if (score && user && score.participant && score.participant.user_id == user.id) { + classNames.push('is-self'); + } + return classNames.join(' '); +}; + +const getPlacementDisplay = score => { + if (score.placement === 1) { + return ; + } + if (score.placement === 2) { + return ; + } + if (score.placement === 3) { + return ; + } + return score.placement; +}; + +const Scoreboard = ({ tournament, user }) => +
+ - + {calculateScores(tournament).map(score => - - - + + + + )} @@ -28,6 +70,8 @@ const Scoreboard = ({ tournament }) => Scoreboard.propTypes = { tournament: PropTypes.shape({ }), + user: PropTypes.shape({ + }), }; -export default withTranslation()(Scoreboard); +export default withTranslation()(withUser(Scoreboard));
{i18n.t('participants.placementShort')} {i18n.t('participants.participant')}{i18n.t('participants.score')}{i18n.t('participants.scoreShort')}
{score.score}
+ {getPlacementDisplay(score)} + +
+ + {score.participant.user.stream_link ? + + : null} +
+
{score.score}