X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fprotocol%2FItem.js;h=3ccefbfe5d6f47ac5804708739f59b1f7c50b02c;hb=43da6b2ec78774e7b045a09c68af39717b5f5dbc;hp=74bfa50039cf82ab62c3395d2e2683d2ec1072df;hpb=a4260a00251cef4ad806c9d5c44d4c444d6ab831;p=alttp.git diff --git a/resources/js/components/protocol/Item.js b/resources/js/components/protocol/Item.js index 74bfa50..3ccefbf 100644 --- a/resources/js/components/protocol/Item.js +++ b/resources/js/components/protocol/Item.js @@ -7,6 +7,7 @@ import { Trans, withTranslation } from 'react-i18next'; import Icon from '../common/Icon'; import Spoiler from '../common/Spoiler'; import { formatTime } from '../../helpers/Result'; +import { getUserName } from '../../helpers/User'; import i18n from '../../i18n'; const getEntryDate = entry => { @@ -16,9 +17,21 @@ const getEntryDate = entry => { : dateStr; }; +const getEntryDetailsUsername = entry => { + if (!entry || !entry.details || !entry.details.user) return 'Anonymous'; + return getUserName(entry.details.user); +}; + const getEntryRoundNumber = entry => (entry && entry.details && entry.details.round && entry.details.round.number) || '?'; +const getEntryResultComment = entry => { + if (!entry || !entry.details || !entry.details.result || !entry.details.result.comment) { + return ''; + } + return entry.details.result.comment; +}; + const getEntryResultTime = entry => { if (!entry || !entry.details || !entry.details.result) return 'ERROR'; const result = entry.details.result; @@ -28,6 +41,22 @@ const getEntryResultTime = entry => { const getEntryDescription = entry => { switch (entry.type) { + case 'application.accepted': + case 'application.received': + case 'application.rejected': + return i18n.t( + `protocol.description.${entry.type}`, + { + ...entry, + username: getEntryDetailsUsername(entry), + }, + ); + case 'result.comment': { + const comment = getEntryResultComment(entry); + return + {{comment}}, + ; + } case 'result.report': { const time = getEntryResultTime(entry); return @@ -36,6 +65,7 @@ const getEntryDescription = entry => { } case 'round.create': case 'round.lock': + case 'round.seed': case 'round.unlock': return i18n.t( `protocol.description.${entry.type}`, @@ -44,8 +74,10 @@ const getEntryDescription = entry => { number: getEntryRoundNumber(entry), }, ); - case 'result.comment': + case 'tournament.close': case 'tournament.lock': + case 'tournament.open': + case 'tournament.unlock': return i18n.t( `protocol.description.${entry.type}`, entry, @@ -62,9 +94,12 @@ const getEntryIcon = entry => { case 'round.create': return ; case 'round.lock': + case 'tournament.close': case 'tournament.lock': return ; case 'round.unlock': + case 'tournament.open': + case 'tournament.unlock': return ; default: return ;