X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fjs%2Fcomponents%2Ftournament%2FScoreboard.js;fp=resources%2Fjs%2Fcomponents%2Ftournament%2FScoreboard.js;h=ea6a6668727385e2165dcc44ab1d2f853e1940d0;hb=6c3125ca01833f7cec3659353840dbe1ddfb0fc6;hp=e142a80e030488f9a96d474d31d390b9a5259617;hpb=c9f99f9ad642f6c387b36b640c3c17cdfe58988a;p=alttp.git diff --git a/resources/js/components/tournament/Scoreboard.js b/resources/js/components/tournament/Scoreboard.js index e142a80..ea6a666 100644 --- a/resources/js/components/tournament/Scoreboard.js +++ b/resources/js/components/tournament/Scoreboard.js @@ -6,19 +6,45 @@ 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 => - + + - + )} @@ -44,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')}
+ {getPlacementDisplay(score)} +
@@ -35,7 +61,7 @@ const Scoreboard = ({ tournament }) => : null}
{score.score}{score.score}