From 96f21488ed9c9572e2f00147a1713e24cc77c543 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sun, 20 Mar 2022 20:10:14 +0100 Subject: [PATCH] spoiler time in protocol --- resources/js/components/common/Spoiler.js | 6 +++++- resources/js/components/protocol/Item.js | 20 ++++++++++++++++++-- resources/js/i18n/de.js | 6 +++++- resources/js/i18n/en.js | 6 +++++- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/resources/js/components/common/Spoiler.js b/resources/js/components/common/Spoiler.js index c4995dc..084de71 100644 --- a/resources/js/components/common/Spoiler.js +++ b/resources/js/components/common/Spoiler.js @@ -13,7 +13,11 @@ const Spoiler = ({ children }) => { }; Spoiler.propTypes = { - children: PropTypes.node, + children: PropTypes.oneOfType([ + PropTypes.node, + PropTypes.object, + PropTypes.string, + ]), }; export default Spoiler; diff --git a/resources/js/components/protocol/Item.js b/resources/js/components/protocol/Item.js index f827f1a..3337d04 100644 --- a/resources/js/components/protocol/Item.js +++ b/resources/js/components/protocol/Item.js @@ -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 + {{time}}, + ; + } case 'round.create': + case 'round.lock': + case 'tournament.lock': return i18n.t( `protocol.description.${entry.type}`, entry, diff --git a/resources/js/i18n/de.js b/resources/js/i18n/de.js index ee1f9c3..75c0b02 100644 --- a/resources/js/i18n/de.js +++ b/resources/js/i18n/de.js @@ -108,10 +108,14 @@ export default { protocol: { description: { result: { - report: 'Ergebnis eingetragen', + report: 'Ergebnis von <0>{{time}} eingetragen', }, round: { create: 'Runde hinzugefügt', + lock: 'Runde festgesetzt', + }, + tournament: { + lock: 'Turnier festgesetzt', }, unknown: 'Unbekannter Protokolleintrag vom Typ {{type}}.', }, diff --git a/resources/js/i18n/en.js b/resources/js/i18n/en.js index bd7fb37..d2ee9c0 100644 --- a/resources/js/i18n/en.js +++ b/resources/js/i18n/en.js @@ -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}}.', }, -- 2.39.2