]> git.localhorst.tv Git - alttp.git/blob - resources/js/components/results/Item.js
result display
[alttp.git] / resources / js / components / results / Item.js
1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { withTranslation } from 'react-i18next';
4
5 import Icon from '../common/Icon';
6 import Box from '../users/Box';
7 import { formatTime } from '../../helpers/Result';
8 import { findResult } from '../../helpers/Participant';
9 import { maySeeResults } from '../../helpers/permissions';
10 import { withUser } from '../../helpers/UserContext';
11
12 const Item = ({
13         participant,
14         round,
15         tournament,
16         user,
17 }) => {
18         const result = findResult(participant, round);
19         return (
20                 <div className="result">
21                         <Box user={participant.user} />
22                         <div className="status">
23                                 <span className="time">
24                                         {result && maySeeResults(user, tournament, round) ?
25                                                 formatTime(result)
26                                         : null}
27                                 </span>
28                                 {result && result.has_finished ?
29                                         <Icon.FINISHED size="lg" />
30                                 :
31                                         <Icon.PENDING size="lg" />
32                                 }
33                         </div>
34                 </div>
35         );
36 };
37
38 Item.propTypes = {
39         participant: PropTypes.shape({
40                 user: PropTypes.shape({
41                 }),
42         }),
43         round: PropTypes.shape({
44         }),
45         tournament: PropTypes.shape({
46         }),
47         user: PropTypes.shape({
48         }),
49 };
50
51 export default withTranslation()(withUser(Item));