X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fprotocol%2FItem.js;h=18b04cc7d6b96f5f5408f0af2d1e5cd6407038e2;hb=6f22614d8c68c68c88b44804802cdffeb3c6a3c7;hp=3337d04621cbd4ae7380c2f0fb880e7ee8535145;hpb=96f21488ed9c9572e2f00147a1713e24cc77c543;p=alttp.git diff --git a/resources/js/components/protocol/Item.js b/resources/js/components/protocol/Item.js index 3337d04..18b04cc 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,6 +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; @@ -25,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 @@ -33,6 +65,15 @@ const getEntryDescription = entry => { } case 'round.create': case 'round.lock': + case 'round.seed': + case 'round.unlock': + return i18n.t( + `protocol.description.${entry.type}`, + { + ...entry, + number: getEntryRoundNumber(entry), + }, + ); case 'tournament.lock': return i18n.t( `protocol.description.${entry.type}`, @@ -45,6 +86,15 @@ const getEntryDescription = entry => { const getEntryIcon = entry => { switch (entry.type) { + case 'result.report': + return ; + case 'round.create': + return ; + case 'round.lock': + case 'tournament.lock': + return ; + case 'round.unlock': + return ; default: return ; }