]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/results/Item.js
result display
[alttp.git] / resources / js / components / results / Item.js
index 771c7b62a68ad825a9fe74288db70935c51bdcb5..cc61dd06b66c15169fd0ed8692acb7273e0b75b4 100644 (file)
@@ -2,23 +2,34 @@ import PropTypes from 'prop-types';
 import React from 'react';
 import { withTranslation } from 'react-i18next';
 
+import Icon from '../common/Icon';
 import Box from '../users/Box';
 import { formatTime } from '../../helpers/Result';
 import { findResult } from '../../helpers/Participant';
-import i18n from '../../i18n';
+import { maySeeResults } from '../../helpers/permissions';
+import { withUser } from '../../helpers/UserContext';
 
 const Item = ({
        participant,
        round,
+       tournament,
+       user,
 }) => {
        const result = findResult(participant, round);
        return (
                <div className="result">
                        <Box user={participant.user} />
-                       <div>
-                               {result ?
-                                       <span>{i18n.t('results.time', { time: formatTime(result) })}</span>
-                               : null}
+                       <div className="status">
+                               <span className="time">
+                                       {result && maySeeResults(user, tournament, round) ?
+                                               formatTime(result)
+                                       : null}
+                               </span>
+                               {result && result.has_finished ?
+                                       <Icon.FINISHED size="lg" />
+                               :
+                                       <Icon.PENDING size="lg" />
+                               }
                        </div>
                </div>
        );
@@ -37,4 +48,4 @@ Item.propTypes = {
        }),
 };
 
-export default withTranslation()(Item);
+export default withTranslation()(withUser(Item));