X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fjs%2Fcomponents%2Fprotocol%2FItem.js;h=00da2ef472c27afb8b8be1c55de2c9cd9e361e0a;hb=b98dac4d596e4bed9a5f96526aa66ea8512ad2ab;hp=2eaae5b6c3cecf7700f533d79155de1974e04903;hpb=80b9fbe436d1ba5447260c30e4527108ab15ab49;p=alttp.git
diff --git a/resources/js/components/protocol/Item.js b/resources/js/components/protocol/Item.js
index 2eaae5b..00da2ef 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,14 +41,36 @@ 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);
+ const number = getEntryRoundNumber(entry);
+ return
+ {{number}}
+ {{comment}},
+ ;
+ }
case 'result.report': {
+ const number = getEntryRoundNumber(entry);
const time = getEntryResultTime(entry);
return
+ {{number}}
{{time}},
;
}
case 'round.create':
+ case 'round.edit':
case 'round.lock':
+ case 'round.seed':
case 'round.unlock':
return i18n.t(
`protocol.description.${entry.type}`,
@@ -44,7 +79,11 @@ const getEntryDescription = entry => {
number: getEntryRoundNumber(entry),
},
);
+ case 'tournament.close':
+ case 'tournament.discord':
case 'tournament.lock':
+ case 'tournament.open':
+ case 'tournament.unlock':
return i18n.t(
`protocol.description.${entry.type}`,
entry,
@@ -61,10 +100,15 @@ 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 ;
+ case 'tournament.discord':
+ return ;
default:
return ;
}