1 import PropTypes from 'prop-types';
2 import React, { useState } from 'react';
3 import { Button } from 'react-bootstrap';
5 import DetailDialog from './DetailDialog';
6 import Box from '../users/Box';
7 import { getIcon, getTime } from '../../helpers/Result';
8 import { maySeeResults } from '../../helpers/permissions';
9 import { findResult } from '../../helpers/User';
10 import { withUser } from '../../helpers/UserContext';
12 const getClassName = result => {
13 const classNames = ['status'];
14 if (result && result.has_finished) {
15 classNames.push('finished');
17 classNames.push('has-comment');
20 classNames.push('pending');
22 return classNames.join(' ');
31 const [showDialog, setShowDialog] = useState(false);
32 const result = findResult(user, round);
33 const maySee = maySeeResults(authUser, tournament, round);
34 return <div className="result">
37 className={getClassName(result)}
38 onClick={() => setShowDialog(true)}
39 title={maySee && result && result.comment ? result.comment : null}
41 <span className="time">
42 {getTime(result, maySee)}
44 {getIcon(result, maySee)}
47 onHide={() => setShowDialog(false)}
50 tournament={tournament}
57 authUser: PropTypes.shape({
59 round: PropTypes.shape({
61 tournament: PropTypes.shape({
63 user: PropTypes.shape({
67 export default withUser(Item, 'authUser');