+++ /dev/null
-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 { maySeeResults } from '../../helpers/permissions';
-import { findResult } from '../../helpers/User';
-import { withUser } from '../../helpers/UserContext';
-import i18n from '../../i18n';
-
-const getPlacement = result =>
- `${result.placement}. (${i18n.t('results.points', { count: result.score })})`;
-
-const DetailDialog = ({
- authUser,
- onHide,
- round,
- show,
- tournament,
- user,
-}) => {
- const result = findResult(user, round);
- const maySee = maySeeResults(authUser, 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={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 = {
- authUser: PropTypes.shape({
- }),
- onHide: PropTypes.func,
- round: PropTypes.shape({
- created_at: PropTypes.string,
- number: PropTypes.number,
- }),
- show: PropTypes.bool,
- tournament: PropTypes.shape({
- }),
- user: PropTypes.shape({
- }),
-};
-
-export default withTranslation()(withUser(DetailDialog, 'authUser'));