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 { findResult } from '../../helpers/Participant';
9 import { maySeeResults } from '../../helpers/permissions';
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(participant, round);
33 const maySee = maySeeResults(user, tournament, round);
34 return <div className="result">
35 <Box user={participant.user} />
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)}
48 participant={participant}
51 tournament={tournament}
57 participant: PropTypes.shape({
58 user: PropTypes.shape({
61 round: PropTypes.shape({
63 tournament: PropTypes.shape({
65 user: PropTypes.shape({
69 export default withUser(Item);