]> git.localhorst.tv Git - alttp.git/commitdiff
spoiler time in protocol
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 20 Mar 2022 19:10:14 +0000 (20:10 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 20 Mar 2022 19:10:14 +0000 (20:10 +0100)
resources/js/components/common/Spoiler.js
resources/js/components/protocol/Item.js
resources/js/i18n/de.js
resources/js/i18n/en.js

index c4995dcd3ef37aab498abecf3590a69cb5a25043..084de71477156faca03d45dfce2388ca58305de6 100644 (file)
@@ -13,7 +13,11 @@ const Spoiler = ({ children }) => {
 };
 
 Spoiler.propTypes = {
-       children: PropTypes.node,
+       children: PropTypes.oneOfType([
+               PropTypes.node,
+               PropTypes.object,
+               PropTypes.string,
+       ]),
 };
 
 export default Spoiler;
index f827f1ab0f9b8409dcbb5f15f5d7f735fefa0cfd..3337d04621cbd4ae7380c2f0fb880e7ee8535145 100644 (file)
@@ -2,9 +2,11 @@ import moment from 'moment';
 import PropTypes from 'prop-types';
 import React from 'react';
 import { ListGroup } from 'react-bootstrap';
-import { withTranslation } from 'react-i18next';
+import { Trans, withTranslation } from 'react-i18next';
 
 import Icon from '../common/Icon';
+import Spoiler from '../common/Spoiler';
+import { formatTime } from '../../helpers/Result';
 import i18n from '../../i18n';
 
 const getEntryDate = entry => {
@@ -14,10 +16,24 @@ const getEntryDate = entry => {
                : dateStr;
 };
 
+const getEntryResultTime = entry => {
+       if (!entry || !entry.details || !entry.details.result) return 'ERROR';
+       const result = entry.details.result;
+       if (result.forfeit) return 'DNF XX';
+       return formatTime(result);
+};
+
 const getEntryDescription = entry => {
        switch (entry.type) {
-               case 'result.report':
+               case 'result.report': {
+                       const time = getEntryResultTime(entry);
+                       return <Trans i18nKey={`protocol.description.${entry.type}`}>
+                               <Spoiler>{{time}}</Spoiler>,
+                       </Trans>;
+               }
                case 'round.create':
+               case 'round.lock':
+               case 'tournament.lock':
                        return i18n.t(
                                `protocol.description.${entry.type}`,
                                entry,
index ee1f9c3e77d4cc881edb63037cd8844eef1ba5ba..75c0b02fb401b9d13f00484c614cbfb5d7edb8a9 100644 (file)
@@ -108,10 +108,14 @@ export default {
                protocol: {
                        description: {
                                result: {
-                                       report: 'Ergebnis eingetragen',
+                                       report: 'Ergebnis von <0>{{time}}</0> eingetragen',
                                },
                                round: {
                                        create: 'Runde hinzugefĆ¼gt',
+                                       lock: 'Runde festgesetzt',
+                               },
+                               tournament: {
+                                       lock: 'Turnier festgesetzt',
                                },
                                unknown: 'Unbekannter Protokolleintrag vom Typ {{type}}.',
                        },
index bd7fb372535c825d296d5554e3f49e64692b65d2..d2ee9c09f5358c33925df987efb06a776b4754f7 100644 (file)
@@ -108,10 +108,14 @@ export default {
                protocol: {
                        description: {
                                result: {
-                                       report: 'Result reported',
+                                       report: 'Result of {{time}} reported',
                                },
                                round: {
                                        create: 'Round added',
+                                       lock: 'Round locked',
+                               },
+                               tournament: {
+                                       lock: 'Tournament locked',
                                },
                                unknown: 'Unknown protocol entry of type {{type}}.',
                        },