+import PropTypes from 'prop-types';
+import React from 'react';
+import { Button, Col, Form, Modal, Row } from 'react-bootstrap';
+import { withTranslation } from 'react-i18next';
+
+import Box from '../users/Box';
+import { getTime } from '../../helpers/Result';
+import { findResult } from '../../helpers/Participant';
+import { maySeeResults } from '../../helpers/permissions';
+import { withUser } from '../../helpers/UserContext';
+import i18n from '../../i18n';
+
+const getPlacement = result =>
+ `${result.placement}. (${i18n.t('results.points', { count: result.score })})`;
+
+const DetailDialog = ({
+ onHide,
+ participant,
+ round,
+ show,
+ tournament,
+ user,
+}) => {
+ const result = findResult(participant, round);
+ const maySee = maySeeResults(user, tournament, round);
+ return <Modal className="result-dialog" onHide={onHide} show={show}>
+ <Modal.Header closeButton>
+ <Modal.Title>
+ {i18n.t('results.details')}
+ </Modal.Title>
+ </Modal.Header>
+ <Modal.Body>
+ <Row>
+ <Form.Group as={Col} sm={6}>
+ <Form.Label>{i18n.t('results.round')}</Form.Label>
+ <div>
+ #{round.number || '?'}
+ {' '}
+ {i18n.t('rounds.date', { date: new Date(round.created_at) })}
+ </div>
+ </Form.Group>
+ <Form.Group as={Col} sm={6}>
+ <Form.Label>{i18n.t('results.runner')}</Form.Label>
+ <div><Box user={participant.user} /></div>
+ </Form.Group>
+ <Form.Group as={Col} sm={6}>
+ <Form.Label>{i18n.t('results.result')}</Form.Label>
+ <div>
+ {maySee && result && result.has_finished
+ ? getTime(result, maySee)
+ : i18n.t('results.pending')}
+ </div>
+ </Form.Group>
+ <Form.Group as={Col} sm={6}>
+ <Form.Label>{i18n.t('results.placement')}</Form.Label>
+ <div>
+ {maySee && result && result.placement
+ ? getPlacement(result)
+ : i18n.t('results.pending')}
+ </div>
+ </Form.Group>
+ {maySee && result && result.comment ?
+ <Form.Group as={Col} sm={12}>
+ <Form.Label>{i18n.t('results.comment')}</Form.Label>
+ <div>{result.comment}</div>
+ </Form.Group>
+ : null}
+ </Row>
+ </Modal.Body>
+ <Modal.Footer>
+ <Button onClick={onHide} variant="secondary">
+ {i18n.t('button.close')}
+ </Button>
+ </Modal.Footer>
+ </Modal>;
+};
+
+DetailDialog.propTypes = {
+ onHide: PropTypes.func,
+ participant: PropTypes.shape({
+ user: PropTypes.shape({
+ }),
+ }),
+ round: PropTypes.shape({
+ created_at: PropTypes.string,
+ number: PropTypes.number,
+ }),
+ show: PropTypes.bool,
+ tournament: PropTypes.shape({
+ }),
+ user: PropTypes.shape({
+ }),
+};
+
+export default withTranslation()(withUser(DetailDialog));